Api
MEOW: Modeling of Eigenmodes and Overlaps in Waveguides.
AxisDirection = Literal['x', 'y', 'z']
module-attribute
Axis direction: "x", "y", or "z".
BoolArray1D = Annotated[NDArray, Dim(1), DType('bool')]
module-attribute
1D boolean numpy array.
BoolArray2D = Annotated[NDArray, Dim(2), DType('bool')]
module-attribute
2D boolean numpy array.
Complex = Annotated[NDArray, Dim(0), DType('complex128')]
module-attribute
0D (scalar) complex128 numpy array.
ComplexArray1D = Annotated[NDArray, Dim(1), DType('complex128')]
module-attribute
1D complex128 numpy array.
ComplexArray2D = Annotated[NDArray, Dim(2), DType('complex128')]
module-attribute
2D complex128 numpy array.
FloatArray1D = Annotated[NDArray, Dim(1), DType('float64')]
module-attribute
1D float64 numpy array.
FloatArray2D = Annotated[NDArray, Dim(2), DType('float64')]
module-attribute
2D float64 numpy array.
Geometry = Geometry2D | Geometry3D
module-attribute
Any 2D or 3D geometry.
Geometry2D = Rectangle | Polygon2D
module-attribute
A 2D geometry: either a Rectangle or a Polygon2D.
Geometry3D = Box | Prism
module-attribute
A 3D geometry: either a Box or a Prism.
IntArray1D = Annotated[NDArray, Dim(1), DType('int64')]
module-attribute
1D int64 numpy array.
IntArray2D = Annotated[NDArray, Dim(2), DType('int64')]
module-attribute
2D int64 numpy array.
Material = IndexMaterial | SampledMaterial | TidyMaterial
module-attribute
A material: IndexMaterial, SampledMaterial, or TidyMaterial.
Materials = list[Material]
module-attribute
A list of Material objects.
Modes = list[Mode]
module-attribute
A list of Mode objects.
NDArray = Annotated[np.ndarray, ArraySchema, PlainSerializer(_serialize_ndarray), BeforeValidator(_validate_ndarray), AfterValidator(_coerce_immutable)]
module-attribute
A numpy ndarray with pydantic serialization support.
PassivityMethod = Literal['none', 'clip', 'invert', 'subtract']
module-attribute
Method for enforcing S-matrix passivity.
Sim = Any
module-attribute
A lumerical simulation object.
BaseModel
Bases: BaseModel
Base model class for all models.
Source code in src/meow/base_model.py
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 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 | |
model_validate(obj, *, strict=None, from_attributes=None, context=None)
classmethod
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
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 | |
model_validate_json(json_data, *, strict=None, context=None)
classmethod
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
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 | |
Box
Bases: Geometry3DBase
A Box is a simple rectangular cuboid.
Source code in src/meow/geometries.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
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
Source code in src/meow/cell.py
21 22 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 | |
length
property
The length of the cell.
z
property
The z-position of the center of the cell.
m_full()
The full material mask for the cell.
Source code in src/meow/cell.py
64 65 66 67 68 69 70 71 | |
materials()
A mapping of the materials in the cell to their indices.
Source code in src/meow/cell.py
47 48 49 50 51 52 53 54 | |
structures_2d()
The 2D structures in the cell.
Source code in src/meow/cell.py
56 57 58 59 60 61 62 | |
CrossSection
Bases: BaseModel
A CrossSection is built from a Cell with an Environment.
This uniquely defines the refractive index everywhere.
Source code in src/meow/cross_section.py
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 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 | |
from_cell(*, cell, env, subpixel_smoothing=True)
classmethod
Create a CrossSection from a Cell and Environment.
Source code in src/meow/cross_section.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
materials()
Return a dictionary mapping materials to their indices.
Source code in src/meow/cross_section.py
63 64 65 66 67 68 69 70 | |
n_full()
Return the refractive index array for the full mesh.
Source code in src/meow/cross_section.py
77 78 79 80 81 82 83 | |
nx()
Return the smoothed refractive index on the Ex positions.
Source code in src/meow/cross_section.py
85 86 87 88 89 90 91 92 93 94 | |
ny()
Return the smoothed refractive index on the Ey positions.
Source code in src/meow/cross_section.py
96 97 98 99 100 101 102 103 104 105 | |
nz()
Return the smoothed refractive index on the Ez positions.
Source code in src/meow/cross_section.py
107 108 109 110 111 112 113 114 115 116 | |
Environment
Bases: BaseModel
An environment contains all variables that don't depend on the structure.
Source code in src/meow/environment.py
10 11 12 13 14 15 16 17 18 19 | |
GdsExtrusionRule
Bases: BaseModel
A GdsExtrusionRule describes a single extrusion rule.
Multiple of such rules can later be associated with a gds layer tuple.
Source code in src/meow/gds_structures.py
20 21 22 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 | |
__call__(poly)
Apply the extrusion rule to a polygon.
Source code in src/meow/gds_structures.py
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 | |
Geometry2DBase
Bases: BaseModel
Base class for 2D geometries.
Source code in src/meow/geometries.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
Geometry3DBase
Bases: BaseModel
Base class for 3D geometries.
Source code in src/meow/geometries.py
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 | |
IndexMaterial
Bases: MaterialBase
A material with a constant refractive index.
Source code in src/meow/materials.py
108 109 110 111 112 113 114 115 | |
__call__(env)
Get the refractive index of the material for the given environment.
Source code in src/meow/materials.py
113 114 115 | |
MaterialBase
Bases: BaseModel
a Material defines the index of a Structure3D in an Environment.
Source code in src/meow/materials.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 | |
__call__(env)
Get the refractive index of the material for the given environment.
Source code in src/meow/materials.py
36 37 38 39 | |
Mesh2D
Bases: BaseModel
A Mesh2D describes how a Structure3D is discritized into a Cell.
Source code in src/meow/mesh.py
15 16 17 18 19 20 21 22 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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
X_full
property
X at half-integer locations.
Xx
property
X at Ex locations.
Xy
property
X at Ey locations.
Xz
property
X at Ez locations.
Xz_
property
X at Hz locations.
Y_full
property
Y at half-integer locations.
Yx
property
Y at Ex locations.
Yy
property
Y at Ey locations.
Yz
property
Y at Ez locations.
Yz_
property
Y at Hz locations.
XY_full()
X and Y at half-integer locations.
Source code in src/meow/mesh.py
99 100 101 102 103 | |
dx()
dx at Hz locations, i.e. center of the 2D cell.
Source code in src/meow/mesh.py
69 70 71 72 | |
dy()
dy at Hz locations, i.e. center of the 2D cell.
Source code in src/meow/mesh.py
74 75 76 77 | |
x_()
x at Hz locations, i.e. center of the 2D cell.
Source code in src/meow/mesh.py
79 80 81 82 | |
x_full()
x at half-integer locations.
Source code in src/meow/mesh.py
89 90 91 92 | |
y_()
y at Hz locations, i.e. center of the 2D cell.
Source code in src/meow/mesh.py
84 85 86 87 | |
y_full()
y at half-integer locations.
Source code in src/meow/mesh.py
94 95 96 97 | |
Mode
Bases: BaseModel
A Mode contains the field information for a given CrossSection.
Source code in src/meow/mode.py
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 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 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | |
Px
property
The x-component of the Poynting vector.
Py
property
The y-component of the Poynting vector.
Pz
property
The z-component of the Poynting vector.
env
property
The environment of the mode.
mesh
property
The mesh of the mode.
te_fraction
property
The TE polarization fraction of the mode.
interpolate(location)
Interpolate the mode to the given location.
Source code in src/meow/mode.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
load(filename)
classmethod
Load a mode from a file.
Source code in src/meow/mode.py
223 224 225 226 | |
save(filename)
Save the mode to a file.
Source code in src/meow/mode.py
217 218 219 220 221 | |
ModelMetaclass
Bases: ModelMetaclass
Metaclass for all models.
Source code in src/meow/base_model.py
27 28 29 30 31 32 | |
Polygon2D
Bases: Geometry2DBase
A 2D polygon defined by a list of vertices.
Source code in src/meow/geometries.py
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 | |
Prism
Bases: Geometry3DBase
A prism is a 2D Polygon extruded along a axis direction ('x', 'y', 'z').
Source code in src/meow/geometries.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 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 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | |
Rectangle
Bases: Geometry2DBase
A Rectangle.
Source code in src/meow/geometries.py
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 | |
SampledMaterial
Bases: MaterialBase
A material with a sampled refractive index.
Source code in src/meow/materials.py
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 | |
__call__(env)
Get the refractive index of the material for the given environment.
Source code in src/meow/materials.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
from_df(name, df, meta=None)
classmethod
Create a SampledMaterial from a DataFrame.
Source code in src/meow/materials.py
158 159 160 161 162 163 164 165 166 167 168 169 170 | |
from_path(path, meta=None)
classmethod
Create a SampledMaterial from a CSV file.
Source code in src/meow/materials.py
150 151 152 153 154 155 156 | |
SerializedArray
Bases: BaseModel
A serialized representation of a numpy array.
Source code in src/meow/arrays.py
19 20 21 22 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 | |
from_array(x)
classmethod
Create a SerializedArray from a numpy array.
Source code in src/meow/arrays.py
26 27 28 29 30 31 32 33 34 35 36 37 38 | |
to_array()
Convert the SerializedArray back to a numpy array.
Source code in src/meow/arrays.py
40 41 42 43 44 45 46 47 48 49 50 51 | |
Structure2D
Bases: BaseModel
A Structure2D is an association between a Geometry2D and a Material.
Source code in src/meow/structures.py
61 62 63 64 65 66 67 68 69 70 71 72 | |
Structure3D
Bases: BaseModel
A Structure3D is an association between a Geometry3D and a Material.
Source code in src/meow/structures.py
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 | |
TidyMaterial
Bases: MaterialBase
A material from the Tidy3D material library.
Source code in src/meow/materials.py
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 | |
__call__(env)
Get the refractive index of the material for the given environment.
Source code in src/meow/materials.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
__init__(**kwargs)
Initialize the TidyMaterial.
Source code in src/meow/materials.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
DType(dtype, *, coerce=True)
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
147 148 149 150 151 152 153 154 155 156 157 158 | |
Dim(ndim, *, coerce=True)
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
133 134 135 136 137 138 139 140 141 142 143 144 | |
Shape(*shape, coerce=True)
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
161 162 163 164 165 166 167 168 169 170 171 172 | |
Structure(*, material, geometry, mesh_order=DEFAULT_MESH_ORDER)
Structure(
*,
material: Material,
geometry: Geometry2D,
mesh_order: int = DEFAULT_MESH_ORDER,
) -> Structure2D
Structure(
*,
material: Material,
geometry: Geometry3D,
mesh_order: int = DEFAULT_MESH_ORDER,
) -> 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
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
cache(prop)
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
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
cached_property(method)
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
210 211 212 213 214 215 216 217 218 219 | |
compute_interface_s_matrices(modes, *, inner_product=inner_product, conjugate=None, tsvd_rcond=0.001, passivity_method='invert', enforce_reciprocity=True, ignore_warnings=True)
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
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
compute_interface_s_matrix(modes1, modes2, *, inner_product=inner_product, conjugate=None, tsvd_rcond=0.001, passivity_method='invert', enforce_reciprocity=True, ignore_warnings=True)
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(u, v, m, excitation_l, excitation_r)
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
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
compute_modes_lumerical(cs, num_modes=10, unit=1e-06, post_process=post_process_modes, sim=None)
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:
| Type | Description |
|---|---|
list[Mode]
|
The computed and post-processed list of modes. |
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(cs, num_modes=10, target_neff=None, precision='double', post_process=post_process_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
20 21 22 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 | |
compute_propagation_s_matrices(modes, cells, *, cell_lengths=None)
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
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 | |
compute_propagation_s_matrix(modes, cell_length)
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
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
compute_s_matrix_sax(modes, *, cells=None, cell_lengths=None, sax_backend='klu', interfaces_fn=compute_interface_s_matrices, propagations_fn=compute_propagation_s_matrices, **_)
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
22 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 | |
create_cells(structures, mesh, Ls, z_min=0.0)
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:
| Type | Description |
|---|---|
list[Cell]
|
A list of Cell objects spanning the given lengths. |
Source code in src/meow/cell.py
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 | |
create_lumerical_geometries(sim, structures, env, unit)
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
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
downselect_s(S, ports)
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
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
electric_energy(mode)
Get the electric energy contained in a Mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Mode
|
the mode to compute the electric energy of. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The total electric energy summed over the cross section. |
Source code in src/meow/mode.py
490 491 492 493 494 495 496 497 498 499 | |
electric_energy_density(mode)
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
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | |
energy(mode)
Get the energy contained in a Mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Mode
|
the mode to compute the energy of. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The total energy summed over the cross section. |
Source code in src/meow/mode.py
542 543 544 545 546 547 548 549 550 551 | |
energy_density(mode)
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
530 531 532 533 534 535 536 537 538 539 | |
enforce_passivity(singular_values, *, method='invert')
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
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | |
extrude_gds(cell, extrusions)
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
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
filter_modes(modes, conditions=(is_pml_mode, is_lossy_mode))
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
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
get_sim(**kwargs)
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
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 | |
inner_product(mode1, mode2, *, symmetric=False, conjugate=False, ignore_pml=True, interpolation=None)
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
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 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 | |
invert_mode(mode)
Invert a Mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Mode
|
the mode to invert. |
required |
Returns:
| Type | Description |
|---|---|
Mode
|
A new mode with all field components negated. |
Source code in src/meow/mode.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | |
is_lossy_mode(mode, *, threshold=1.0)
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
620 621 622 623 624 625 626 627 628 629 630 | |
is_pml_mode(mode, *, threshold=0.1)
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
604 605 606 607 608 609 610 611 612 613 614 615 616 617 | |
l2r_matrices(pairs, identity, sax_backend)
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
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
magnetic_energy(mode)
Get the magnetic energy contained in a Mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Mode
|
the mode to compute the magnetic energy of. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The total magnetic energy summed over the cross section. |
Source code in src/meow/mode.py
518 519 520 521 522 523 524 525 526 527 | |
magnetic_energy_density(mode)
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
502 503 504 505 506 507 508 509 510 511 512 513 514 515 | |
normalize(mode, inner_product)
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
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | |
normalize_energy(mode)
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
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 | |
normalize_modes(modes, inner_product)
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
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
orthonormalize_modes(modes, inner_product, *, tolerance=0.01)
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
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 | |
overlap_matrix(modes1, modes2, inner_product)
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
21 22 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 | |
pi_pairs(propagations, interfaces, sax_backend)
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:
| Type | Description |
|---|---|
list[STypeMM]
|
List of cascaded propagation-interface S-matrices, one per cell. |
Source code in src/meow/eme/propagation.py
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 | |
plot_fields(modes, cells, forwards, backwards, y, z)
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
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
pml_fraction(mode)
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
578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | |
post_process_modes(modes, inner_product=inner_product, gm_tolerance=0.01)
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
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
propagate(l2rs, r2ls, excitation_l, excitation_r)
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
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | |
propagate_modes(modes, cells, *, excitation_l=None, excitation_r=None, excite_mode_l=0, excite_mode_r=None, y=None, z=None, num_z=1000, sax_backend='default', interface_kwargs=None, track=True, tracking_inner_product=inner_product, interfaces_fn=compute_interface_s_matrices, interface_fn=compute_interface_s_matrix)
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(pairs, sax_backend)
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:
| Type | Description |
|---|---|
list[STypeMM]
|
List of cumulative S-matrices from each cell to the right boundary. |
Source code in src/meow/eme/propagation.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
select_ports(S, 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
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
sort_structures(structures)
sort_structures(
structures: list[Structure3D],
) -> list[Structure3D]
sort_structures(
structures: list[Structure2D],
) -> list[Structure2D]
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
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
split_square_matrix(matrix, idx)
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
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
te_fraction(mode)
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
633 634 635 636 637 638 639 640 641 642 643 644 645 | |
track_modes(modes, *, inner_product_fn=inner_product)
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:
| Type | Description |
|---|---|
list[Modes]
|
Reordered and phase-aligned list of modal bases. |
Source code in src/meow/eme/propagation.py
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 | |
tsvd_solve(A, B, rcond=0.001)
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
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 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 | |
visualize(obj, **kwargs)
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
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 | |
zero_phase(mode)
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. |
Source code in src/meow/mode.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |