Skip to content

Commit aece7d7

Browse files
Maybe we just need to upload the terminal compontn modeler as a job
1 parent bb315dc commit aece7d7

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

tidy3d/plugins/smatrix/component_modelers/terminal.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from tidy3d.plugins.smatrix.ports.coaxial_lumped import CoaxialLumpedPort
2929
from tidy3d.plugins.smatrix.ports.rectangular_lumped import LumpedPort
3030
from tidy3d.plugins.smatrix.ports.wave import WavePort
31-
from tidy3d.web.api.container import Batch, BatchData
31+
from tidy3d.web.api.container import Batch, BatchData, Job
3232

3333
from .base import AbstractComponentModeler, TerminalPortType
3434

@@ -663,8 +663,30 @@ def get_antenna_metrics_data(
663663
def run(self, path_dir: str = DEFAULT_DATA_DIR) -> TerminalPortDataArray:
664664
"""Solves for the scattering matrix of the system."""
665665
_ = self.get_path_dir(path_dir)
666+
_ = self._upload_terminal_modeler()
666667
return self._construct_smatrix()
667668

669+
@cached_property
670+
def _terminal_modeler_path(self) -> str:
671+
"""Where we store the for this :class:`TerminalComponentModeler` instance after the run."""
672+
return os.path.join(self.path_dir, "tcp_" + str(hash(self)) + ".hdf5")
673+
674+
def _upload_terminal_modeler(self) -> Job:
675+
# first try loading the terminal_component_modeler from file, if it exists
676+
terminal_modeler_path = self._terminal_modeler_path
677+
678+
if os.path.exists(terminal_modeler_path):
679+
return Job.from_file(fname=terminal_modeler_path)
680+
681+
return Job(
682+
simulation=self,
683+
folder_name=self.folder_name,
684+
callback_url=self.callback_url,
685+
verbose=self.verbose,
686+
solver_version=self.solver_version,
687+
simulation_type="microwave",
688+
)
689+
668690
@cached_property
669691
def batch(self) -> Batch:
670692
""":class:`.Batch` associated with this component modeler."""

tidy3d/web/api/tidy3d_stub.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from tidy3d.components.tcad.simulation.heat import HeatSimulation
2727
from tidy3d.components.tcad.simulation.heat_charge import HeatChargeSimulation
2828
from tidy3d.plugins.mode.mode_solver import ModeSolver
29+
from tidy3d.plugins.smatrix import TerminalComponentModeler
2930
from tidy3d.web.core.file_util import (
3031
read_simulation_from_hdf5,
3132
read_simulation_from_hdf5_gz,
@@ -42,6 +43,7 @@
4243
ModeSolver,
4344
ModeSimulation,
4445
VolumeMesher,
46+
TerminalComponentModeler,
4547
]
4648
SimulationDataType = Union[
4749
SimulationData,
@@ -100,6 +102,9 @@ def from_file(cls, file_path: str) -> SimulationType:
100102
sim = ModeSimulation.from_file(file_path)
101103
elif type_ == "VolumeMesher":
102104
sim = VolumeMesher.from_file(file_path)
105+
elif type_ == "TerminalComponentModeler":
106+
# TODO Remove: An aberration this is here, but alas necessity.
107+
sim = TerminalComponentModeler.from_file(file_path)
103108

104109
return sim
105110

@@ -162,6 +167,8 @@ def get_type(self) -> str:
162167
return TaskType.MODE.name
163168
elif isinstance(self.simulation, VolumeMesher):
164169
return TaskType.VOLUME_MESH.name
170+
if isinstance(self.simulation, TerminalComponentModeler):
171+
return TaskType.TERMINAL_COMPONENT_MODELER.name
165172

166173
def validate_pre_upload(self, source_required) -> None:
167174
"""Perform some pre-checks on instances of component"""

tidy3d/web/core/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class TaskType(str, Enum):
5555
EME = "EME"
5656
MODE = "MODE"
5757
VOLUME_MESH = "VOLUME_MESH"
58+
TERMINAL_COMPONENT_MODELER = "TERMINAL_COMPONENT_MODELER"
5859

5960

6061
class PayType(str, Enum):

0 commit comments

Comments
 (0)