sources#

Functions related to sources in the FMM algorithm.

Copyright (c) Meta Platforms, Inc. and affiliates.

fmmax.sources.amplitudes_for_fields(ex: Array, ey: Array, hx: Array, hy: Array, layer_solve_result: LayerSolveResult, brillouin_grid_axes: Tuple[int, int] | None = None) Tuple[Array, Array][source]#

Computes the amplitudes for fields.

The fields are expected to be given for a supercell containing one or more unit cells, i.e. for a calculation with in-plane wavevector generated by basis.brillouin_zone_in_plane_wavevector. The shape of the supercell is inferred from the batch shape of the layer_solve_result and the specified brillouin_grid_axes.

Parameters:
  • ex – The x-oriented electric field on the real-space grid, with a trailing batch dimension.

  • ey – The y-oriented electric field on the real-space grid, with shape (…, nx, ny, num_fields).

  • hx – The x-oriented magnetic field on the real-space grid.

  • hy – The y-oriented magnetic field on the real-space grid.

  • layer_solve_result – The eigensolve result for the layer containing the fields.

  • brillouin_grid_axes – The batch axes corresponding to the Brillouin zone grid.

Returns:

The forward and backward wave amplitudes.

fmmax.sources.amplitudes_for_source(jx: Array, jy: Array, jz: Array, s_matrix_before_source: ScatteringMatrix, s_matrix_after_source: ScatteringMatrix) Tuple[Array, Array, Array, Array, Array, Array][source]#

Computes wave amplitudes resulting from an internal source.

The configuration of the calculation is depicted below. A source is located at the interface of two layers. The layer stacks before and after the source are named as such. The function computes the amplitudes of forward-going and backward-going waves at various locations within the stack, also depicted below.

source _____

__before_______________________V___after_____________________

| | | | | |
layer 0 | … | layer i | layer | … | layer N |
start layer | | | i + 1 | | end layer |
| | | | | |

-> a_i -> a_i+1 -> a_N

b_0 <- b_i <- b_i+1 <-

Parameters:
  • jx – The x-oriented dipole amplitude; must be at least rank-3 with a trailing batch dimension.

  • jy – The y-oriented dipole amplitude, with shape matching jx.

  • jz – The z-oriented dipole amplitude, with shape matching jx.

  • s_matrix_before_source – The scattering matrix for the layer substack before the source, having no overlap with the after-source substack. Scattering matrix pairs returned by scattering.stack_s_matrices_interior may not be directly used.

  • s_matrix_after_source – The scattering matrix for the layer substack after the source.

Returns:

backward_amplitude_0_end: The backward-going wave amplitude at the end

of the first layer.

forward_amplitude_before_start: The forward-going wave amplitude at the

start of the layer preceding the source.

backward_amplitude_before_end: The backward-going wave amplitude at the

end of the layer preceding the source, i.e. just before the source.

forward_amplitude_after_start: The forward-going wave amplitude at the

start of the layer following the source, i.e. just after the source.

backward_amplitude_after_end: The backward-going wave amplitude at the

end of the layer following the source.

forward_amplitude_N_start: The forward-going wave amplitude at the start

of the final layer.

Return type:

The wave amplitudes

fmmax.sources.dirac_delta_source(location: Array, in_plane_wavevector: Array, primitive_lattice_vectors: LatticeVectors, expansion: Expansion) Array[source]#

Returns the coefficients for a delta source at the specified location.

This function is appropriate for creating sources to be used with amplitudes_for_source.

Parameters:
  • location – The location of the source, with shape (num_sources, 2) and the trailing axis giving the x and y location. By convention, the center of the unit cell is at (0, 0).

  • in_plane_wavevector – The in-plane wavevevector for the calculation, which gives the offset of the plane wave decomposition. Has shape (…, 2) with possible batch dimensions.

  • primitive_lattice_vectors – The primitive lattice vectors of the unit cell.

  • expansion – The Fourier expansion used for the calculation.

Returns:

The coefficients, with the shape (…, expansion.num_terms, num_sources).

fmmax.sources.gaussian_source(fwhm: Array, location: Array, in_plane_wavevector: Array, primitive_lattice_vectors: LatticeVectors, expansion: Expansion) Array[source]#

Returns the coefficients for a Gaussian source at the specified location.

This function is appropriate for creating sources to be used with amplitudes_for_source.

Parameters:
  • fwhm – The full-width at half-maximum for the Gaussian source.

  • location – The location of the source, with shape (num_sources, 2) and the trailing axis giving the x and y location. By convention, the center of the unit cell is at (0, 0).

  • in_plane_wavevector – The in-plane wavevevector for the calculation, which gives the offset of the plane wave decomposition. Has shape (…, 2) with possible batch dimensions.

  • primitive_lattice_vectors – The primitive lattice vectors of the unit cell.

  • expansion – The Fourier expansion used for the calculation.

Returns:

The coefficients, with the shape (…, expansion.num_terms, num_sources).