Conformal mapping and Helmholtz equation

Inspired by [10.1126/science.1126493]. Conformal transformation and Helmholtz equation Consider the Helmholtz equation describing a scalar phasor field $\psi$ in a 2D space filled by a isotropic medium of index $n(\mathbf{r})$. $$ (\nabla^2 + n^2k_0^2)\psi = 0. $$ the phasor field is corresponding to a given light polarization. We can introduce the complex variable $z=x+iy$, and we have the relations $$ \partial_x = \partial_z+\partial_{\bar{z}}, $$ $$ \partial_y = i\left(\partial_z-\partial_{\bar{z}}\right). $$ By substitution, $\nabla^2 = 4\partial_z\partial_{\bar{z}}$. Consider now an analytical function $w(z)$. We have $$ \partial_z\partial_{\bar{z}} = \left|\partial_z w\right|^2 \partial_w\partial_{\bar{w}}. $$ We can map the Helmholtz equation into $$ (4\partial_w\partial_{\bar{w}} + n’^2k_0^2)\psi = 0 $$ where the new index is $n’ = n |\partial_z w|$. Then, we can map again the Helmholtz equation into new variables $u, v$, having $w=u+iv$, obtaining $$ (\partial_u^2+\partial_v^2 + n’^2k_0^2)\psi = 0 $$ therefore mapping the previous electromagnetic problem into a new problem with a transformed index. ...

August 31, 2024 · 2 min

Longitudinal and transverse relativistic dynamics

A very simple calculation in relativistic dynamics show an impressive aspect that differentiates the momentum change due to a force in the direction of movement of the body and the transverse ones. By using the definition of relativistic momentum $\mathbf{p}=\gamma m \mathbf{v}$, we can write $$ \frac{d\mathbf{p}}{dt} = \frac{d\gamma}{dt} m \mathbf{v} + \gamma m \frac{d\mathbf{v}}{dt}, $$ by defining the longitudinal and transverse acceleration, with respect to the vector $\mathbf{v}$ $$ \frac{d\mathbf{v}}{dt} = \mathbf{a}_L +\mathbf{a}_T, $$ it is simple to show that the first term in the first equation is only longitudinal $$ \frac{d\gamma}{dt} m \mathbf{v} = \frac{v^2}{c^2} \gamma^3 m \mathbf{a}_L , $$ and the second term is composed of longitudinal and transverse parts $$ \gamma m \frac{d\mathbf{v}}{dt}=\gamma m (\mathbf{a}_L+\mathbf{a}_T). $$ Summing the contributions, we can separate the Newton equation with respect to transverse and longitudinal forces, obtaining $$ \frac{d\mathbf{p}}{dt}=\gamma^3m \mathbf{a}_L+\gamma m \mathbf{a}_T. $$ ...

July 24, 2024 · 1 min

Simple (but nontrivial) vectorization in Numpy

f(a, b, c, d) Let’s say we want to explore the behavior of f in some range of parameters. How can we vectorize the function and iterate over all possible combinations? Is building a Cartesian product the best way? We expect this to be very inefficient, like $O(n^2)$ with respect to $O(n)$ inefficient in memory, at least. Let’s say the parameters have a definite number of samples (len(x) or np.shape(x) in pyhon, with x a parameter vector). We change the axis of the numpy vectors, making them multi-dimensional vectors (or, respecting the notion of dimension in algebra, multi-axial): ...

May 9, 2024 · 2 min

Simple Multiprocessing in Julia

In this short post, we analyze the computation of a two-variable function on a grid, that is a common task for exploring physical properties of systems through phase diagrams, and similar using Distributed, Printf @info @sprintf("Number of workers: %d", nprocs()) @everywhere function loop_compute(x) for i in 1:100000000 x += sin(x) end return x end t0 = @elapsed loop_compute(1.0) @info @sprintf("Single eval time [s]: %4.3e", t0) mat = rand(10, 10) t_pmap = @elapsed pmap(loop_compute, mat) @info @sprintf("pmap eval time [s] : %4.3e", t_pmap) t_sing = @elapsed loop_compute.(mat) @info @sprintf("serial eval time [s] : %4.3e", t_sing) @info @sprintf("Speeup ratio: %4444", t_sing/t_pmap) Try to run this simple script using ...

March 27, 2024 · 1 min

Linux Admin Tools

This post is designed to be updated as soon as new tricks come handy. Useful commands Instruction Command Change user su - <username> Change owner chown user:group -R folder Check owner & permissions stat filename List all users with UID cut -d: -f1,3 /etc/passwd List all groups with GID getent group Linux ownership system rwx Owner and permissions: typing la we get informations about the pemissions about a file or a folder ...

February 12, 2024 · 1 min

A clean installation of SLURM scheduler

Desired topology and active services SLURM super quick start guide The guide is available here. On Centos8Stream, we first install MUNGE, then install SLURM by the bzip package. Status of munge can be probed by munge -n | unmunge Installing the SLURM package is done manually wget https://download.schedmd.com/slurm/slurm-23.11.3.tar.bz2 We then unzip, configure, and build SLURM We then need to create, by the SLURM user “slurm”, the directories of log files PID files State save and make them writable. We take inspiration from an existing slurm.conf file. So the directories will be ...

February 11, 2024 · 7 min

The Kapitza pendulum

The Kapitza pendulum is a model in classical mechanics that exhibits counterintuitive behaviour. It is a pendulum with a pivot point that oscillates vertically. If $\phi$ is the angle the pendulum have with respect to the vertical downward position, for some values of the driving frequency and amplitude, it can be stable in the inverted position $\phi = \pi$, and unstable in the upright position $\phi = 0$. ...

February 11, 2024 · 1 min

Binomial from Poisson in composite process

This is a classical calculation in Poisson processes, indicating how to obtain a binomial variable from two Poisson processes. Let $X_1(t) \sim \mathcal{P}(\lambda_1 t)$ and $X_2(t) \sim \mathcal{P}(\lambda_2 t)$ be two independent Poisson processes, with parameters $\lambda_1$ and $\lambda_2$ respectively, that can be interpreted as arrivals in a second. Let us consider the following conditional $$ \begin{align} & P[X_1(t)=k \ | \ X_1(t)+X_2(t) &= n+k] \end{align} $$ that is the probability that there are $k$ arrivals from the variable 1, conditioned on the number of total arrivals being $n+k$. $$ \begin{align} & P[X_1(t)=k \ | \ X_1(t)+X_2(t) &= n+k] = \\ &= \frac{P[X_1(t)=k, X_2(t)= n]}{P[X_1(t) + X_2(t)= n+k]} \\ &=\frac{(\lambda_1 t)^k (k!)^{-1} e^{-\lambda_1 t} (\lambda_2 t)^n (n!)^{-1} e^{-\lambda_2 t}}{((\lambda_1 + \lambda_2) t)^{n+k} ((n+k)!)^{-1} e^{-(\lambda_1+\lambda_2) t}} \\ &= \frac{(n+k)!}{n! k!}\frac{\lambda_1^k \lambda_2^n}{((\lambda_1 + \lambda_2))^{n+k}} \\ &= \binom{n+k}{k} \left(\frac{\lambda_1}{\lambda_1+\lambda_2}\right)^k \left(\frac{\lambda_2}{\lambda_1+\lambda_2}\right)^n. \end{align} $$ Here we found that this probability distribution coincides to the one of a binomial variable $$ Y \sim \text{Bin}(n+k, p) $$ where $$ p = \frac{\lambda_1}{\lambda_1+ \lambda_2} $$ This result is well rooted in our intuition: every arrival comes from process 1 or process 2, with a probability which is proportional to the arrival rate of the two processes. Expressing this results with the rates $\lambda_i$, we obtain a sum of Bernoulli variables, that boils down to the binomial variable we found. ...

October 27, 2023 · 2 min

Second quantization of the electromagnetic field

The procedure of quantization of a classical theory has its crucial passage in the promotion of the dynamical variables to operators in the Hilbert space of the quantum states of the system. The quantization is successful if these operators form a complete set of commuting observables (this set is called ICOC). In this case, every quantum state of the system can be expressed as a sum of eigenstates, and we can write the probability amplitudes, and take the averages of all the dynamical variables. The quantized description of the electromagnetic field in the vacuum is obtained by expressing the field hamiltonian in a finite volume $V$, and then taking the limit for $V \to \infty$. The promotion to operators is performed by the position and conjugate momentum operators, which are introduced by writing the field hamiltonian in terms of a sum, possibly infinite, of uncoupled harmonic oscillators. We start by expressing the hamiltonian of the field in a volume of space $V$. $$ H = \int_{V}dV \dfrac{1}{2}\varepsilon_0 |\mathbf{E}|^2 + \dfrac{1}{2\mu_0}|\mathbf{B}|^2. $$ Now we remember that it is possible to express the fields $\mathbf{E}$, $\mathbf{B}$ using the magnetic vector potential $\mathbf{A}$ in this way, choosing the Coulomb gauge: $$ \begin{align} \mathbf{E} &= - \dfrac{\partial}{\partial t} \mathbf{A} \\ \mathbf{B} &= \nabla \times \mathbf{A}. \end{align} $$ We recall that, from the Maxwell equations, the wave equation for the field $\mathbf{A}$ $$ \left(\nabla^2 - \dfrac{1}{c^2} \dfrac{\partial^2}{\partial t^2} \right)\mathbf{A} =0. $$ Since we are in a limited volume of space, we can impose a periodic boundary condition, and express the field $\mathbf{A}$ according to its Fourier series, by summing complex exponentials. We choose to express the component plane waves as linearly polarized waves. This does not affect the generality of the procedure, as other polarizations can be expressed as sums of linearly polarized waves, with appropriate phase shifts. Let therefore $\mathbf{k}$ be the wave vector, and $s$ the linear polarization ($s \in {\alpha, \beta}$ where $\alpha, \beta$ are two possible orthogonal polarizations given the wave vector $\mathbf{k}$). We have that ...

October 27, 2023 · 5 min

Canonical nonlinear dynamics is described by Nonlinear Schrödinger equation

Nonlinear Schrödinger equations appears in numerous physical setups, like nonlinear optics, condensed matter physics and plasma physics. In all of these scenarios, it describes the dynamics of wave envelopes in the presence of dispersion and weak nonlinearity. A natural question is to understand if it is possible to write the equation regardless of the physical details, starting from a purely mathematical assumptions on the evolution of the fields. This is illuminating from the mathematical point of view, besides being an useful exercise. ...

August 14, 2023 · 2 min