meow package#
MEOW: Modeling of Eigenmodes and Overlaps in Waveguides
Subpackages#
Submodules#
Provides a custom pydantic BaseModel which handles numpy arrays better
- class BaseModel[source]#
Bases:
BaseModel
A customized pydantic base model that handles numpy array type hints
an EME Cell
- class Cell(*, structures, mesh, z_min, z_max)[source]#
Bases:
BaseModel
A Cell defines an interval in z (the direction of propagation) within the simulation domain. The intersecting Structure3Ds are discretized by a given mesh at the center of the Cell
- Parameters:
structures (List[Structure3D]) –
mesh (Mesh2D) –
z_min (float) –
z_max (float) –
- structures: List[Structure3D]#
- z_min: float#
- z_max: float#
- property z#
- property length#
- property materials#
- property structures_2d: List[Structure2D]#
- property m_full#
- create_cells(structures, mesh, Ls, z_min=0.0)[source]#
easily create multiple Cell objects given a Mesh and a collection of cell lengths
- Parameters:
structures (List[Structure3D]) –
Ls (ndarray[Tuple[int], dtype[float64]]) –
z_min (float) –
- Return type:
List[Cell]
A CrossSection
- class CrossSection(*, structures, mesh, env)[source]#
Bases:
BaseModel
A CrossSection is created from the association of a Cell with an Environment, which uniquely defines the refractive index everywhere.
- Parameters:
structures (List[Structure2D]) –
mesh (Mesh2D) –
env (Environment) –
- structures: List[Structure2D]#
- env: Environment#
- classmethod from_cell(*, cell, env)[source]#
- Parameters:
cell (Cell) –
env (Environment) –
- property materials#
- property n_full#
- property nx#
- property ny#
- property nz#
A simulation Environment
- class Environment(*, wl=1.5, T=25.0, **kwargs)[source]#
Bases:
BaseModel
An environment contains all variables that don’t depend on the geometry/structure itself such as most commonly wavelength and temperature.
- Parameters:
wl (float) –
T (float) –
- wl: float#
- T: float#
- class Config[source]#
Bases:
Config
- allow_population_by_field_name = True#
- extra = 'allow'#
- arbitrary_types_allowed = True#
- json_encoders = {<class 'numpy.ndarray'>: <function _serialize_array>, <class 'meow.base_model._array'>: <function _serialize_array>, <class 'complex'>: <function _ModelMetaclass.__new__.<locals>.<lambda>>}#
GDS Extrusions
- class GdsExtrusionRule(*, material, h_min, h_max, buffer=0.0, mesh_order=5.0)[source]#
Bases:
BaseModel
a GdsExtrusionRule describes a single extrusion rule. Multiple of such rules can later be associated with a gds layer tuple.
- Parameters:
material (Material) –
h_min (float) –
h_max (float) –
buffer (float) –
mesh_order (int) –
- h_min: float#
- h_max: float#
- buffer: float#
- mesh_order: int#
- extrude_gds(cell, extrusions)[source]#
extrude a gds cell given a dictionary of extruson rules
- Parameters:
cell – a gdspy or gdstk Cell to extrude
extrusions (Dict[Tuple[int, int], List[GdsExtrusionRule]]) – the extrusion rules to use (if not given, the example extrusions will be used.)
- class Rectangle(*, type='', x_min, x_max, y_min, y_max)[source]#
Bases:
Geometry2D
a Rectangle
- Parameters:
type (str) –
x_min (float) –
x_max (float) –
y_min (float) –
y_max (float) –
- x_min: float#
- x_max: float#
- y_min: float#
- y_max: float#
- class Box(*, type='', x_min, x_max, y_min, y_max, z_min, z_max)[source]#
Bases:
Geometry3D
A Box is a simple rectangular cuboid
- Parameters:
type (str) –
x_min (float) –
x_max (float) –
y_min (float) –
y_max (float) –
z_min (float) –
z_max (float) –
- x_min: float#
- x_max: float#
- y_min: float#
- y_max: float#
- z_min: float#
- z_max: float#
- class Prism(*, type='', poly, h_min, h_max, axis='y')[source]#
Bases:
Geometry3D
A prism is a 2D Polygon extruded along a certain axis direction (‘x’, ‘y’, or ‘z’).
- Parameters:
type (str) –
poly (Array) –
h_min (float) –
h_max (float) –
axis (Union[Literal['x'], ~typing.Literal['y'], ~typing.Literal['z']]) –
- poly: Array#
- h_min: float#
- h_max: float#
- axis: Union[Literal['x'], Literal['y'], Literal['z']]#
- integrate_interpolate_2d(x, y, data, extent=None)[source]#
First the data on the given grid is interpolated and then integrated using scipy.dblquad. This procedure is best suited if one wants to integrate over a (small) region of interest that can be placed at off-grid positions
Materials
- class Material(*, type='', name, meta=None)[source]#
Bases:
BaseModel
a Material defines the refractive index of a Structure3D within an Environment.
- Parameters:
type (str) –
name (str) –
meta (Dict[str, Any]) –
- type: str#
- name: str#
- meta: Dict[str, Any]#
- __init__(**kwargs)[source]#
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- class Config[source]#
Bases:
Config
- fields = {'meta': {'exclude': True}}#
- arbitrary_types_allowed = True#
- json_encoders = {<class 'numpy.ndarray'>: <function _serialize_array>, <class 'meow.base_model._array'>: <function _serialize_array>, <class 'complex'>: <function _ModelMetaclass.__new__.<locals>.<lambda>>}#
- class TidyMaterial(*, type='', name, meta=None, variant)[source]#
Bases:
Material
- Parameters:
type (str) –
name (str) –
meta (Dict[str, Any]) –
variant (str) –
- name: str#
- variant: str#
- class SampledMaterial(*, type='', name, meta=None, params, n)[source]#
Bases:
Material
- Parameters:
type (str) –
name (str) –
meta (Dict[str, Any]) –
params (Dict[str, ndarray[Tuple[int], dtype[float64]]]) –
n (Array) –
- params: Dict[str, ndarray[Tuple[int], dtype[float64]]]#
- n: Array#
a 2D Mesh
- class Mesh2D(*, x, y, angle_phi=0.0, angle_theta=0.0, bend_radius=None, bend_axis=None, num_pml=(0, 0), ez_interfaces=False)[source]#
Bases:
Mesh
a 2D Mesh or
Mesh2D
describes how aStructure3D
is discritized into aCell
orCrossSection
- Parameters:
x (Array) –
y (Array) –
angle_phi (float) –
angle_theta (float) –
bend_radius (Optional[float]) –
bend_axis (Optional[Literal[0, 1]]) –
num_pml (Tuple[NonNegativeInt, NonNegativeInt]) –
ez_interfaces (bool) –
- x: Array#
- y: Array#
- angle_phi: float#
- angle_theta: float#
- bend_radius: Optional[float]#
- bend_axis: Optional[Literal[0, 1]]#
- num_pml: Tuple[NonNegativeInt, NonNegativeInt]#
- ez_interfaces: bool#
- property dx#
dx at Hz locations, i.e. center of the 2D cell
- property dy#
dy at Hz locations, i.e. center of the 2D cell
- property x_#
x at Hz locations, i.e. center of the 2D cell
- property y_#
y at Hz locations, i.e. center of the 2D cell
- property x_full#
x at half-integer locations
- property y_full#
y at half-integer locations
- property XY_full#
X and Y at half-integer locations
- property X_full#
X at half-integer locations
- property Y_full#
Y at half-integer locations
- property Xx#
X at Ex locations
- property Yx#
Y at Ex locations
- property Xy#
X at Ey locations
- property Yy#
Y at Ey locations
- property Xz#
X at Ez locations
- property Yz#
Y at Ez locations
- property Xz_#
X at Hz locations
- property Yz_#
Y at Hz locations
An EigenMode
- class Mode(*, neff, cs, Ex, Ey, Ez, Hx, Hy, Hz, interpolation=None)[source]#
Bases:
BaseModel
A Mode contains the field information for a given CrossSection.
- Parameters:
neff (Array) –
cs (CrossSection) –
Ex (Array) –
Ey (Array) –
Ez (Array) –
Hx (Array) –
Hy (Array) –
Hz (Array) –
interpolation (Optional[Literal['Ex', 'Ey', 'Ez', 'Hz']]) –
- neff: Array#
- cs: CrossSection#
- Ex: Array#
- Ey: Array#
- Ez: Array#
- Hx: Array#
- Hy: Array#
- Hz: Array#
- interpolation: Optional[Literal['Ex', 'Ey', 'Ez', 'Hz']]#
- property te_fraction#
the TE polarization fraction of the mode.
- property Px#
- property Py#
- property Pz#
- property A#
mode area
- property env#
- property mesh#
- inner_product(mode1, mode2)[source]#
the inner product of a Mode with another Mode is uniquely defined.
- inner_product_conj(mode1, mode2)[source]#
the inner product of a Mode with another Mode is uniquely defined.
- electric_energy_density(mode)[source]#
get the electric energy density contained in a Mode
- Parameters:
mode (Mode) –
- Return type:
ndarray[Tuple[int, int], dtype[float64]]
- electric_energy(mode)[source]#
get the electric energy contained in a Mode
- Parameters:
mode (Mode) –
- Return type:
float
- magnetic_energy_density(mode)[source]#
get the magnetic energy density contained in a Mode
- Parameters:
mode (Mode) –
- Return type:
ndarray[Tuple[int, int], dtype[float64]]
- magnetic_energy(mode)[source]#
get the magnetic energy contained in a Mode
- Parameters:
mode (Mode) –
- Return type:
float
- energy_density(mode)[source]#
get the energy density contained in a Mode
- Parameters:
mode (Mode) –
- Return type:
ndarray[Tuple[int, int], dtype[float64]]
- energy(mode)[source]#
get the energy contained in a Mode
- Parameters:
mode (Mode) –
- Return type:
float
- is_pml_mode(mode, threshold)[source]#
check whether a mode can be considered a PML mode.
- Parameters:
mode – the mode to classify as PML mode or not.
pml_mode_threshold – If the mode has more than pml_mode_threshold part of its energy in the PML, it will be removed.
- Returns:
whether the mode is a PML mode or not
- Return type:
bool
- te_fraction(mode)[source]#
the TE polarization fraction of the Mode
- Parameters:
mode (Mode) –
- Return type:
float
a Structure is a combination of a Geometry with a material (and an optional mesh order)
- Structure(*, material, geometry, mesh_order=5)[source]#
- Parameters:
material (Material) –
geometry (Union[Geometry2D, Geometry3D]) –
mesh_order (int) –
- class Structure2D(*, material, geometry, mesh_order=5)[source]#
Bases:
BaseModel
a Structure2D is an association between a Geometry2D and a Material
- Parameters:
material (Material) –
geometry (Geometry2D) –
mesh_order (int) –
- geometry: Geometry2D#
- mesh_order: int#
- class Structure3D(*, material, geometry, mesh_order=5)[source]#
Bases:
BaseModel
a Structure3D is an association between a Geometry3D and a Material
- Parameters:
material (Material) –
geometry (Geometry3D) –
mesh_order (int) –
- geometry: Geometry3D#
- mesh_order: int#
Visualizations for common meow-datatypes
- visualize(obj, **kwargs)[source]#
visualize any meow object
- Parameters:
obj (Any) – the meow object to visualize
**kwargs (Any) – extra configuration to visualize the object
Note
Most meow objects have a ._visualize method. Check out its help to see which kwargs are accepted.
- vis(obj, **kwargs)#
visualize any meow object
- Parameters:
obj (Any) – the meow object to visualize
**kwargs (Any) – extra configuration to visualize the object
Note
Most meow objects have a ._visualize method. Check out its help to see which kwargs are accepted.