|
24 | 24 | from tidy3d.components.tcad.doping import ConstantDoping, GaussianDoping
|
25 | 25 | from tidy3d.components.tcad.viz import HEAT_SOURCE_CMAP
|
26 | 26 |
|
27 |
| -from ..constants import CONDUCTIVITY, LARGE_NUMBER, THERMAL_CONDUCTIVITY, inf |
| 27 | +from ..constants import CONDUCTIVITY, THERMAL_CONDUCTIVITY, inf |
28 | 28 | from ..exceptions import SetupError, Tidy3dError
|
29 | 29 | from ..log import log
|
30 | 30 | from .base import Tidy3dBaseModel, cached_property
|
|
43 | 43 | AbstractCustomMedium,
|
44 | 44 | AbstractMedium,
|
45 | 45 | AbstractPerturbationMedium,
|
46 |
| - LossyMetalMedium, |
47 | 46 | Medium,
|
48 | 47 | Medium2D,
|
49 | 48 | )
|
|
56 | 55 | InterpMethod,
|
57 | 56 | LengthUnit,
|
58 | 57 | PermittivityComponent,
|
59 |
| - OverlappingPriority, |
| 58 | + PriorityMode, |
60 | 59 | Shapely,
|
61 | 60 | Size,
|
62 | 61 | )
|
@@ -108,19 +107,20 @@ class Scene(Tidy3dBaseModel):
|
108 | 107 | (),
|
109 | 108 | title="Structures",
|
110 | 109 | description="Tuple of structures present in scene. "
|
111 |
| - "Note: In regions of spatial overlapping between structures, " |
112 |
| - "material properties are dictated by structure of higher priority " |
113 |
| - "defined by ``overlapping_priority``.", |
| 110 | + "Note: In regions of spatial overlap between structures, " |
| 111 | + "material properties are dictated by structure of higher priority. " |
| 112 | + "The priority for structure of `priority=None` is set automatically " |
| 113 | + "from `structure_priority_mode`. For structures of equal priority, " |
| 114 | + "the structure added later to the structure list takes precedence.", |
114 | 115 | )
|
115 | 116 |
|
116 |
| - overlapping_priority: OverlappingPriority = pd.Field( |
117 |
| - "latter", |
118 |
| - title="Resolution Strategy In Structure Overlapping Region", |
119 |
| - description="In regions of spatial overlapping between structures, " |
120 |
| - "if ``overlapping_priority=latter``, structures defined later in the list haver higher " |
121 |
| - "priority. If ``overlapping_priority=metal``, metallic structures of higher conductivity " |
122 |
| - "have higher priority; when the structures are of the same priority from material perspecive, " |
123 |
| - "the one defined later in the list has higher priority.", |
| 117 | + structure_priority_mode: PriorityMode = pd.Field( |
| 118 | + "equal", |
| 119 | + title="Automatic Structure Priority Setup", |
| 120 | + description="This field only affects structures of `priority=None`. " |
| 121 | + "If `equal`, the priority of those structures is set to 0; if `conductor`, " |
| 122 | + "the priority of structures made of `LossyMetalMedium` is set to 90, " |
| 123 | + "`PECMedium` to 100, and others to 0.", |
124 | 124 | )
|
125 | 125 |
|
126 | 126 | plot_length_units: Optional[LengthUnit] = pd.Field(
|
@@ -260,31 +260,18 @@ def medium_map(self) -> Dict[StructureMediumType, pd.NonNegativeInt]:
|
260 | 260 |
|
261 | 261 | @cached_property
|
262 | 262 | def sorted_structures(self) -> List[Structure]:
|
263 |
| - """Returns a list of sorted structures based on the priority strategy when structures |
264 |
| - overlap. In the sorted list, latter added structures take higher priority. |
| 263 | + """Returns a list of sorted structures based on their priority.In the sorted list, |
| 264 | + latter added structures take higher priority. |
265 | 265 |
|
266 | 266 | Returns
|
267 | 267 | -------
|
268 | 268 | List[:class:`.Structure`]
|
269 | 269 | """
|
270 | 270 |
|
271 |
| - if self.overlapping_priority == "latter": |
272 |
| - return self.structures |
273 |
| - |
274 |
| - # The other strategy is "metal": |
275 |
| - # Prioritize metallic structures including LossyMetal and PEC. When two metallic structures overlap, |
276 |
| - # prioritize the structure of higher conductivity. |
277 | 271 | def structure_comparator(struct1, struct2):
|
278 |
| - mat_list = [struct1.medium, struct2.medium] |
279 |
| - # For implementation convenience, let's denote conductivity of regular medium as -1, |
280 |
| - # so that it's lower than that of any metal. |
281 |
| - sigmas = [-1, -1] |
282 |
| - for ind, mat in enumerate(mat_list): |
283 |
| - if mat.is_pec: |
284 |
| - sigmas[ind] = LARGE_NUMBER |
285 |
| - elif isinstance(mat, LossyMetalMedium): |
286 |
| - sigmas[ind] = mat.conductivity |
287 |
| - return sigmas[0] - sigmas[1] |
| 272 | + return struct1._priority(self.structure_priority_mode) - struct2._priority( |
| 273 | + self.structure_priority_mode |
| 274 | + ) |
288 | 275 |
|
289 | 276 | return sorted(self.structures, key=cmp_to_key(structure_comparator))
|
290 | 277 |
|
|
0 commit comments