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 extruson 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 |
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
¶
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
¶
Return the refractive index array for the full mesh.
Source code in src/meow/cross_section.py
nx
¶
Return the smoothed refractive index on the Ex positions.
Source code in src/meow/cross_section.py
ny
¶
Return the smoothed refractive index on the Ey positions.
Source code in src/meow/cross_section.py
nz
¶
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. |
dx
¶
dy
¶
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_full
¶
y_
¶
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
save
¶
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
¶
from_array(x: ndarray) -> Self
Create a SerializedArray from a numpy array.
Source code in src/meow/arrays.py
to_array
¶
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.
Dim
¶
Validator to ensure the array has a specific number of dimensions.
Shape
¶
Validator to ensure the array has a specific shape.
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.
Source code in src/meow/structures.py
cache
¶
Decorator to cache the result of a property method.
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.
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
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 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 | |
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.
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 givenFdeSpec` (Lumerical backend).
Source code in src/meow/fde/lumerical.py
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.
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
¶
compute_propagation_s_matrix(
modes: Modes, cell_length: float
) -> SDictMM
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.
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.
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.
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.
Source code in src/meow/fde/lumerical.py
downselect_s
¶
Downselect the S-matrix to the given ports.
Source code in src/meow/eme/cascade.py
electric_energy
¶
electric_energy_density
¶
Get the electric energy density contained in a Mode.
Source code in src/meow/mode.py
energy
¶
energy_density
¶
enforce_passivity
¶
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 extruson 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 |
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_sim(**kwargs: Any) -> Sim
Get the 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
¶
is_pml_mode
¶
Check whether a mode can be considered a PML mode.
Source code in src/meow/mode.py
l2r_matrices
¶
Return cumulative left-to-right S-matrices.
Source code in src/meow/eme/propagation.py
magnetic_energy
¶
magnetic_energy_density
¶
Get the magnetic energy density contained in a Mode.
Source code in src/meow/mode.py
normalize
¶
Normalize a Mode according to the inner_product with itself.
Source code in src/meow/mode.py
normalize_energy
¶
Normalize a mode according to the energy it contains.
Source code in src/meow/mode.py
normalize_modes
¶
normalize_modes(
modes: Modes, inner_product: Callable
) -> 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.
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.
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.
Source code in src/meow/eme/propagation.py
pml_fraction
¶
Fraction of energy density in the PML region.
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.
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
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |
r2l_matrices
¶
Return cumulative right-to-left S-matrices.
Source code in src/meow/eme/propagation.py
select_ports
¶
Keep a subset of ports from an S-matrix.
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.
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.
Source code in src/meow/eme/propagation.py
te_fraction
¶
The TE polarization fraction of the Mode.
track_modes
¶
track_modes(
modes: list[Modes],
*,
inner_product_fn: Callable = inner_product,
) -> list[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.
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 |
{}
|
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.