tidy3d.GridSpec#
- class GridSpec[source]#
Bases:
Tidy3dBaseModel
Collective grid specification for all three dimensions.
- Parameters:
grid_x (Attribute:
grid_x
) –Type
Union[UniformGrid, CustomGrid, AutoGrid]
Default
= AutoGrid(type’AutoGrid’, min_steps_per_wvl10.0, max_scale1.4, dl_min0.0, mesherGradedMesher(type’GradedMesher’))
Description
Grid specification along x-axis
grid_y (Attribute:
grid_y
) –Type
Union[UniformGrid, CustomGrid, AutoGrid]
Default
= AutoGrid(type’AutoGrid’, min_steps_per_wvl10.0, max_scale1.4, dl_min0.0, mesherGradedMesher(type’GradedMesher’))
Description
Grid specification along y-axis
grid_z (Attribute:
grid_z
) –Type
Union[UniformGrid, CustomGrid, AutoGrid]
Default
= AutoGrid(type’AutoGrid’, min_steps_per_wvl10.0, max_scale1.4, dl_min0.0, mesherGradedMesher(type’GradedMesher’))
Description
Grid specification along z-axis
wavelength (Attribute:
wavelength
) –Type
Optional[float]
Default
= None
Units
um
Description
Free-space wavelength for automatic nonuniform grid. It can be ‘None’ if there is at least one source in the simulation, in which case it is defined by the source central frequency. Note: it only takes effect when at least one of the three dimensions uses
AutoGrid
.override_structures (Attribute:
override_structures
) –Type
Tuple[Annotated[Union[tidy3d.components.structure.Structure, tidy3d.components.structure.MeshOverrideStructure], FieldInfo(default=PydanticUndefined, discriminator=’type’, extra={})], …]
Default
= ()
Description
A set of structures that is added on top of the simulation structures in the process of generating the grid. This can be used to refine the grid or make it coarser depending than the expected need for higher/lower resolution regions. Note: it only takes effect when at least one of the three dimensions uses
AutoGrid
.
Example
>>> uniform = UniformGrid(dl=0.1) >>> custom = CustomGrid(dl=[0.2, 0.2, 0.1, 0.1, 0.1, 0.2, 0.2]) >>> auto = AutoGrid(min_steps_per_wvl=12) >>> grid_spec = GridSpec(grid_x=uniform, grid_y=custom, grid_z=auto, wavelength=1.5)
See also
UniformGrid
Uniform 1D grid.
AutoGrid
Specification for non-uniform grid along a given dimension.
- Notebooks:
- Lectures:
Attributes
True if any of the three dimensions uses
AutoGrid
.True if any of the three dimensions uses
CustomGrid
.Along each axis,
True
if any override structure is used.Methods
auto
([wavelength, min_steps_per_wvl, ...])Use the same
AutoGrid
along each of the three directions.make_grid
(structures, symmetry, periodic, ...)Make the entire simulation grid based on some simulation parameters.
uniform
(dl)Use the same
UniformGrid
along each of the three directions.wavelength_from_sources
(sources)Define a wavelength based on supplied sources.
- grid_x#
- grid_y#
- grid_z#
- wavelength#
- override_structures#
- property custom_grid_used#
True if any of the three dimensions uses
CustomGrid
.
- static wavelength_from_sources(sources)[source]#
Define a wavelength based on supplied sources. Called if auto mesh is used and
self.wavelength is None
.
- property override_structures_used#
Along each axis,
True
if any override structure is used. However, it is stillFalse
if onlyMeshOverrideStructure
is supplied, and theirdl[axis]
all take theNone
value.
- make_grid(structures, symmetry, periodic, sources, num_pml_layers)[source]#
Make the entire simulation grid based on some simulation parameters.
- Parameters:
structures (List[Structure]) – List of structures present in the simulation. The first structure must be the simulation geometry with the simulation background medium.
symmetry (Tuple[Symmetry, Symmetry, Symmetry]) – Reflection symmetry across a plane bisecting the simulation domain normal to each of the three axes.
sources (List[SourceType]) – List of sources.
num_pml_layers (List[Tuple[float, float]]) – List containing the number of absorber layers in - and + boundaries.
- Returns:
Entire simulation grid.
- Return type:
- classmethod auto(wavelength=None, min_steps_per_wvl=10.0, max_scale=1.4, override_structures=(), dl_min=0.0, mesher=GradedMesher(type='GradedMesher'))[source]#
Use the same
AutoGrid
along each of the three directions.- Parameters:
wavelength (pd.PositiveFloat, optional) – Free-space wavelength for automatic nonuniform grid. It can be ‘None’ if there is at least one source in the simulation, in which case it is defined by the source central frequency.
min_steps_per_wvl (pd.PositiveFloat, optional) – Minimal number of steps per wavelength in each medium.
max_scale (pd.PositiveFloat, optional) – Sets the maximum ratio between any two consecutive grid steps.
override_structures (List[StructureType]) – A list of structures that is added on top of the simulation structures in the process of generating the grid. This can be used to refine the grid or make it coarser depending than the expected need for higher/lower resolution regions.
dl_min (pd.NonNegativeFloat) – Lower bound of grid size.
mesher (MesherType = GradedMesher()) – The type of mesher to use to generate the grid automatically.
- Returns:
GridSpec
with the same automatic nonuniform grid settings in each direction.- Return type:
- classmethod uniform(dl)[source]#
Use the same
UniformGrid
along each of the three directions.
- __hash__()#
Hash method.