{
  "title": "GridSpec",
  "public_path": "flex_rf.tidy3d.GridSpec",
  "lookup_path": "tidy3d.GridSpec",
  "slug": "flex_rf/tidy3d/GridSpec",
  "public_url": "/rf/latest/autogenerated/flex_rf/tidy3d/gridspec/",
  "object_kind": "class",
  "introduction": "Collective grid specification for all three dimensions.",
  "notes": "**Practical Advice**\n\nWhen using `AutoGrid`, the `wavelength` parameter determines the scale for automatic meshing.\nIf omitted, it is inferred from sources in the simulation. For simulations without sources or where\nfiner control is needed, set it explicitly:\n\n```python\ngrid_spec = GridSpec.auto(min_steps_per_wvl=20, wavelength=1.55)\n```",
  "examples": "```python\nuniform = UniformGrid(dl=0.1)\ncustom = CustomGrid(dl=[0.2, 0.2, 0.1, 0.1, 0.1, 0.2, 0.2])\nauto = AutoGrid(min_steps_per_wvl=12)\ngrid_spec = GridSpec(grid_x=uniform, grid_y=custom, grid_z=auto, wavelength=1.5)\n```",
  "references": "",
  "signature": "class GridSpec(Tidy3dBaseModel)",
  "source": {
    "path": "flex/public/tidy3d/tidy3d/components/grid/grid_spec.py",
    "url": "",
    "lineno": 2556,
    "endlineno": 3695
  },
  "bases": [
    "Tidy3dBaseModel"
  ],
  "parameter_rows": [
    {
      "name": "grid_x",
      "annotation": "GridType",
      "default": "factory: AutoGrid",
      "description": "Grid specification along x-axis",
      "origin": "declared"
    },
    {
      "name": "grid_y",
      "annotation": "GridType",
      "default": "factory: AutoGrid",
      "description": "Grid specification along y-axis",
      "origin": "declared"
    },
    {
      "name": "grid_z",
      "annotation": "GridType",
      "default": "factory: AutoGrid",
      "description": "Grid specification along z-axis",
      "origin": "declared"
    },
    {
      "name": "wavelength",
      "annotation": "PositiveFloat | None",
      "default": "None",
      "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`.",
      "origin": "declared"
    },
    {
      "name": "override_structures",
      "annotation": "tuple[discriminated_union(StructureType), ...]",
      "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` or `QuasiUniformGrid`.",
      "origin": "declared"
    },
    {
      "name": "snapping_points",
      "annotation": "tuple[CoordinateOptional, ...]",
      "default": "()",
      "description": "A set of points that enforce grid boundaries to pass through them. However, some points might be skipped if they are too close. When points are very close to `override_structures`, `snapping_points` have higher prioirty so that the structures might be skipped. Note: it only takes effect when at least one of the three dimensions uses `AutoGrid` or `QuasiUniformGrid`.",
      "origin": "declared"
    },
    {
      "name": "layer_refinement_specs",
      "annotation": "tuple[LayerRefinementSpec, ...]",
      "default": "()",
      "description": "Automatic mesh refinement according to layer specifications. The material distribution is assumed to be uniform inside the layer along the layer axis. Mesh can be refined around corners on the layer cross section, and around upper and lower bounds of the layer.",
      "origin": "declared"
    },
    {
      "name": "attrs",
      "annotation": "dict",
      "default": "factory: dict",
      "description": "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 an `attr` `obj.attrs['foo'] = bar`. Also note that Tidy3D will raise a `TypeError` if `attrs` contain objects that can not be serialized. One can check if `attrs` are serializable by calling `obj.model_dump_json()`.",
      "origin": "inherited"
    }
  ],
  "members": [
    {
      "name": "all_override_structures",
      "kind": "function",
      "signature": "all_override_structures(structures: list[Structure], wavelength: PositiveFloat, lumped_elements: list[LumpedElementType], boundary_types: tuple[tuple[str, str], tuple[str, str], tuple[str, str]], sim_bounds: tuple, structure_priority_mode: PriorityMode = 'equal', internal_override_structures: list[MeshOverrideStructure] | None = None)",
      "description": "Internal and external mesh override structures sorted based on their priority. By default, the priority of internal override structures is -1, and 0 for external ones."
    },
    {
      "name": "all_snapping_points",
      "kind": "function",
      "signature": "all_snapping_points(structures: list[Structure], lumped_elements: list[LumpedElementType], boundary_types: tuple[tuple[str, str], tuple[str, str], tuple[str, str]], sim_bounds: tuple, internal_snapping_points: list[CoordinateOptional] | None = None)",
      "description": "Internal and external snapping points. External snapping points take higher priority. So far, internal snapping points are generated by `layer_refinement_specs`."
    },
    {
      "name": "auto",
      "kind": "function",
      "signature": "auto(wavelength: PositiveFloat = None, min_steps_per_wvl: PositiveFloat = 10.0, max_scale: PositiveFloat = 1.4, override_structures: list[StructureType] = (), snapping_points: tuple[CoordinateOptional, ...] = (), layer_refinement_specs: list[LayerRefinementSpec] = (), dl_min: NonNegativeFloat = 0.0, min_steps_per_sim_size: PositiveFloat = 10.0, mesher: MesherType = Undefined)",
      "description": "Use the same `AutoGrid` along each of the three directions."
    },
    {
      "name": "auto_grid_used",
      "kind": "function",
      "signature": "auto_grid_used()",
      "description": "True if any of the three dimensions uses `AutoGrid`."
    },
    {
      "name": "custom_grid_used",
      "kind": "attribute",
      "signature": "custom_grid_used: bool",
      "description": "True if any of the three dimensions uses `CustomGrid`."
    },
    {
      "name": "external_override_structures",
      "kind": "attribute",
      "signature": "external_override_structures: list[StructureType]",
      "description": "External supplied override structure list."
    },
    {
      "name": "from_grid",
      "kind": "function",
      "signature": "from_grid(grid: Grid)",
      "description": "Import grid directly from another simulation, e.g. `grid_spec = GridSpec.from_grid(sim.grid)`."
    },
    {
      "name": "get_wavelength",
      "kind": "function",
      "signature": "get_wavelength(sources: list[SourceType])",
      "description": "Get wavelength for automatic mesh generation if needed."
    },
    {
      "name": "internal_override_structures",
      "kind": "function",
      "signature": "internal_override_structures(structures: list[Structure], wavelength: PositiveFloat, sim_bounds: tuple, lumped_elements: list[LumpedElementType], boundary_types: tuple[tuple[str, str], tuple[str, str], tuple[str, str]], cached_corners_and_convexity: list[CornersAndConvexity] | None = None, cached_merged_geos: list[tuple[Any, Shapely]] | None = None)",
      "description": "Internal mesh override structures. So far, internal override structures are generated by `layer_refinement_specs` and lumped element."
    },
    {
      "name": "internal_snapping_points",
      "kind": "function",
      "signature": "internal_snapping_points(structures: list[Structure], lumped_elements: list[LumpedElementType], boundary_types: tuple[tuple[str, str], tuple[str, str], tuple[str, str]], sim_bounds: tuple, cached_corners_and_convexity: list[CornersAndConvexity] | None = None, cached_merged_geos: list[tuple[Any, Shapely]] | None = None)",
      "description": "Internal snapping points. So far, internal snapping points are generated by `layer_refinement_specs` and lumped element."
    },
    {
      "name": "layer_refinement_used",
      "kind": "function",
      "signature": "layer_refinement_used()",
      "description": "Whether layer_refiement_specs are applied."
    },
    {
      "name": "make_grid",
      "kind": "function",
      "signature": "make_grid(structures: list[Structure], symmetry: tuple[Symmetry, Symmetry, Symmetry], periodic: tuple[bool, bool, bool], sources: list[SourceType], num_pml_layers: list[tuple[NonNegativeInt, NonNegativeInt]], lumped_elements: list[LumpedElementType] = (), internal_override_structures: list[MeshOverrideStructure] | None = None, internal_snapping_points: list[CoordinateOptional] | None = None, boundary_types: tuple[tuple[str, str], tuple[str, str], tuple[str, str]] = [[None, None], [None, None], [None, None]], structure_priority_mode: PriorityMode = 'equal')",
      "description": "Make the entire simulation grid based on some simulation parameters."
    },
    {
      "name": "override_structures_used",
      "kind": "attribute",
      "signature": "override_structures_used: tuple[bool, bool, bool]",
      "description": "Along each axis, `True` if any override structure is used. However, it is still `False` if only `MeshOverrideStructure` is supplied, and their `dl[axis]` all take the `None` value."
    },
    {
      "name": "quasiuniform",
      "kind": "function",
      "signature": "quasiuniform(dl: float, max_scale: PositiveFloat = 1.4, override_structures: list[StructureType] = (), snapping_points: tuple[CoordinateOptional, ...] = (), mesher: MesherType = Undefined)",
      "description": "Use the same `QuasiUniformGrid` along each of the three directions."
    },
    {
      "name": "snapped_grid_used",
      "kind": "function",
      "signature": "snapped_grid_used()",
      "description": "True if any of the three dimensions uses `AbstractAutoGrid` that will adjust grid with snapping points and geometry boundaries."
    },
    {
      "name": "snapping_points_used",
      "kind": "attribute",
      "signature": "snapping_points_used: tuple[bool, bool, bool]",
      "description": "Along each axis, `True` if any snapping point is used. However, it is still `False` if all snapping points take value `None` along the axis."
    },
    {
      "name": "uniform",
      "kind": "function",
      "signature": "uniform(dl: float)",
      "description": "Use the same `UniformGrid` along each of the three directions."
    },
    {
      "name": "wavelength_from_sources",
      "kind": "function",
      "signature": "wavelength_from_sources(sources: list[SourceType])",
      "description": "Define a wavelength based on supplied sources. Called if auto mesh is used and `self.wavelength is None`."
    }
  ],
  "group": "flex_rf.tidy3d"
}
