metabox.rcwa_tf package¶
Submodules¶
metabox.rcwa_tf.shane_rcwa_tf module¶
- metabox.rcwa_tf.shane_rcwa_tf.convmat(A, P, Q)[source]¶
This function computes a convolution matrix for a real space matrix A that represents either a relative permittivity or permeability distribution for a set of pixels, layers, and batch. :param A: A tf.Tensor of dtype complex and shape (batchSize, pixelsX, :param pixelsY: :param n_layersers: :param Nx: :param Ny) specifying real space values on a Cartesian: :param grid.: :param P: A positive and odd int specifying the number of spatial harmonics :param along T1.: :param Q: A positive and odd int specifying the number of spatial harmonics :param along T2.:
- Returns:
A tf.Tensor of dtype complex and shape (batchSize, pixelsX, pixelsY, n_layersers, P * Q, P * Q) representing a stack of convolution matrices based on A.
- metabox.rcwa_tf.shane_rcwa_tf.eig_general(A, eps=1e-06)[source]¶
Computes the eigendecomposition of a batch of matrices, the same as tf.eig() but assumes the input shape also has extra dimensions for pixels and layers. This function also provides the reverse mode gradient of the eigendecomposition as derived in 10.1109/ICASSP.2017.7952140. This applies for general, complex matrices that do not have to be self adjoint. This result gives the exact reverse mode gradient for nondegenerate eigenvalue problems. To extend to the case of degenerate eigenvalues common in RCWA, we approximate the gradient by a Lorentzian broadening technique that introduces a small error but stabilizes the calculation. This is based on 10.1103/PhysRevX.9.031041. :param A: A tf.Tensor of shape (batchSize, pixelsX, pixelsY, n_layersers, Nx, :param Ny) and dtype tf.complex64 where the last two dimensions define: :param matrices for which we will calculate the eigendecomposition of their: :param reverse mode gradients.: :param eps: A float defining a regularization parameter used in the :param denominator of the Lorentzian broadening calculation to enable reverse: :param mode gradients for degenerate eigenvalues.:
- Returns:
A Tuple(List[tf.Tensor, tf.Tensor], tf.Tensor), where the List specifies the eigendecomposition as computed by tf.eig() and the second element of the Tuple gives the reverse mode gradient of the eigendecompostion of the input argument A.
- metabox.rcwa_tf.shane_rcwa_tf.expand_and_tile_np(array, batchSize, pixelsX, pixelsY)[source]¶
Expands and tile a numpy array for a given batchSize and number of pixels. :param array: A np.ndarray of shape (Nx, Ny).
- Returns:
A np.ndarray of shape (batchSize, pixelsX, pixelsY, Nx, Ny) with the values from array tiled over the new dimensions.
- metabox.rcwa_tf.shane_rcwa_tf.expand_and_tile_tf(tensor, batchSize, pixelsX, pixelsY)[source]¶
Expands and tile a tf.Tensor for a given batchSize and number of pixels. :param tensor: A tf.Tensor of shape (Nx, Ny).
- Returns:
A tf.Tensor of shape (batchSize, pixelsX, pixelsY, Nx, Ny) with the values from tensor tiled over the new dimensions.
- metabox.rcwa_tf.shane_rcwa_tf.redheffer_star_product(SA, SB)[source]¶
This function computes the redheffer star product of two block matrices, which is the result of combining the S-parameter of two systems. :param SA: A dict of tf.Tensor values specifying the block matrix :param corresponding to the S-parameters of a system. SA needs to have the: :param keys: :type keys: ‘S11’, ‘S12’, ‘S21’, ‘S22’ :param of shape : :type of shape `: batchSize, pixelsX, pixelsY, 2*NH, 2*NH :param total number of spatial harmonics.: :param SB: A `dict of tf.Tensor values specifying the block matrix :param corresponding to the S-parameters of a second system. SB needs to have: :param the keys: :type the keys: ‘S11’, ‘S12’, ‘S21’, ‘S22’ :param tf.Tensor of shape : :type `tf.Tensor of shape `: batchSize, pixelsX, pixelsY, 2*NH, 2*NH :param NH is the total number of spatial harmonics.:
- Returns:
A dict of tf.Tensor values specifying the block matrix corresponding to the S-parameters of the combined system. SA needs to have the keys (‘S11’, ‘S12’, ‘S21’, ‘S22’), where each key maps to a tf.Tensor of shape `(batchSize, pixelsX, pixelsY, 2*NH, 2*NH), where NH is the total number of spatial harmonics.
- metabox.rcwa_tf.shane_rcwa_tf.simulate_rcwa(incidence_dict: dict, PQ: Tuple[int, int], n_cells: int, n_layers: int, layer_thicknesses: Tensor, L_xy: Tuple[Feature | float | Tensor, Feature | float | Tensor], er1: Feature | float | Tensor, er2: Feature | float | Tensor, ER_t: Tensor, UR_t: Tensor, refl_n: Feature | float | Tensor)[source]¶
Simulates the periodic unit cell using RCWA.
- Parameters:
incidence_dict – A dict of tf.Tensor values specifying the incidence parameters. incidence_dict needs to have the keys (‘wavelength’, ‘theta’, ‘phi’, ‘polarization’)
PQ – A tuple of int values specifying the number of spatial harmonics in the x and y directions.
n_cells – An int specifying the number of unit cells in the x direction.
n_layers – An int specifying the number of layers in the unit cell.
layer_thicknesses – A tf.Tensor of shape (n_layers, ) specifying the thickness of each layer in the unit cell.
L_xy – A tuple of ParameterType values specifying the size of the unit cell in the x and y directions.
er1 – A ParameterType specifying the relative permittivity of the transmission region in the unit cell.
er2 – A ParameterType specifying the relative permittivity of the reflection region in the unit cell.
ER_t – A tf.Tensor specifying the relative permittivity of each layer in the unit cell.
UR_t – A tf.Tensor specifying the relative permeability of each layer in the unit cell.
refl_n – A ParameterType specifying the refractive index of the reflection region in the unit cell.
- Returns:
The diffraction coefficients of the unit cell.