diff --git a/tidy3d/components/simulation.py b/tidy3d/components/simulation.py index d4aec37fea..1093886338 100644 --- a/tidy3d/components/simulation.py +++ b/tidy3d/components/simulation.py @@ -100,12 +100,13 @@ class Simulation(Box): # pylint:disable=too-many-public-methods units=MICROMETER, ) - run_time: pydantic.PositiveFloat = pydantic.Field( - ..., + run_time: pydantic.NonNegativeFloat = pydantic.Field( + 0.0, title="Run Time", description="Total electromagnetic evolution time in seconds. " "Note: If simulation 'shutoff' is specified, " - "simulation will terminate early when shutoff condition met.", + "simulation will terminate early when shutoff condition met. " + "Must be set > 0 before running Simulation on our servers.", units=SECOND, ) @@ -468,10 +469,11 @@ def _plane_wave_homogeneous(cls, val, values): """ Pre submit validation (before web.upload()) """ - def validate_contents(self) -> None: - """Validate the fully initialized simulation is within allowed limits.""" + def validate_pre_upload(self) -> None: + """Validate the fully initialized simulation is ok for upload to our servers.""" self._validate_size() self._validate_monitor_size() + self._validate_run_time() def _validate_size(self) -> None: """Ensures the simulation is within size limits before simulation is uploaded.""" @@ -516,6 +518,15 @@ def _validate_monitor_size(self) -> None: f"a maximum of {MAX_MONITOR_DATA_SIZE_BYTES:.2e} are allowed." ) + def _validate_run_time(self) -> None: + """Ensures that the simulation run time is > 0.""" + + if not self.run_time > 0: + raise SetupError( + "The `Simulation.run_time` parameter was left at its default value of 0.0. " + "For running a simulation on our servers it must be set to > 0.0." + ) + """ Accounting """ @property diff --git a/tidy3d/web/webapi.py b/tidy3d/web/webapi.py index 2babbfeff9..6458099174 100644 --- a/tidy3d/web/webapi.py +++ b/tidy3d/web/webapi.py @@ -428,7 +428,7 @@ def _upload_task( # pylint:disable=too-many-locals,too-many-arguments ) -> TaskId: """upload with all kwargs exposed""" - simulation.validate_contents() + simulation.validate_pre_upload() json_string = simulation._json_string() # pylint:disable=protected-access data = {