79
79
plot_params_heat_bc ,
80
80
plot_params_heat_source ,
81
81
)
82
- from tidy3d .components .types import TYPE_TAG_STR , Ax , Bound , ScalarSymmetry , Shapely
82
+ from tidy3d .components .types import TYPE_TAG_STR , Ax , Bound , ScalarSymmetry , Shapely , annotate_type
83
83
from tidy3d .components .viz import PlotParams , add_ax_if_none , equal_aspect
84
84
from tidy3d .constants import VOLUMETRIC_HEAT_RATE , inf
85
85
from tidy3d .exceptions import SetupError
@@ -260,22 +260,24 @@ class HeatChargeSimulation(AbstractSimulation):
260
260
Background medium of simulation, defaults to a standard dispersion-less :class:`Medium` if not specified.
261
261
"""
262
262
263
- sources : Tuple [HeatChargeSourceType , ...] = pd .Field (
263
+ sources : Tuple [annotate_type ( HeatChargeSourceType ) , ...] = pd .Field (
264
264
(),
265
265
title = "Heat and Charge sources" ,
266
266
description = "List of heat and/or charge sources." ,
267
267
discriminator = TYPE_TAG_STR ,
268
268
)
269
269
270
- monitors : Tuple [HeatChargeMonitorType , ...] = pd .Field (
270
+ monitors : Tuple [annotate_type ( HeatChargeMonitorType ) , ...] = pd .Field (
271
271
(), title = "Monitors" , description = "Monitors in the simulation." , discriminator = TYPE_TAG_STR
272
272
)
273
273
274
- boundary_spec : Tuple [Union [HeatChargeBoundarySpec , HeatBoundarySpec ], ...] = pd .Field (
275
- (),
276
- title = "Boundary Condition Specifications" ,
277
- description = "List of boundary condition specifications." ,
278
- discriminator = TYPE_TAG_STR ,
274
+ boundary_spec : Tuple [annotate_type (Union [HeatChargeBoundarySpec , HeatBoundarySpec ]), ...] = (
275
+ pd .Field (
276
+ (),
277
+ title = "Boundary Condition Specifications" ,
278
+ description = "List of boundary condition specifications." ,
279
+ discriminator = TYPE_TAG_STR ,
280
+ )
279
281
)
280
282
# NOTE: creating a union with HeatBoundarySpec for backwards compatibility
281
283
@@ -320,7 +322,7 @@ def _check_cross_solids(objs: Tuple[Box, ...], values: Dict) -> Tuple[int, ...]:
320
322
321
323
# NOTE: when considering CONDUCTION or CHARGE cases, both conductors and semiconductors
322
324
# will be accepted
323
- ValidElectricTypes = Union [ SemiconductorMedium , ChargeConductorMedium ]
325
+ valid_electric_medium = ( SemiconductorMedium , ChargeConductorMedium )
324
326
325
327
try :
326
328
size = values ["size" ]
@@ -356,7 +358,8 @@ def _check_cross_solids(objs: Tuple[Box, ...], values: Dict) -> Tuple[int, ...]:
356
358
isinstance (medium .heat_spec , SolidSpec ) for medium in medium_set
357
359
)
358
360
crosses_elec_spec = any (
359
- isinstance (medium .charge , ValidElectricTypes ) for medium in medium_set
361
+ any ([isinstance (medium .charge , medium_i )] for medium_i in valid_electric_medium )
362
+ for medium in medium_set
360
363
)
361
364
else :
362
365
# approximate check for volumetric objects based on bounding boxes
@@ -369,7 +372,10 @@ def _check_cross_solids(objs: Tuple[Box, ...], values: Dict) -> Tuple[int, ...]:
369
372
crosses_elec_spec = any (
370
373
obj .intersects (structure .geometry )
371
374
for structure in total_structures
372
- if isinstance (structure .medium .charge , ValidElectricTypes )
375
+ if any (
376
+ [isinstance (structure .medium .charge , medium_i )]
377
+ for medium_i in valid_electric_medium
378
+ )
373
379
)
374
380
375
381
if not crosses_solid :
0 commit comments