meow
MEOW: Modeling of Eigenmodes and Overlaps in Waveguides.
Modules:
| Name | Description |
|---|---|
arrays |
MEOW array tools for pydantic models. |
base_model |
The pydantic base model all other models are based on. |
cell |
an EME Cell. |
cross_section |
A CrossSection. |
eme |
SAX EME. |
environment |
One place to gather your environment settings. |
fde |
FDE Implementations & Backends. |
gds_structures |
GDS Extrusions. |
geometries |
MEOW geometries. |
materials |
Meow Materials. |
mesh |
A 2D Mesh. |
mode |
An EigenMode. |
structures |
A Structure is a combination of a Geometry with a material. |
visualization |
Visualizations for common meow-datatypes. |
Classes:
| Name | Description |
|---|---|
BaseModel |
Base model class for all models. |
Box |
A Box is a simple rectangular cuboid. |
Cell |
An EME Cell. |
CrossSection |
A |
Environment |
An environment contains all variables that don't depend on the structure. |
GdsExtrusionRule |
A |
Geometry2DBase |
Base class for 2D geometries. |
Geometry3DBase |
Base class for 3D geometries. |
IndexMaterial |
A material with a constant refractive index. |
MaterialBase |
a |
Mesh2D |
A |
Mode |
A |
ModelMetaclass |
Metaclass for all models. |
Polygon2D |
A 2D polygon defined by a list of vertices. |
Prism |
A prism is a 2D Polygon extruded along a axis direction ('x', 'y', 'z'). |
Rectangle |
A Rectangle. |
SampledMaterial |
A material with a sampled refractive index. |
SerializedArray |
A serialized representation of a numpy array. |
Structure2D |
A |
Structure3D |
A |
TidyMaterial |
A material from the Tidy3D material library. |
Functions:
| Name | Description |
|---|---|
DType |
Validator to ensure the array has a specific dtype. |
Dim |
Validator to ensure the array has a specific number of dimensions. |
Shape |
Validator to ensure the array has a specific shape. |
Structure |
Create a Structure from a Material and Geometry. |
cache |
Decorator to cache the result of a property method. |
cached_property |
Decorator to cache the result of a property method. |
compute_interface_s_matrices |
Compute interface S-matrices for each adjacent pair of mode sets. |
compute_interface_s_matrix |
Compute the interface S-matrix between two modal bases. |
compute_mode_amplitudes |
Solve for the forward and backward modal amplitudes in one cell. |
compute_modes_lumerical |
Compute |
compute_modes_tidy3d |
Compute |
compute_propagation_s_matrices |
Return the propagation S-matrix for every cell in a stack. |
compute_propagation_s_matrix |
Return the diagonal propagation S-matrix for one cell. |
compute_s_matrix_sax |
Calculate the S-matrix for given sets of modes. |
create_cells |
Create multiple |
create_lumerical_geometries |
Create Lumerical geometries from a list of structures. |
downselect_s |
Downselect the S-matrix to the given ports. |
electric_energy |
Get the electric energy contained in a |
electric_energy_density |
Get the electric energy density contained in a |
energy |
Get the energy contained in a |
energy_density |
Get the energy density contained in a |
enforce_passivity |
Project singular values onto a passive interval. |
extrude_gds |
Extrude a gds cell given a dictionary of extrusion rules. |
filter_modes |
Filter a set of modes according to certain criteria. |
get_sim |
Get the Lumerical simulation object. |
inner_product |
The modal inner product for z-normal mode planes. |
invert_mode |
Invert a |
is_lossy_mode |
Check whether a mode can be considered lossy. |
is_pml_mode |
Check whether a mode can be considered a PML mode. |
l2r_matrices |
Return cumulative left-to-right S-matrices. |
magnetic_energy |
Get the magnetic energy contained in a |
magnetic_energy_density |
Get the magnetic energy density contained in a |
normalize |
Normalize a |
normalize_energy |
Normalize a mode according to the energy it contains. |
normalize_modes |
Self-normalize a set of modes. |
orthonormalize_modes |
Gram-Schmidt orthonormalization with drop tolerance. |
overlap_matrix |
Build the modal overlap matrix between two mode sets. |
pi_pairs |
Return propagation-interface pairs for a full stack. |
plot_fields |
Reconstruct an |
pml_fraction |
Fraction of energy density in the PML region. |
post_process_modes |
Default post-processing pipeline after FDE. |
propagate |
Propagate boundary excitations through cumulative S-matrices. |
propagate_modes |
Propagate modal excitations through a stack of cells. |
r2l_matrices |
Return cumulative right-to-left S-matrices. |
select_ports |
Keep a subset of ports from an S-matrix. |
sort_structures |
Sort structures by mesh order, then by order of definition. |
split_square_matrix |
Split a square matrix into its four block submatrices. |
te_fraction |
The TE polarization fraction of the |
track_modes |
Track modal order and phase continuously across a cell stack. |
tsvd_solve |
Solve |
visualize |
Visualize any meow object. |
zero_phase |
Normalize (zero out) the phase of a |
Attributes:
| Name | Type | Description |
|---|---|---|
AxisDirection |
TypeAlias
|
Axis direction: |
BoolArray1D |
TypeAlias
|
1D boolean numpy array. |
BoolArray2D |
TypeAlias
|
2D boolean numpy array. |
Complex |
TypeAlias
|
0D (scalar) complex128 numpy array. |
ComplexArray1D |
TypeAlias
|
1D complex128 numpy array. |
ComplexArray2D |
TypeAlias
|
2D complex128 numpy array. |
FloatArray1D |
TypeAlias
|
1D float64 numpy array. |
FloatArray2D |
TypeAlias
|
2D float64 numpy array. |
Geometry |
TypeAlias
|
Any 2D or 3D geometry. |
Geometry2D |
TypeAlias
|
A 2D geometry: either a |
Geometry3D |
TypeAlias
|
A 3D geometry: either a |
IntArray1D |
TypeAlias
|
1D int64 numpy array. |
IntArray2D |
TypeAlias
|
2D int64 numpy array. |
Material |
TypeAlias
|
A material: |
Materials |
TypeAlias
|
A list of |
Modes |
TypeAlias
|
A list of |
NDArray |
TypeAlias
|
A numpy ndarray with pydantic serialization support. |
PassivityMethod |
TypeAlias
|
Method for enforcing S-matrix passivity. |
Sim |
TypeAlias
|
A lumerical simulation object. |
AxisDirection
module-attribute
Axis direction: "x", "y", or "z".
BoolArray1D
module-attribute
1D boolean numpy array.
BoolArray2D
module-attribute
2D boolean numpy array.
Complex
module-attribute
0D (scalar) complex128 numpy array.
ComplexArray1D
module-attribute
1D complex128 numpy array.
ComplexArray2D
module-attribute
2D complex128 numpy array.
FloatArray1D
module-attribute
1D float64 numpy array.
FloatArray2D
module-attribute
2D float64 numpy array.
Geometry2D
module-attribute
A 2D geometry: either a Rectangle or a Polygon2D.
Geometry3D
module-attribute
A 3D geometry: either a Box or a Prism.
IntArray1D
module-attribute
1D int64 numpy array.
IntArray2D
module-attribute
2D int64 numpy array.
Material
module-attribute
Material: TypeAlias = (
IndexMaterial | SampledMaterial | TidyMaterial
)
A material: IndexMaterial, SampledMaterial, or TidyMaterial.
NDArray
module-attribute
NDArray: TypeAlias = Annotated[
ndarray,
ArraySchema,
PlainSerializer(_serialize_ndarray),
BeforeValidator(_validate_ndarray),
AfterValidator(_coerce_immutable),
]
A numpy ndarray with pydantic serialization support.
PassivityMethod
module-attribute
Method for enforcing S-matrix passivity.
BaseModel
Bases: BaseModel
Base model class for all models.
Methods:
| Name | Description |
|---|---|
model_validate |
Validate a pydantic model instance. |
model_validate_json |
Validate a pydantic model instance. |
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
Whether to extract data from object attributes. |
required | |
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
Box
Bases: Geometry3DBase
A Box is a simple rectangular cuboid.
Methods:
| Name | Description |
|---|---|
model_validate |
Validate a pydantic model instance. |
model_validate_json |
Validate a pydantic model instance. |
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
Whether to extract data from object attributes. |
required | |
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
Cell
Bases: BaseModel
An EME Cell.
This 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
Methods:
| Name | Description |
|---|---|
m_full |
The full material mask for the cell. |
materials |
A mapping of the materials in the cell to their indices. |
model_validate |
Validate a pydantic model instance. |
model_validate_json |
Validate a pydantic model instance. |
structures_2d |
The 2D structures in the cell. |
Attributes:
| Name | Type | Description |
|---|---|---|
length |
float
|
The length of the cell. |
z |
float
|
The z-position of the center of the cell. |
m_full
m_full() -> IntArray2D
materials
A mapping of the materials in the cell to their indices.
Source code in src/meow/cell.py
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
Whether to extract data from object attributes. |
required | |
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
structures_2d
structures_2d() -> list[Structure2D]
The 2D structures in the cell.
Source code in src/meow/cell.py
CrossSection
Bases: BaseModel
A CrossSection is built from a Cell with an Environment.
This uniquely defines the refractive index everywhere.
Methods:
| Name | Description |
|---|---|
from_cell |
Create a CrossSection from a Cell and Environment. |
materials |
Return a dictionary mapping materials to their indices. |
model_validate |
Validate a pydantic model instance. |
model_validate_json |
Validate a pydantic model instance. |
n_full |
Return the refractive index array for the full mesh. |
nx |
Return the smoothed refractive index on the Ex positions. |
ny |
Return the smoothed refractive index on the Ey positions. |
nz |
Return the smoothed refractive index on the Ez positions. |
from_cell
classmethod
from_cell(
*,
cell: Cell,
env: Environment,
subpixel_smoothing: bool = True,
) -> Self
Create a CrossSection from a Cell and Environment.
Source code in src/meow/cross_section.py
materials
Return a dictionary mapping materials to their indices.
Source code in src/meow/cross_section.py
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
Whether to extract data from object attributes. |
required | |
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
n_full
n_full() -> ComplexArray2D
Return the refractive index array for the full mesh.
Source code in src/meow/cross_section.py
nx
nx() -> ComplexArray2D
Return the smoothed refractive index on the Ex positions.
Source code in src/meow/cross_section.py
ny
ny() -> ComplexArray2D
Return the smoothed refractive index on the Ey positions.
Source code in src/meow/cross_section.py
nz
nz() -> ComplexArray2D
Return the smoothed refractive index on the Ez positions.
Source code in src/meow/cross_section.py
Environment
Bases: BaseModel
An environment contains all variables that don't depend on the structure.
Methods:
| Name | Description |
|---|---|
model_validate |
Validate a pydantic model instance. |
model_validate_json |
Validate a pydantic model instance. |
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
Whether to extract data from object attributes. |
required | |
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
GdsExtrusionRule
Bases: BaseModel
A GdsExtrusionRule describes a single extrusion rule.
Multiple of such rules can later be associated with a gds layer tuple.
Methods:
| Name | Description |
|---|---|
model_validate |
Validate a pydantic model instance. |
model_validate_json |
Validate a pydantic model instance. |
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
Whether to extract data from object attributes. |
required | |
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
Geometry2DBase
Bases: BaseModel
Base class for 2D geometries.
Methods:
| Name | Description |
|---|---|
model_validate |
Validate a pydantic model instance. |
model_validate_json |
Validate a pydantic model instance. |
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
Whether to extract data from object attributes. |
required | |
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
Geometry3DBase
Bases: BaseModel
Base class for 3D geometries.
Methods:
| Name | Description |
|---|---|
model_validate |
Validate a pydantic model instance. |
model_validate_json |
Validate a pydantic model instance. |
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
Whether to extract data from object attributes. |
required | |
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
IndexMaterial
Bases: MaterialBase
A material with a constant refractive index.
Methods:
| Name | Description |
|---|---|
model_validate |
Validate a pydantic model instance. |
model_validate_json |
Validate a pydantic model instance. |
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
Whether to extract data from object attributes. |
required | |
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
MaterialBase
Bases: BaseModel
a Material defines the index of a Structure3D in an Environment.
Methods:
| Name | Description |
|---|---|
model_validate |
Validate a pydantic model instance. |
model_validate_json |
Validate a pydantic model instance. |
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
Whether to extract data from object attributes. |
required | |
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
Mesh2D
Bases: BaseModel
A Mesh2D describes how a Structure3D is discritized into a Cell.
Methods:
| Name | Description |
|---|---|
XY_full |
X and Y at half-integer locations. |
dx |
dx at Hz locations, i.e. center of the 2D cell. |
dy |
dy at Hz locations, i.e. center of the 2D cell. |
model_validate |
Validate a pydantic model instance. |
model_validate_json |
Validate a pydantic model instance. |
x_ |
x at Hz locations, i.e. center of the 2D cell. |
x_full |
x at half-integer locations. |
y_ |
y at Hz locations, i.e. center of the 2D cell. |
y_full |
y at half-integer locations. |
Attributes:
| Name | Type | Description |
|---|---|---|
X_full |
FloatArray2D
|
X at half-integer locations. |
Xx |
FloatArray2D
|
X at Ex locations. |
Xy |
FloatArray2D
|
X at Ey locations. |
Xz |
FloatArray2D
|
X at Ez locations. |
Xz_ |
FloatArray2D
|
X at Hz locations. |
Y_full |
FloatArray2D
|
Y at half-integer locations. |
Yx |
FloatArray2D
|
Y at Ex locations. |
Yy |
FloatArray2D
|
Y at Ey locations. |
Yz |
FloatArray2D
|
Y at Ez locations. |
Yz_ |
FloatArray2D
|
Y at Hz locations. |
XY_full
XY_full() -> tuple[FloatArray2D, FloatArray2D]
dx
dx() -> FloatArray1D
dy
dy() -> FloatArray1D
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
Whether to extract data from object attributes. |
required | |
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
x_
x_() -> FloatArray1D
x_full
x_full() -> FloatArray1D
y_
y_() -> FloatArray1D
y_full
y_full() -> FloatArray1D
Mode
Bases: BaseModel
A Mode contains the field information for a given CrossSection.
Methods:
| Name | Description |
|---|---|
interpolate |
Interpolate the mode to the given location. |
load |
Load a mode from a file. |
model_validate |
Validate a pydantic model instance. |
model_validate_json |
Validate a pydantic model instance. |
save |
Save the mode to a file. |
Attributes:
| Name | Type | Description |
|---|---|---|
Px |
ComplexArray2D
|
The x-component of the Poynting vector. |
Py |
ComplexArray2D
|
The y-component of the Poynting vector. |
Pz |
ComplexArray2D
|
The z-component of the Poynting vector. |
env |
Environment
|
The environment of the mode. |
mesh |
Mesh2D
|
The mesh of the mode. |
te_fraction |
float
|
The TE polarization fraction of the mode. |
interpolate
Interpolate the mode to the given location.
Source code in src/meow/mode.py
load
classmethod
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
Whether to extract data from object attributes. |
required | |
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
ModelMetaclass
Bases: ModelMetaclass
Metaclass for all models.
Polygon2D
Bases: Geometry2DBase
A 2D polygon defined by a list of vertices.
Methods:
| Name | Description |
|---|---|
model_validate |
Validate a pydantic model instance. |
model_validate_json |
Validate a pydantic model instance. |
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
Whether to extract data from object attributes. |
required | |
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
Prism
Bases: Geometry3DBase
A prism is a 2D Polygon extruded along a axis direction ('x', 'y', 'z').
Methods:
| Name | Description |
|---|---|
model_validate |
Validate a pydantic model instance. |
model_validate_json |
Validate a pydantic model instance. |
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
Whether to extract data from object attributes. |
required | |
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
Rectangle
Bases: Geometry2DBase
A Rectangle.
Methods:
| Name | Description |
|---|---|
model_validate |
Validate a pydantic model instance. |
model_validate_json |
Validate a pydantic model instance. |
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
Whether to extract data from object attributes. |
required | |
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
SampledMaterial
Bases: MaterialBase
A material with a sampled refractive index.
Methods:
| Name | Description |
|---|---|
from_df |
Create a SampledMaterial from a DataFrame. |
from_path |
Create a SampledMaterial from a CSV file. |
model_validate |
Validate a pydantic model instance. |
model_validate_json |
Validate a pydantic model instance. |
from_df
classmethod
Create a SampledMaterial from a DataFrame.
Source code in src/meow/materials.py
from_path
classmethod
Create a SampledMaterial from a CSV file.
Source code in src/meow/materials.py
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
Whether to extract data from object attributes. |
required | |
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
SerializedArray
Bases: BaseModel
A serialized representation of a numpy array.
Methods:
| Name | Description |
|---|---|
from_array |
Create a SerializedArray from a numpy array. |
to_array |
Convert the SerializedArray back to a numpy array. |
from_array
classmethod
Create a SerializedArray from a numpy array.
Source code in src/meow/arrays.py
to_array
to_array() -> ndarray
Convert the SerializedArray back to a numpy array.
Source code in src/meow/arrays.py
Structure2D
Bases: BaseModel
A Structure2D is an association between a Geometry2D and a Material.
Methods:
| Name | Description |
|---|---|
model_validate |
Validate a pydantic model instance. |
model_validate_json |
Validate a pydantic model instance. |
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
Whether to extract data from object attributes. |
required | |
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
Structure3D
Bases: BaseModel
A Structure3D is an association between a Geometry3D and a Material.
Methods:
| Name | Description |
|---|---|
model_validate |
Validate a pydantic model instance. |
model_validate_json |
Validate a pydantic model instance. |
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
Whether to extract data from object attributes. |
required | |
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
TidyMaterial
TidyMaterial(**kwargs: Any)
Bases: MaterialBase
A material from the Tidy3D material library.
Methods:
| Name | Description |
|---|---|
model_validate |
Validate a pydantic model instance. |
model_validate_json |
Validate a pydantic model instance. |
Source code in src/meow/materials.py
model_validate
classmethod
model_validate(
obj: Any,
*,
strict: bool | None = None,
from_attributes: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
bool | None
|
Whether to extract data from object attributes. |
None
|
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
model_validate_json
classmethod
model_validate_json(
json_data: str | bytes | bytearray,
*,
strict: bool | None = None,
context: dict[str, Any] | None = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The object to validate. |
required |
strict
|
bool | None
|
Whether to enforce types strictly. |
None
|
from_attributes
|
Whether to extract data from object attributes. |
required | |
context
|
dict[str, Any] | None
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object could not be validated. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Source code in src/meow/base_model.py
DType
Validator to ensure the array has a specific dtype.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype
|
str
|
the required data type as a string (e.g. "float64"). |
required |
coerce
|
bool
|
if True, cast the array to the dtype; if False, raise on mismatch. |
True
|
Returns:
| Type | Description |
|---|---|
AfterValidator
|
A pydantic AfterValidator that checks or coerces the array dtype. |
Source code in src/meow/arrays.py
Dim
Validator to ensure the array has a specific number of dimensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ndim
|
int
|
the required number of dimensions. |
required |
coerce
|
bool
|
if True, reshape the array to match; if False, raise on mismatch. |
True
|
Returns:
| Type | Description |
|---|---|
AfterValidator
|
A pydantic AfterValidator that checks or coerces the array dimensions. |
Source code in src/meow/arrays.py
Shape
Validator to ensure the array has a specific shape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*shape
|
int
|
the required dimensions of the array. |
()
|
coerce
|
bool
|
if True, reshape the array to match; if False, raise on mismatch. |
True
|
Returns:
| Type | Description |
|---|---|
AfterValidator
|
A pydantic AfterValidator that checks or coerces the array shape. |
Source code in src/meow/arrays.py
Structure
Structure(
*,
material: Material,
geometry: Geometry2D,
mesh_order: int = DEFAULT_MESH_ORDER,
) -> Structure2D
Structure(
*,
material: Material,
geometry: Geometry3D,
mesh_order: int = DEFAULT_MESH_ORDER,
) -> Structure3D
Structure(
*,
material: Material,
geometry: Geometry2D | Geometry3D,
mesh_order: int = DEFAULT_MESH_ORDER,
) -> Structure2D | Structure3D
Create a Structure from a Material and Geometry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
material
|
Material
|
the material of the structure. |
required |
geometry
|
Geometry2D | Geometry3D
|
a 2D or 3D geometry for the structure. |
required |
mesh_order
|
int
|
the mesh order used for rasterization priority. |
DEFAULT_MESH_ORDER
|
Returns:
| Type | Description |
|---|---|
Structure2D | Structure3D
|
A Structure2D if geometry is 2D, otherwise a Structure3D. |
Source code in src/meow/structures.py
cache
Decorator to cache the result of a property method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prop
|
Callable
|
the property method whose result should be cached. |
required |
Returns:
| Type | Description |
|---|---|
Callable
|
A wrapped callable that caches and returns the computed value. |
Source code in src/meow/base_model.py
cached_property
cached_property(method: Callable)
Decorator to cache the result of a property method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
Callable
|
the method to wrap as a cached property. |
required |
Returns:
| Type | Description |
|---|---|
|
A property descriptor that caches the method's return value. |
Source code in src/meow/base_model.py
compute_interface_s_matrices
compute_interface_s_matrices(
modes: list[Modes],
*,
inner_product: Callable = inner_product,
conjugate: bool | None = None,
tsvd_rcond: float = 0.001,
passivity_method: PassivityMethod = "invert",
enforce_reciprocity: bool = True,
ignore_warnings: bool = True,
) -> dict[str, SDenseMM]
Compute interface S-matrices for each adjacent pair of mode sets.
This is a thin wrapper around :func:compute_interface_s_matrix applied to
every neighboring pair in modes.
The same sharp edges apply here as for the single-interface solve: orthonormalization, inner-product choice, TSVD cutoff, and passivity method must all be interpreted consistently across the full stack.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modes
|
list[Modes]
|
Ordered list of modal bases across the stack. |
required |
inner_product
|
Callable
|
Inner-product callable for forming overlap matrices. |
inner_product
|
conjugate
|
bool | None
|
Whether to use the conjugated formulation. Inferred from inner_product if None. |
None
|
tsvd_rcond
|
float
|
Relative singular-value cutoff for the TSVD solve. |
0.001
|
passivity_method
|
PassivityMethod
|
Method for enforcing S-matrix passivity. |
'invert'
|
enforce_reciprocity
|
bool
|
Whether to symmetrize each interface S-matrix. |
True
|
ignore_warnings
|
bool
|
Whether to suppress numerical warnings. |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, SDenseMM]
|
Dict mapping interface names (e.g. |
dict[str, SDenseMM]
|
multimode S-matrix tuples. |
Source code in src/meow/eme/interface.py
compute_interface_s_matrix
compute_interface_s_matrix(
modes1: Modes,
modes2: Modes,
*,
inner_product: Callable = inner_product,
conjugate: bool | None = None,
tsvd_rcond: float = 0.001,
passivity_method: PassivityMethod = "invert",
enforce_reciprocity: bool = True,
ignore_warnings: bool = True,
) -> SDenseMM
Compute the interface S-matrix between two modal bases.
This implements the overlap-based EME interface solve for a step discontinuity. The transmission blocks are obtained from a TSVD-regularized solve, then the reflection blocks are reconstructed from the two continuity equations and averaged:
R_LL = 0.5 * ((O_RL^adj @ T_LR - I) + (I - O_LR @ T_LR))R_RR = 0.5 * ((O_LR^adj @ T_RL - I) + (I - O_RL @ T_RL))
High-level assumptions
- the supplied mode sets are already orthonormalized in the same metric
used by
inner_product; - the interface formulas are therefore used in their simplified
G = Iform; - any remaining non-passivity is treated as a numerical/truncation issue and corrected afterwards via singular-value processing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modes1
|
Modes
|
Modes on the left side of the interface. |
required |
modes2
|
Modes
|
Modes on the right side of the interface. |
required |
inner_product
|
Callable
|
Inner-product callable used to form the overlap matrices. This must be consistent with how the modes were orthonormalized. |
inner_product
|
conjugate
|
bool | None
|
Whether to use the conjugated (power-conserving) formulation. If None, inferred from the inner_product callable. Must match the conjugate setting used in inner_product for physical consistency: - conjugate=True: uses O_RL.conj().T (Hermitian transpose) - conjugate=False: uses O_RL.T (transpose) |
None
|
tsvd_rcond
|
float
|
Relative singular-value cutoff for the TSVD solve used to build the transmission blocks. |
0.001
|
passivity_method
|
PassivityMethod
|
Method for enforcing passivity ("none", "clip", "invert", "subtract"). |
'invert'
|
enforce_reciprocity
|
bool
|
Whether to symmetrize the final S-matrix as
|
True
|
ignore_warnings
|
bool
|
Whether to suppress numerical warnings. |
True
|
Returns:
| Type | Description |
|---|---|
SDenseMM
|
A tuple |
Notes
The default path is internally consistent because the default
meow.mode.inner_product is the asymmetric, unconjugated overlap and
the default mode post-processing uses that same callable. If you change
the interface inner product, you should generally use the same callable
during mode post-processing.
Source code in src/meow/eme/interface.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
compute_mode_amplitudes
compute_mode_amplitudes(
u: ComplexArray2D,
v: ComplexArray2D,
m: int,
excitation_l: ComplexArray1D,
excitation_r: ComplexArray1D,
) -> tuple[ComplexArray1D, ComplexArray1D]
Solve for the forward and backward modal amplitudes in one cell.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
ComplexArray2D
|
Cumulative left-to-right S-matrix (dense array). |
required |
v
|
ComplexArray2D
|
Cumulative right-to-left S-matrix (dense array). |
required |
m
|
int
|
Number of right-side (forward) modes. |
required |
excitation_l
|
ComplexArray1D
|
Left boundary excitation vector. |
required |
excitation_r
|
ComplexArray1D
|
Right boundary excitation vector. |
required |
Returns:
| Type | Description |
|---|---|
tuple[ComplexArray1D, ComplexArray1D]
|
Tuple |
Source code in src/meow/eme/propagation.py
compute_modes_lumerical
compute_modes_lumerical(
cs: CrossSection,
num_modes: PositiveInt = 10,
unit: float = 1e-06,
post_process: Callable = post_process_modes,
sim: Sim | None = None,
) -> list[Mode]
Compute Modes for a given CrossSection (Lumerical backend).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cs
|
CrossSection
|
the cross-section to solve modes for. |
required |
num_modes
|
PositiveInt
|
number of modes to compute. |
10
|
unit
|
float
|
unit scaling factor (default 1e-6 for micrometres). |
1e-06
|
post_process
|
Callable
|
callable applied to the raw mode list before returning. |
post_process_modes
|
sim
|
Sim | None
|
optional Lumerical simulation object; uses the global one if None. |
None
|
Returns:
Source code in src/meow/fde/lumerical.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
compute_modes_tidy3d
compute_modes_tidy3d(
cs: CrossSection,
num_modes: PositiveInt = 10,
target_neff: PositiveFloat | None = None,
precision: Literal["single", "double"] = "double",
post_process: Callable = post_process_modes,
) -> Modes
Compute Modes for a given CrossSection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cs
|
CrossSection
|
the cross-section to solve modes for. |
required |
num_modes
|
PositiveInt
|
number of modes to compute. |
10
|
target_neff
|
PositiveFloat | None
|
effective index near which to search for modes. |
None
|
precision
|
Literal['single', 'double']
|
floating-point precision, |
'double'
|
post_process
|
Callable
|
callable applied to the raw mode list before returning. |
post_process_modes
|
Returns:
| Type | Description |
|---|---|
Modes
|
The computed and post-processed collection of modes. |
Source code in src/meow/fde/tidy3d.py
compute_propagation_s_matrices
compute_propagation_s_matrices(
modes: list[Modes],
cells: list[Cell],
*,
cell_lengths: list[float] | None = None,
) -> dict[str, SDictMM]
Return the propagation S-matrix for every cell in a stack.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modes
|
list[Modes]
|
Modal basis for each cell. |
required |
cells
|
list[Cell]
|
Cells through which the modes propagate. |
required |
cell_lengths
|
list[float] | None
|
Optional explicit lengths. If omitted, they are derived
from |
None
|
Source code in src/meow/eme/propagation.py
compute_propagation_s_matrix
Return the diagonal propagation S-matrix for one cell.
Each mode acquires a phase exp(2j * pi * neff / wl * cell_length) while
propagating through the cell. Backward propagation is mirrored by the
bidirectional port mapping in the returned SAX dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modes
|
Modes
|
Modal basis for the cell. |
required |
cell_length
|
float
|
Physical length of the cell. |
required |
Returns:
| Type | Description |
|---|---|
SDictMM
|
SAX dictionary mapping port pairs to complex transmission values. |
Source code in src/meow/eme/propagation.py
compute_s_matrix_sax
compute_s_matrix_sax(
modes: list[Modes],
*,
cells: list[Cell] | None = None,
cell_lengths: list[float] | None = None,
sax_backend: Backend = "klu",
interfaces_fn: Callable = compute_interface_s_matrices,
propagations_fn: Callable = compute_propagation_s_matrices,
**_: Any,
) -> SDenseMM
Calculate the S-matrix for given sets of modes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modes
|
list[Modes]
|
Modal basis for each cell in the stack. |
required |
cells
|
list[Cell] | None
|
Cells from which to derive propagation lengths. Either cells or cell_lengths must be provided. |
None
|
cell_lengths
|
list[float] | None
|
Optional explicit propagation lengths per cell. |
None
|
sax_backend
|
Backend
|
SAX backend used for circuit evaluation. |
'klu'
|
interfaces_fn
|
Callable
|
Callable that computes interface S-matrices. |
compute_interface_s_matrices
|
propagations_fn
|
Callable
|
Callable that computes propagation S-matrices. |
compute_propagation_s_matrices
|
Returns:
| Type | Description |
|---|---|
SDenseMM
|
A tuple |
Source code in src/meow/eme/cascade.py
create_cells
create_cells(
structures: list[Structure3D],
mesh: Mesh2D | list[Mesh2D],
Ls: Annotated[NDArray, Dim(1), DType("float64")],
z_min: float = 0.0,
) -> list[Cell]
Create multiple Cell objects with a Mesh and a collection of cell lengths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
structures
|
list[Structure3D]
|
the 3D structures shared by all cells. |
required |
mesh
|
Mesh2D | list[Mesh2D]
|
a single mesh or a list of meshes, one per cell. |
required |
Ls
|
Annotated[NDArray, Dim(1), DType('float64')]
|
a 1D array of cell lengths. |
required |
z_min
|
float
|
the starting z-coordinate for the first cell. |
0.0
|
Returns:
Source code in src/meow/cell.py
create_lumerical_geometries
create_lumerical_geometries(
sim: Sim,
structures: list[Structure3D],
env: Environment,
unit: float,
) -> None
Create Lumerical geometries from a list of structures.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sim
|
Sim
|
the Lumerical simulation object. |
required |
structures
|
list[Structure3D]
|
3-D structures to add to the simulation. |
required |
env
|
Environment
|
the environment containing material/wavelength info. |
required |
unit
|
float
|
unit scaling factor. |
required |
Source code in src/meow/fde/lumerical.py
downselect_s
Downselect the S-matrix to the given ports.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
S
|
SDenseMM
|
A tuple |
required |
ports
|
list[str]
|
Port names to keep. |
required |
Returns:
| Type | Description |
|---|---|
SDenseMM
|
A new |
Source code in src/meow/eme/cascade.py
electric_energy
electric_energy_density
Get the electric energy density contained in a Mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Mode
|
the mode to compute the electric energy density of. |
required |
Returns:
| Type | Description |
|---|---|
ndarray[tuple[int, int], dtype[float64]]
|
A 2D array of electric energy density values. |
Source code in src/meow/mode.py
energy
energy_density
Get the energy density contained in a Mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Mode
|
the mode to compute the energy density of. |
required |
Returns:
| Type | Description |
|---|---|
ndarray[tuple[int, int], dtype[float64]]
|
A 2D array of total (electric + magnetic) energy density values. |
Source code in src/meow/mode.py
enforce_passivity
enforce_passivity(
singular_values: ndarray,
*,
method: PassivityMethod = "invert",
) -> ndarray
Project singular values onto a passive interval.
This function post-processes the singular values of an S-matrix so that the resulting matrix has singular values no larger than one.
Available methods
"none": leave the singular values unchanged."clip": replace values larger than one by exactly one."invert": replacesigmaby1 / sigmawhensigma > 1."subtract": replacesigmabymax(0, 2 - sigma)whensigma > 1.
High-level interpretation
clip is the most conservative algebraic projection. invert and
subtract both map modest gain above one to modest loss below one,
which can be useful when the excess gain is interpreted as missing
radiation channels in a truncated basis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
singular_values
|
ndarray
|
Singular values to correct. |
required |
method
|
PassivityMethod
|
Passivity enforcement strategy. |
'invert'
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Corrected singular values. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/meow/eme/interface.py
extrude_gds
extrude_gds(
cell: Any,
extrusions: dict[
tuple[int, int], list[GdsExtrusionRule]
],
) -> list[Structure3D]
Extrude a gds cell given a dictionary of extrusion rules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cell
|
Any
|
a gdspy or gdstk Cell to extrude. |
required |
extrusions
|
dict[tuple[int, int], list[GdsExtrusionRule]]
|
the extrusion rules to use (if not given, the example extrusions will be used). |
required |
Returns:
| Type | Description |
|---|---|
list[Structure3D]
|
A list of Structure3D objects created from the extruded polygons. |
Source code in src/meow/gds_structures.py
filter_modes
filter_modes(
modes: Modes,
conditions: Iterable[Callable] = (
is_pml_mode,
is_lossy_mode,
),
) -> Modes
Filter a set of modes according to certain criteria.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modes
|
Modes
|
the list of modes to filter |
required |
conditions
|
Iterable[Callable]
|
the conditions to filter the modes with |
(is_pml_mode, is_lossy_mode)
|
Returns:
| Type | Description |
|---|---|
Modes
|
the filtered modes |
Source code in src/meow/fde/post_process.py
get_sim
Get the Lumerical simulation object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
keyword arguments; pass |
{}
|
Returns:
| Type | Description |
|---|---|
Sim
|
The active Lumerical simulation object. |
Source code in src/meow/fde/lumerical.py
inner_product
inner_product(
mode1: Mode,
mode2: Mode,
*,
symmetric: bool = False,
conjugate: bool = False,
ignore_pml: bool = True,
interpolation: Literal[
"Ex", "Ey", "Ez", "Hx", "Hy", "Hz"
]
| None = None,
) -> complex
The modal inner product for z-normal mode planes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode1
|
Mode
|
the left mode |
required |
mode2
|
Mode
|
the right mode |
required |
symmetric
|
bool
|
use the symmetric inner product definition |
False
|
conjugate
|
bool
|
use the conjugage inner product definition (power normalization) |
False
|
ignore_pml
|
bool
|
ignore PML region while taking the inner product |
True
|
interpolation
|
Literal['Ex', 'Ey', 'Ez', 'Hx', 'Hy', 'Hz'] | None
|
interpolate both modes to a certain field-grid position before taking the inner product. |
None
|
Returns:
| Type | Description |
|---|---|
complex
|
the inner product |
Source code in src/meow/mode.py
invert_mode
is_lossy_mode
Check whether a mode can be considered lossy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Mode
|
the mode to check. |
required |
threshold
|
float
|
imaginary neff value above which the mode is considered lossy. |
1.0
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the absolute imaginary part of neff exceeds the threshold. |
Source code in src/meow/mode.py
is_pml_mode
Check whether a mode can be considered a PML mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Mode
|
the mode to check. |
required |
threshold
|
float
|
PML energy fraction above which the mode is considered a PML mode. |
0.1
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the PML energy fraction exceeds the threshold. |
Source code in src/meow/mode.py
l2r_matrices
Return cumulative left-to-right S-matrices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pairs
|
list[STypeMM]
|
Propagation-interface pair S-matrices from |
required |
identity
|
SDenseMM
|
Identity-like S-matrix used as the initial accumulator. |
required |
sax_backend
|
Backend
|
SAX backend used for cascading. |
required |
Returns:
| Type | Description |
|---|---|
list[STypeMM]
|
List of cumulative S-matrices from the left boundary up to each cell. |
Source code in src/meow/eme/propagation.py
magnetic_energy
magnetic_energy_density
Get the magnetic energy density contained in a Mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Mode
|
the mode to compute the magnetic energy density of. |
required |
Returns:
| Type | Description |
|---|---|
ndarray[tuple[int, int], dtype[float64]]
|
A 2D array of magnetic energy density values. |
Source code in src/meow/mode.py
normalize
Normalize a Mode according to the inner_product with itself.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Mode
|
the mode to normalize. |
required |
inner_product
|
Callable
|
a callable computing the inner product of two modes. |
required |
Returns:
| Type | Description |
|---|---|
Mode
|
A new mode normalized such that its self-inner-product is unity. |
Source code in src/meow/mode.py
normalize_energy
Normalize a mode according to the energy it contains.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Mode
|
the mode to normalize. |
required |
Returns:
| Type | Description |
|---|---|
Mode
|
A new mode with fields scaled so that electric and magnetic energies are 0.5. |
Source code in src/meow/mode.py
normalize_modes
Self-normalize a set of modes.
This only fixes the norm of each mode individually. It does not make the
mode set mutually orthogonal. For overlap-based interface formulas, use
:func:orthonormalize_modes if you need the simplified G = I metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modes
|
Modes
|
the modes to normalize. |
required |
inner_product
|
Callable
|
callable computing the inner product between two modes. |
required |
Returns:
| Type | Description |
|---|---|
Modes
|
The normalized (and zero-phased) modes. |
Source code in src/meow/fde/post_process.py
orthonormalize_modes
Gram-Schmidt orthonormalization with drop tolerance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modes
|
Modes
|
the modes to orthonormalize |
required |
inner_product
|
Callable
|
the inner product to orthonormalize them under |
required |
tolerance
|
float
|
any mode that can't expand the basis beyond this tolerance will be dropped. |
0.01
|
Returns:
| Type | Description |
|---|---|
Modes
|
Orthonormalized mode basis. |
Notes
This routine first self-normalizes each mode and then applies
Gram-Schmidt. The inner_product passed here should generally be the
same one used later to build interface overlaps; otherwise the final
basis is orthonormal in the wrong metric.
Source code in src/meow/fde/post_process.py
overlap_matrix
overlap_matrix(
modes1: Modes, modes2: Modes, inner_product: Callable
) -> ndarray[tuple[int, int], dtype[complex128]]
Build the modal overlap matrix between two mode sets.
The entry M[i, j] is inner_product(modes1[i], modes2[j]). In the
interface derivation this is used both for self-overlaps (the metric G)
and cross-overlaps between the left and right waveguide bases.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modes1
|
Modes
|
Left/test mode set. |
required |
modes2
|
Modes
|
Right/expansion mode set. |
required |
inner_product
|
Callable
|
Modal inner-product callable. |
required |
Returns:
| Type | Description |
|---|---|
ndarray[tuple[int, int], dtype[complex128]]
|
Complex overlap matrix of shape |
Source code in src/meow/eme/interface.py
pi_pairs
pi_pairs(
propagations: dict[str, SDictMM],
interfaces: dict[str, SDenseMM],
sax_backend: Backend,
) -> list[STypeMM]
Return propagation-interface pairs for a full stack.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
propagations
|
dict[str, SDictMM]
|
Propagation S-matrices keyed by cell index. |
required |
interfaces
|
dict[str, SDenseMM]
|
Interface S-matrices keyed by adjacent cell pairs. |
required |
sax_backend
|
Backend
|
SAX backend used for cascading. |
required |
Returns:
Source code in src/meow/eme/propagation.py
plot_fields
plot_fields(
modes: list[list[Mode]],
cells: list[Cell],
forwards: list[ComplexArray1D],
backwards: list[ComplexArray1D],
y: float,
z: FloatArray1D,
) -> tuple[ComplexArray2D, FloatArray1D]
Reconstruct an Ex(x, z) field slice from propagated modal amplitudes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modes
|
list[list[Mode]]
|
Mode sets for each cell. |
required |
cells
|
list[Cell]
|
Cells defining the geometry and mesh. |
required |
forwards
|
list[ComplexArray1D]
|
Forward amplitude vectors per cell. |
required |
backwards
|
list[ComplexArray1D]
|
Backward amplitude vectors per cell. |
required |
y
|
float
|
Transverse y-coordinate at which to sample the field. |
required |
z
|
FloatArray1D
|
Global z-grid on which to reconstruct the field. |
required |
Returns:
| Type | Description |
|---|---|
ComplexArray2D
|
Tuple |
FloatArray1D
|
array and |
Source code in src/meow/eme/propagation.py
pml_fraction
Fraction of energy density in the PML region.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Mode
|
the mode to evaluate. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The fraction of total energy density located in the PML region (0.0 to 1.0). |
Source code in src/meow/mode.py
post_process_modes
post_process_modes(
modes: Modes,
inner_product: Callable = inner_product,
gm_tolerance: float = 0.01,
) -> Modes
Default post-processing pipeline after FDE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modes
|
Modes
|
the modes to post process |
required |
inner_product
|
Callable
|
the inner product with which to post-process the modes |
inner_product
|
gm_tolerance
|
float
|
Gramm-Schmidt orthonormalization tolerance |
0.01
|
Returns:
| Type | Description |
|---|---|
Modes
|
Filtered and orthonormalized modes. |
Notes
This is the default post_process used by compute_modes. The
choice of inner_product here matters downstream: if interface
overlaps are later built with a different inner product, the resulting
mode basis is no longer orthonormal in the interface metric.
Source code in src/meow/fde/post_process.py
propagate
propagate(
l2rs: list[STypeMM],
r2ls: list[STypeMM],
excitation_l: ComplexArray1D,
excitation_r: ComplexArray1D,
) -> tuple[list[ComplexArray1D], list[ComplexArray1D]]
Propagate boundary excitations through cumulative S-matrices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
l2rs
|
list[STypeMM]
|
Cumulative left-to-right S-matrices for each cell. |
required |
r2ls
|
list[STypeMM]
|
Cumulative right-to-left S-matrices for each cell. |
required |
excitation_l
|
ComplexArray1D
|
Left boundary excitation vector. |
required |
excitation_r
|
ComplexArray1D
|
Right boundary excitation vector. |
required |
Returns:
| Type | Description |
|---|---|
list[ComplexArray1D]
|
Tuple |
list[ComplexArray1D]
|
complex amplitude vectors, one per cell. |
Source code in src/meow/eme/propagation.py
propagate_modes
propagate_modes(
modes: list[list[Mode]],
cells: list[Cell],
*,
excitation_l: ComplexArray1D | None = None,
excitation_r: ComplexArray1D | None = None,
excite_mode_l: int = 0,
excite_mode_r: int | None = None,
y: float | None = None,
z: FloatArray1D | None = None,
num_z: int = 1000,
sax_backend: BackendLike = "default",
interface_kwargs: dict[str, Any] | None = None,
track: bool = True,
tracking_inner_product: Callable = inner_product,
interfaces_fn: Callable = compute_interface_s_matrices,
interface_fn: Callable = compute_interface_s_matrix,
) -> tuple[ComplexArray2D, FloatArray1D]
Propagate modal excitations through a stack of cells.
This is a convenience wrapper around the propagation and interface S-matrix machinery. The only required positional inputs are the modal bases and the cells. Everything else has defaults that are inferred from the stack:
- by default the left boundary excites mode 0 with unit amplitude;
- by default there is no right-side excitation;
- by default
yis the center of the transverse mesh; - by default
zspans the full device withnum_zsamples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modes
|
list[list[Mode]]
|
Mode set for each cell. |
required |
cells
|
list[Cell]
|
Cells associated with |
required |
excitation_l
|
ComplexArray1D | None
|
Optional explicit left excitation vector. |
None
|
excitation_r
|
ComplexArray1D | None
|
Optional explicit right excitation vector. |
None
|
excite_mode_l
|
int
|
Left mode to excite if |
0
|
excite_mode_r
|
int | None
|
Right mode to excite if |
None
|
y
|
float | None
|
Transverse y-coordinate at which to reconstruct |
None
|
z
|
FloatArray1D | None
|
Global z-grid on which to reconstruct the field. |
None
|
num_z
|
int
|
Number of z samples if |
1000
|
sax_backend
|
BackendLike
|
SAX backend used for cascading. |
'default'
|
interface_kwargs
|
dict[str, Any] | None
|
Optional keyword arguments forwarded to both
|
None
|
track
|
bool
|
Whether to reorder and phase-align modes between neighboring cells before propagation. |
True
|
tracking_inner_product
|
Callable
|
Inner product used for mode tracking. |
inner_product
|
interfaces_fn
|
Callable
|
Factory for interface S-matrices across the stack. |
compute_interface_s_matrices
|
interface_fn
|
Callable
|
Factory for the identity-like same-basis interface used to seed the left-to-right accumulation. |
compute_interface_s_matrix
|
Returns:
| Type | Description |
|---|---|
ComplexArray2D
|
|
FloatArray1D
|
and |
Source code in src/meow/eme/propagation.py
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | |
r2l_matrices
Return cumulative right-to-left S-matrices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pairs
|
list[STypeMM]
|
Propagation-interface pair S-matrices from |
required |
sax_backend
|
Backend
|
SAX backend used for cascading. |
required |
Returns:
Source code in src/meow/eme/propagation.py
select_ports
Keep a subset of ports from an S-matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
S
|
SDenseMM
|
A tuple |
required |
ports
|
list[str]
|
Port names to retain. |
required |
Returns:
| Type | Description |
|---|---|
SDenseMM
|
A new |
Source code in src/meow/eme/propagation.py
sort_structures
sort_structures(
structures: list[Structure3D],
) -> list[Structure3D]
sort_structures(
structures: list[Structure2D],
) -> list[Structure2D]
sort_structures(
structures: list[Structure3D] | list[Structure2D],
) -> list[Structure2D] | list[Structure3D]
Sort structures by mesh order, then by order of definition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
structures
|
list[Structure3D] | list[Structure2D]
|
the list of structures to sort. |
required |
Returns:
| Type | Description |
|---|---|
list[Structure2D] | list[Structure3D]
|
A new list of structures sorted by descending mesh order. |
Source code in src/meow/structures.py
split_square_matrix
split_square_matrix(
matrix: ComplexArray2D, idx: int
) -> tuple[
tuple[ComplexArray2D, ComplexArray2D],
tuple[ComplexArray2D, ComplexArray2D],
]
Split a square matrix into its four block submatrices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
ComplexArray2D
|
Square matrix to split. |
required |
idx
|
int
|
Row/column index at which to split. |
required |
Returns:
| Type | Description |
|---|---|
tuple[tuple[ComplexArray2D, ComplexArray2D], tuple[ComplexArray2D, ComplexArray2D]]
|
Nested tuple |
Source code in src/meow/eme/propagation.py
te_fraction
The TE polarization fraction of the Mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Mode
|
the mode to compute the TE fraction of. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The TE fraction (0.0 for pure TM, 1.0 for pure TE). |
Source code in src/meow/mode.py
track_modes
Track modal order and phase continuously across a cell stack.
Modes are solved independently in each cell, so neighboring cells may differ by permutation and arbitrary complex phase. This helper reorders each mode set by maximum overlap with the previous cell and phase-aligns matched modes so that the tracking overlap is real-positive.
Unmatched modes are appended after the matched subset in their original order. This function does not change the physics of the interface solve; it only makes the local basis more continuous for reconstruction and plotting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modes
|
list[Modes]
|
Ordered list of modal bases across the stack. |
required |
inner_product_fn
|
Callable
|
Inner-product callable used to compute overlaps between neighboring mode sets. |
inner_product
|
Returns:
Source code in src/meow/eme/propagation.py
tsvd_solve
Solve A X = B with a truncated-SVD pseudoinverse.
This is the regularized solve used by the EME interface construction. The
smallest singular directions of A are the first place where truncated
mode sets become numerically unstable, so the solve is performed as
X = pinv_tsvd(A) @ B
with a relative cutoff
s_cut = rcond * s_max.
Singular values below s_cut are discarded entirely.
High-level behavior
- small
rcondkeeps more singular directions and is closer to the exact inverse, but is more sensitive to ill-conditioning; - large
rconddrops more singular directions and is more stable, but biases the result towards a lower-rank approximation.
This routine does not enforce passivity by itself. It only stabilizes the linear inversion. Passivity is handled afterwards on the assembled interface S-matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
ndarray
|
System matrix to invert approximately. |
required |
B
|
ndarray
|
Right-hand side. |
required |
rcond
|
float
|
Relative singular-value cutoff. Singular values smaller than
|
0.001
|
Returns:
| Type | Description |
|---|---|
ndarray
|
A tuple |
ndarray
|
the singular values of |
float
|
retained singular directions. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If all singular values are rejected. |
Source code in src/meow/eme/solve.py
visualize
Visualize any meow object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
the meow object to visualize |
required |
**kwargs
|
Any
|
extra configuration to visualize the object |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
The result of the visualization function for the given object. |
Note
Most meow objects have a ._visualize method.
Check out its help to see which kwargs are accepted.
Source code in src/meow/visualization.py
zero_phase
Normalize (zero out) the phase of a Mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Mode
|
the mode to normalize the phase of. |
required |
Returns:
| Type | Description |
|---|---|
Mode
|
A new mode with zeroed-out phase. |