Skip to content

Commit 68a6e5b

Browse files
committed
simulation_type default to "tidy3d" always
1 parent b95a49e commit 68a6e5b

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

tidy3d/components/simulation.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import math
66
import pathlib
77
from abc import ABC, abstractmethod
8-
from typing import Dict, List, Set, Tuple, Union
8+
from typing import Dict, List, Optional, Set, Tuple, Union
99

1010
import autograd.numpy as np
1111
import matplotlib as mpl
@@ -204,11 +204,13 @@ class AbstractYeeGridSimulation(AbstractSimulation, ABC):
204204
", or ``False`` to apply staircasing.",
205205
)
206206

207-
simulation_type: Literal["autograd_fwd", "autograd_bwd", None] = pydantic.Field(
208-
None,
209-
title="Simulation Type",
210-
description="Tag used internally to distinguish types of simulations for "
211-
"``autograd`` gradient processing.",
207+
simulation_type: Optional[Literal["autograd_fwd", "autograd_bwd", "tidy3d", None]] = (
208+
pydantic.Field(
209+
"tidy3d",
210+
title="Simulation Type",
211+
description="Tag used internally to distinguish types of simulations for "
212+
"``autograd`` gradient processing.",
213+
)
212214
)
213215

214216
post_norm: Union[float, FreqDataArray] = pydantic.Field(
@@ -262,6 +264,13 @@ class AbstractYeeGridSimulation(AbstractSimulation, ABC):
262264
* `Dielectric constant assignment on Yee grids <https://www.flexcompute.com/fdtd101/Lecture-9-Dielectric-constant-assignment-on-Yee-grids/>`_
263265
"""
264266

267+
@pydantic.validator("simulation_type", always=True)
268+
def _validate_simulation_type_tidy3d(cls, val):
269+
"""Enforce the simulation_type is 'tidy3d' if passed as None for bkwrds compatibility."""
270+
if val is None:
271+
return "tidy3d"
272+
return val
273+
265274
@pydantic.validator("lumped_elements", always=True)
266275
@skip_if_fields_missing(["structures"])
267276
def _validate_num_lumped_elements(cls, val, values):

tidy3d/plugins/adjoint/web.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ class AdjointJob(Job):
260260
"""Job that uploads a jax_info object and also includes new fields for adjoint tasks."""
261261

262262
simulation_type: AdjointSimulationType = pd.Field(
263-
None,
263+
"tidy3d",
264264
title="Simulation Type",
265265
description="Type of simulation, used internally only.",
266266
)

tidy3d/web/core/task_core.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ def create(
225225
:class:`SimulationTask` object containing info about status, size,
226226
credits of task and others.
227227
"""
228+
229+
# handle backwards compatibility, "tidy3d" is the default simulation_type
230+
if simulation_type is None:
231+
simulation_type = "tidy3d"
232+
228233
folder = Folder.get(folder_name, create=True)
229234
resp = http.post(
230235
f"tidy3d/projects/{folder.folder_id}/tasks",

0 commit comments

Comments
 (0)