|
29 | 29 | from .source import CustomCurrentSource, CustomSourceTime, ContinuousWave
|
30 | 30 | from .source import TFSF, Source, ModeSource
|
31 | 31 | from .monitor import MonitorType, Monitor, FreqMonitor, SurfaceIntegrationMonitor
|
32 |
| -from .monitor import AbstractModeMonitor, FieldMonitor |
| 32 | +from .monitor import AbstractModeMonitor, FieldMonitor, TimeMonitor |
33 | 33 | from .monitor import PermittivityMonitor, DiffractionMonitor, AbstractFieldProjectionMonitor
|
34 | 34 | from .monitor import FieldProjectionAngleMonitor, FieldProjectionKSpaceMonitor
|
35 | 35 | from .data.dataset import Dataset
|
@@ -1065,7 +1065,7 @@ def validate_pre_upload(self, source_required: bool = True) -> None:
|
1065 | 1065 | self._validate_modes_size()
|
1066 | 1066 | self._validate_datasets_not_none()
|
1067 | 1067 | self._validate_tfsf_structure_intersections()
|
1068 |
| - # self._validate_run_time() |
| 1068 | + self._warn_time_monitors_outside_run_time() |
1069 | 1069 | _ = self.volumetric_structures
|
1070 | 1070 | log.end_capture(self)
|
1071 | 1071 | if source_required and len(self.sources) == 0:
|
@@ -1282,6 +1282,21 @@ def _validate_tfsf_structure_intersections(self) -> None:
|
1282 | 1282 | f" '{'xyz'[source.injection_axis]}'."
|
1283 | 1283 | )
|
1284 | 1284 |
|
| 1285 | + def _warn_time_monitors_outside_run_time(self) -> None: |
| 1286 | + """Warn if time monitors start after the simulation run_time. |
| 1287 | + TODO: (remove this comment later) this is done as a pre-upload validator in view of a |
| 1288 | + planned change to allow ``run_time`` to accept a ``RunTimeSpec`` which would automatically |
| 1289 | + determine a run time based on simulation details. Then, we would have to access the |
| 1290 | + dynamically computed run_time e.g. through a ``_run_time`` cached property. |
| 1291 | + """ |
| 1292 | + with log as consolidated_logger: |
| 1293 | + for monitor in self.monitors: |
| 1294 | + if isinstance(monitor, TimeMonitor) and monitor.start > self.run_time: |
| 1295 | + consolidated_logger.warning( |
| 1296 | + f"Monitor {monitor.name} has a start time {monitor.start:1.2e}s exceeding" |
| 1297 | + f"the simulation run time {self.run_time:1.2e}s. No data will be recorded." |
| 1298 | + ) |
| 1299 | + |
1285 | 1300 | """ Accounting """
|
1286 | 1301 |
|
1287 | 1302 | # candidate for removal in 3.0
|
|
0 commit comments