meow package

Contents

meow package#

MEOW: Modeling of Eigenmodes and Overlaps in Waveguides

Subpackages#

Submodules#

meow array tools for pydantic models

class SerializedArray[source]#

Bases: BaseModel

Show JSON schema
{
   "title": "SerializedArray",
   "type": "object",
   "properties": {
      "values": {
         "items": {},
         "title": "Values",
         "type": "array"
      },
      "shape": {
         "items": {
            "type": "integer"
         },
         "title": "Shape",
         "type": "array"
      },
      "dtype": {
         "title": "Dtype",
         "type": "string"
      }
   },
   "required": [
      "values",
      "shape",
      "dtype"
   ]
}

Fields:
attribute values: list[Any] [Required]#
attribute shape: tuple[int, ...] [Required]#
attribute dtype: str [Required]#
classmethod from_array(x)[source]#
Parameters:

x (ndarray)

to_array()[source]#
Dim(ndim, coerce=True)[source]#
Parameters:
  • ndim (int)

  • coerce (bool)

DType(dtype, coerce=True)[source]#
Parameters:
  • dtype (str)

  • coerce (bool)

Shape(*shape, coerce=True)[source]#
Parameters:
  • shape (int)

  • coerce (bool)

the pydantic base model all other models are based on

class ModelMetaclass(cls_name, bases, namespace, __pydantic_generic_metadata__=None, __pydantic_reset_parent_namespace__=True, _create_model_module=None, **kwargs)[source]#

Bases: ModelMetaclass

Parameters:
  • cls_name (str)

  • bases (tuple[type[Any], ...])

  • namespace (dict[str, Any])

  • __pydantic_generic_metadata__ (PydanticGenericMetadata | None)

  • __pydantic_reset_parent_namespace__ (bool)

  • _create_model_module (str | None)

  • kwargs (Any)

Return type:

type

class BaseModel[source]#

Bases: BaseModel

Show JSON schema
{
   "title": "BaseModel",
   "type": "object",
   "properties": {
      "type": {
         "default": "",
         "title": "Type",
         "type": "string"
      }
   }
}

Fields:
attribute type: str = ''#
Validated by:
  • _validate_field_type

  • _validate_model

classmethod model_validate(obj, *, strict=None, from_attributes=None, context=None)[source]#

Validate a pydantic model instance.

Parameters:
  • obj (Any) – The object to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • from_attributes (bool | None) – Whether to extract data from object attributes.

  • context (dict[str, Any] | None) – Additional context to pass to the validator.

Raises:

ValidationError – If the object could not be validated.

Returns:

The validated model instance.

classmethod model_validate_json(json_data, *, strict=None, context=None)[source]#

Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing

Validate the given JSON data against the Pydantic model.

Parameters:
  • json_data (str | bytes | 'bytearray') – The JSON data to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • context (dict[str, Any] | None) – Extra variables to pass to the validator.

Returns:

The validated Pydantic model.

Raises:

ValidationError – If json_data is not a JSON string or the object could not be validated.

model_post_init(context, /)#

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

Return type:

None

cache(prop)[source]#
cached_property(method)[source]#
enable_cache()[source]#
disable_cache()[source]#
empty_cache()[source]#
cache_model(obj)[source]#
cached_model(cls)[source]#
Parameters:

cls (T)

Return type:

T

an EME Cell

class Cell[source]#

Bases: BaseModel

A Cell defines an interval in z (the direction of propagation) within the simulation domain. The intersecting Structure3Ds are discretized by a given mesh at the center of the Cell

Show JSON schema
{
   "title": "Cell",
   "description": "A Cell defines an interval in z (the direction of propagation) within\nthe simulation domain. The intersecting Structure3Ds are discretized by\na given mesh at the center of the Cell",
   "type": "object",
   "properties": {
      "type": {
         "default": "",
         "title": "Type",
         "type": "string"
      },
      "structures": {
         "description": "the 3D structures which will be sliced by the cell",
         "items": {
            "$ref": "#/$defs/Structure3D"
         },
         "title": "Structures",
         "type": "array"
      },
      "mesh": {
         "$ref": "#/$defs/Mesh2D",
         "description": "the mesh to discretize the structures with"
      },
      "z_min": {
         "description": "the starting z-coordinate of the cell",
         "title": "Z Min",
         "type": "number"
      },
      "z_max": {
         "description": "the ending z-coordinate of the cell",
         "title": "Z Max",
         "type": "number"
      }
   },
   "$defs": {
      "Box": {
         "description": "A Box is a simple rectangular cuboid",
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "x_min": {
               "description": "the minimum x-value of the box",
               "title": "X Min",
               "type": "number"
            },
            "x_max": {
               "description": "the maximum x-value of the box",
               "title": "X Max",
               "type": "number"
            },
            "y_min": {
               "description": "the minimum y-value of the box",
               "title": "Y Min",
               "type": "number"
            },
            "y_max": {
               "description": "the maximum y-value of the box",
               "title": "Y Max",
               "type": "number"
            },
            "z_min": {
               "description": "the minimum z-value of the box",
               "title": "Z Min",
               "type": "number"
            },
            "z_max": {
               "description": "the maximum z-value of the box",
               "title": "Z Max",
               "type": "number"
            }
         },
         "required": [
            "x_min",
            "x_max",
            "y_min",
            "y_max",
            "z_min",
            "z_max"
         ],
         "title": "Box",
         "type": "object"
      },
      "IndexMaterial": {
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "name": {
               "description": "the name of the material",
               "title": "Name",
               "type": "string"
            },
            "meta": {
               "description": "metadata for the material",
               "title": "Meta",
               "type": "object"
            },
            "n": {
               "description": "the refractive index of the material",
               "title": "N",
               "type": "number"
            }
         },
         "required": [
            "name",
            "n"
         ],
         "title": "IndexMaterial",
         "type": "object"
      },
      "Mesh2D": {
         "description": "a ``Mesh2D`` describes how a ``Structure3D`` is discritized into a ``Cell`` or ``CrossSection``",
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "x": {
               "description": "x-coordinates of the mesh (Ez locations, i.e. corners of the 2D cell)",
               "properties": {
                  "values": {
                     "items": {},
                     "title": "Values",
                     "type": "array"
                  },
                  "shape": {
                     "items": {
                        "type": "integer"
                     },
                     "title": "Shape",
                     "type": "array"
                  },
                  "dtype": {
                     "title": "Dtype",
                     "type": "string"
                  }
               },
               "required": [
                  "values",
                  "shape",
                  "dtype"
               ],
               "title": "SerializedArray",
               "type": "object"
            },
            "y": {
               "description": "y-coordinates of the mesh (Ez locations, i.e. corners of the 2D cell)",
               "properties": {
                  "values": {
                     "items": {},
                     "title": "Values",
                     "type": "array"
                  },
                  "shape": {
                     "items": {
                        "type": "integer"
                     },
                     "title": "Shape",
                     "type": "array"
                  },
                  "dtype": {
                     "title": "Dtype",
                     "type": "string"
                  }
               },
               "required": [
                  "values",
                  "shape",
                  "dtype"
               ],
               "title": "SerializedArray",
               "type": "object"
            },
            "angle_phi": {
               "default": 0.0,
               "description": "Azimuth angle of the propagation axis in the plane orthogonal to the mesh.",
               "title": "Angle Phi",
               "type": "number"
            },
            "angle_theta": {
               "default": 0.0,
               "description": "Polar angle of the propagation axis from the injection axis.",
               "title": "Angle Theta",
               "type": "number"
            },
            "bend_radius": {
               "default": NaN,
               "description": "A curvature radius for simulation of waveguide bends. Tidy3D: Can be negative, in which case the mode plane center has a smaller value than the curvature center along the tangential axis perpendicular to the bend axis.",
               "title": "Bend Radius",
               "type": "number"
            },
            "bend_axis": {
               "default": 0,
               "description": "Index into the two tangential axes defining the normal to the plane in which the bend lies. This must be provided if ``bend_radius`` is not ``None``. For example, for a ring in the global xy-plane, and a mode plane in either the xz or the yz plane, the ``bend_axis`` is always 1 (the global z axis).",
               "enum": [
                  0,
                  1
               ],
               "title": "Bend Axis",
               "type": "integer"
            },
            "num_pml": {
               "default": [
                  0,
                  0
               ],
               "description": "Number of standard pml layers to add in the two tangential axes.",
               "maxItems": 2,
               "minItems": 2,
               "prefixItems": [
                  {
                     "minimum": 0,
                     "type": "integer"
                  },
                  {
                     "minimum": 0,
                     "type": "integer"
                  }
               ],
               "title": "Num Pml",
               "type": "array"
            },
            "ez_interfaces": {
               "default": false,
               "description": "when enabled, the meshing algorithm will throw away any index values at the interfaces which are not on even (Ez) half-grid locations. Enabling this should result in more symmetric modes.",
               "title": "Ez Interfaces",
               "type": "boolean"
            }
         },
         "required": [
            "x",
            "y"
         ],
         "title": "Mesh2D",
         "type": "object"
      },
      "Prism": {
         "description": "A prism is a 2D Polygon extruded along a certain axis direction ('x', 'y', or 'z').",
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "poly": {
               "description": "the 2D array (Nx2) with polygon vertices",
               "properties": {
                  "values": {
                     "items": {},
                     "title": "Values",
                     "type": "array"
                  },
                  "shape": {
                     "items": {
                        "type": "integer"
                     },
                     "title": "Shape",
                     "type": "array"
                  },
                  "dtype": {
                     "title": "Dtype",
                     "type": "string"
                  }
               },
               "required": [
                  "values",
                  "shape",
                  "dtype"
               ],
               "title": "SerializedArray",
               "type": "object"
            },
            "h_min": {
               "description": "the start height of the extrusion",
               "title": "H Min",
               "type": "number"
            },
            "h_max": {
               "description": "the end height of the extrusion",
               "title": "H Max",
               "type": "number"
            },
            "axis": {
               "default": "y",
               "description": "the axis along which the polygon will be extruded ('x', 'y', or 'z').",
               "enum": [
                  "x",
                  "y",
                  "z"
               ],
               "title": "Axis",
               "type": "string"
            }
         },
         "required": [
            "poly",
            "h_min",
            "h_max"
         ],
         "title": "Prism",
         "type": "object"
      },
      "SampledMaterial": {
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "name": {
               "description": "the name of the material",
               "title": "Name",
               "type": "string"
            },
            "meta": {
               "description": "metadata for the material",
               "title": "Meta",
               "type": "object"
            },
            "n": {
               "description": "the complex refractive index of the material",
               "properties": {
                  "values": {
                     "items": {},
                     "title": "Values",
                     "type": "array"
                  },
                  "shape": {
                     "items": {
                        "type": "integer"
                     },
                     "title": "Shape",
                     "type": "array"
                  },
                  "dtype": {
                     "title": "Dtype",
                     "type": "string"
                  }
               },
               "required": [
                  "values",
                  "shape",
                  "dtype"
               ],
               "title": "SerializedArray",
               "type": "object"
            },
            "params": {
               "additionalProperties": {
                  "properties": {
                     "values": {
                        "items": {},
                        "title": "Values",
                        "type": "array"
                     },
                     "shape": {
                        "items": {
                           "type": "integer"
                        },
                        "title": "Shape",
                        "type": "array"
                     },
                     "dtype": {
                        "title": "Dtype",
                        "type": "string"
                     }
                  },
                  "required": [
                     "values",
                     "shape",
                     "dtype"
                  ],
                  "type": "object"
               },
               "description": "the wavelength over which the refractive index is defined.",
               "title": "Params",
               "type": "object"
            }
         },
         "required": [
            "name",
            "n",
            "params"
         ],
         "title": "SampledMaterial",
         "type": "object"
      },
      "Structure3D": {
         "description": "a `Structure3D` is an association between a `Geometry3D` and a `Material`",
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "material": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/IndexMaterial"
                  },
                  {
                     "$ref": "#/$defs/SampledMaterial"
                  },
                  {
                     "$ref": "#/$defs/TidyMaterial"
                  }
               ],
               "description": "the material of the structure",
               "title": "Material"
            },
            "geometry": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/Box"
                  },
                  {
                     "$ref": "#/$defs/Prism"
                  }
               ],
               "description": "the geometry of the structure",
               "title": "Geometry"
            },
            "mesh_order": {
               "default": 5,
               "description": "the mesh order of the structure",
               "title": "Mesh Order",
               "type": "integer"
            }
         },
         "required": [
            "material",
            "geometry"
         ],
         "title": "Structure3D",
         "type": "object"
      },
      "TidyMaterial": {
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "name": {
               "description": "The material name as also used by tidy3d",
               "title": "Name",
               "type": "string"
            },
            "meta": {
               "description": "metadata for the material",
               "title": "Meta",
               "type": "object"
            },
            "variant": {
               "description": "The material variant as also used by tidy3d",
               "title": "Variant",
               "type": "string"
            }
         },
         "required": [
            "name",
            "variant"
         ],
         "title": "TidyMaterial",
         "type": "object"
      }
   },
   "required": [
      "structures",
      "mesh",
      "z_min",
      "z_max"
   ]
}

Fields:
attribute structures: list[Structure3D] [Required]#

the 3D structures which will be sliced by the cell

Validated by:
  • _validate_model

attribute mesh: Mesh2D [Required]#

the mesh to discretize the structures with

Validated by:
  • _validate_model

attribute z_min: float [Required]#

the starting z-coordinate of the cell

Validated by:
  • _validate_model

attribute z_max: float [Required]#

the ending z-coordinate of the cell

Validated by:
  • _validate_model

property z#
property length#
property materials#
property structures_2d: list[Structure2D]#
property m_full#
model_post_init(context, /)#

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
Return type:

None

create_cells(structures, mesh, Ls, z_min=0.0)[source]#

easily create multiple Cell objects given a Mesh and a collection of cell lengths

Parameters:
  • structures (list[Structure3D])

  • mesh (Mesh2D | list[Mesh2D])

  • Ls (Annotated[ndarray, GetPydanticSchema(get_pydantic_core_schema=~meow.array._get_ndarray_core_schema, get_pydantic_json_schema=~meow.array._get_ndarray_json_schema), PlainSerializer(func=~meow.array._serialize_ndarray, return_type=PydanticUndefined, when_used=always), BeforeValidator(func=~meow.array._validate_ndarray, json_schema_input_type=PydanticUndefined), AfterValidator(func=~meow.array._coerce_immutable), AfterValidator(func=functools.partial(<function _coerce_dim at 0x7fabc691f6a0>, ndim=1)), AfterValidator(func=functools.partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype='float64'))])

  • z_min (float)

Return type:

list[Cell]

A CrossSection

class CrossSection[source]#

Bases: BaseModel

A CrossSection is created from the association of a Cell with an Environment, which uniquely defines the refractive index everywhere.

Show JSON schema
{
   "title": "CrossSection",
   "description": "A `CrossSection` is created from the association of a `Cell` with an `Environment`,\nwhich uniquely defines the refractive index everywhere.",
   "type": "object",
   "properties": {
      "type": {
         "default": "",
         "title": "Type",
         "type": "string"
      },
      "structures": {
         "description": "the 2D structures in the CrossSection",
         "items": {
            "$ref": "#/$defs/Structure2D"
         },
         "title": "Structures",
         "type": "array"
      },
      "mesh": {
         "$ref": "#/$defs/Mesh2D",
         "description": "the mesh to discretize the structures with"
      },
      "env": {
         "$ref": "#/$defs/Environment",
         "description": "the environment for which the cross section was calculated"
      }
   },
   "$defs": {
      "Environment": {
         "additionalProperties": true,
         "description": "An environment contains all variables that don't depend on the\ngeometry/structure itself such as most commonly wavelength and temperature.",
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "wl": {
               "default": 1.5,
               "description": "the wavelength of the environment",
               "title": "Wl",
               "type": "number"
            },
            "T": {
               "default": 25.0,
               "description": "the temperature of the environment",
               "title": "T",
               "type": "number"
            }
         },
         "title": "Environment",
         "type": "object"
      },
      "IndexMaterial": {
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "name": {
               "description": "the name of the material",
               "title": "Name",
               "type": "string"
            },
            "meta": {
               "description": "metadata for the material",
               "title": "Meta",
               "type": "object"
            },
            "n": {
               "description": "the refractive index of the material",
               "title": "N",
               "type": "number"
            }
         },
         "required": [
            "name",
            "n"
         ],
         "title": "IndexMaterial",
         "type": "object"
      },
      "Mesh2D": {
         "description": "a ``Mesh2D`` describes how a ``Structure3D`` is discritized into a ``Cell`` or ``CrossSection``",
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "x": {
               "description": "x-coordinates of the mesh (Ez locations, i.e. corners of the 2D cell)",
               "properties": {
                  "values": {
                     "items": {},
                     "title": "Values",
                     "type": "array"
                  },
                  "shape": {
                     "items": {
                        "type": "integer"
                     },
                     "title": "Shape",
                     "type": "array"
                  },
                  "dtype": {
                     "title": "Dtype",
                     "type": "string"
                  }
               },
               "required": [
                  "values",
                  "shape",
                  "dtype"
               ],
               "title": "SerializedArray",
               "type": "object"
            },
            "y": {
               "description": "y-coordinates of the mesh (Ez locations, i.e. corners of the 2D cell)",
               "properties": {
                  "values": {
                     "items": {},
                     "title": "Values",
                     "type": "array"
                  },
                  "shape": {
                     "items": {
                        "type": "integer"
                     },
                     "title": "Shape",
                     "type": "array"
                  },
                  "dtype": {
                     "title": "Dtype",
                     "type": "string"
                  }
               },
               "required": [
                  "values",
                  "shape",
                  "dtype"
               ],
               "title": "SerializedArray",
               "type": "object"
            },
            "angle_phi": {
               "default": 0.0,
               "description": "Azimuth angle of the propagation axis in the plane orthogonal to the mesh.",
               "title": "Angle Phi",
               "type": "number"
            },
            "angle_theta": {
               "default": 0.0,
               "description": "Polar angle of the propagation axis from the injection axis.",
               "title": "Angle Theta",
               "type": "number"
            },
            "bend_radius": {
               "default": NaN,
               "description": "A curvature radius for simulation of waveguide bends. Tidy3D: Can be negative, in which case the mode plane center has a smaller value than the curvature center along the tangential axis perpendicular to the bend axis.",
               "title": "Bend Radius",
               "type": "number"
            },
            "bend_axis": {
               "default": 0,
               "description": "Index into the two tangential axes defining the normal to the plane in which the bend lies. This must be provided if ``bend_radius`` is not ``None``. For example, for a ring in the global xy-plane, and a mode plane in either the xz or the yz plane, the ``bend_axis`` is always 1 (the global z axis).",
               "enum": [
                  0,
                  1
               ],
               "title": "Bend Axis",
               "type": "integer"
            },
            "num_pml": {
               "default": [
                  0,
                  0
               ],
               "description": "Number of standard pml layers to add in the two tangential axes.",
               "maxItems": 2,
               "minItems": 2,
               "prefixItems": [
                  {
                     "minimum": 0,
                     "type": "integer"
                  },
                  {
                     "minimum": 0,
                     "type": "integer"
                  }
               ],
               "title": "Num Pml",
               "type": "array"
            },
            "ez_interfaces": {
               "default": false,
               "description": "when enabled, the meshing algorithm will throw away any index values at the interfaces which are not on even (Ez) half-grid locations. Enabling this should result in more symmetric modes.",
               "title": "Ez Interfaces",
               "type": "boolean"
            }
         },
         "required": [
            "x",
            "y"
         ],
         "title": "Mesh2D",
         "type": "object"
      },
      "Rectangle": {
         "description": "a Rectangle",
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "x_min": {
               "description": "the minimum x-value of the box",
               "title": "X Min",
               "type": "number"
            },
            "x_max": {
               "description": "the maximum x-value of the box",
               "title": "X Max",
               "type": "number"
            },
            "y_min": {
               "description": "the minimum y-value of the box",
               "title": "Y Min",
               "type": "number"
            },
            "y_max": {
               "description": "the maximum y-value of the box",
               "title": "Y Max",
               "type": "number"
            }
         },
         "required": [
            "x_min",
            "x_max",
            "y_min",
            "y_max"
         ],
         "title": "Rectangle",
         "type": "object"
      },
      "SampledMaterial": {
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "name": {
               "description": "the name of the material",
               "title": "Name",
               "type": "string"
            },
            "meta": {
               "description": "metadata for the material",
               "title": "Meta",
               "type": "object"
            },
            "n": {
               "description": "the complex refractive index of the material",
               "properties": {
                  "values": {
                     "items": {},
                     "title": "Values",
                     "type": "array"
                  },
                  "shape": {
                     "items": {
                        "type": "integer"
                     },
                     "title": "Shape",
                     "type": "array"
                  },
                  "dtype": {
                     "title": "Dtype",
                     "type": "string"
                  }
               },
               "required": [
                  "values",
                  "shape",
                  "dtype"
               ],
               "title": "SerializedArray",
               "type": "object"
            },
            "params": {
               "additionalProperties": {
                  "properties": {
                     "values": {
                        "items": {},
                        "title": "Values",
                        "type": "array"
                     },
                     "shape": {
                        "items": {
                           "type": "integer"
                        },
                        "title": "Shape",
                        "type": "array"
                     },
                     "dtype": {
                        "title": "Dtype",
                        "type": "string"
                     }
                  },
                  "required": [
                     "values",
                     "shape",
                     "dtype"
                  ],
                  "type": "object"
               },
               "description": "the wavelength over which the refractive index is defined.",
               "title": "Params",
               "type": "object"
            }
         },
         "required": [
            "name",
            "n",
            "params"
         ],
         "title": "SampledMaterial",
         "type": "object"
      },
      "Structure2D": {
         "description": "a `Structure2D` is an association between a `Geometry2D` and a `Material`",
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "material": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/IndexMaterial"
                  },
                  {
                     "$ref": "#/$defs/SampledMaterial"
                  },
                  {
                     "$ref": "#/$defs/TidyMaterial"
                  }
               ],
               "description": "the material of the structure",
               "title": "Material"
            },
            "geometry": {
               "$ref": "#/$defs/Rectangle",
               "description": "the geometry of the structure"
            },
            "mesh_order": {
               "default": 5,
               "description": "the mesh order of the structure",
               "title": "Mesh Order",
               "type": "integer"
            }
         },
         "required": [
            "material",
            "geometry"
         ],
         "title": "Structure2D",
         "type": "object"
      },
      "TidyMaterial": {
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "name": {
               "description": "The material name as also used by tidy3d",
               "title": "Name",
               "type": "string"
            },
            "meta": {
               "description": "metadata for the material",
               "title": "Meta",
               "type": "object"
            },
            "variant": {
               "description": "The material variant as also used by tidy3d",
               "title": "Variant",
               "type": "string"
            }
         },
         "required": [
            "name",
            "variant"
         ],
         "title": "TidyMaterial",
         "type": "object"
      }
   },
   "required": [
      "structures",
      "mesh",
      "env"
   ]
}

Fields:
attribute structures: list[Structure2D] [Required]#

the 2D structures in the CrossSection

Validated by:
  • _validate_model

attribute mesh: Mesh2D [Required]#

the mesh to discretize the structures with

Validated by:
  • _validate_model

attribute env: Environment [Required]#

the environment for which the cross section was calculated

Validated by:
  • _validate_model

classmethod from_cell(*, cell, env)[source]#
Parameters:
property materials#
property n_full#
property nx#
property ny#
property nz#
model_post_init(context, /)#

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
Return type:

None

one place to gather your environment settings

class Environment[source]#

Bases: BaseModel

An environment contains all variables that don’t depend on the geometry/structure itself such as most commonly wavelength and temperature.

Show JSON schema
{
   "title": "Environment",
   "description": "An environment contains all variables that don't depend on the\ngeometry/structure itself such as most commonly wavelength and temperature.",
   "type": "object",
   "properties": {
      "type": {
         "default": "",
         "title": "Type",
         "type": "string"
      },
      "wl": {
         "default": 1.5,
         "description": "the wavelength of the environment",
         "title": "Wl",
         "type": "number"
      },
      "T": {
         "default": 25.0,
         "description": "the temperature of the environment",
         "title": "T",
         "type": "number"
      }
   },
   "additionalProperties": true
}

Fields:
attribute wl: float = 1.5#

the wavelength of the environment

Validated by:
  • _validate_model

attribute T: float = 25.0#

the temperature of the environment

Validated by:
  • _validate_model

model_post_init(context, /)#

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
Return type:

None

GDS Extrusions

class GdsExtrusionRule[source]#

Bases: BaseModel

a GdsExtrusionRule describes a single extrusion rule. Multiple of such rules can later be associated with a gds layer tuple.

Show JSON schema
{
   "title": "GdsExtrusionRule",
   "description": "a `GdsExtrusionRule` describes a single extrusion rule.\nMultiple of such rules can later be associated with a gds layer tuple.",
   "type": "object",
   "properties": {
      "type": {
         "default": "",
         "title": "Type",
         "type": "string"
      },
      "material": {
         "anyOf": [
            {
               "$ref": "#/$defs/IndexMaterial"
            },
            {
               "$ref": "#/$defs/SampledMaterial"
            },
            {
               "$ref": "#/$defs/TidyMaterial"
            }
         ],
         "description": "the material of the extrusion",
         "title": "Material"
      },
      "h_min": {
         "description": "the extrusion starting height",
         "title": "H Min",
         "type": "number"
      },
      "h_max": {
         "description": "the extrusion ending height",
         "title": "H Max",
         "type": "number"
      },
      "buffer": {
         "default": 0.0,
         "description": "an extra buffer (=grow or shrink) operation applied to the polygon",
         "title": "Buffer",
         "type": "number"
      },
      "mesh_order": {
         "default": 5.0,
         "description": "the mesh order of the resulting `Structure3D`",
         "title": "Mesh Order",
         "type": "integer"
      }
   },
   "$defs": {
      "IndexMaterial": {
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "name": {
               "description": "the name of the material",
               "title": "Name",
               "type": "string"
            },
            "meta": {
               "description": "metadata for the material",
               "title": "Meta",
               "type": "object"
            },
            "n": {
               "description": "the refractive index of the material",
               "title": "N",
               "type": "number"
            }
         },
         "required": [
            "name",
            "n"
         ],
         "title": "IndexMaterial",
         "type": "object"
      },
      "SampledMaterial": {
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "name": {
               "description": "the name of the material",
               "title": "Name",
               "type": "string"
            },
            "meta": {
               "description": "metadata for the material",
               "title": "Meta",
               "type": "object"
            },
            "n": {
               "description": "the complex refractive index of the material",
               "properties": {
                  "values": {
                     "items": {},
                     "title": "Values",
                     "type": "array"
                  },
                  "shape": {
                     "items": {
                        "type": "integer"
                     },
                     "title": "Shape",
                     "type": "array"
                  },
                  "dtype": {
                     "title": "Dtype",
                     "type": "string"
                  }
               },
               "required": [
                  "values",
                  "shape",
                  "dtype"
               ],
               "title": "SerializedArray",
               "type": "object"
            },
            "params": {
               "additionalProperties": {
                  "properties": {
                     "values": {
                        "items": {},
                        "title": "Values",
                        "type": "array"
                     },
                     "shape": {
                        "items": {
                           "type": "integer"
                        },
                        "title": "Shape",
                        "type": "array"
                     },
                     "dtype": {
                        "title": "Dtype",
                        "type": "string"
                     }
                  },
                  "required": [
                     "values",
                     "shape",
                     "dtype"
                  ],
                  "type": "object"
               },
               "description": "the wavelength over which the refractive index is defined.",
               "title": "Params",
               "type": "object"
            }
         },
         "required": [
            "name",
            "n",
            "params"
         ],
         "title": "SampledMaterial",
         "type": "object"
      },
      "TidyMaterial": {
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "name": {
               "description": "The material name as also used by tidy3d",
               "title": "Name",
               "type": "string"
            },
            "meta": {
               "description": "metadata for the material",
               "title": "Meta",
               "type": "object"
            },
            "variant": {
               "description": "The material variant as also used by tidy3d",
               "title": "Variant",
               "type": "string"
            }
         },
         "required": [
            "name",
            "variant"
         ],
         "title": "TidyMaterial",
         "type": "object"
      }
   },
   "required": [
      "material",
      "h_min",
      "h_max"
   ]
}

Fields:
attribute material: IndexMaterial | SampledMaterial | TidyMaterial [Required]#

the material of the extrusion

Validated by:
  • _validate_model

attribute h_min: float [Required]#

the extrusion starting height

Validated by:
  • _validate_model

attribute h_max: float [Required]#

the extrusion ending height

Validated by:
  • _validate_model

attribute buffer: float = 0.0#

an extra buffer (=grow or shrink) operation applied to the polygon

Validated by:
  • _validate_model

attribute mesh_order: int = 5.0#

the mesh order of the resulting Structure3D

Validated by:
  • _validate_model

model_post_init(context, /)#

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
Return type:

None

extrude_gds(cell, extrusions)[source]#

extrude a gds cell given a dictionary of extruson rules

Parameters:
  • cell – a gdspy or gdstk Cell to extrude

  • extrusions (dict[tuple[int, int], list[GdsExtrusionRule]]) – the extrusion rules to use (if not given, the example extrusions will be used.)

meow geometries

class Geometry2DBase[source]#

Bases: BaseModel

Show JSON schema
{
   "title": "Geometry2DBase",
   "type": "object",
   "properties": {
      "type": {
         "default": "",
         "title": "Type",
         "type": "string"
      }
   }
}

Fields:
model_post_init(context, /)#

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
Return type:

None

attribute type: str = ''#
Validated by:
  • _validate_field_type

  • _validate_model

class Rectangle[source]#

Bases: Geometry2DBase

a Rectangle

Show JSON schema
{
   "title": "Rectangle",
   "description": "a Rectangle",
   "type": "object",
   "properties": {
      "type": {
         "default": "",
         "title": "Type",
         "type": "string"
      },
      "x_min": {
         "description": "the minimum x-value of the box",
         "title": "X Min",
         "type": "number"
      },
      "x_max": {
         "description": "the maximum x-value of the box",
         "title": "X Max",
         "type": "number"
      },
      "y_min": {
         "description": "the minimum y-value of the box",
         "title": "Y Min",
         "type": "number"
      },
      "y_max": {
         "description": "the maximum y-value of the box",
         "title": "Y Max",
         "type": "number"
      }
   },
   "required": [
      "x_min",
      "x_max",
      "y_min",
      "y_max"
   ]
}

Fields:
attribute x_min: float [Required]#

the minimum x-value of the box

Validated by:
  • _validate_model

attribute x_max: float [Required]#

the maximum x-value of the box

Validated by:
  • _validate_model

attribute y_min: float [Required]#

the minimum y-value of the box

Validated by:
  • _validate_model

attribute y_max: float [Required]#

the maximum y-value of the box

Validated by:
  • _validate_model

model_post_init(context, /)#

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
Return type:

None

Geometry2D#

alias of Rectangle

class Geometry3DBase[source]#

Bases: BaseModel

Show JSON schema
{
   "title": "Geometry3DBase",
   "type": "object",
   "properties": {
      "type": {
         "default": "",
         "title": "Type",
         "type": "string"
      }
   }
}

Fields:
model_post_init(context, /)#

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
Return type:

None

attribute type: str = ''#
Validated by:
  • _validate_field_type

  • _validate_model

class Box[source]#

Bases: Geometry3DBase

A Box is a simple rectangular cuboid

Show JSON schema
{
   "title": "Box",
   "description": "A Box is a simple rectangular cuboid",
   "type": "object",
   "properties": {
      "type": {
         "default": "",
         "title": "Type",
         "type": "string"
      },
      "x_min": {
         "description": "the minimum x-value of the box",
         "title": "X Min",
         "type": "number"
      },
      "x_max": {
         "description": "the maximum x-value of the box",
         "title": "X Max",
         "type": "number"
      },
      "y_min": {
         "description": "the minimum y-value of the box",
         "title": "Y Min",
         "type": "number"
      },
      "y_max": {
         "description": "the maximum y-value of the box",
         "title": "Y Max",
         "type": "number"
      },
      "z_min": {
         "description": "the minimum z-value of the box",
         "title": "Z Min",
         "type": "number"
      },
      "z_max": {
         "description": "the maximum z-value of the box",
         "title": "Z Max",
         "type": "number"
      }
   },
   "required": [
      "x_min",
      "x_max",
      "y_min",
      "y_max",
      "z_min",
      "z_max"
   ]
}

Fields:
attribute x_min: float [Required]#

the minimum x-value of the box

Validated by:
  • _validate_model

attribute x_max: float [Required]#

the maximum x-value of the box

Validated by:
  • _validate_model

attribute y_min: float [Required]#

the minimum y-value of the box

Validated by:
  • _validate_model

attribute y_max: float [Required]#

the maximum y-value of the box

Validated by:
  • _validate_model

attribute z_min: float [Required]#

the minimum z-value of the box

Validated by:
  • _validate_model

attribute z_max: float [Required]#

the maximum z-value of the box

Validated by:
  • _validate_model

model_post_init(context, /)#

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
Return type:

None

class Prism[source]#

Bases: Geometry3DBase

A prism is a 2D Polygon extruded along a certain axis direction (‘x’, ‘y’, or ‘z’).

Show JSON schema
{
   "title": "Prism",
   "description": "A prism is a 2D Polygon extruded along a certain axis direction ('x', 'y', or 'z').",
   "type": "object",
   "properties": {
      "type": {
         "default": "",
         "title": "Type",
         "type": "string"
      },
      "poly": {
         "description": "the 2D array (Nx2) with polygon vertices",
         "properties": {
            "values": {
               "items": {},
               "title": "Values",
               "type": "array"
            },
            "shape": {
               "items": {
                  "type": "integer"
               },
               "title": "Shape",
               "type": "array"
            },
            "dtype": {
               "title": "Dtype",
               "type": "string"
            }
         },
         "required": [
            "values",
            "shape",
            "dtype"
         ],
         "title": "SerializedArray",
         "type": "object"
      },
      "h_min": {
         "description": "the start height of the extrusion",
         "title": "H Min",
         "type": "number"
      },
      "h_max": {
         "description": "the end height of the extrusion",
         "title": "H Max",
         "type": "number"
      },
      "axis": {
         "default": "y",
         "description": "the axis along which the polygon will be extruded ('x', 'y', or 'z').",
         "enum": [
            "x",
            "y",
            "z"
         ],
         "title": "Axis",
         "type": "string"
      }
   },
   "required": [
      "poly",
      "h_min",
      "h_max"
   ]
}

Fields:
attribute poly: Annotated[NDArray, Shape(-1, 2), DType('float64')] [Required]#

the 2D array (Nx2) with polygon vertices

Constraints:
  • get_pydantic_core_schema = <function _get_ndarray_core_schema at 0x7fabc691fb00>

  • get_pydantic_json_schema = <function _get_ndarray_json_schema at 0x7fabc691fba0>

  • func = functools.partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype=’float64’)

  • return_type = PydanticUndefined

  • when_used = always

  • json_schema_input_type = PydanticUndefined

Validated by:
  • _validate_model

attribute h_min: float [Required]#

the start height of the extrusion

Validated by:
  • _validate_model

attribute h_max: float [Required]#

the end height of the extrusion

Validated by:
  • _validate_model

attribute axis: AxisDirection = 'y'#

the axis along which the polygon will be extruded (‘x’, ‘y’, or ‘z’).

Validated by:
  • _validate_model

model_post_init(context, /)#

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
Return type:

None

integrate_interpolate_2d(x, y, data, extent=None)[source]#

First the data on the given grid is interpolated and then integrated using scipy.dblquad. This procedure is best suited if one wants to integrate over a (small) region of interest that can be placed at off-grid positions

integrate_2d(x, y, data)[source]#

much simpler integration over the full grid

Return type:

float

Meow Materials

class MaterialBase[source]#

Bases: BaseModel

a Material defines the refractive index of a Structure3D within an Environment.

Show JSON schema
{
   "title": "MaterialBase",
   "description": "a `Material` defines the refractive index of a `Structure3D` within an `Environment`.",
   "type": "object",
   "properties": {
      "type": {
         "default": "",
         "title": "Type",
         "type": "string"
      },
      "name": {
         "description": "the name of the material",
         "title": "Name",
         "type": "string"
      },
      "meta": {
         "description": "metadata for the material",
         "title": "Meta",
         "type": "object"
      }
   },
   "required": [
      "name"
   ]
}

Fields:
attribute name: str [Required]#

the name of the material

Validated by:
  • _validate_model

attribute meta: dict[str, Any] [Optional]#

metadata for the material

Validated by:
  • _validate_model

model_post_init(context, /)#

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
Return type:

None

class TidyMaterial[source]#

Bases: MaterialBase

Show JSON schema
{
   "title": "TidyMaterial",
   "type": "object",
   "properties": {
      "type": {
         "default": "",
         "title": "Type",
         "type": "string"
      },
      "name": {
         "description": "The material name as also used by tidy3d",
         "title": "Name",
         "type": "string"
      },
      "meta": {
         "description": "metadata for the material",
         "title": "Meta",
         "type": "object"
      },
      "variant": {
         "description": "The material variant as also used by tidy3d",
         "title": "Variant",
         "type": "string"
      }
   },
   "required": [
      "name",
      "variant"
   ]
}

Fields:
attribute name: str [Required]#

The material name as also used by tidy3d

Validated by:
  • _validate_model

attribute variant: str [Required]#

The material variant as also used by tidy3d

Validated by:
  • _validate_model

__init__(**kwargs)[source]#

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

model_post_init(context, /)#

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
Return type:

None

class IndexMaterial[source]#

Bases: MaterialBase

Show JSON schema
{
   "title": "IndexMaterial",
   "type": "object",
   "properties": {
      "type": {
         "default": "",
         "title": "Type",
         "type": "string"
      },
      "name": {
         "description": "the name of the material",
         "title": "Name",
         "type": "string"
      },
      "meta": {
         "description": "metadata for the material",
         "title": "Meta",
         "type": "object"
      },
      "n": {
         "description": "the refractive index of the material",
         "title": "N",
         "type": "number"
      }
   },
   "required": [
      "name",
      "n"
   ]
}

Fields:
attribute n: float [Required]#

the refractive index of the material

Validated by:
  • _validate_model

model_post_init(context, /)#

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
Return type:

None

class SampledMaterial[source]#

Bases: MaterialBase

Show JSON schema
{
   "title": "SampledMaterial",
   "type": "object",
   "properties": {
      "type": {
         "default": "",
         "title": "Type",
         "type": "string"
      },
      "name": {
         "description": "the name of the material",
         "title": "Name",
         "type": "string"
      },
      "meta": {
         "description": "metadata for the material",
         "title": "Meta",
         "type": "object"
      },
      "n": {
         "description": "the complex refractive index of the material",
         "properties": {
            "values": {
               "items": {},
               "title": "Values",
               "type": "array"
            },
            "shape": {
               "items": {
                  "type": "integer"
               },
               "title": "Shape",
               "type": "array"
            },
            "dtype": {
               "title": "Dtype",
               "type": "string"
            }
         },
         "required": [
            "values",
            "shape",
            "dtype"
         ],
         "title": "SerializedArray",
         "type": "object"
      },
      "params": {
         "additionalProperties": {
            "properties": {
               "values": {
                  "items": {},
                  "title": "Values",
                  "type": "array"
               },
               "shape": {
                  "items": {
                     "type": "integer"
                  },
                  "title": "Shape",
                  "type": "array"
               },
               "dtype": {
                  "title": "Dtype",
                  "type": "string"
               }
            },
            "required": [
               "values",
               "shape",
               "dtype"
            ],
            "type": "object"
         },
         "description": "the wavelength over which the refractive index is defined.",
         "title": "Params",
         "type": "object"
      }
   },
   "required": [
      "name",
      "n",
      "params"
   ]
}

Fields:
  • meta ()

  • n (Annotated[numpy.ndarray, pydantic.types.GetPydanticSchema(get_pydantic_core_schema=meow.array._get_ndarray_core_schema, get_pydantic_json_schema=meow.array._get_ndarray_json_schema), pydantic.functional_serializers.PlainSerializer(func=meow.array._serialize_ndarray, return_type=PydanticUndefined, when_used=always), pydantic.functional_validators.BeforeValidator(func=meow.array._validate_ndarray, json_schema_input_type=PydanticUndefined), pydantic.functional_validators.AfterValidator(func=meow.array._coerce_immutable), pydantic.functional_validators.AfterValidator(func=functools.partial(

  • name ()

  • params (dict[str, Annotated[numpy.ndarray, pydantic.types.GetPydanticSchema(get_pydantic_core_schema=meow.array._get_ndarray_core_schema, get_pydantic_json_schema=meow.array._get_ndarray_json_schema), pydantic.functional_serializers.PlainSerializer(func=meow.array._serialize_ndarray, return_type=PydanticUndefined, when_used=always), pydantic.functional_validators.BeforeValidator(func=meow.array._validate_ndarray, json_schema_input_type=PydanticUndefined), pydantic.functional_validators.AfterValidator(func=meow.array._coerce_immutable), pydantic.functional_validators.AfterValidator(func=functools.partial(

  • type ()

attribute n: partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype='float64'))] [Required]#

the complex refractive index of the material

Constraints:
  • get_pydantic_core_schema = <function _get_ndarray_core_schema at 0x7fabc691fb00>

  • get_pydantic_json_schema = <function _get_ndarray_json_schema at 0x7fabc691fba0>

  • func = functools.partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype=’float64’)

  • return_type = PydanticUndefined

  • when_used = always

  • json_schema_input_type = PydanticUndefined

Validated by:
  • _validate_model

  • validate_params_length

attribute params: dict[str, ~typing.Annotated[~numpy.ndarray, ~pydantic.types.GetPydanticSchema(get_pydantic_core_schema=~meow.array._get_ndarray_core_schema, get_pydantic_json_schema=~meow.array._get_ndarray_json_schema), ~pydantic.functional_serializers.PlainSerializer(func=~meow.array._serialize_ndarray, return_type=PydanticUndefined, when_used=always), ~pydantic.functional_validators.BeforeValidator(func=~meow.array._validate_ndarray, json_schema_input_type=PydanticUndefined), ~pydantic.functional_validators.AfterValidator(func=~meow.array._coerce_immutable), ~pydantic.functional_validators.AfterValidator(func=functools.partial(<function _coerce_dim at 0x7fabc691f6a0>, ndim=1)), ~pydantic.functional_validators.AfterValidator(func=functools.partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype='float64'))]] [Required]#

the wavelength over which the refractive index is defined.

Validated by:
  • _validate_model

  • validate_params_length

classmethod from_path(path, meta=None)[source]#
classmethod from_df(name, df, meta=None)[source]#
model_post_init(context, /)#

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
Return type:

None

a 2D Mesh

class Mesh2D[source]#

Bases: BaseModel

a Mesh2D describes how a Structure3D is discritized into a Cell or CrossSection

Show JSON schema
{
   "title": "Mesh2D",
   "description": "a ``Mesh2D`` describes how a ``Structure3D`` is discritized into a ``Cell`` or ``CrossSection``",
   "type": "object",
   "properties": {
      "type": {
         "default": "",
         "title": "Type",
         "type": "string"
      },
      "x": {
         "description": "x-coordinates of the mesh (Ez locations, i.e. corners of the 2D cell)",
         "properties": {
            "values": {
               "items": {},
               "title": "Values",
               "type": "array"
            },
            "shape": {
               "items": {
                  "type": "integer"
               },
               "title": "Shape",
               "type": "array"
            },
            "dtype": {
               "title": "Dtype",
               "type": "string"
            }
         },
         "required": [
            "values",
            "shape",
            "dtype"
         ],
         "title": "SerializedArray",
         "type": "object"
      },
      "y": {
         "description": "y-coordinates of the mesh (Ez locations, i.e. corners of the 2D cell)",
         "properties": {
            "values": {
               "items": {},
               "title": "Values",
               "type": "array"
            },
            "shape": {
               "items": {
                  "type": "integer"
               },
               "title": "Shape",
               "type": "array"
            },
            "dtype": {
               "title": "Dtype",
               "type": "string"
            }
         },
         "required": [
            "values",
            "shape",
            "dtype"
         ],
         "title": "SerializedArray",
         "type": "object"
      },
      "angle_phi": {
         "default": 0.0,
         "description": "Azimuth angle of the propagation axis in the plane orthogonal to the mesh.",
         "title": "Angle Phi",
         "type": "number"
      },
      "angle_theta": {
         "default": 0.0,
         "description": "Polar angle of the propagation axis from the injection axis.",
         "title": "Angle Theta",
         "type": "number"
      },
      "bend_radius": {
         "default": NaN,
         "description": "A curvature radius for simulation of waveguide bends. Tidy3D: Can be negative, in which case the mode plane center has a smaller value than the curvature center along the tangential axis perpendicular to the bend axis.",
         "title": "Bend Radius",
         "type": "number"
      },
      "bend_axis": {
         "default": 0,
         "description": "Index into the two tangential axes defining the normal to the plane in which the bend lies. This must be provided if ``bend_radius`` is not ``None``. For example, for a ring in the global xy-plane, and a mode plane in either the xz or the yz plane, the ``bend_axis`` is always 1 (the global z axis).",
         "enum": [
            0,
            1
         ],
         "title": "Bend Axis",
         "type": "integer"
      },
      "num_pml": {
         "default": [
            0,
            0
         ],
         "description": "Number of standard pml layers to add in the two tangential axes.",
         "maxItems": 2,
         "minItems": 2,
         "prefixItems": [
            {
               "minimum": 0,
               "type": "integer"
            },
            {
               "minimum": 0,
               "type": "integer"
            }
         ],
         "title": "Num Pml",
         "type": "array"
      },
      "ez_interfaces": {
         "default": false,
         "description": "when enabled, the meshing algorithm will throw away any index values at the interfaces which are not on even (Ez) half-grid locations. Enabling this should result in more symmetric modes.",
         "title": "Ez Interfaces",
         "type": "boolean"
      }
   },
   "required": [
      "x",
      "y"
   ]
}

Fields:
attribute x: Annotated[NDArray, Dim(1), DType('float64')] [Required]#

x-coordinates of the mesh (Ez locations, i.e. corners of the 2D cell)

Constraints:
  • get_pydantic_core_schema = <function _get_ndarray_core_schema at 0x7fabc691fb00>

  • get_pydantic_json_schema = <function _get_ndarray_json_schema at 0x7fabc691fba0>

  • func = functools.partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype=’float64’)

  • return_type = PydanticUndefined

  • when_used = always

  • json_schema_input_type = PydanticUndefined

Validated by:
  • _validate_model

attribute y: Annotated[NDArray, Dim(1), DType('float64')] [Required]#

y-coordinates of the mesh (Ez locations, i.e. corners of the 2D cell)

Constraints:
  • get_pydantic_core_schema = <function _get_ndarray_core_schema at 0x7fabc691fb00>

  • get_pydantic_json_schema = <function _get_ndarray_json_schema at 0x7fabc691fba0>

  • func = functools.partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype=’float64’)

  • return_type = PydanticUndefined

  • when_used = always

  • json_schema_input_type = PydanticUndefined

Validated by:
  • _validate_model

attribute angle_phi: float = 0.0#

Azimuth angle of the propagation axis in the plane orthogonal to the mesh.

Validated by:
  • _validate_model

attribute angle_theta: float = 0.0#

Polar angle of the propagation axis from the injection axis.

Validated by:
  • _validate_model

attribute bend_radius: Annotated[float, BeforeValidator(lambda x: np.nan if x is None else x)] = nan#

A curvature radius for simulation of waveguide bends. Tidy3D: Can be negative, in which case the mode plane center has a smaller value than the curvature center along the tangential axis perpendicular to the bend axis.

Constraints:
  • func = <function <lambda> at 0x7fabae8eb100>

  • json_schema_input_type = PydanticUndefined

Validated by:
  • _validate_model

attribute bend_axis: Literal[0, 1] = 0#

Index into the two tangential axes defining the normal to the plane in which the bend lies. This must be provided if bend_radius is not None. For example, for a ring in the global xy-plane, and a mode plane in either the xz or the yz plane, the bend_axis is always 1 (the global z axis).

Validated by:
  • _validate_model

attribute num_pml: tuple[NonNegativeInt, NonNegativeInt] = (0, 0)#

Number of standard pml layers to add in the two tangential axes.

Validated by:
  • _validate_model

attribute ez_interfaces: bool = False#

when enabled, the meshing algorithm will throw away any index values at the interfaces which are not on even (Ez) half-grid locations. Enabling this should result in more symmetric modes.

Validated by:
  • _validate_model

property dx#

dx at Hz locations, i.e. center of the 2D cell

property dy#

dy at Hz locations, i.e. center of the 2D cell

property x_#

x at Hz locations, i.e. center of the 2D cell

property y_#

y at Hz locations, i.e. center of the 2D cell

property x_full#

x at half-integer locations

property y_full#

y at half-integer locations

property XY_full#

X and Y at half-integer locations

property X_full#

X at half-integer locations

property Y_full#

Y at half-integer locations

property Xx#

X at Ex locations

property Yx#

Y at Ex locations

property Xy#

X at Ey locations

property Yy#

Y at Ey locations

property Xz#

X at Ez locations

property Yz#

Y at Ez locations

property Xz_#

X at Hz locations

property Yz_#

Y at Hz locations

model_post_init(context, /)#

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
Return type:

None

An EigenMode

class Mode[source]#

Bases: BaseModel

A Mode contains the field information for a given CrossSection.

Show JSON schema
{
   "title": "Mode",
   "description": "A `Mode` contains the field information for a given `CrossSection`.",
   "type": "object",
   "properties": {
      "type": {
         "default": "",
         "title": "Type",
         "type": "string"
      },
      "neff": {
         "description": "the effective index of the mode",
         "properties": {
            "values": {
               "items": {},
               "title": "Values",
               "type": "array"
            },
            "shape": {
               "items": {
                  "type": "integer"
               },
               "title": "Shape",
               "type": "array"
            },
            "dtype": {
               "title": "Dtype",
               "type": "string"
            }
         },
         "required": [
            "values",
            "shape",
            "dtype"
         ],
         "title": "SerializedArray",
         "type": "object"
      },
      "cs": {
         "$ref": "#/$defs/CrossSection",
         "description": "the index cross section for which the mode was calculated"
      },
      "Ex": {
         "description": "the Ex-fields of the mode",
         "properties": {
            "values": {
               "items": {},
               "title": "Values",
               "type": "array"
            },
            "shape": {
               "items": {
                  "type": "integer"
               },
               "title": "Shape",
               "type": "array"
            },
            "dtype": {
               "title": "Dtype",
               "type": "string"
            }
         },
         "required": [
            "values",
            "shape",
            "dtype"
         ],
         "title": "SerializedArray",
         "type": "object"
      },
      "Ey": {
         "description": "the Ey-fields of the mode",
         "properties": {
            "values": {
               "items": {},
               "title": "Values",
               "type": "array"
            },
            "shape": {
               "items": {
                  "type": "integer"
               },
               "title": "Shape",
               "type": "array"
            },
            "dtype": {
               "title": "Dtype",
               "type": "string"
            }
         },
         "required": [
            "values",
            "shape",
            "dtype"
         ],
         "title": "SerializedArray",
         "type": "object"
      },
      "Ez": {
         "description": "the Ez-fields of the mode",
         "properties": {
            "values": {
               "items": {},
               "title": "Values",
               "type": "array"
            },
            "shape": {
               "items": {
                  "type": "integer"
               },
               "title": "Shape",
               "type": "array"
            },
            "dtype": {
               "title": "Dtype",
               "type": "string"
            }
         },
         "required": [
            "values",
            "shape",
            "dtype"
         ],
         "title": "SerializedArray",
         "type": "object"
      },
      "Hx": {
         "description": "the Hx-fields of the mode",
         "properties": {
            "values": {
               "items": {},
               "title": "Values",
               "type": "array"
            },
            "shape": {
               "items": {
                  "type": "integer"
               },
               "title": "Shape",
               "type": "array"
            },
            "dtype": {
               "title": "Dtype",
               "type": "string"
            }
         },
         "required": [
            "values",
            "shape",
            "dtype"
         ],
         "title": "SerializedArray",
         "type": "object"
      },
      "Hy": {
         "description": "the Hy-fields of the mode",
         "properties": {
            "values": {
               "items": {},
               "title": "Values",
               "type": "array"
            },
            "shape": {
               "items": {
                  "type": "integer"
               },
               "title": "Shape",
               "type": "array"
            },
            "dtype": {
               "title": "Dtype",
               "type": "string"
            }
         },
         "required": [
            "values",
            "shape",
            "dtype"
         ],
         "title": "SerializedArray",
         "type": "object"
      },
      "Hz": {
         "description": "the Hz-fields of the mode",
         "properties": {
            "values": {
               "items": {},
               "title": "Values",
               "type": "array"
            },
            "shape": {
               "items": {
                  "type": "integer"
               },
               "title": "Shape",
               "type": "array"
            },
            "dtype": {
               "title": "Dtype",
               "type": "string"
            }
         },
         "required": [
            "values",
            "shape",
            "dtype"
         ],
         "title": "SerializedArray",
         "type": "object"
      },
      "interpolation": {
         "default": "",
         "description": "To which 2D Yee-location the fields are interpolated to.",
         "enum": [
            "Ex",
            "Ey",
            "Ez",
            "Hz",
            ""
         ],
         "title": "Interpolation",
         "type": "string"
      }
   },
   "$defs": {
      "CrossSection": {
         "description": "A `CrossSection` is created from the association of a `Cell` with an `Environment`,\nwhich uniquely defines the refractive index everywhere.",
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "structures": {
               "description": "the 2D structures in the CrossSection",
               "items": {
                  "$ref": "#/$defs/Structure2D"
               },
               "title": "Structures",
               "type": "array"
            },
            "mesh": {
               "$ref": "#/$defs/Mesh2D",
               "description": "the mesh to discretize the structures with"
            },
            "env": {
               "$ref": "#/$defs/Environment",
               "description": "the environment for which the cross section was calculated"
            }
         },
         "required": [
            "structures",
            "mesh",
            "env"
         ],
         "title": "CrossSection",
         "type": "object"
      },
      "Environment": {
         "additionalProperties": true,
         "description": "An environment contains all variables that don't depend on the\ngeometry/structure itself such as most commonly wavelength and temperature.",
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "wl": {
               "default": 1.5,
               "description": "the wavelength of the environment",
               "title": "Wl",
               "type": "number"
            },
            "T": {
               "default": 25.0,
               "description": "the temperature of the environment",
               "title": "T",
               "type": "number"
            }
         },
         "title": "Environment",
         "type": "object"
      },
      "IndexMaterial": {
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "name": {
               "description": "the name of the material",
               "title": "Name",
               "type": "string"
            },
            "meta": {
               "description": "metadata for the material",
               "title": "Meta",
               "type": "object"
            },
            "n": {
               "description": "the refractive index of the material",
               "title": "N",
               "type": "number"
            }
         },
         "required": [
            "name",
            "n"
         ],
         "title": "IndexMaterial",
         "type": "object"
      },
      "Mesh2D": {
         "description": "a ``Mesh2D`` describes how a ``Structure3D`` is discritized into a ``Cell`` or ``CrossSection``",
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "x": {
               "description": "x-coordinates of the mesh (Ez locations, i.e. corners of the 2D cell)",
               "properties": {
                  "values": {
                     "items": {},
                     "title": "Values",
                     "type": "array"
                  },
                  "shape": {
                     "items": {
                        "type": "integer"
                     },
                     "title": "Shape",
                     "type": "array"
                  },
                  "dtype": {
                     "title": "Dtype",
                     "type": "string"
                  }
               },
               "required": [
                  "values",
                  "shape",
                  "dtype"
               ],
               "title": "SerializedArray",
               "type": "object"
            },
            "y": {
               "description": "y-coordinates of the mesh (Ez locations, i.e. corners of the 2D cell)",
               "properties": {
                  "values": {
                     "items": {},
                     "title": "Values",
                     "type": "array"
                  },
                  "shape": {
                     "items": {
                        "type": "integer"
                     },
                     "title": "Shape",
                     "type": "array"
                  },
                  "dtype": {
                     "title": "Dtype",
                     "type": "string"
                  }
               },
               "required": [
                  "values",
                  "shape",
                  "dtype"
               ],
               "title": "SerializedArray",
               "type": "object"
            },
            "angle_phi": {
               "default": 0.0,
               "description": "Azimuth angle of the propagation axis in the plane orthogonal to the mesh.",
               "title": "Angle Phi",
               "type": "number"
            },
            "angle_theta": {
               "default": 0.0,
               "description": "Polar angle of the propagation axis from the injection axis.",
               "title": "Angle Theta",
               "type": "number"
            },
            "bend_radius": {
               "default": NaN,
               "description": "A curvature radius for simulation of waveguide bends. Tidy3D: Can be negative, in which case the mode plane center has a smaller value than the curvature center along the tangential axis perpendicular to the bend axis.",
               "title": "Bend Radius",
               "type": "number"
            },
            "bend_axis": {
               "default": 0,
               "description": "Index into the two tangential axes defining the normal to the plane in which the bend lies. This must be provided if ``bend_radius`` is not ``None``. For example, for a ring in the global xy-plane, and a mode plane in either the xz or the yz plane, the ``bend_axis`` is always 1 (the global z axis).",
               "enum": [
                  0,
                  1
               ],
               "title": "Bend Axis",
               "type": "integer"
            },
            "num_pml": {
               "default": [
                  0,
                  0
               ],
               "description": "Number of standard pml layers to add in the two tangential axes.",
               "maxItems": 2,
               "minItems": 2,
               "prefixItems": [
                  {
                     "minimum": 0,
                     "type": "integer"
                  },
                  {
                     "minimum": 0,
                     "type": "integer"
                  }
               ],
               "title": "Num Pml",
               "type": "array"
            },
            "ez_interfaces": {
               "default": false,
               "description": "when enabled, the meshing algorithm will throw away any index values at the interfaces which are not on even (Ez) half-grid locations. Enabling this should result in more symmetric modes.",
               "title": "Ez Interfaces",
               "type": "boolean"
            }
         },
         "required": [
            "x",
            "y"
         ],
         "title": "Mesh2D",
         "type": "object"
      },
      "Rectangle": {
         "description": "a Rectangle",
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "x_min": {
               "description": "the minimum x-value of the box",
               "title": "X Min",
               "type": "number"
            },
            "x_max": {
               "description": "the maximum x-value of the box",
               "title": "X Max",
               "type": "number"
            },
            "y_min": {
               "description": "the minimum y-value of the box",
               "title": "Y Min",
               "type": "number"
            },
            "y_max": {
               "description": "the maximum y-value of the box",
               "title": "Y Max",
               "type": "number"
            }
         },
         "required": [
            "x_min",
            "x_max",
            "y_min",
            "y_max"
         ],
         "title": "Rectangle",
         "type": "object"
      },
      "SampledMaterial": {
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "name": {
               "description": "the name of the material",
               "title": "Name",
               "type": "string"
            },
            "meta": {
               "description": "metadata for the material",
               "title": "Meta",
               "type": "object"
            },
            "n": {
               "description": "the complex refractive index of the material",
               "properties": {
                  "values": {
                     "items": {},
                     "title": "Values",
                     "type": "array"
                  },
                  "shape": {
                     "items": {
                        "type": "integer"
                     },
                     "title": "Shape",
                     "type": "array"
                  },
                  "dtype": {
                     "title": "Dtype",
                     "type": "string"
                  }
               },
               "required": [
                  "values",
                  "shape",
                  "dtype"
               ],
               "title": "SerializedArray",
               "type": "object"
            },
            "params": {
               "additionalProperties": {
                  "properties": {
                     "values": {
                        "items": {},
                        "title": "Values",
                        "type": "array"
                     },
                     "shape": {
                        "items": {
                           "type": "integer"
                        },
                        "title": "Shape",
                        "type": "array"
                     },
                     "dtype": {
                        "title": "Dtype",
                        "type": "string"
                     }
                  },
                  "required": [
                     "values",
                     "shape",
                     "dtype"
                  ],
                  "type": "object"
               },
               "description": "the wavelength over which the refractive index is defined.",
               "title": "Params",
               "type": "object"
            }
         },
         "required": [
            "name",
            "n",
            "params"
         ],
         "title": "SampledMaterial",
         "type": "object"
      },
      "Structure2D": {
         "description": "a `Structure2D` is an association between a `Geometry2D` and a `Material`",
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "material": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/IndexMaterial"
                  },
                  {
                     "$ref": "#/$defs/SampledMaterial"
                  },
                  {
                     "$ref": "#/$defs/TidyMaterial"
                  }
               ],
               "description": "the material of the structure",
               "title": "Material"
            },
            "geometry": {
               "$ref": "#/$defs/Rectangle",
               "description": "the geometry of the structure"
            },
            "mesh_order": {
               "default": 5,
               "description": "the mesh order of the structure",
               "title": "Mesh Order",
               "type": "integer"
            }
         },
         "required": [
            "material",
            "geometry"
         ],
         "title": "Structure2D",
         "type": "object"
      },
      "TidyMaterial": {
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "name": {
               "description": "The material name as also used by tidy3d",
               "title": "Name",
               "type": "string"
            },
            "meta": {
               "description": "metadata for the material",
               "title": "Meta",
               "type": "object"
            },
            "variant": {
               "description": "The material variant as also used by tidy3d",
               "title": "Variant",
               "type": "string"
            }
         },
         "required": [
            "name",
            "variant"
         ],
         "title": "TidyMaterial",
         "type": "object"
      }
   },
   "required": [
      "neff",
      "cs",
      "Ex",
      "Ey",
      "Ez",
      "Hx",
      "Hy",
      "Hz"
   ]
}

Fields:
  • Ex (Annotated[numpy.ndarray, pydantic.types.GetPydanticSchema(get_pydantic_core_schema=meow.array._get_ndarray_core_schema, get_pydantic_json_schema=meow.array._get_ndarray_json_schema), pydantic.functional_serializers.PlainSerializer(func=meow.array._serialize_ndarray, return_type=PydanticUndefined, when_used=always), pydantic.functional_validators.BeforeValidator(func=meow.array._validate_ndarray, json_schema_input_type=PydanticUndefined), pydantic.functional_validators.AfterValidator(func=meow.array._coerce_immutable), pydantic.functional_validators.AfterValidator(func=functools.partial(

  • Ey (Annotated[numpy.ndarray, pydantic.types.GetPydanticSchema(get_pydantic_core_schema=meow.array._get_ndarray_core_schema, get_pydantic_json_schema=meow.array._get_ndarray_json_schema), pydantic.functional_serializers.PlainSerializer(func=meow.array._serialize_ndarray, return_type=PydanticUndefined, when_used=always), pydantic.functional_validators.BeforeValidator(func=meow.array._validate_ndarray, json_schema_input_type=PydanticUndefined), pydantic.functional_validators.AfterValidator(func=meow.array._coerce_immutable), pydantic.functional_validators.AfterValidator(func=functools.partial(

  • Ez (Annotated[numpy.ndarray, pydantic.types.GetPydanticSchema(get_pydantic_core_schema=meow.array._get_ndarray_core_schema, get_pydantic_json_schema=meow.array._get_ndarray_json_schema), pydantic.functional_serializers.PlainSerializer(func=meow.array._serialize_ndarray, return_type=PydanticUndefined, when_used=always), pydantic.functional_validators.BeforeValidator(func=meow.array._validate_ndarray, json_schema_input_type=PydanticUndefined), pydantic.functional_validators.AfterValidator(func=meow.array._coerce_immutable), pydantic.functional_validators.AfterValidator(func=functools.partial(

  • Hx (Annotated[numpy.ndarray, pydantic.types.GetPydanticSchema(get_pydantic_core_schema=meow.array._get_ndarray_core_schema, get_pydantic_json_schema=meow.array._get_ndarray_json_schema), pydantic.functional_serializers.PlainSerializer(func=meow.array._serialize_ndarray, return_type=PydanticUndefined, when_used=always), pydantic.functional_validators.BeforeValidator(func=meow.array._validate_ndarray, json_schema_input_type=PydanticUndefined), pydantic.functional_validators.AfterValidator(func=meow.array._coerce_immutable), pydantic.functional_validators.AfterValidator(func=functools.partial(

  • Hy (Annotated[numpy.ndarray, pydantic.types.GetPydanticSchema(get_pydantic_core_schema=meow.array._get_ndarray_core_schema, get_pydantic_json_schema=meow.array._get_ndarray_json_schema), pydantic.functional_serializers.PlainSerializer(func=meow.array._serialize_ndarray, return_type=PydanticUndefined, when_used=always), pydantic.functional_validators.BeforeValidator(func=meow.array._validate_ndarray, json_schema_input_type=PydanticUndefined), pydantic.functional_validators.AfterValidator(func=meow.array._coerce_immutable), pydantic.functional_validators.AfterValidator(func=functools.partial(

  • Hz (Annotated[numpy.ndarray, pydantic.types.GetPydanticSchema(get_pydantic_core_schema=meow.array._get_ndarray_core_schema, get_pydantic_json_schema=meow.array._get_ndarray_json_schema), pydantic.functional_serializers.PlainSerializer(func=meow.array._serialize_ndarray, return_type=PydanticUndefined, when_used=always), pydantic.functional_validators.BeforeValidator(func=meow.array._validate_ndarray, json_schema_input_type=PydanticUndefined), pydantic.functional_validators.AfterValidator(func=meow.array._coerce_immutable), pydantic.functional_validators.AfterValidator(func=functools.partial(

  • cs (meow.cross_section.CrossSection)

  • interpolation (Literal['Ex', 'Ey', 'Ez', 'Hz', ''])

  • neff (Annotated[numpy.ndarray, pydantic.types.GetPydanticSchema(get_pydantic_core_schema=meow.array._get_ndarray_core_schema, get_pydantic_json_schema=meow.array._get_ndarray_json_schema), pydantic.functional_serializers.PlainSerializer(func=meow.array._serialize_ndarray, return_type=PydanticUndefined, when_used=always), pydantic.functional_validators.BeforeValidator(func=meow.array._validate_ndarray, json_schema_input_type=PydanticUndefined), pydantic.functional_validators.AfterValidator(func=meow.array._coerce_immutable), pydantic.functional_validators.AfterValidator(func=functools.partial(

  • type ()

attribute neff: partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype='complex128'))] [Required]#

the effective index of the mode

Constraints:
  • get_pydantic_core_schema = <function _get_ndarray_core_schema at 0x7fabc691fb00>

  • get_pydantic_json_schema = <function _get_ndarray_json_schema at 0x7fabc691fba0>

  • func = functools.partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype=’complex128’)

  • return_type = PydanticUndefined

  • when_used = always

  • json_schema_input_type = PydanticUndefined

Validated by:
  • _validate_model

attribute cs: CrossSection [Required]#

the index cross section for which the mode was calculated

Validated by:
  • _validate_model

attribute Ex: partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype='complex128'))] [Required]#

the Ex-fields of the mode

Constraints:
  • get_pydantic_core_schema = <function _get_ndarray_core_schema at 0x7fabc691fb00>

  • get_pydantic_json_schema = <function _get_ndarray_json_schema at 0x7fabc691fba0>

  • func = functools.partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype=’complex128’)

  • return_type = PydanticUndefined

  • when_used = always

  • json_schema_input_type = PydanticUndefined

Validated by:
  • _validate_model

attribute Ey: partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype='complex128'))] [Required]#

the Ey-fields of the mode

Constraints:
  • get_pydantic_core_schema = <function _get_ndarray_core_schema at 0x7fabc691fb00>

  • get_pydantic_json_schema = <function _get_ndarray_json_schema at 0x7fabc691fba0>

  • func = functools.partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype=’complex128’)

  • return_type = PydanticUndefined

  • when_used = always

  • json_schema_input_type = PydanticUndefined

Validated by:
  • _validate_model

attribute Ez: partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype='complex128'))] [Required]#

the Ez-fields of the mode

Constraints:
  • get_pydantic_core_schema = <function _get_ndarray_core_schema at 0x7fabc691fb00>

  • get_pydantic_json_schema = <function _get_ndarray_json_schema at 0x7fabc691fba0>

  • func = functools.partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype=’complex128’)

  • return_type = PydanticUndefined

  • when_used = always

  • json_schema_input_type = PydanticUndefined

Validated by:
  • _validate_model

attribute Hx: partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype='complex128'))] [Required]#

the Hx-fields of the mode

Constraints:
  • get_pydantic_core_schema = <function _get_ndarray_core_schema at 0x7fabc691fb00>

  • get_pydantic_json_schema = <function _get_ndarray_json_schema at 0x7fabc691fba0>

  • func = functools.partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype=’complex128’)

  • return_type = PydanticUndefined

  • when_used = always

  • json_schema_input_type = PydanticUndefined

Validated by:
  • _validate_model

attribute Hy: partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype='complex128'))] [Required]#

the Hy-fields of the mode

Constraints:
  • get_pydantic_core_schema = <function _get_ndarray_core_schema at 0x7fabc691fb00>

  • get_pydantic_json_schema = <function _get_ndarray_json_schema at 0x7fabc691fba0>

  • func = functools.partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype=’complex128’)

  • return_type = PydanticUndefined

  • when_used = always

  • json_schema_input_type = PydanticUndefined

Validated by:
  • _validate_model

attribute Hz: partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype='complex128'))] [Required]#

the Hz-fields of the mode

Constraints:
  • get_pydantic_core_schema = <function _get_ndarray_core_schema at 0x7fabc691fb00>

  • get_pydantic_json_schema = <function _get_ndarray_json_schema at 0x7fabc691fba0>

  • func = functools.partial(<function _coerce_dtype at 0x7fabc691f7e0>, dtype=’complex128’)

  • return_type = PydanticUndefined

  • when_used = always

  • json_schema_input_type = PydanticUndefined

Validated by:
  • _validate_model

attribute interpolation: Literal['Ex', 'Ey', 'Ez', 'Hz', ''] = ''#

To which 2D Yee-location the fields are interpolated to.

Validated by:
  • _validate_model

interpolate(location)[source]#
Parameters:

location (Literal['Ex', 'Ey', 'Ez', 'Hx', 'Hy', 'Hz'])

property te_fraction#

the TE polarization fraction of the mode.

property Px#
property Py#
property Pz#
property A#

mode area

property env#
property mesh#
save(filename)[source]#
classmethod load(filename)[source]#
model_post_init(context, /)#

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
Return type:

None

zero_phase(mode)[source]#

normalize (zero out) the phase of a Mode

Parameters:

mode (Mode)

Return type:

Mode

invert_mode(mode)[source]#

invert a Mode

Parameters:

mode (Mode)

Return type:

Mode

inner_product(mode1, mode2)[source]#

the inner product of a Mode with another Mode is uniquely defined.

Parameters:
Return type:

float

inner_product_conj(mode1, mode2)[source]#

the inner product of a Mode with another Mode is uniquely defined.

Parameters:
Return type:

float

normalize_product(mode)[source]#

normalize a Mode according to the inner_product with itself

Parameters:

mode (Mode)

Return type:

Mode

electric_energy_density(mode)[source]#

get the electric energy density contained in a Mode

Parameters:

mode (Mode)

Return type:

ndarray[tuple[int, int], dtype[float64]]

electric_energy(mode)[source]#

get the electric energy contained in a Mode

Parameters:

mode (Mode)

Return type:

float

magnetic_energy_density(mode)[source]#

get the magnetic energy density contained in a Mode

Parameters:

mode (Mode)

Return type:

ndarray[tuple[int, int], dtype[float64]]

magnetic_energy(mode)[source]#

get the magnetic energy contained in a Mode

Parameters:

mode (Mode)

Return type:

float

energy_density(mode)[source]#

get the energy density contained in a Mode

Parameters:

mode (Mode)

Return type:

ndarray[tuple[int, int], dtype[float64]]

energy(mode)[source]#

get the energy contained in a Mode

Parameters:

mode (Mode)

Return type:

float

normalize_energy(mode)[source]#

normalize a mode according to the energy it contains

Parameters:

mode (Mode)

Return type:

Mode

is_pml_mode(mode, threshold)[source]#

check whether a mode can be considered a PML mode.

Parameters:
  • mode – the mode to classify as PML mode or not.

  • pml_mode_threshold – If the mode has more than pml_mode_threshold part of its energy in the PML, it will be removed.

Returns:

whether the mode is a PML mode or not

Return type:

bool

te_fraction(mode)[source]#

the TE polarization fraction of the Mode

Parameters:

mode (Mode)

Return type:

float

a Structure is a combination of a Geometry with a material (and an optional mesh order)

Structure(*, material: IndexMaterial | SampledMaterial | TidyMaterial, geometry: Rectangle, mesh_order: int = DEFAULT_MESH_ORDER) Structure2D[source]#
Structure(*, material: IndexMaterial | SampledMaterial | TidyMaterial, geometry: Box | Prism, mesh_order: int = DEFAULT_MESH_ORDER) Structure3D
class Structure2D[source]#

Bases: BaseModel

a Structure2D is an association between a Geometry2D and a Material

Show JSON schema
{
   "title": "Structure2D",
   "description": "a `Structure2D` is an association between a `Geometry2D` and a `Material`",
   "type": "object",
   "properties": {
      "type": {
         "default": "",
         "title": "Type",
         "type": "string"
      },
      "material": {
         "anyOf": [
            {
               "$ref": "#/$defs/IndexMaterial"
            },
            {
               "$ref": "#/$defs/SampledMaterial"
            },
            {
               "$ref": "#/$defs/TidyMaterial"
            }
         ],
         "description": "the material of the structure",
         "title": "Material"
      },
      "geometry": {
         "$ref": "#/$defs/Rectangle",
         "description": "the geometry of the structure"
      },
      "mesh_order": {
         "default": 5,
         "description": "the mesh order of the structure",
         "title": "Mesh Order",
         "type": "integer"
      }
   },
   "$defs": {
      "IndexMaterial": {
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "name": {
               "description": "the name of the material",
               "title": "Name",
               "type": "string"
            },
            "meta": {
               "description": "metadata for the material",
               "title": "Meta",
               "type": "object"
            },
            "n": {
               "description": "the refractive index of the material",
               "title": "N",
               "type": "number"
            }
         },
         "required": [
            "name",
            "n"
         ],
         "title": "IndexMaterial",
         "type": "object"
      },
      "Rectangle": {
         "description": "a Rectangle",
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "x_min": {
               "description": "the minimum x-value of the box",
               "title": "X Min",
               "type": "number"
            },
            "x_max": {
               "description": "the maximum x-value of the box",
               "title": "X Max",
               "type": "number"
            },
            "y_min": {
               "description": "the minimum y-value of the box",
               "title": "Y Min",
               "type": "number"
            },
            "y_max": {
               "description": "the maximum y-value of the box",
               "title": "Y Max",
               "type": "number"
            }
         },
         "required": [
            "x_min",
            "x_max",
            "y_min",
            "y_max"
         ],
         "title": "Rectangle",
         "type": "object"
      },
      "SampledMaterial": {
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "name": {
               "description": "the name of the material",
               "title": "Name",
               "type": "string"
            },
            "meta": {
               "description": "metadata for the material",
               "title": "Meta",
               "type": "object"
            },
            "n": {
               "description": "the complex refractive index of the material",
               "properties": {
                  "values": {
                     "items": {},
                     "title": "Values",
                     "type": "array"
                  },
                  "shape": {
                     "items": {
                        "type": "integer"
                     },
                     "title": "Shape",
                     "type": "array"
                  },
                  "dtype": {
                     "title": "Dtype",
                     "type": "string"
                  }
               },
               "required": [
                  "values",
                  "shape",
                  "dtype"
               ],
               "title": "SerializedArray",
               "type": "object"
            },
            "params": {
               "additionalProperties": {
                  "properties": {
                     "values": {
                        "items": {},
                        "title": "Values",
                        "type": "array"
                     },
                     "shape": {
                        "items": {
                           "type": "integer"
                        },
                        "title": "Shape",
                        "type": "array"
                     },
                     "dtype": {
                        "title": "Dtype",
                        "type": "string"
                     }
                  },
                  "required": [
                     "values",
                     "shape",
                     "dtype"
                  ],
                  "type": "object"
               },
               "description": "the wavelength over which the refractive index is defined.",
               "title": "Params",
               "type": "object"
            }
         },
         "required": [
            "name",
            "n",
            "params"
         ],
         "title": "SampledMaterial",
         "type": "object"
      },
      "TidyMaterial": {
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "name": {
               "description": "The material name as also used by tidy3d",
               "title": "Name",
               "type": "string"
            },
            "meta": {
               "description": "metadata for the material",
               "title": "Meta",
               "type": "object"
            },
            "variant": {
               "description": "The material variant as also used by tidy3d",
               "title": "Variant",
               "type": "string"
            }
         },
         "required": [
            "name",
            "variant"
         ],
         "title": "TidyMaterial",
         "type": "object"
      }
   },
   "required": [
      "material",
      "geometry"
   ]
}

Fields:
attribute material: Material [Required]#

the material of the structure

Validated by:
  • _validate_model

attribute geometry: Geometry2D [Required]#

the geometry of the structure

Validated by:
  • _validate_model

attribute mesh_order: int = 5#

the mesh order of the structure

Validated by:
  • _validate_model

model_post_init(context, /)#

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
Return type:

None

class Structure3D[source]#

Bases: BaseModel

a Structure3D is an association between a Geometry3D and a Material

Show JSON schema
{
   "title": "Structure3D",
   "description": "a `Structure3D` is an association between a `Geometry3D` and a `Material`",
   "type": "object",
   "properties": {
      "type": {
         "default": "",
         "title": "Type",
         "type": "string"
      },
      "material": {
         "anyOf": [
            {
               "$ref": "#/$defs/IndexMaterial"
            },
            {
               "$ref": "#/$defs/SampledMaterial"
            },
            {
               "$ref": "#/$defs/TidyMaterial"
            }
         ],
         "description": "the material of the structure",
         "title": "Material"
      },
      "geometry": {
         "anyOf": [
            {
               "$ref": "#/$defs/Box"
            },
            {
               "$ref": "#/$defs/Prism"
            }
         ],
         "description": "the geometry of the structure",
         "title": "Geometry"
      },
      "mesh_order": {
         "default": 5,
         "description": "the mesh order of the structure",
         "title": "Mesh Order",
         "type": "integer"
      }
   },
   "$defs": {
      "Box": {
         "description": "A Box is a simple rectangular cuboid",
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "x_min": {
               "description": "the minimum x-value of the box",
               "title": "X Min",
               "type": "number"
            },
            "x_max": {
               "description": "the maximum x-value of the box",
               "title": "X Max",
               "type": "number"
            },
            "y_min": {
               "description": "the minimum y-value of the box",
               "title": "Y Min",
               "type": "number"
            },
            "y_max": {
               "description": "the maximum y-value of the box",
               "title": "Y Max",
               "type": "number"
            },
            "z_min": {
               "description": "the minimum z-value of the box",
               "title": "Z Min",
               "type": "number"
            },
            "z_max": {
               "description": "the maximum z-value of the box",
               "title": "Z Max",
               "type": "number"
            }
         },
         "required": [
            "x_min",
            "x_max",
            "y_min",
            "y_max",
            "z_min",
            "z_max"
         ],
         "title": "Box",
         "type": "object"
      },
      "IndexMaterial": {
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "name": {
               "description": "the name of the material",
               "title": "Name",
               "type": "string"
            },
            "meta": {
               "description": "metadata for the material",
               "title": "Meta",
               "type": "object"
            },
            "n": {
               "description": "the refractive index of the material",
               "title": "N",
               "type": "number"
            }
         },
         "required": [
            "name",
            "n"
         ],
         "title": "IndexMaterial",
         "type": "object"
      },
      "Prism": {
         "description": "A prism is a 2D Polygon extruded along a certain axis direction ('x', 'y', or 'z').",
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "poly": {
               "description": "the 2D array (Nx2) with polygon vertices",
               "properties": {
                  "values": {
                     "items": {},
                     "title": "Values",
                     "type": "array"
                  },
                  "shape": {
                     "items": {
                        "type": "integer"
                     },
                     "title": "Shape",
                     "type": "array"
                  },
                  "dtype": {
                     "title": "Dtype",
                     "type": "string"
                  }
               },
               "required": [
                  "values",
                  "shape",
                  "dtype"
               ],
               "title": "SerializedArray",
               "type": "object"
            },
            "h_min": {
               "description": "the start height of the extrusion",
               "title": "H Min",
               "type": "number"
            },
            "h_max": {
               "description": "the end height of the extrusion",
               "title": "H Max",
               "type": "number"
            },
            "axis": {
               "default": "y",
               "description": "the axis along which the polygon will be extruded ('x', 'y', or 'z').",
               "enum": [
                  "x",
                  "y",
                  "z"
               ],
               "title": "Axis",
               "type": "string"
            }
         },
         "required": [
            "poly",
            "h_min",
            "h_max"
         ],
         "title": "Prism",
         "type": "object"
      },
      "SampledMaterial": {
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "name": {
               "description": "the name of the material",
               "title": "Name",
               "type": "string"
            },
            "meta": {
               "description": "metadata for the material",
               "title": "Meta",
               "type": "object"
            },
            "n": {
               "description": "the complex refractive index of the material",
               "properties": {
                  "values": {
                     "items": {},
                     "title": "Values",
                     "type": "array"
                  },
                  "shape": {
                     "items": {
                        "type": "integer"
                     },
                     "title": "Shape",
                     "type": "array"
                  },
                  "dtype": {
                     "title": "Dtype",
                     "type": "string"
                  }
               },
               "required": [
                  "values",
                  "shape",
                  "dtype"
               ],
               "title": "SerializedArray",
               "type": "object"
            },
            "params": {
               "additionalProperties": {
                  "properties": {
                     "values": {
                        "items": {},
                        "title": "Values",
                        "type": "array"
                     },
                     "shape": {
                        "items": {
                           "type": "integer"
                        },
                        "title": "Shape",
                        "type": "array"
                     },
                     "dtype": {
                        "title": "Dtype",
                        "type": "string"
                     }
                  },
                  "required": [
                     "values",
                     "shape",
                     "dtype"
                  ],
                  "type": "object"
               },
               "description": "the wavelength over which the refractive index is defined.",
               "title": "Params",
               "type": "object"
            }
         },
         "required": [
            "name",
            "n",
            "params"
         ],
         "title": "SampledMaterial",
         "type": "object"
      },
      "TidyMaterial": {
         "properties": {
            "type": {
               "default": "",
               "title": "Type",
               "type": "string"
            },
            "name": {
               "description": "The material name as also used by tidy3d",
               "title": "Name",
               "type": "string"
            },
            "meta": {
               "description": "metadata for the material",
               "title": "Meta",
               "type": "object"
            },
            "variant": {
               "description": "The material variant as also used by tidy3d",
               "title": "Variant",
               "type": "string"
            }
         },
         "required": [
            "name",
            "variant"
         ],
         "title": "TidyMaterial",
         "type": "object"
      }
   },
   "required": [
      "material",
      "geometry"
   ]
}

Fields:
attribute material: Material [Required]#

the material of the structure

Validated by:
  • _validate_model

attribute geometry: Geometry3D [Required]#

the geometry of the structure

Validated by:
  • _validate_model

attribute mesh_order: int = 5#

the mesh order of the structure

Validated by:
  • _validate_model

model_post_init(context, /)#

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
Return type:

None

Visualizations for common meow-datatypes

visualize(obj, **kwargs)[source]#

visualize any meow object

Parameters:
  • obj (Any) – the meow object to visualize

  • **kwargs (Any) – extra configuration to visualize the object

Note

Most meow objects have a ._visualize method. Check out its help to see which kwargs are accepted.

vis(obj, **kwargs)#

visualize any meow object

Parameters:
  • obj (Any) – the meow object to visualize

  • **kwargs (Any) – extra configuration to visualize the object

Note

Most meow objects have a ._visualize method. Check out its help to see which kwargs are accepted.