tidy3d.EMECompositeGrid#
- class EMECompositeGrid[source]#
Bases:
EMEGridSpec
EME grid made out of multiple subgrids.
- Parameters:
attrs (dict = {}) – Dictionary storing arbitrary metadata for a Tidy3D object. This dictionary can be freely used by the user for storing data without affecting the operation of Tidy3D as it is not used internally. Note that, unlike regular Tidy3D fields,
attrs
are mutable. For example, the following is allowed for setting anattr
obj.attrs['foo'] = bar
. Also note that Tidy3D` will raise aTypeError
ifattrs
contain objects that can not be serialized. One can check ifattrs
are serializable by callingobj.json()
.num_reps (PositiveInt = 1) – Number of periodic repetitions of this EME grid. Useful for efficiently simulating long periodic structures like Bragg gratings. Instead of explicitly repeating the cells, setting ‘num_reps’ allows the EME solver to reuse the modes and cell interface scattering matrices.
name (Optional[str] = None) – Name of this ‘EMEGridSpec’. Used in ‘EMEPeriodicitySweep’.
subgrids (ForwardRef('List[EMESubgridType]')) – Subgrids in the composite grid.
subgrid_boundaries (ArrayLike[dtype=float, ndim=1]) – List of coordinates of internal subgrid boundaries along the propagation axis. Must contain one fewer item than ‘subgrids’, and must be strictly increasing. Each subgrid spans the region between an adjacent pair of subgrid boundaries. The first (last) subgrid spans the region between the first (last) subgrid boundary and the simulation boundary.
Example
>>> from tidy3d import EMEUniformGrid, EMEModeSpec >>> mode_spec1 = EMEModeSpec(num_modes=10) >>> mode_spec2 = EMEModeSpec(num_modes=20) >>> subgrid1 = EMEUniformGrid(num_cells=5, mode_spec=mode_spec1) >>> subgrid2 = EMEUniformGrid(num_cells=10, mode_spec=mode_spec2) >>> eme_grid = EMECompositeGrid( ... subgrids=[subgrid1, subgrid2], ... subgrid_boundaries=[1] ... )
Attributes
Number of real cells in this EME grid spec.
The cell indices inside this EME grid, starting at 0 and including periodic repetition of cells with
num_reps
.Methods
from_structure_groups
(structure_groups, ...)Create a composite EME grid with boundaries aligned with structure bounding boxes.
make_grid
(center, size, axis)Generate EME grid from the EME grid spec.
subgrid_bounds
(center, size, axis)Subgrid bounds: a list of pairs (rmin, rmax) of the bounds of the subgrids along the propagation axis.
Inherited Common Usage
- subgrids#
- subgrid_boundaries#
- subgrid_bounds(center, size, axis)[source]#
Subgrid bounds: a list of pairs (rmin, rmax) of the bounds of the subgrids along the propagation axis.
- Parameters:
center (
Coordinate
) – Center of the EME simulation.size (
Size
) – Size of the EME simulation.axis (
Axis
) – Propagation axis for the EME simulation.
- Returns:
A list of pairs (rmin, rmax) of the bounds of the subgrids along the propagation axis.
- Return type:
List[Tuple[float, float]]
- make_grid(center, size, axis)[source]#
Generate EME grid from the EME grid spec.
- Parameters:
center (
Coordinate
) – Center of the EME simulation.size (
Size
) – Size of the EME simulation.axis (
Axis
) – Propagation axis for the EME simulation.
- Returns:
An EME grid dividing the EME simulation into cells, as defined by the EME grid spec.
- Return type:
- property num_real_cells#
Number of real cells in this EME grid spec.
- property virtual_cell_indices#
The cell indices inside this EME grid, starting at 0 and including periodic repetition of cells with
num_reps
.
- classmethod from_structure_groups(structure_groups, axis, mode_specs, names=None, num_reps=None)[source]#
Create a composite EME grid with boundaries aligned with structure bounding boxes.
- Parameters:
structure_groups (List[List[
Structure
]]) – A list of structure groups to define theEMECompositeGrid
. Each structure group will be used to generate anEMEExplicitGrid
with boundaries aligned with the bounding boxes of the structures in that group. These will then be assembled as subgrids of anEMECompositeGrid
. Empty structure groups give rise to grids containing a single cell. The boundary between adjacent subgrids is determined from the structure groups; thus they must be consistent, meaning that either the upper bound of one structure group must equal the lower bound of the next, or one of the structure groups must be empty. Two adjacent structure groups cannot be empty.axis (
Axis
) – Propagation axis for the EME simulation.mode_specs (List[
EMEModeSpec
]) – Mode specifications for each subgrid. Must be the same length asstructure_groups
.names (List[str] = None) – Names for each subgrid. Must be the same length as
structure_groups
. IfNone
, the subgrids do not recieve names.num_reps (List[pd.PositiveInt] = None) – Number of repetitions for each subgrid. Must be the same length as
structure_groups
. IfNone
, the subgrids are not repeated.
- Returns:
Composite EME grid with subgrids defined by the structure groups.
- Return type:
Example
>>> from tidy3d import EMEModeSpec, Structure, Box, Medium >>> mode_spec = EMEModeSpec(num_modes=1) >>> box = Structure( ... geometry=Box(center=(0, 0, 0), size=(1, 2, 3)), ... medium=Medium(permittivity=5), ... ) >>> box2 = Structure( ... geometry=Box(center=(0, 0, 3), size=(1, 2, 3)), ... medium=Medium(permittivity=5), ... ) >>> eme_grid_spec = EMECompositeGrid.from_structure_groups( ... structure_groups=[[box], [box2]], ... axis=2, ... mode_specs=[mode_spec]*2, ... names=["subgrid1", None], ... num_reps=[2, 1] ... )
- __hash__()#
Hash method.