tidy3d.GridSpec#

class tidy3d.GridSpec#

Bases: tidy3d.components.base.Tidy3dBaseModel

Collective grid specification for all three dimensions.

Parameters
  • grid_x (Union[UniformGrid, CustomGrid, AutoGrid] = AutoGrid(type='AutoGrid', min_steps_per_wvl=10.0, max_scale=1.4, dl_min=0.0, mesher=GradedMesher(type='GradedMesher'))) – Grid specification along x-axis

  • grid_y (Union[UniformGrid, CustomGrid, AutoGrid] = AutoGrid(type='AutoGrid', min_steps_per_wvl=10.0, max_scale=1.4, dl_min=0.0, mesher=GradedMesher(type='GradedMesher'))) – Grid specification along y-axis

  • grid_z (Union[UniformGrid, CustomGrid, AutoGrid] = AutoGrid(type='AutoGrid', min_steps_per_wvl=10.0, max_scale=1.4, dl_min=0.0, mesher=GradedMesher(type='GradedMesher'))) – Grid specification along z-axis

  • wavelength (Optional[float] = None) – [units = um]. 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.

  • override_structures (Tuple[Annotated[Union[tidy3d.components.structure.Structure, tidy3d.components.structure.MeshOverrideStructure], FieldInfo(default=PydanticUndefined, discriminator='type', extra={})], ...] = ()) – 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.

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)

Show JSON schema
{
   "title": "GridSpec",
   "description": "Collective grid specification for all three dimensions.\n\nParameters\n----------\ngrid_x : Union[UniformGrid, CustomGrid, AutoGrid] = AutoGrid(type='AutoGrid', min_steps_per_wvl=10.0, max_scale=1.4, dl_min=0.0, mesher=GradedMesher(type='GradedMesher'))\n    Grid specification along x-axis\ngrid_y : Union[UniformGrid, CustomGrid, AutoGrid] = AutoGrid(type='AutoGrid', min_steps_per_wvl=10.0, max_scale=1.4, dl_min=0.0, mesher=GradedMesher(type='GradedMesher'))\n    Grid specification along y-axis\ngrid_z : Union[UniformGrid, CustomGrid, AutoGrid] = AutoGrid(type='AutoGrid', min_steps_per_wvl=10.0, max_scale=1.4, dl_min=0.0, mesher=GradedMesher(type='GradedMesher'))\n    Grid specification along z-axis\nwavelength : Optional[float] = None\n    [units = um].  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.\noverride_structures : Tuple[Annotated[Union[tidy3d.components.structure.Structure, tidy3d.components.structure.MeshOverrideStructure], FieldInfo(default=PydanticUndefined, discriminator='type', extra={})], ...] = ()\n    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.\n\nExample\n-------\n>>> uniform = UniformGrid(dl=0.1)\n>>> custom = CustomGrid(dl=[0.2, 0.2, 0.1, 0.1, 0.1, 0.2, 0.2])\n>>> auto = AutoGrid(min_steps_per_wvl=12)\n>>> grid_spec = GridSpec(grid_x=uniform, grid_y=custom, grid_z=auto, wavelength=1.5)",
   "type": "object",
   "properties": {
      "grid_x": {
         "title": "Grid specification along x-axis",
         "description": "Grid specification along x-axis",
         "default": {
            "type": "AutoGrid",
            "min_steps_per_wvl": 10.0,
            "max_scale": 1.4,
            "dl_min": 0.0,
            "mesher": {
               "type": "GradedMesher"
            }
         },
         "anyOf": [
            {
               "$ref": "#/definitions/UniformGrid"
            },
            {
               "$ref": "#/definitions/CustomGrid"
            },
            {
               "$ref": "#/definitions/AutoGrid"
            }
         ]
      },
      "grid_y": {
         "title": "Grid specification along y-axis",
         "description": "Grid specification along y-axis",
         "default": {
            "type": "AutoGrid",
            "min_steps_per_wvl": 10.0,
            "max_scale": 1.4,
            "dl_min": 0.0,
            "mesher": {
               "type": "GradedMesher"
            }
         },
         "anyOf": [
            {
               "$ref": "#/definitions/UniformGrid"
            },
            {
               "$ref": "#/definitions/CustomGrid"
            },
            {
               "$ref": "#/definitions/AutoGrid"
            }
         ]
      },
      "grid_z": {
         "title": "Grid specification along z-axis",
         "description": "Grid specification along z-axis",
         "default": {
            "type": "AutoGrid",
            "min_steps_per_wvl": 10.0,
            "max_scale": 1.4,
            "dl_min": 0.0,
            "mesher": {
               "type": "GradedMesher"
            }
         },
         "anyOf": [
            {
               "$ref": "#/definitions/UniformGrid"
            },
            {
               "$ref": "#/definitions/CustomGrid"
            },
            {
               "$ref": "#/definitions/AutoGrid"
            }
         ]
      },
      "wavelength": {
         "title": "Free-space wavelength",
         "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.",
         "units": "um",
         "type": "number"
      },
      "override_structures": {
         "title": "Grid specification override structures",
         "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.",
         "default": [],
         "type": "array",
         "items": {
            "discriminator": {
               "propertyName": "type",
               "mapping": {
                  "Structure": "#/definitions/Structure",
                  "MeshOverrideStructure": "#/definitions/MeshOverrideStructure"
               }
            },
            "oneOf": [
               {
                  "$ref": "#/definitions/Structure"
               },
               {
                  "$ref": "#/definitions/MeshOverrideStructure"
               }
            ]
         }
      },
      "type": {
         "title": "Type",
         "default": "GridSpec",
         "enum": [
            "GridSpec"
         ],
         "type": "string"
      }
   },
   "additionalProperties": false,
   "definitions": {
      "UniformGrid": {
         "title": "UniformGrid",
         "description": "Uniform 1D grid.\n\nParameters\n----------\ndl : PositiveFloat\n    [units = um].  Grid size for uniform grid generation.\n\nExample\n-------\n>>> grid_1d = UniformGrid(dl=0.1)",
         "type": "object",
         "properties": {
            "type": {
               "title": "Type",
               "default": "UniformGrid",
               "enum": [
                  "UniformGrid"
               ],
               "type": "string"
            },
            "dl": {
               "title": "Grid Size",
               "description": "Grid size for uniform grid generation.",
               "units": "um",
               "exclusiveMinimum": 0,
               "type": "number"
            }
         },
         "required": [
            "dl"
         ],
         "additionalProperties": false
      },
      "CustomGrid": {
         "title": "CustomGrid",
         "description": "Custom 1D grid supplied as a list of grid cell sizes centered on the simulation center.\n\nParameters\n----------\ndl : Tuple[PositiveFloat, ...]\n    [units = um].  An array of custom nonuniform grid sizes. The resulting grid is centered on the simulation center such that it spans the region ``(center - sum(dl)/2, center + sum(dl)/2)``. Note: if supplied sizes do not cover the simulation size, the first and last sizes are repeated to cover the simulation domain.\n\nExample\n-------\n>>> grid_1d = CustomGrid(dl=[0.2, 0.2, 0.1, 0.1, 0.1, 0.2, 0.2])",
         "type": "object",
         "properties": {
            "type": {
               "title": "Type",
               "default": "CustomGrid",
               "enum": [
                  "CustomGrid"
               ],
               "type": "string"
            },
            "dl": {
               "title": "Customized grid sizes.",
               "description": "An array of custom nonuniform grid sizes. The resulting grid is centered on the simulation center such that it spans the region ``(center - sum(dl)/2, center + sum(dl)/2)``. Note: if supplied sizes do not cover the simulation size, the first and last sizes are repeated to cover the simulation domain.",
               "units": "um",
               "type": "array",
               "items": {
                  "type": "number",
                  "exclusiveMinimum": 0
               }
            }
         },
         "required": [
            "dl"
         ],
         "additionalProperties": false
      },
      "GradedMesher": {
         "title": "GradedMesher",
         "description": "Implements automatic nonuniform meshing with a set minimum steps per wavelength and\na graded mesh expanding from higher- to lower-resolution regions.\n\nParameters\n----------",
         "type": "object",
         "properties": {
            "type": {
               "title": "Type",
               "default": "GradedMesher",
               "enum": [
                  "GradedMesher"
               ],
               "type": "string"
            }
         },
         "additionalProperties": false
      },
      "AutoGrid": {
         "title": "AutoGrid",
         "description": "Specification for non-uniform grid along a given dimension.\n\nParameters\n----------\nmin_steps_per_wvl : ConstrainedFloatValue = 10.0\n    Minimal number of steps per wavelength in each medium.\nmax_scale : ConstrainedFloatValue = 1.4\n    Sets the maximum ratio between any two consecutive grid steps.\ndl_min : NonNegativeFloat = 0\n    Lower bound of the grid size along this dimension regardless of structures present in the simulation, including override structures with ``enforced=True``. It is a soft bound, meaning that the actual minimal grid size might be slightly smaller.\nmesher : GradedMesher = GradedMesher(type='GradedMesher')\n    The type of mesher to use to generate the grid automatically.\n\nExample\n-------\n>>> grid_1d = AutoGrid(min_steps_per_wvl=16, max_scale=1.4)",
         "type": "object",
         "properties": {
            "type": {
               "title": "Type",
               "default": "AutoGrid",
               "enum": [
                  "AutoGrid"
               ],
               "type": "string"
            },
            "min_steps_per_wvl": {
               "title": "Minimal number of steps per wavelength",
               "description": "Minimal number of steps per wavelength in each medium.",
               "default": 10.0,
               "minimum": 6.0,
               "type": "number"
            },
            "max_scale": {
               "title": "Maximum Grid Size Scaling",
               "description": "Sets the maximum ratio between any two consecutive grid steps.",
               "default": 1.4,
               "exclusiveMaximum": 2.0,
               "minimum": 1.2,
               "type": "number"
            },
            "dl_min": {
               "title": "Lower bound of grid size",
               "description": "Lower bound of the grid size along this dimension regardless of structures present in the simulation, including override structures with ``enforced=True``. It is a soft bound, meaning that the actual minimal grid size might be slightly smaller.",
               "default": 0,
               "minimum": 0,
               "type": "number"
            },
            "mesher": {
               "title": "Grid Construction Tool",
               "description": "The type of mesher to use to generate the grid automatically.",
               "default": {
                  "type": "GradedMesher"
               },
               "allOf": [
                  {
                     "$ref": "#/definitions/GradedMesher"
                  }
               ]
            }
         },
         "additionalProperties": false
      },
      "Box": {
         "title": "Box",
         "description": "Rectangular prism.\n   Also base class for :class:`Simulation`, :class:`Monitor`, and :class:`Source`.\n\nParameters\n----------\ncenter : Tuple[float, float, float] = (0.0, 0.0, 0.0)\n    [units = um].  Center of object in x, y, and z.\nsize : Tuple[NonNegativeFloat, NonNegativeFloat, NonNegativeFloat]\n    [units = um].  Size in x, y, and z directions.\n\nExample\n-------\n>>> b = Box(center=(1,2,3), size=(2,2,2))",
         "type": "object",
         "properties": {
            "type": {
               "title": "Type",
               "default": "Box",
               "enum": [
                  "Box"
               ],
               "type": "string"
            },
            "center": {
               "title": "Center",
               "description": "Center of object in x, y, and z.",
               "default": [
                  0.0,
                  0.0,
                  0.0
               ],
               "units": "um",
               "type": "array",
               "minItems": 3,
               "maxItems": 3,
               "items": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "number"
                  },
                  {
                     "type": "number"
                  }
               ]
            },
            "size": {
               "title": "Size",
               "description": "Size in x, y, and z directions.",
               "units": "um",
               "type": "array",
               "minItems": 3,
               "maxItems": 3,
               "items": [
                  {
                     "type": "number",
                     "minimum": 0
                  },
                  {
                     "type": "number",
                     "minimum": 0
                  },
                  {
                     "type": "number",
                     "minimum": 0
                  }
               ]
            }
         },
         "required": [
            "size"
         ],
         "additionalProperties": false
      },
      "Sphere": {
         "title": "Sphere",
         "description": "Spherical geometry.\n\nParameters\n----------\nradius : NonNegativeFloat\n    [units = um].  Radius of geometry.\ncenter : Tuple[float, float, float] = (0.0, 0.0, 0.0)\n    [units = um].  Center of object in x, y, and z.\n\nExample\n-------\n>>> b = Sphere(center=(1,2,3), radius=2)",
         "type": "object",
         "properties": {
            "type": {
               "title": "Type",
               "default": "Sphere",
               "enum": [
                  "Sphere"
               ],
               "type": "string"
            },
            "radius": {
               "title": "Radius",
               "description": "Radius of geometry.",
               "units": "um",
               "minimum": 0,
               "type": "number"
            },
            "center": {
               "title": "Center",
               "description": "Center of object in x, y, and z.",
               "default": [
                  0.0,
                  0.0,
                  0.0
               ],
               "units": "um",
               "type": "array",
               "minItems": 3,
               "maxItems": 3,
               "items": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "number"
                  },
                  {
                     "type": "number"
                  }
               ]
            }
         },
         "required": [
            "radius"
         ],
         "additionalProperties": false
      },
      "Cylinder": {
         "title": "Cylinder",
         "description": "Cylindrical geometry with optional sidewall angle along axis\ndirection. When ``sidewall_angle`` is nonzero, the shape is a\nconical frustum or a cone.\n\nParameters\n----------\naxis : Literal[0, 1, 2] = 2\n    Specifies dimension of the planar axis (0,1,2) -> (x,y,z).\nsidewall_angle : ConstrainedFloatValue = 0.0\n    [units = rad].  Angle of the sidewall. ``sidewall_angle=0`` (default) specifies a vertical wall; ``0<sidewall_angle<np.pi/2`` specifies a shrinking cross section along the ``axis`` direction; and ``-np.pi/2<sidewall_angle<0`` specifies an expanding cross section along the ``axis`` direction.\nreference_plane : Literal['bottom', 'middle', 'top'] = bottom\n    The position of the plane where the supplied cross section are defined. The plane is perpendicular to the ``axis``. The plane is located at the ``bottom``, ``middle``, or ``top`` of the geometry with respect to the axis. E.g. if ``axis=1``, ``bottom`` refers to the negative side of the y-axis, and ``top`` refers to the positive side of the y-axis.\nradius : NonNegativeFloat\n    [units = um].  Radius of geometry.\ncenter : Tuple[float, float, float] = (0.0, 0.0, 0.0)\n    [units = um].  Center of object in x, y, and z.\nlength : NonNegativeFloat\n    [units = um].  Defines thickness of cylinder along axis dimension.\n\nExample\n-------\n>>> c = Cylinder(center=(1,2,3), radius=2, length=5, axis=2)",
         "type": "object",
         "properties": {
            "type": {
               "title": "Type",
               "default": "Cylinder",
               "enum": [
                  "Cylinder"
               ],
               "type": "string"
            },
            "axis": {
               "title": "Axis",
               "description": "Specifies dimension of the planar axis (0,1,2) -> (x,y,z).",
               "default": 2,
               "enum": [
                  0,
                  1,
                  2
               ],
               "type": "integer"
            },
            "sidewall_angle": {
               "title": "Sidewall angle",
               "description": "Angle of the sidewall. ``sidewall_angle=0`` (default) specifies a vertical wall; ``0<sidewall_angle<np.pi/2`` specifies a shrinking cross section along the ``axis`` direction; and ``-np.pi/2<sidewall_angle<0`` specifies an expanding cross section along the ``axis`` direction.",
               "default": 0.0,
               "exclusiveMinimum": -1.5707963267948966,
               "exclusiveMaximum": 1.5707963267948966,
               "units": "rad",
               "type": "number"
            },
            "reference_plane": {
               "title": "Reference plane for cross section",
               "description": "The position of the plane where the supplied cross section are defined. The plane is perpendicular to the ``axis``. The plane is located at the ``bottom``, ``middle``, or ``top`` of the geometry with respect to the axis. E.g. if ``axis=1``, ``bottom`` refers to the negative side of the y-axis, and ``top`` refers to the positive side of the y-axis.",
               "default": "bottom",
               "enum": [
                  "bottom",
                  "middle",
                  "top"
               ],
               "type": "string"
            },
            "radius": {
               "title": "Radius",
               "description": "Radius of geometry.",
               "units": "um",
               "minimum": 0,
               "type": "number"
            },
            "center": {
               "title": "Center",
               "description": "Center of object in x, y, and z.",
               "default": [
                  0.0,
                  0.0,
                  0.0
               ],
               "units": "um",
               "type": "array",
               "minItems": 3,
               "maxItems": 3,
               "items": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "number"
                  },
                  {
                     "type": "number"
                  }
               ]
            },
            "length": {
               "title": "Length",
               "description": "Defines thickness of cylinder along axis dimension.",
               "units": "um",
               "minimum": 0,
               "type": "number"
            }
         },
         "required": [
            "radius",
            "length"
         ],
         "additionalProperties": false
      },
      "PolySlab": {
         "title": "PolySlab",
         "description": "Polygon extruded with optional sidewall angle along axis direction.\n\nParameters\n----------\naxis : Literal[0, 1, 2] = 2\n    Specifies dimension of the planar axis (0,1,2) -> (x,y,z).\nsidewall_angle : ConstrainedFloatValue = 0.0\n    [units = rad].  Angle of the sidewall. ``sidewall_angle=0`` (default) specifies a vertical wall; ``0<sidewall_angle<np.pi/2`` specifies a shrinking cross section along the ``axis`` direction; and ``-np.pi/2<sidewall_angle<0`` specifies an expanding cross section along the ``axis`` direction.\nreference_plane : Literal['bottom', 'middle', 'top'] = bottom\n    The position of the plane where the supplied cross section are defined. The plane is perpendicular to the ``axis``. The plane is located at the ``bottom``, ``middle``, or ``top`` of the geometry with respect to the axis. E.g. if ``axis=1``, ``bottom`` refers to the negative side of the y-axis, and ``top`` refers to the positive side of the y-axis.\nslab_bounds : Tuple[float, float]\n    [units = um].  Minimum and maximum positions of the slab along axis dimension.\ndilation : float = 0.0\n    [units = um].  Dilation of the supplied polygon by shifting each edge along its normal outwards direction by a distance; a negative value corresponds to erosion.\nvertices : Union[Tuple[Tuple[float, float], ...], Array]\n    [units = um].  List of (d1, d2) defining the 2 dimensional positions of the polygon face vertices at the ``reference_plane``. The index of dimension should be in the ascending order: e.g. if the slab normal axis is ``axis=y``, the coordinate of the vertices will be in (x, z)\n\nExample\n-------\n>>> vertices = np.array([(0,0), (1,0), (1,1)])\n>>> p = PolySlab(vertices=vertices, axis=2, slab_bounds=(-1, 1))",
         "type": "object",
         "properties": {
            "type": {
               "title": "Type",
               "default": "PolySlab",
               "enum": [
                  "PolySlab"
               ],
               "type": "string"
            },
            "axis": {
               "title": "Axis",
               "description": "Specifies dimension of the planar axis (0,1,2) -> (x,y,z).",
               "default": 2,
               "enum": [
                  0,
                  1,
                  2
               ],
               "type": "integer"
            },
            "sidewall_angle": {
               "title": "Sidewall angle",
               "description": "Angle of the sidewall. ``sidewall_angle=0`` (default) specifies a vertical wall; ``0<sidewall_angle<np.pi/2`` specifies a shrinking cross section along the ``axis`` direction; and ``-np.pi/2<sidewall_angle<0`` specifies an expanding cross section along the ``axis`` direction.",
               "default": 0.0,
               "exclusiveMinimum": -1.5707963267948966,
               "exclusiveMaximum": 1.5707963267948966,
               "units": "rad",
               "type": "number"
            },
            "reference_plane": {
               "title": "Reference plane for cross section",
               "description": "The position of the plane where the supplied cross section are defined. The plane is perpendicular to the ``axis``. The plane is located at the ``bottom``, ``middle``, or ``top`` of the geometry with respect to the axis. E.g. if ``axis=1``, ``bottom`` refers to the negative side of the y-axis, and ``top`` refers to the positive side of the y-axis.",
               "default": "bottom",
               "enum": [
                  "bottom",
                  "middle",
                  "top"
               ],
               "type": "string"
            },
            "slab_bounds": {
               "title": "Slab Bounds",
               "description": "Minimum and maximum positions of the slab along axis dimension.",
               "units": "um",
               "type": "array",
               "minItems": 2,
               "maxItems": 2,
               "items": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "number"
                  }
               ]
            },
            "dilation": {
               "title": "Dilation",
               "description": "Dilation of the supplied polygon by shifting each edge along its normal outwards direction by a distance; a negative value corresponds to erosion.",
               "default": 0.0,
               "units": "um",
               "type": "number"
            },
            "vertices": {
               "title": "Vertices",
               "description": "List of (d1, d2) defining the 2 dimensional positions of the polygon face vertices at the ``reference_plane``. The index of dimension should be in the ascending order: e.g. if the slab normal axis is ``axis=y``, the coordinate of the vertices will be in (x, z)",
               "units": "um",
               "anyOf": [
                  {
                     "type": "array",
                     "items": {
                        "type": "array",
                        "minItems": 2,
                        "maxItems": 2,
                        "items": [
                           {
                              "type": "number"
                           },
                           {
                              "type": "number"
                           }
                        ]
                     }
                  },
                  {
                     "title": "Array Like",
                     "description": "Accepts sequence (tuple, list, numpy array) and converts to tuple.",
                     "type": "tuple",
                     "properties": {},
                     "required": []
                  }
               ]
            }
         },
         "required": [
            "slab_bounds",
            "vertices"
         ],
         "additionalProperties": false
      },
      "GeometryGroup": {
         "title": "GeometryGroup",
         "description": "A collection of Geometry objects that can be called as a single geometry object.\n\nParameters\n----------\ngeometries : Tuple[Annotated[Union[tidy3d.components.geometry.Box, tidy3d.components.geometry.Sphere, tidy3d.components.geometry.Cylinder, tidy3d.components.geometry.PolySlab], FieldInfo(default=PydanticUndefined, discriminator='type', extra={})], ...]\n    Tuple of geometries in a single grouping. Can provide significant performance enhancement in ``Structure`` when all geometries are assigned the same medium.",
         "type": "object",
         "properties": {
            "type": {
               "title": "Type",
               "default": "GeometryGroup",
               "enum": [
                  "GeometryGroup"
               ],
               "type": "string"
            },
            "geometries": {
               "title": "Geometries",
               "description": "Tuple of geometries in a single grouping. Can provide significant performance enhancement in ``Structure`` when all geometries are assigned the same medium.",
               "type": "array",
               "items": {
                  "discriminator": {
                     "propertyName": "type",
                     "mapping": {
                        "Box": "#/definitions/Box",
                        "Sphere": "#/definitions/Sphere",
                        "Cylinder": "#/definitions/Cylinder",
                        "PolySlab": "#/definitions/PolySlab"
                     }
                  },
                  "oneOf": [
                     {
                        "$ref": "#/definitions/Box"
                     },
                     {
                        "$ref": "#/definitions/Sphere"
                     },
                     {
                        "$ref": "#/definitions/Cylinder"
                     },
                     {
                        "$ref": "#/definitions/PolySlab"
                     }
                  ]
               }
            }
         },
         "required": [
            "geometries"
         ],
         "additionalProperties": false
      },
      "Medium": {
         "title": "Medium",
         "description": "Dispersionless medium.\n\nParameters\n----------\nname : Optional[str] = None\n    Optional unique name for medium.\nfrequency_range : Optional[Tuple[float, float]] = None\n    [units = (Hz, Hz)].  Optional range of validity for the medium.\npermittivity : ConstrainedFloatValue = 1.0\n    [units = None (relative permittivity)].  Relative permittivity.\nconductivity : ConstrainedFloatValue = 0.0\n    [units = S/um].  Electric conductivity.  Defined such that the imaginary part of the complex permittivity at angular frequency omega is given by conductivity/omega.\n\nExample\n-------\n>>> dielectric = Medium(permittivity=4.0, name='my_medium')\n>>> eps = dielectric.eps_model(200e12)",
         "type": "object",
         "properties": {
            "name": {
               "title": "Name",
               "description": "Optional unique name for medium.",
               "type": "string"
            },
            "frequency_range": {
               "title": "Frequency Range",
               "description": "Optional range of validity for the medium.",
               "units": [
                  "Hz",
                  "Hz"
               ],
               "type": "array",
               "minItems": 2,
               "maxItems": 2,
               "items": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "number"
                  }
               ]
            },
            "type": {
               "title": "Type",
               "default": "Medium",
               "enum": [
                  "Medium"
               ],
               "type": "string"
            },
            "permittivity": {
               "title": "Permittivity",
               "description": "Relative permittivity.",
               "default": 1.0,
               "minimum": 1.0,
               "units": "None (relative permittivity)",
               "type": "number"
            },
            "conductivity": {
               "title": "Conductivity",
               "description": "Electric conductivity.  Defined such that the imaginary part of the complex permittivity at angular frequency omega is given by conductivity/omega.",
               "default": 0.0,
               "minimum": 0.0,
               "units": "S/um",
               "type": "number"
            }
         },
         "additionalProperties": false
      },
      "PermittivityDataset": {
         "title": "PermittivityDataset",
         "description": "Dataset storing the diagonal components of the permittivity tensor.\n\nParameters\n----------\neps_xx : ScalarFieldDataArray\n    Spatial distribution of the xx-component of the relative permittivity.\neps_yy : ScalarFieldDataArray\n    Spatial distribution of the yy-component of the relative permittivity.\neps_zz : ScalarFieldDataArray\n    Spatial distribution of the zz-component of the relative permittivity.\n\nExample\n-------\n>>> x = [-1,1]\n>>> y = [-2,0,2]\n>>> z = [-3,-1,1,3]\n>>> f = [2e14, 3e14]\n>>> coords = dict(x=x, y=y, z=z, f=f)\n>>> sclr_fld = ScalarFieldDataArray((1+1j) * np.random.random((2,3,4,2)), coords=coords)\n>>> data = PermittivityDataset(eps_xx=sclr_fld, eps_yy=sclr_fld, eps_zz=sclr_fld)",
         "type": "object",
         "properties": {
            "type": {
               "title": "Type",
               "default": "PermittivityDataset",
               "enum": [
                  "PermittivityDataset"
               ],
               "type": "string"
            },
            "eps_xx": {
               "title": "DataArray",
               "description": "Spatial distribution of the xx-component of the relative permittivity.",
               "type": "xr.DataArray",
               "properties": {
                  "_dims": {
                     "title": "_dims",
                     "type": "Tuple[str, ...]"
                  }
               },
               "required": [
                  "_dims"
               ]
            },
            "eps_yy": {
               "title": "DataArray",
               "description": "Spatial distribution of the yy-component of the relative permittivity.",
               "type": "xr.DataArray",
               "properties": {
                  "_dims": {
                     "title": "_dims",
                     "type": "Tuple[str, ...]"
                  }
               },
               "required": [
                  "_dims"
               ]
            },
            "eps_zz": {
               "title": "DataArray",
               "description": "Spatial distribution of the zz-component of the relative permittivity.",
               "type": "xr.DataArray",
               "properties": {
                  "_dims": {
                     "title": "_dims",
                     "type": "Tuple[str, ...]"
                  }
               },
               "required": [
                  "_dims"
               ]
            }
         },
         "required": [
            "eps_xx",
            "eps_yy",
            "eps_zz"
         ],
         "additionalProperties": false
      },
      "CustomMedium": {
         "title": "CustomMedium",
         "description": ":class:`.Medium` with user-supplied permittivity distribution.\n\nParameters\n----------\nname : Optional[str] = None\n    Optional unique name for medium.\nfrequency_range : Optional[Tuple[float, float]] = None\n    [units = (Hz, Hz)].  Optional range of validity for the medium.\neps_dataset : PermittivityDataset\n    User-supplied dataset containing complex-valued permittivity as a function of space. Permittivity distribution over the Yee-grid will be interpolated based on ``interp_method``.\ninterp_method : Literal['nearest', 'linear'] = nearest\n    Interpolation method to obtain permittivity values that are not supplied at the Yee grids; For grids outside the range of the supplied data, extrapolation will be applied. When the extrapolated value is smaller (greater) than the minimal (maximal) of the supplied data, the extrapolated value will take the minimal (maximal) of the supplied data.\n\nExample\n-------\n>>> Nx, Ny, Nz = 10, 9, 8\n>>> X = np.linspace(-1, 1, Nx)\n>>> Y = np.linspace(-1, 1, Ny)\n>>> Z = np.linspace(-1, 1, Nz)\n>>> freqs = [2e14]\n>>> data = np.ones((Nx, Ny, Nz, 1))\n>>> eps_diagonal_data = ScalarFieldDataArray(data, coords=dict(x=X, y=Y, z=Z, f=freqs))\n>>> eps_components = {f\"eps_{d}{d}\": eps_diagonal_data for d in \"xyz\"}\n>>> eps_dataset = PermittivityDataset(**eps_components)\n>>> dielectric = CustomMedium(eps_dataset=eps_dataset, name='my_medium')\n>>> eps = dielectric.eps_model(200e12)",
         "type": "object",
         "properties": {
            "name": {
               "title": "Name",
               "description": "Optional unique name for medium.",
               "type": "string"
            },
            "frequency_range": {
               "title": "Frequency Range",
               "description": "Optional range of validity for the medium.",
               "units": [
                  "Hz",
                  "Hz"
               ],
               "type": "array",
               "minItems": 2,
               "maxItems": 2,
               "items": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "number"
                  }
               ]
            },
            "type": {
               "title": "Type",
               "default": "CustomMedium",
               "enum": [
                  "CustomMedium"
               ],
               "type": "string"
            },
            "eps_dataset": {
               "title": "Permittivity Dataset",
               "description": "User-supplied dataset containing complex-valued permittivity as a function of space. Permittivity distribution over the Yee-grid will be interpolated based on ``interp_method``.",
               "allOf": [
                  {
                     "$ref": "#/definitions/PermittivityDataset"
                  }
               ]
            },
            "interp_method": {
               "title": "Interpolation method",
               "description": "Interpolation method to obtain permittivity values that are not supplied at the Yee grids; For grids outside the range of the supplied data, extrapolation will be applied. When the extrapolated value is smaller (greater) than the minimal (maximal) of the supplied data, the extrapolated value will take the minimal (maximal) of the supplied data.",
               "default": "nearest",
               "enum": [
                  "nearest",
                  "linear"
               ],
               "type": "string"
            }
         },
         "required": [
            "eps_dataset"
         ],
         "additionalProperties": false
      },
      "ComplexNumber": {
         "title": "ComplexNumber",
         "description": "Complex number with a well defined schema.",
         "type": "object",
         "properties": {
            "real": {
               "title": "Real",
               "type": "number"
            },
            "imag": {
               "title": "Imag",
               "type": "number"
            }
         },
         "required": [
            "real",
            "imag"
         ]
      },
      "PoleResidue": {
         "title": "PoleResidue",
         "description": "A dispersive medium described by the pole-residue pair model.\nThe frequency-dependence of the complex-valued permittivity is described by:\n\nParameters\n----------\nname : Optional[str] = None\n    Optional unique name for medium.\nfrequency_range : Optional[Tuple[float, float]] = None\n    [units = (Hz, Hz)].  Optional range of validity for the medium.\neps_inf : float = 1.0\n    [units = None (relative permittivity)].  Relative permittivity at infinite frequency (:math:`\\epsilon_\\infty`).\npoles : Tuple[Tuple[Union[tidy3d.components.types.tidycomplex, tidy3d.components.types.ComplexNumber], Union[tidy3d.components.types.tidycomplex, tidy3d.components.types.ComplexNumber]], ...] = ()\n    [units = (rad/sec, rad/sec)].  Tuple of complex-valued (:math:`a_i, c_i`) poles for the model.\n\nNote\n----\n.. math::\n\n    \\epsilon(\\omega) = \\epsilon_\\infty - \\sum_i\n    \\left[\\frac{c_i}{j \\omega + a_i} +\n    \\frac{c_i^*}{j \\omega + a_i^*}\\right]\n\nExample\n-------\n>>> pole_res = PoleResidue(eps_inf=2.0, poles=[((1+2j), (3+4j)), ((5+6j), (7+8j))])\n>>> eps = pole_res.eps_model(200e12)",
         "type": "object",
         "properties": {
            "name": {
               "title": "Name",
               "description": "Optional unique name for medium.",
               "type": "string"
            },
            "frequency_range": {
               "title": "Frequency Range",
               "description": "Optional range of validity for the medium.",
               "units": [
                  "Hz",
                  "Hz"
               ],
               "type": "array",
               "minItems": 2,
               "maxItems": 2,
               "items": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "number"
                  }
               ]
            },
            "type": {
               "title": "Type",
               "default": "PoleResidue",
               "enum": [
                  "PoleResidue"
               ],
               "type": "string"
            },
            "eps_inf": {
               "title": "Epsilon at Infinity",
               "description": "Relative permittivity at infinite frequency (:math:`\\epsilon_\\infty`).",
               "default": 1.0,
               "units": "None (relative permittivity)",
               "type": "number"
            },
            "poles": {
               "title": "Poles",
               "description": "Tuple of complex-valued (:math:`a_i, c_i`) poles for the model.",
               "default": [],
               "units": [
                  "rad/sec",
                  "rad/sec"
               ],
               "type": "array",
               "items": {
                  "type": "array",
                  "minItems": 2,
                  "maxItems": 2,
                  "items": [
                     {
                        "anyOf": [
                           {
                              "title": "ComplexNumber",
                              "description": "Complex number with a well defined schema.",
                              "type": "object",
                              "properties": {
                                 "real": {
                                    "title": "Real",
                                    "type": "number"
                                 },
                                 "imag": {
                                    "title": "Imag",
                                    "type": "number"
                                 }
                              },
                              "required": [
                                 "real",
                                 "imag"
                              ]
                           },
                           {
                              "$ref": "#/definitions/ComplexNumber"
                           }
                        ]
                     },
                     {
                        "anyOf": [
                           {
                              "title": "ComplexNumber",
                              "description": "Complex number with a well defined schema.",
                              "type": "object",
                              "properties": {
                                 "real": {
                                    "title": "Real",
                                    "type": "number"
                                 },
                                 "imag": {
                                    "title": "Imag",
                                    "type": "number"
                                 }
                              },
                              "required": [
                                 "real",
                                 "imag"
                              ]
                           },
                           {
                              "$ref": "#/definitions/ComplexNumber"
                           }
                        ]
                     }
                  ]
               }
            }
         },
         "additionalProperties": false
      },
      "Sellmeier": {
         "title": "Sellmeier",
         "description": "A dispersive medium described by the Sellmeier model.\nThe frequency-dependence of the refractive index is described by:\n\nParameters\n----------\nname : Optional[str] = None\n    Optional unique name for medium.\nfrequency_range : Optional[Tuple[float, float]] = None\n    [units = (Hz, Hz)].  Optional range of validity for the medium.\ncoeffs : Tuple[Tuple[float, pydantic.types.PositiveFloat], ...]\n    [units = (None, um^2)].  List of Sellmeier (:math:`B_i, C_i`) coefficients.\n\nNote\n----\n.. math::\n\n    n(\\lambda)^2 = 1 + \\sum_i \\frac{B_i \\lambda^2}{\\lambda^2 - C_i}\n\nExample\n-------\n>>> sellmeier_medium = Sellmeier(coeffs=[(1,2), (3,4)])\n>>> eps = sellmeier_medium.eps_model(200e12)",
         "type": "object",
         "properties": {
            "name": {
               "title": "Name",
               "description": "Optional unique name for medium.",
               "type": "string"
            },
            "frequency_range": {
               "title": "Frequency Range",
               "description": "Optional range of validity for the medium.",
               "units": [
                  "Hz",
                  "Hz"
               ],
               "type": "array",
               "minItems": 2,
               "maxItems": 2,
               "items": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "number"
                  }
               ]
            },
            "type": {
               "title": "Type",
               "default": "Sellmeier",
               "enum": [
                  "Sellmeier"
               ],
               "type": "string"
            },
            "coeffs": {
               "title": "Coefficients",
               "description": "List of Sellmeier (:math:`B_i, C_i`) coefficients.",
               "units": [
                  null,
                  "um^2"
               ],
               "type": "array",
               "items": {
                  "type": "array",
                  "minItems": 2,
                  "maxItems": 2,
                  "items": [
                     {
                        "type": "number"
                     },
                     {
                        "type": "number",
                        "exclusiveMinimum": 0
                     }
                  ]
               }
            }
         },
         "required": [
            "coeffs"
         ],
         "additionalProperties": false
      },
      "Lorentz": {
         "title": "Lorentz",
         "description": "A dispersive medium described by the Lorentz model.\nThe frequency-dependence of the complex-valued permittivity is described by:\n\nParameters\n----------\nname : Optional[str] = None\n    Optional unique name for medium.\nfrequency_range : Optional[Tuple[float, float]] = None\n    [units = (Hz, Hz)].  Optional range of validity for the medium.\neps_inf : float = 1.0\n    [units = None (relative permittivity)].  Relative permittivity at infinite frequency (:math:`\\epsilon_\\infty`).\ncoeffs : Tuple[Tuple[float, float, float], ...]\n    [units = (None (relative permittivity), Hz, Hz)].  List of (:math:`\\Delta\\epsilon_i, f_i, \\delta_i`) values for model.\n\nNote\n----\n.. math::\n\n    \\epsilon(f) = \\epsilon_\\infty + \\sum_i\n    \\frac{\\Delta\\epsilon_i f_i^2}{f_i^2 - 2jf\\delta_i - f^2}\n\nExample\n-------\n>>> lorentz_medium = Lorentz(eps_inf=2.0, coeffs=[(1,2,3), (4,5,6)])\n>>> eps = lorentz_medium.eps_model(200e12)",
         "type": "object",
         "properties": {
            "name": {
               "title": "Name",
               "description": "Optional unique name for medium.",
               "type": "string"
            },
            "frequency_range": {
               "title": "Frequency Range",
               "description": "Optional range of validity for the medium.",
               "units": [
                  "Hz",
                  "Hz"
               ],
               "type": "array",
               "minItems": 2,
               "maxItems": 2,
               "items": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "number"
                  }
               ]
            },
            "type": {
               "title": "Type",
               "default": "Lorentz",
               "enum": [
                  "Lorentz"
               ],
               "type": "string"
            },
            "eps_inf": {
               "title": "Epsilon at Infinity",
               "description": "Relative permittivity at infinite frequency (:math:`\\epsilon_\\infty`).",
               "default": 1.0,
               "units": "None (relative permittivity)",
               "type": "number"
            },
            "coeffs": {
               "title": "Coefficients",
               "description": "List of (:math:`\\Delta\\epsilon_i, f_i, \\delta_i`) values for model.",
               "units": [
                  "None (relative permittivity)",
                  "Hz",
                  "Hz"
               ],
               "type": "array",
               "items": {
                  "type": "array",
                  "minItems": 3,
                  "maxItems": 3,
                  "items": [
                     {
                        "type": "number"
                     },
                     {
                        "type": "number"
                     },
                     {
                        "type": "number"
                     }
                  ]
               }
            }
         },
         "required": [
            "coeffs"
         ],
         "additionalProperties": false
      },
      "Debye": {
         "title": "Debye",
         "description": "A dispersive medium described by the Debye model.\nThe frequency-dependence of the complex-valued permittivity is described by:\n\nParameters\n----------\nname : Optional[str] = None\n    Optional unique name for medium.\nfrequency_range : Optional[Tuple[float, float]] = None\n    [units = (Hz, Hz)].  Optional range of validity for the medium.\neps_inf : float = 1.0\n    [units = None (relative permittivity)].  Relative permittivity at infinite frequency (:math:`\\epsilon_\\infty`).\ncoeffs : Tuple[Tuple[float, pydantic.types.PositiveFloat], ...]\n    [units = (None (relative permittivity), sec)].  List of (:math:`\\Delta\\epsilon_i, \\tau_i`) values for model.\n\nNote\n----\n.. math::\n\n    \\epsilon(f) = \\epsilon_\\infty + \\sum_i\n    \\frac{\\Delta\\epsilon_i}{1 - jf\\tau_i}\n\nExample\n-------\n>>> debye_medium = Debye(eps_inf=2.0, coeffs=[(1,2),(3,4)])\n>>> eps = debye_medium.eps_model(200e12)",
         "type": "object",
         "properties": {
            "name": {
               "title": "Name",
               "description": "Optional unique name for medium.",
               "type": "string"
            },
            "frequency_range": {
               "title": "Frequency Range",
               "description": "Optional range of validity for the medium.",
               "units": [
                  "Hz",
                  "Hz"
               ],
               "type": "array",
               "minItems": 2,
               "maxItems": 2,
               "items": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "number"
                  }
               ]
            },
            "type": {
               "title": "Type",
               "default": "Debye",
               "enum": [
                  "Debye"
               ],
               "type": "string"
            },
            "eps_inf": {
               "title": "Epsilon at Infinity",
               "description": "Relative permittivity at infinite frequency (:math:`\\epsilon_\\infty`).",
               "default": 1.0,
               "units": "None (relative permittivity)",
               "type": "number"
            },
            "coeffs": {
               "title": "Coefficients",
               "description": "List of (:math:`\\Delta\\epsilon_i, \\tau_i`) values for model.",
               "units": [
                  "None (relative permittivity)",
                  "sec"
               ],
               "type": "array",
               "items": {
                  "type": "array",
                  "minItems": 2,
                  "maxItems": 2,
                  "items": [
                     {
                        "type": "number"
                     },
                     {
                        "type": "number",
                        "exclusiveMinimum": 0
                     }
                  ]
               }
            }
         },
         "required": [
            "coeffs"
         ],
         "additionalProperties": false
      },
      "Drude": {
         "title": "Drude",
         "description": "A dispersive medium described by the Drude model.\nThe frequency-dependence of the complex-valued permittivity is described by:\n\nParameters\n----------\nname : Optional[str] = None\n    Optional unique name for medium.\nfrequency_range : Optional[Tuple[float, float]] = None\n    [units = (Hz, Hz)].  Optional range of validity for the medium.\neps_inf : float = 1.0\n    [units = None (relative permittivity)].  Relative permittivity at infinite frequency (:math:`\\epsilon_\\infty`).\ncoeffs : Tuple[Tuple[float, pydantic.types.PositiveFloat], ...]\n    [units = (Hz, Hz)].  List of (:math:`f_i, \\delta_i`) values for model.\n\nNote\n----\n.. math::\n\n    \\epsilon(f) = \\epsilon_\\infty - \\sum_i\n    \\frac{ f_i^2}{f^2 + jf\\delta_i}\n\nExample\n-------\n>>> drude_medium = Drude(eps_inf=2.0, coeffs=[(1,2), (3,4)])\n>>> eps = drude_medium.eps_model(200e12)",
         "type": "object",
         "properties": {
            "name": {
               "title": "Name",
               "description": "Optional unique name for medium.",
               "type": "string"
            },
            "frequency_range": {
               "title": "Frequency Range",
               "description": "Optional range of validity for the medium.",
               "units": [
                  "Hz",
                  "Hz"
               ],
               "type": "array",
               "minItems": 2,
               "maxItems": 2,
               "items": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "number"
                  }
               ]
            },
            "type": {
               "title": "Type",
               "default": "Drude",
               "enum": [
                  "Drude"
               ],
               "type": "string"
            },
            "eps_inf": {
               "title": "Epsilon at Infinity",
               "description": "Relative permittivity at infinite frequency (:math:`\\epsilon_\\infty`).",
               "default": 1.0,
               "units": "None (relative permittivity)",
               "type": "number"
            },
            "coeffs": {
               "title": "Coefficients",
               "description": "List of (:math:`f_i, \\delta_i`) values for model.",
               "units": [
                  "Hz",
                  "Hz"
               ],
               "type": "array",
               "items": {
                  "type": "array",
                  "minItems": 2,
                  "maxItems": 2,
                  "items": [
                     {
                        "type": "number"
                     },
                     {
                        "type": "number",
                        "exclusiveMinimum": 0
                     }
                  ]
               }
            }
         },
         "required": [
            "coeffs"
         ],
         "additionalProperties": false
      },
      "AnisotropicMedium": {
         "title": "AnisotropicMedium",
         "description": "Diagonally anisotropic medium.\n\nParameters\n----------\nname : Optional[str] = None\n    Optional unique name for medium.\nfrequency_range : Optional[Tuple[float, float]] = None\n    [units = (Hz, Hz)].  Optional range of validity for the medium.\nxx : Union[Medium, PoleResidue, Sellmeier, Lorentz, Debye, Drude]\n    Medium describing the xx-component of the diagonal permittivity tensor.\nyy : Union[Medium, PoleResidue, Sellmeier, Lorentz, Debye, Drude]\n    Medium describing the yy-component of the diagonal permittivity tensor.\nzz : Union[Medium, PoleResidue, Sellmeier, Lorentz, Debye, Drude]\n    Medium describing the zz-component of the diagonal permittivity tensor.\n\nNote\n----\nOnly diagonal anisotropy is currently supported.\n\nExample\n-------\n>>> medium_xx = Medium(permittivity=4.0)\n>>> medium_yy = Medium(permittivity=4.1)\n>>> medium_zz = Medium(permittivity=3.9)\n>>> anisotropic_dielectric = AnisotropicMedium(xx=medium_xx, yy=medium_yy, zz=medium_zz)",
         "type": "object",
         "properties": {
            "name": {
               "title": "Name",
               "description": "Optional unique name for medium.",
               "type": "string"
            },
            "frequency_range": {
               "title": "Frequency Range",
               "description": "Optional range of validity for the medium.",
               "units": [
                  "Hz",
                  "Hz"
               ],
               "type": "array",
               "minItems": 2,
               "maxItems": 2,
               "items": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "number"
                  }
               ]
            },
            "type": {
               "title": "Type",
               "default": "AnisotropicMedium",
               "enum": [
                  "AnisotropicMedium"
               ],
               "type": "string"
            },
            "xx": {
               "title": "XX Component",
               "description": "Medium describing the xx-component of the diagonal permittivity tensor.",
               "discriminator": {
                  "propertyName": "type",
                  "mapping": {
                     "Medium": "#/definitions/Medium",
                     "PoleResidue": "#/definitions/PoleResidue",
                     "Sellmeier": "#/definitions/Sellmeier",
                     "Lorentz": "#/definitions/Lorentz",
                     "Debye": "#/definitions/Debye",
                     "Drude": "#/definitions/Drude"
                  }
               },
               "oneOf": [
                  {
                     "$ref": "#/definitions/Medium"
                  },
                  {
                     "$ref": "#/definitions/PoleResidue"
                  },
                  {
                     "$ref": "#/definitions/Sellmeier"
                  },
                  {
                     "$ref": "#/definitions/Lorentz"
                  },
                  {
                     "$ref": "#/definitions/Debye"
                  },
                  {
                     "$ref": "#/definitions/Drude"
                  }
               ]
            },
            "yy": {
               "title": "YY Component",
               "description": "Medium describing the yy-component of the diagonal permittivity tensor.",
               "discriminator": {
                  "propertyName": "type",
                  "mapping": {
                     "Medium": "#/definitions/Medium",
                     "PoleResidue": "#/definitions/PoleResidue",
                     "Sellmeier": "#/definitions/Sellmeier",
                     "Lorentz": "#/definitions/Lorentz",
                     "Debye": "#/definitions/Debye",
                     "Drude": "#/definitions/Drude"
                  }
               },
               "oneOf": [
                  {
                     "$ref": "#/definitions/Medium"
                  },
                  {
                     "$ref": "#/definitions/PoleResidue"
                  },
                  {
                     "$ref": "#/definitions/Sellmeier"
                  },
                  {
                     "$ref": "#/definitions/Lorentz"
                  },
                  {
                     "$ref": "#/definitions/Debye"
                  },
                  {
                     "$ref": "#/definitions/Drude"
                  }
               ]
            },
            "zz": {
               "title": "ZZ Component",
               "description": "Medium describing the zz-component of the diagonal permittivity tensor.",
               "discriminator": {
                  "propertyName": "type",
                  "mapping": {
                     "Medium": "#/definitions/Medium",
                     "PoleResidue": "#/definitions/PoleResidue",
                     "Sellmeier": "#/definitions/Sellmeier",
                     "Lorentz": "#/definitions/Lorentz",
                     "Debye": "#/definitions/Debye",
                     "Drude": "#/definitions/Drude"
                  }
               },
               "oneOf": [
                  {
                     "$ref": "#/definitions/Medium"
                  },
                  {
                     "$ref": "#/definitions/PoleResidue"
                  },
                  {
                     "$ref": "#/definitions/Sellmeier"
                  },
                  {
                     "$ref": "#/definitions/Lorentz"
                  },
                  {
                     "$ref": "#/definitions/Debye"
                  },
                  {
                     "$ref": "#/definitions/Drude"
                  }
               ]
            }
         },
         "required": [
            "xx",
            "yy",
            "zz"
         ],
         "additionalProperties": false
      },
      "PECMedium": {
         "title": "PECMedium",
         "description": "Perfect electrical conductor class.\n\nParameters\n----------\nname : Optional[str] = None\n    Optional unique name for medium.\nfrequency_range : Optional[Tuple[float, float]] = None\n    [units = (Hz, Hz)].  Optional range of validity for the medium.\n\nNote\n----\nTo avoid confusion from duplicate PECs, should import ``tidy3d.PEC`` instance directly.",
         "type": "object",
         "properties": {
            "name": {
               "title": "Name",
               "description": "Optional unique name for medium.",
               "type": "string"
            },
            "frequency_range": {
               "title": "Frequency Range",
               "description": "Optional range of validity for the medium.",
               "units": [
                  "Hz",
                  "Hz"
               ],
               "type": "array",
               "minItems": 2,
               "maxItems": 2,
               "items": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "number"
                  }
               ]
            },
            "type": {
               "title": "Type",
               "default": "PECMedium",
               "enum": [
                  "PECMedium"
               ],
               "type": "string"
            }
         },
         "additionalProperties": false
      },
      "Structure": {
         "title": "Structure",
         "description": "Defines a physical object that interacts with the electromagnetic fields.\nA :class:`Structure` is a combination of a material property (:class:`AbstractMedium`)\nand a :class:`Geometry`.\n\nParameters\n----------\ngeometry : Union[Box, Sphere, Cylinder, PolySlab, GeometryGroup]\n    Defines geometric properties of the structure.\nname : Optional[str] = None\n    Optional name for the structure.\nmedium : Union[Medium, CustomMedium, AnisotropicMedium, PECMedium, PoleResidue, Sellmeier, Lorentz, Debye, Drude]\n    Defines the electromagnetic properties of the structure's medium.\n\nExample\n-------\n>>> from tidy3d import Box, Medium\n>>> box = Box(center=(0,0,1), size=(2, 2, 2))\n>>> glass = Medium(permittivity=3.9)\n>>> struct = Structure(geometry=box, medium=glass, name='glass_box')",
         "type": "object",
         "properties": {
            "geometry": {
               "title": "Geometry",
               "description": "Defines geometric properties of the structure.",
               "discriminator": {
                  "propertyName": "type",
                  "mapping": {
                     "Box": "#/definitions/Box",
                     "Sphere": "#/definitions/Sphere",
                     "Cylinder": "#/definitions/Cylinder",
                     "PolySlab": "#/definitions/PolySlab",
                     "GeometryGroup": "#/definitions/GeometryGroup"
                  }
               },
               "oneOf": [
                  {
                     "$ref": "#/definitions/Box"
                  },
                  {
                     "$ref": "#/definitions/Sphere"
                  },
                  {
                     "$ref": "#/definitions/Cylinder"
                  },
                  {
                     "$ref": "#/definitions/PolySlab"
                  },
                  {
                     "$ref": "#/definitions/GeometryGroup"
                  }
               ]
            },
            "name": {
               "title": "Name",
               "description": "Optional name for the structure.",
               "type": "string"
            },
            "type": {
               "title": "Type",
               "default": "Structure",
               "enum": [
                  "Structure"
               ],
               "type": "string"
            },
            "medium": {
               "title": "Medium",
               "description": "Defines the electromagnetic properties of the structure's medium.",
               "discriminator": {
                  "propertyName": "type",
                  "mapping": {
                     "Medium": "#/definitions/Medium",
                     "CustomMedium": "#/definitions/CustomMedium",
                     "AnisotropicMedium": "#/definitions/AnisotropicMedium",
                     "PECMedium": "#/definitions/PECMedium",
                     "PoleResidue": "#/definitions/PoleResidue",
                     "Sellmeier": "#/definitions/Sellmeier",
                     "Lorentz": "#/definitions/Lorentz",
                     "Debye": "#/definitions/Debye",
                     "Drude": "#/definitions/Drude"
                  }
               },
               "oneOf": [
                  {
                     "$ref": "#/definitions/Medium"
                  },
                  {
                     "$ref": "#/definitions/CustomMedium"
                  },
                  {
                     "$ref": "#/definitions/AnisotropicMedium"
                  },
                  {
                     "$ref": "#/definitions/PECMedium"
                  },
                  {
                     "$ref": "#/definitions/PoleResidue"
                  },
                  {
                     "$ref": "#/definitions/Sellmeier"
                  },
                  {
                     "$ref": "#/definitions/Lorentz"
                  },
                  {
                     "$ref": "#/definitions/Debye"
                  },
                  {
                     "$ref": "#/definitions/Drude"
                  }
               ]
            }
         },
         "required": [
            "geometry",
            "medium"
         ],
         "additionalProperties": false
      },
      "MeshOverrideStructure": {
         "title": "MeshOverrideStructure",
         "description": "Defines an object that is only used in the process of generating the mesh.\nA :class:`MeshOverrideStructure` is a combination of geometry :class:`Geometry`,\ngrid size along x,y,z directions, and a boolean on whether the override\nwill be enforced.\n\nParameters\n----------\ngeometry : Union[Box, Sphere, Cylinder, PolySlab, GeometryGroup]\n    Defines geometric properties of the structure.\nname : Optional[str] = None\n    Optional name for the structure.\ndl : Tuple[PositiveFloat, PositiveFloat, PositiveFloat]\n    [units = um].  Grid size along x, y, z directions.\nenforce : bool = False\n    If ``True``, enforce the grid size setup inside the structure even if the structure is inside a structure of smaller grid size. In the intersection region of multiple structures of ``enforce=True``, grid size is decided by the last added structure of ``enforce=True``.\n\nExample\n-------\n>>> from tidy3d import Box\n>>> box = Box(center=(0,0,1), size=(2, 2, 2))\n>>> struct_override = MeshOverrideStructure(geometry=box, dl=(0.1,0.2,0.3), name='override_box')",
         "type": "object",
         "properties": {
            "geometry": {
               "title": "Geometry",
               "description": "Defines geometric properties of the structure.",
               "discriminator": {
                  "propertyName": "type",
                  "mapping": {
                     "Box": "#/definitions/Box",
                     "Sphere": "#/definitions/Sphere",
                     "Cylinder": "#/definitions/Cylinder",
                     "PolySlab": "#/definitions/PolySlab",
                     "GeometryGroup": "#/definitions/GeometryGroup"
                  }
               },
               "oneOf": [
                  {
                     "$ref": "#/definitions/Box"
                  },
                  {
                     "$ref": "#/definitions/Sphere"
                  },
                  {
                     "$ref": "#/definitions/Cylinder"
                  },
                  {
                     "$ref": "#/definitions/PolySlab"
                  },
                  {
                     "$ref": "#/definitions/GeometryGroup"
                  }
               ]
            },
            "name": {
               "title": "Name",
               "description": "Optional name for the structure.",
               "type": "string"
            },
            "type": {
               "title": "Type",
               "default": "MeshOverrideStructure",
               "enum": [
                  "MeshOverrideStructure"
               ],
               "type": "string"
            },
            "dl": {
               "title": "Grid Size",
               "description": "Grid size along x, y, z directions.",
               "units": "um",
               "type": "array",
               "minItems": 3,
               "maxItems": 3,
               "items": [
                  {
                     "type": "number",
                     "exclusiveMinimum": 0
                  },
                  {
                     "type": "number",
                     "exclusiveMinimum": 0
                  },
                  {
                     "type": "number",
                     "exclusiveMinimum": 0
                  }
               ]
            },
            "enforce": {
               "title": "Enforce grid size",
               "description": "If ``True``, enforce the grid size setup inside the structure even if the structure is inside a structure of smaller grid size. In the intersection region of multiple structures of ``enforce=True``, grid size is decided by the last added structure of ``enforce=True``.",
               "default": false,
               "type": "boolean"
            }
         },
         "required": [
            "geometry",
            "dl"
         ],
         "additionalProperties": false
      }
   }
}

attribute grid_x: Union[tidy3d.components.grid.grid_spec.UniformGrid, tidy3d.components.grid.grid_spec.CustomGrid, tidy3d.components.grid.grid_spec.AutoGrid] = AutoGrid(type='AutoGrid', min_steps_per_wvl=10.0, max_scale=1.4, dl_min=0.0, mesher=GradedMesher(type='GradedMesher'))#

Grid specification along x-axis

attribute grid_y: Union[tidy3d.components.grid.grid_spec.UniformGrid, tidy3d.components.grid.grid_spec.CustomGrid, tidy3d.components.grid.grid_spec.AutoGrid] = AutoGrid(type='AutoGrid', min_steps_per_wvl=10.0, max_scale=1.4, dl_min=0.0, mesher=GradedMesher(type='GradedMesher'))#

Grid specification along y-axis

attribute grid_z: Union[tidy3d.components.grid.grid_spec.UniformGrid, tidy3d.components.grid.grid_spec.CustomGrid, tidy3d.components.grid.grid_spec.AutoGrid] = AutoGrid(type='AutoGrid', min_steps_per_wvl=10.0, max_scale=1.4, dl_min=0.0, mesher=GradedMesher(type='GradedMesher'))#

Grid specification along z-axis

attribute override_structures: Tuple[Union[tidy3d.components.structure.Structure, tidy3d.components.structure.MeshOverrideStructure], ...] = ()#

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.

attribute wavelength: float = None#

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.

classmethod add_type_field() None#

Automatically place “type” field with model name in the model field dictionary.

classmethod auto(wavelength: Optional[pydantic.types.PositiveFloat] = None, min_steps_per_wvl: pydantic.types.PositiveFloat = 10.0, max_scale: pydantic.types.PositiveFloat = 1.4, override_structures: List[Union[tidy3d.components.structure.Structure, tidy3d.components.structure.MeshOverrideStructure]] = (), dl_min: pydantic.types.NonNegativeFloat = 0.0, mesher: tidy3d.components.grid.mesher.GradedMesher = GradedMesher(type='GradedMesher')) tidy3d.components.grid.grid_spec.GridSpec#

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

GridSpec

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model#

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values

copy(**kwargs) tidy3d.components.base.Tidy3dBaseModel#

Copy a Tidy3dBaseModel. With deep=True as default.

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny#

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

classmethod dict_from_file(fname: str, group_path: Optional[str] = None) dict#

Loads a dictionary containing the model from a .yaml, .json, or .hdf5 file.

Parameters
  • fname (str) – Full path to the .yaml or .json file to load the Tidy3dBaseModel from.

  • group_path (str, optional) – Path to a group inside the file to use as the base level.

Returns

A dictionary containing the model.

Return type

dict

Example

>>> simulation = Simulation.from_file(fname='folder/sim.json') 
classmethod dict_from_hdf5(fname: str, group_path: str = '') dict#

Loads a dictionary containing the model contents from a .hdf5 file.

Parameters
  • fname (str) – Full path to the .hdf5 file to load the Tidy3dBaseModel from.

  • group_path (str, optional) – Path to a group inside the file to selectively load a sub-element of the model only.

Returns

Dictionary containing the model.

Return type

dict

Example

>>> sim_dict = Simulation.dict_from_hdf5(fname='folder/sim.hdf5') 
classmethod dict_from_json(fname: str) dict#

Load dictionary of the model from a .json file.

Parameters

fname (str) – Full path to the .json file to load the Tidy3dBaseModel from.

Returns

A dictionary containing the model.

Return type

dict

Example

>>> sim_dict = Simulation.dict_from_json(fname='folder/sim.json') 
classmethod dict_from_yaml(fname: str) dict#

Load dictionary of the model from a .yaml file.

Parameters

fname (str) – Full path to the .yaml file to load the Tidy3dBaseModel from.

Returns

A dictionary containing the model.

Return type

dict

Example

>>> sim_dict = Simulation.dict_from_yaml(fname='folder/sim.yaml') 
classmethod from_file(fname: str, group_path: Optional[str] = None, **parse_obj_kwargs) tidy3d.components.base.Tidy3dBaseModel#

Loads a Tidy3dBaseModel from .yaml, .json, or .hdf5 file.

Parameters
  • fname (str) – Full path to the .yaml or .json file to load the Tidy3dBaseModel from.

  • group_path (str, optional) – Path to a group inside the file to use as the base level. Only for .hdf5 files. Starting / is optional.

  • **parse_obj_kwargs – Keyword arguments passed to either pydantic’s parse_obj function when loading model.

Returns

An instance of the component class calling load.

Return type

Tidy3dBaseModel

Example

>>> simulation = Simulation.from_file(fname='folder/sim.json') 
classmethod from_hdf5(fname: str, group_path: str = '', **parse_obj_kwargs) tidy3d.components.base.Tidy3dBaseModel#

Loads Tidy3dBaseModel instance to .hdf5 file.

Parameters
  • fname (str) – Full path to the .hdf5 file to load the Tidy3dBaseModel from.

  • group_path (str, optional) – Path to a group inside the file to selectively load a sub-element of the model only. Starting / is optional.

  • **parse_obj_kwargs – Keyword arguments passed to pydantic’s parse_obj method.

Example

>>> simulation.to_hdf5(fname='folder/sim.hdf5') 
classmethod from_json(fname: str, **parse_obj_kwargs) tidy3d.components.base.Tidy3dBaseModel#

Load a Tidy3dBaseModel from .json file.

Parameters

fname (str) – Full path to the .json file to load the Tidy3dBaseModel from.

Returns

  • Tidy3dBaseModel – An instance of the component class calling load.

  • **parse_obj_kwargs – Keyword arguments passed to pydantic’s parse_obj method.

Example

>>> simulation = Simulation.from_json(fname='folder/sim.json') 
classmethod from_orm(obj: Any) Model#
classmethod from_yaml(fname: str, **parse_obj_kwargs) tidy3d.components.base.Tidy3dBaseModel#

Loads Tidy3dBaseModel from .yaml file.

Parameters
  • fname (str) – Full path to the .yaml file to load the Tidy3dBaseModel from.

  • **parse_obj_kwargs – Keyword arguments passed to pydantic’s parse_obj method.

Returns

An instance of the component class calling from_yaml.

Return type

Tidy3dBaseModel

Example

>>> simulation = Simulation.from_yaml(fname='folder/sim.yaml') 
classmethod generate_docstring() str#

Generates a docstring for a Tidy3D mode and saves it to the __doc__ of the class.

classmethod get_sub_model(group_path: str, model_dict: dict | list) dict#

Get the sub model for a given group path.

static get_tuple_group_name(index: int) str#

Get the group name of a tuple element.

static get_tuple_index(key_name: str) int#

Get the index into the tuple based on its group name.

help(methods: bool = False) None#

Prints message describing the fields and methods of a Tidy3dBaseModel.

Parameters

methods (bool = False) – Whether to also print out information about object’s methods.

Example

>>> simulation.help(methods=True) 
json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode#

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

make_grid(structures: List[tidy3d.components.structure.Structure], symmetry: Tuple[typing.Literal[0, - 1, 1], typing.Literal[0, - 1, 1], typing.Literal[0, - 1, 1]], sources: List[Union[tidy3d.components.source.UniformCurrentSource, tidy3d.components.source.PointDipole, tidy3d.components.source.GaussianBeam, tidy3d.components.source.AstigmaticGaussianBeam, tidy3d.components.source.ModeSource, tidy3d.components.source.PlaneWave, tidy3d.components.source.CustomFieldSource]], num_pml_layers: List[Tuple[pydantic.types.NonNegativeInt, pydantic.types.NonNegativeInt]]) tidy3d.components.grid.grid.Grid#

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

Grid

classmethod parse_file(path: Union[str, pathlib.Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: pydantic.parse.Protocol = None, allow_pickle: bool = False) Model#
classmethod parse_obj(obj: Any) Model#
classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: pydantic.parse.Protocol = None, allow_pickle: bool = False) Model#
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') DictStrAny#
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) unicode#
to_file(fname: str) None#

Exports Tidy3dBaseModel instance to .yaml, .json, or .hdf5 file

Parameters

fname (str) – Full path to the .yaml or .json file to save the Tidy3dBaseModel to.

Example

>>> simulation.to_file(fname='folder/sim.json') 
to_hdf5(fname: str) None#

Exports Tidy3dBaseModel instance to .hdf5 file.

Parameters

fname (str) – Full path to the .hdf5 file to save the Tidy3dBaseModel to.

Example

>>> simulation.to_hdf5(fname='folder/sim.hdf5') 
to_json(fname: str) None#

Exports Tidy3dBaseModel instance to .json file

Parameters

fname (str) – Full path to the .json file to save the Tidy3dBaseModel to.

Example

>>> simulation.to_json(fname='folder/sim.json') 
to_yaml(fname: str) None#

Exports Tidy3dBaseModel instance to .yaml file.

Parameters

fname (str) – Full path to the .yaml file to save the Tidy3dBaseModel to.

Example

>>> simulation.to_yaml(fname='folder/sim.yaml') 
classmethod tuple_to_dict(tuple_values: tuple) dict#

How we generate a dictionary mapping new keys to tuple values for hdf5.

classmethod uniform(dl: float) tidy3d.components.grid.grid_spec.GridSpec#

Use the same UniformGrid along each of the three directions.

Parameters

dl (float) – Grid size for uniform grid generation.

Returns

GridSpec with the same uniform grid size in each direction.

Return type

GridSpec

classmethod update_forward_refs(**localns: Any) None#

Try to update ForwardRefs on fields based on this Model, globalns and localns.

updated_copy(**kwargs) tidy3d.components.base.Tidy3dBaseModel#

Make copy of a component instance with **kwargs indicating updated field values.

classmethod validate(value: Any) Model#
static wavelength_from_sources(sources: List[Union[tidy3d.components.source.UniformCurrentSource, tidy3d.components.source.PointDipole, tidy3d.components.source.GaussianBeam, tidy3d.components.source.AstigmaticGaussianBeam, tidy3d.components.source.ModeSource, tidy3d.components.source.PlaneWave, tidy3d.components.source.CustomFieldSource]]) pydantic.types.PositiveFloat#

Define a wavelength based on supplied sources. Called if auto mesh is used and self.wavelength is None.

property auto_grid_used: bool#

True if any of the three dimensions uses AutoGrid.

property override_structures_used: List[bool, bool, bool]#

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.