Skip to content

Commit 655282e

Browse files
committed
revise
1 parent 6a738b1 commit 655282e

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

tidy3d/components/microwave/path_integrals/impedance_spec.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pydantic.v1 as pd
88

9-
from tidy3d.components.base import Tidy3dBaseModel
9+
from tidy3d.components.base import Tidy3dBaseModel, skip_if_fields_missing
1010
from tidy3d.components.microwave.path_integrals.types import (
1111
CurrentPathSpecTypes,
1212
VoltagePathSpecTypes,
@@ -17,21 +17,21 @@
1717
class AutoImpedanceSpec(Tidy3dBaseModel):
1818
"""Specification for fully automatic transmission line impedance computation.
1919
20-
This specification automatically calculates impedance by calculating the current associated
21-
with each conductor that intersects the mode plane.
20+
This specification automatically calculates impedance by current
21+
paths based on the simulation geometry and conductors that intersect the mode plane.
22+
No user-defined path specifications are required.
2223
"""
2324

2425

2526
class CustomImpedanceSpec(Tidy3dBaseModel):
2627
"""Specification for custom transmission line voltages and currents in mode solvers.
2728
2829
The :class:`.CustomImpedanceSpec` class specifies how quantities related to transmission line
29-
modes are computed. For example, it defines the paths for line integrals, which are used to
30+
modes are computed. It defines the paths for line integrals, which are used to
3031
compute voltage, current, and characteristic impedance of the transmission line.
3132
32-
Users may supply their own voltage and current path specifications to control where these integrals
33-
are evaluated. If neither voltage nor current specifications are provided, an automatic choice of
34-
paths will be made based on the simulation geometry and context.
33+
Users must supply at least one of voltage or current path specifications to control where these integrals
34+
are evaluated. Both voltage_spec and current_spec cannot be ``None`` simultaneously.
3535
"""
3636

3737
voltage_spec: Optional[VoltagePathSpecTypes] = pd.Field(
@@ -51,9 +51,12 @@ class CustomImpedanceSpec(Tidy3dBaseModel):
5151
)
5252

5353
@pd.validator("current_spec", always=True)
54+
@skip_if_fields_missing(["voltage_spec"])
5455
def check_path_spec_combinations(cls, val, values):
55-
"""In order to define voltage/current/impedance, either a voltage or current path specification
56-
must be provided.
56+
"""Validate that at least one of voltage_spec or current_spec is provided.
57+
58+
In order to define voltage/current/impedance, either a voltage or current path specification
59+
must be provided. Both cannot be ``None`` simultaneously.
5760
"""
5861

5962
voltage_spec = values["voltage_spec"]

tidy3d/components/mode/mode_solver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,8 +1381,7 @@ def _make_path_integrals(
13811381
)
13821382

13831383
def _add_microwave_data(self, mode_solver_data: ModeSolverData) -> ModeSolverData:
1384-
"""Calculate and add microwave data to ``mode_solver_data`` which uses the path specifications.
1385-
Note: this modifies ``mode_solver_data`` in-place."""
1384+
"""Calculate and add microwave data to ``mode_solver_data`` which uses the path specifications."""
13861385
voltage_integrals, current_integrals = self._make_path_integrals()
13871386
# Need to operate on the full symmetry expanded fields
13881387
mode_solver_data_expanded = mode_solver_data.symmetry_expanded_copy

0 commit comments

Comments
 (0)