RGF is a finite-difference frequency-domain (FDFD) code in MATLAB that uses the recursive Green's function method to solve the scattering matrix (or a portion of it) of a user-specified two-sided structure. Specifically, it solves the scalar Helmholtz equation [∇2+k2εr(r)]ψ(r)=0 in 2D (cal_smatrix_RGF.m
) or 3D (cal_smatrix_RGF_3D.m
). The 2D one is equivalent to Maxwell's equations for 2D transverse-magnetic waves with ψ(x,y)=Ez(x,y), and the 3D one can be used as a scalar approximation of the vectorial Maxwell's equations.
The user-specified relative permittivity profile εr(r) in the scattering region can be an arbitrary real- or complex-valued matrix in 2D or 3D array in 3D, with the imaginary part describing linear gain or absorption. The scattering region is surrounded by semi-infinite homogeneous spaces on the left and right sides (with user-specified constants εL and εR where the input and output channels are defined. In the transverse direction(s), the user can specify periodic, Bloch periodic, or Dirichlet boundary conditions.
RGF solves the discretized wave equation with no additional approximation. The radiation boundary condition is implemented exactly through the retarded Green's function of a semi-infinite space on a square lattice. The scattering matrix RGF computes is normalized by the longitudinal flux and is exactly unitary when εr(r) is real-valued. Reciprocity is also preserved exactly in the scattering matrix.
RGF supports complex-valued frequency, i.e. it can return the scattering matrix analytically continued from a real frequency to an arbitrary complex frequency.
Detailed usage and explanation are given in the first contiguous comment lines, also shown with command help cal_smatrix_RGF
or help cal_smatrix_RGF_3D
in MATLAB. For basic usage, see example_script.m
and example_script_3D.m
.
The recursive Green's function method works by slicing the system and then looping over the slices recursively to compute the side-to-side Green's function. Then the scattering matrix is obtained through the Fisher–Lee relation. The main computations are inversions and multiplications of N-by-N dense matrices, where N=W/Δx in 2D and N=(W/Δx)2 for square cross sections in 3D, W is the transverse width, and Δx is the discretization grid size. So the computing time scales as 𝑂(LW3) in 2D and 𝑂(LW6) in 3D, where L is the longitudinal length. The memory usage scales as 𝑂(LW+W2) in 2D and 𝑂(LW2+W4) in 3D. Michael Wimmer's PhD thesis is a good reference on the recursive Green's function method.
For 2D simulations, it is recommended to use the mesti2s()
function of MESTI.m instead, which considers the same two-sided geometry as here but additionally implements the more powerful augmented partial factorization (APF) method and other features (such as support for transverse-electric polarization, field-profile computation, custom input/output basis, one-sided geometry, and PML).
You can cite this software as: C. W. Hsu, RGF, https://github.com/chiaweihsu/RGF