Ez

Equations

We want to solve

\[\Delta_\perp E_z = \frac{\partial j_x}{\partial x} - \frac{\partial j_y}{\partial y}\]

with Dirichlet (zero) boundary conditions.

Method

The algorithm can be succinctly written as iDST2D(dirichlet_matrix * DST2D(RHS)), where DST2D and iDST2D are Type-1 Forward and Inverse Discrete Sine 2D Trasforms respectively, RHS is the right-hand side of the equiation above, and dirichlet_matrix is a ‘magical’ matrix that does all the work.

lcode.dirichlet_matrix(grid_steps, grid_step_size)[source]

Calculate a magical matrix that solves the Laplace equation if you elementwise-multiply the RHS by it “in DST-space”. See Samarskiy-Nikolaev, p. 187.

In addition to the magic values, it also hosts the DST normalization multiplier.

Todo

DOCS: expand with method description (Kargapolov, Shalimova)

lcode.calculate_Ez(config, jx, jy)[source]

Calculate Ez as iDST2D(dirichlet_matrix * DST2D(djx/dx + djy/dy)).

Note that the outer cells do not participate in the calculations, and the result is simply padded with zeroes in the end.

DST2D

lcode.dst2d(a)[source]

Calculate DST-Type1-2D, jury-rigged from anti-symmetrically-padded rFFT.

As cupy currently ships no readily available function for calculating the DST2D on the GPU, we roll out our own FFT-based implementation.

We don’t need to make a separate iDST2D function as (for Type-1) it matches DST2D up to the normalization multiplier, which is taken into account in dirichlet_matrix().