|
2 | 2 |
|
3 | 3 | from __future__ import annotations
|
4 | 4 |
|
| 5 | +import os |
5 | 6 | from typing import Optional, Union
|
6 | 7 |
|
7 | 8 | import numpy as np
|
|
26 | 27 | from tidy3d.plugins.smatrix.ports.coaxial_lumped import CoaxialLumpedPort
|
27 | 28 | from tidy3d.plugins.smatrix.ports.rectangular_lumped import LumpedPort
|
28 | 29 | from tidy3d.plugins.smatrix.ports.wave import WavePort
|
29 |
| -from tidy3d.web.api.container import BatchData |
| 30 | +from tidy3d.web.api.container import Batch, BatchData |
30 | 31 |
|
31 | 32 | from .base import AbstractComponentModeler, TerminalPortType
|
32 | 33 |
|
@@ -657,3 +658,25 @@ def get_antenna_metrics_data(
|
657 | 658 | return AntennaMetricsData.from_directivity_data(
|
658 | 659 | combined_directivity_data, power_incident, power_reflected
|
659 | 660 | )
|
| 661 | + |
| 662 | + @cached_property |
| 663 | + def batch(self) -> Batch: |
| 664 | + """:class:`.Batch` associated with this component modeler.""" |
| 665 | + |
| 666 | + if self.batch_cached is not None: |
| 667 | + return self.batch_cached |
| 668 | + |
| 669 | + # first try loading the batch from file, if it exists |
| 670 | + batch_path = self._batch_path |
| 671 | + |
| 672 | + if os.path.exists(batch_path): |
| 673 | + return Batch.from_file(fname=batch_path) |
| 674 | + |
| 675 | + return Batch( |
| 676 | + simulations=self.sim_dict, |
| 677 | + folder_name=self.folder_name, |
| 678 | + callback_url=self.callback_url, |
| 679 | + verbose=self.verbose, |
| 680 | + solver_version=self.solver_version, |
| 681 | + simulation_type="microwave", |
| 682 | + ) |
0 commit comments