-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,524 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import pytest | ||
import pydantic.v1 as pd | ||
import numpy as np | ||
from matplotlib import pyplot as plt | ||
|
||
import tidy3d as td | ||
|
||
from ..utils import STL_GEO, assert_log_level, log_capture | ||
|
||
|
||
def test_eme_sim_data(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
"""EME dataset""" | ||
from __future__ import annotations | ||
|
||
|
||
import pydantic.v1 as pd | ||
|
||
from ...data.dataset import Dataset, ElectromagneticFieldDataset | ||
from ...data.data_array import EMEScalarFieldDataArray, EMESMatrixDataArray | ||
|
||
|
||
class EMESMatrixDataset(Dataset): | ||
"""Dataset storing S matrix.""" | ||
|
||
S11: EMESMatrixDataArray = pd.Field( | ||
..., | ||
title="S11 matrix", | ||
description="S matrix relating output modes at port 1 to input modes at port 1.", | ||
) | ||
S12: EMESMatrixDataArray = pd.Field( | ||
..., | ||
title="S12 matrix", | ||
description="S matrix relating output modes at port 1 to input modes at port 2.", | ||
) | ||
S21: EMESMatrixDataArray = pd.Field( | ||
..., | ||
title="S21 matrix", | ||
description="S matrix relating output modes at port 2 to input modes at port 1.", | ||
) | ||
S22: EMESMatrixDataArray = pd.Field( | ||
..., | ||
title="S22 matrix", | ||
description="S matrix relating output modes at port 2 to input modes at port 2.", | ||
) | ||
|
||
|
||
class EMECoefficientDataset(Dataset): | ||
"""Dataset storing expansion coefficients for the modes in a cell. | ||
These are defined at the cell centers. | ||
""" | ||
|
||
A1: EMESMatrixDataArray = pd.Field( | ||
..., | ||
title="A1 coefficient", | ||
description="Coefficient for forward mode in this cell " "when excited from port 1.", | ||
) | ||
B1: EMESMatrixDataArray = pd.Field( | ||
..., | ||
title="B1 coefficient", | ||
description="Coefficient for backward mode in this cell " "when excited from port 1.", | ||
) | ||
A2: EMESMatrixDataArray = pd.Field( | ||
..., | ||
title="A2 coefficient", | ||
description="Coefficient for forward mode in this cell " "when excited from port 2.", | ||
) | ||
B2: EMESMatrixDataArray = pd.Field( | ||
..., | ||
title="B2 coefficient", | ||
description="Coefficient for backward mode in this cell " "when excited from port 2.", | ||
) | ||
|
||
|
||
class EMEFieldDataset(ElectromagneticFieldDataset): | ||
"""Dataset storing scalar components of E and H fields as a function of freq, mode_index, and port_index.""" | ||
|
||
Ex: EMEScalarFieldDataArray = pd.Field( | ||
..., | ||
title="Ex", | ||
description="Spatial distribution of the x-component of the electric field of the mode.", | ||
) | ||
Ey: EMEScalarFieldDataArray = pd.Field( | ||
..., | ||
title="Ey", | ||
description="Spatial distribution of the y-component of the electric field of the mode.", | ||
) | ||
Ez: EMEScalarFieldDataArray = pd.Field( | ||
..., | ||
title="Ez", | ||
description="Spatial distribution of the z-component of the electric field of the mode.", | ||
) | ||
Hx: EMEScalarFieldDataArray = pd.Field( | ||
..., | ||
title="Hx", | ||
description="Spatial distribution of the x-component of the magnetic field of the mode.", | ||
) | ||
Hy: EMEScalarFieldDataArray = pd.Field( | ||
..., | ||
title="Hy", | ||
description="Spatial distribution of the y-component of the magnetic field of the mode.", | ||
) | ||
Hz: EMEScalarFieldDataArray = pd.Field( | ||
..., | ||
title="Hz", | ||
description="Spatial distribution of the z-component of the magnetic field of the mode.", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
"""EME monitor data""" | ||
from __future__ import annotations | ||
|
||
from abc import ABC | ||
|
||
from typing import Union, List | ||
|
||
import pydantic.v1 as pd | ||
|
||
from ...base_sim.data.monitor_data import AbstractMonitorData | ||
from ..monitor import EMEModeSolverMonitor, EMEFieldMonitor, EMECoefficientMonitor | ||
from ...data.monitor_data import ModeSolverData, ElectromagneticFieldData | ||
from ...base import Tidy3dBaseModel | ||
from ....exceptions import ValidationError | ||
|
||
from .dataset import EMEFieldDataset, EMECoefficientDataset | ||
|
||
|
||
class EMEGridData(Tidy3dBaseModel, ABC): | ||
"""Abstract class defining data indexed by a subset of the cells in the EME grid.""" | ||
|
||
cell_indices: List[pd.NonNegativeInt] = pd.Field( | ||
..., title="Cell indices", description="Cell indices" | ||
) | ||
|
||
|
||
class EMEModeSolverData(AbstractMonitorData, EMEGridData): | ||
"""Data associated with an EME mode solver monitor.""" | ||
|
||
monitor: EMEModeSolverMonitor = pd.Field( | ||
..., | ||
title="EME Mode Solver Monitor", | ||
description="EME mode solver monitor associated with this data.", | ||
) | ||
|
||
modes: List[ModeSolverData] = pd.Field( | ||
..., | ||
title="Modes", | ||
description="Modes recorded by the EME mode solver monitor. " | ||
"The corresponding cell indices are stored in 'cell_indices'. " | ||
"A mode is recorded if its mode plane is contained in the monitor geometry.", | ||
) | ||
|
||
@pd.validator("modes", always=True) | ||
def _validate_num_modes(cls, val, values): | ||
"""Check that the number of modes equals the number of cells inside the monitor.""" | ||
num_cells = len(values["cell_indices"]) | ||
num_modes = len(val) | ||
if num_cells != num_modes: | ||
raise ValidationError("The number of 'modes' must equal the number of 'cell_indices'.") | ||
return val | ||
|
||
|
||
class EMEFieldData(EMEFieldDataset, ElectromagneticFieldData): | ||
"""Data associated with an EME field monitor.""" | ||
|
||
monitor: EMEFieldMonitor = pd.Field( | ||
..., title="EME Field Monitor", description="EME field monitor associated with this data." | ||
) | ||
|
||
|
||
class EMECoefficientData(AbstractMonitorData, EMEGridData): | ||
"""Data associated with an EME coefficient monitor.""" | ||
|
||
monitor: EMECoefficientMonitor = pd.Field( | ||
..., | ||
title="EME Coefficient Monitor", | ||
description="EME coefficient monitor associated with this data.", | ||
) | ||
|
||
coeffs: List[EMECoefficientDataset] = pd.Field( | ||
..., | ||
title="Coefficients", | ||
description="Coefficients of the forward and backward traveling modes in each cell " | ||
"contained in the monitor geometry.", | ||
) | ||
|
||
@pd.validator("coeffs", always=True) | ||
def _validate_num_coeffs(cls, val, values): | ||
"""Check that the number of coeffs equals the number of cells inside the monitor.""" | ||
num_cells = len(values["cell_indices"]) | ||
num_coeffs = len(val) | ||
if num_cells != num_coeffs: | ||
raise ValidationError("The number of 'coeffs' must equal the number of 'cell_indices'.") | ||
return val | ||
|
||
|
||
EMEMonitorDataType = Union[EMEModeSolverData, EMEFieldData, EMECoefficientData] |
Oops, something went wrong.