|
5 | 5 | import math
|
6 | 6 | import pathlib
|
7 | 7 | from abc import ABC, abstractmethod
|
8 |
| -from typing import Dict, List, Set, Tuple, Union |
| 8 | +from typing import Dict, List, Optional, Set, Tuple, Union |
9 | 9 |
|
10 | 10 | import autograd.numpy as np
|
11 | 11 | import matplotlib as mpl
|
@@ -204,11 +204,13 @@ class AbstractYeeGridSimulation(AbstractSimulation, ABC):
|
204 | 204 | ", or ``False`` to apply staircasing.",
|
205 | 205 | )
|
206 | 206 |
|
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 | + ) |
212 | 214 | )
|
213 | 215 |
|
214 | 216 | post_norm: Union[float, FreqDataArray] = pydantic.Field(
|
@@ -262,6 +264,13 @@ class AbstractYeeGridSimulation(AbstractSimulation, ABC):
|
262 | 264 | * `Dielectric constant assignment on Yee grids <https://www.flexcompute.com/fdtd101/Lecture-9-Dielectric-constant-assignment-on-Yee-grids/>`_
|
263 | 265 | """
|
264 | 266 |
|
| 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 | + |
265 | 274 | @pydantic.validator("lumped_elements", always=True)
|
266 | 275 | @skip_if_fields_missing(["structures"])
|
267 | 276 | def _validate_num_lumped_elements(cls, val, values):
|
|
0 commit comments