66
77import pydantic .v1 as pd
88
9- from tidy3d .components .base import Tidy3dBaseModel
9+ from tidy3d .components .base import Tidy3dBaseModel , skip_if_fields_missing
1010from tidy3d .components .microwave .path_integrals .types import (
1111 CurrentPathSpecTypes ,
1212 VoltagePathSpecTypes ,
1717class 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
2526class 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" ]
0 commit comments