Skip to content

Commit 6f91441

Browse files
PR comments
1 parent 59f342e commit 6f91441

File tree

2 files changed

+19
-61
lines changed

2 files changed

+19
-61
lines changed

tidy3d/components/boundary.py

Lines changed: 17 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -80,36 +80,34 @@ class PMCBoundary(BoundaryEdge):
8080
class AbstractABCBoundary(BoundaryEdge, ABC):
8181
"""One-way wave equation absorbing boundary conditions abstract base class."""
8282

83-
small_conductivity_approx: bool = pd.Field(
84-
True,
85-
title="Small Conductivity Approximation",
86-
description="If ``False`` then the effective permettivity ``eps`` in the one-wave equation"
87-
" is modified such that the equation exactly satisfy wave propagation at the central "
88-
"frequency.",
89-
)
90-
9183

9284
class ABCBoundary(AbstractABCBoundary):
93-
"""One-way wave equation absorbing boundary conditions."""
85+
"""One-way wave equation absorbing boundary conditions.
86+
See, for example, John B. Schneider, Understanding the Finite-Difference Time-Domain Method, Chapter 6.
87+
"""
9488

9589
permittivity: Optional[pd.PositiveFloat] = pd.Field(
9690
None,
9791
title="Effective Permittivity",
98-
description="Enforced effective permittivity.",
92+
description="Effective permittivity for determining propagation constant. "
93+
"If ``None``, this value will be automatically inferred from the medium at "
94+
"the domain boundary and the central frequency of the source.",
9995
)
10096

10197
conductivity: Optional[pd.NonNegativeFloat] = pd.Field(
10298
None,
10399
title="Effective Conductivity",
104-
description="Enforced effective conductivity.",
100+
description="Effective conductivity for determining propagation constant."
101+
"If ``None``, this value will be automatically inferred from the medium at "
102+
"the domain boundary and the central frequency of the source.",
105103
)
106104

107105
@pd.validator("conductivity", always=True)
108106
@skip_if_fields_missing(["permittivity"])
109107
def _conductivity_only_with_float_permittivity(cls, val, values):
110108
"""Validate that conductivity can be provided only with float permittivity."""
111109
perm = values["permittivity"]
112-
if val is not None and not isinstance(perm, float):
110+
if val is not None and perm is None:
113111
raise ValidationError(
114112
"Field 'conductivity' in 'ABCBoundary' can only be provided "
115113
"simultaneously with 'permittivity'."
@@ -120,25 +118,17 @@ def _conductivity_only_with_float_permittivity(cls, val, values):
120118
class ModeABCBoundary(AbstractABCBoundary):
121119
"""One-way wave equation absorbing boundary conditions for absorbing a waveguide mode."""
122120

123-
small_conductivity_approx: bool = pd.Field(
124-
False,
125-
title="Small Conductivity Approximation",
126-
description="If ``False`` then the effective permettivity ``eps`` in the one-wave equation"
127-
" is modified such that the equation exactly satisfy wave propagation at the central"
128-
" frequency.",
129-
)
130-
131121
mode_spec: ModeSpec = pd.Field(
132122
ModeSpec(),
133123
title="Mode Specification",
134-
description="Parameters to feed to mode solver which determine modes.",
124+
description="Parameters that determine the modes computed by the mode solver.",
135125
)
136126

137127
mode_index: pd.NonNegativeInt = pd.Field(
138128
0,
139129
title="Mode Index",
140130
description="Index into the collection of modes returned by mode solver. "
141-
" Specifies which mode to absorbed using these boundary conditions. "
131+
"The absorbing boundary conditions are configured to absorb the specified mode. "
142132
"If larger than ``mode_spec.num_modes``, "
143133
"``num_modes`` in the solver will be set to ``mode_index + 1``.",
144134
)
@@ -165,19 +155,13 @@ def is_plane(cls, val):
165155
return val
166156

167157
@classmethod
168-
def from_source(
169-
cls, source: ModeSource, small_conductivity_approx: bool = False
170-
) -> ModeABCBoundary:
158+
def from_source(cls, source: ModeSource) -> ModeABCBoundary:
171159
"""Instantiate from a ``ModeSource``.
172160
173161
Parameters
174162
----------
175163
source : :class:`ModeSource`
176164
Mode source.
177-
small_conductivity_approx : bool = False,
178-
If ``False`` then the effective permettivity ``eps`` in the one-wave equation
179-
is modified such that the equation exactly satisfy wave propagation at the central
180-
frequency.
181165
182166
Returns
183167
-------
@@ -197,7 +181,6 @@ def from_source(
197181
mode_spec=source.mode_spec,
198182
mode_index=source.mode_index,
199183
frequency=source.source_time.freq0,
200-
small_conductivity_approx=small_conductivity_approx,
201184
)
202185

203186
@classmethod
@@ -206,7 +189,6 @@ def from_monitor(
206189
monitor: Union[ModeMonitor, ModeSolverMonitor],
207190
mode_index: pd.NonNengativeInt = 0,
208191
frequency: Optional[pd.PositiveFloat] = None,
209-
small_conductivity_approx: bool = False,
210192
) -> ModeABCBoundary:
211193
"""Instantiate from a ``ModeMonitor`` or ``ModeSolverMonitor``.
212194
@@ -218,10 +200,6 @@ def from_monitor(
218200
Mode index.
219201
frequency : Optional[pd.PositiveFloat] = None
220202
Frequency for estimating propagation index of absorbed mode.
221-
small_conductivity_approx : bool = False,
222-
If ``False`` then the effective permettivity ``eps`` in the one-wave equation
223-
is modified such that the equation exactly satisfy wave propagation at the central
224-
frequency.
225203
226204
Returns
227205
-------
@@ -240,7 +218,6 @@ def from_monitor(
240218
mode_spec=monitor.mode_spec,
241219
mode_index=mode_index,
242220
frequency=frequency,
243-
small_conductivity_approx=small_conductivity_approx,
244221
)
245222

246223

@@ -896,7 +873,6 @@ def abc(
896873
cls,
897874
permittivity: Optional[pd.PositiveFloat] = None,
898875
conductivity: Optional[pd.NonNegativeFloat] = None,
899-
small_conductivity_approx: bool = True,
900876
):
901877
"""ABC boundary specification on both sides along a dimension.
902878
@@ -907,12 +883,10 @@ def abc(
907883
plus = ABCBoundary(
908884
permittivity=permittivity,
909885
conductivity=conductivity,
910-
small_conductivity_approx=small_conductivity_approx,
911886
)
912887
minus = ABCBoundary(
913888
permittivity=permittivity,
914889
conductivity=conductivity,
915-
small_conductivity_approx=small_conductivity_approx,
916890
)
917891
return cls(plus=plus, minus=minus)
918892

@@ -923,7 +897,6 @@ def mode_abc(
923897
mode_spec: ModeSpec = ModeSpec(),
924898
mode_index: pd.NonNegativeInt = 0,
925899
frequency: Optional[pd.PositiveFloat] = None,
926-
small_conductivity_approx: bool = False,
927900
):
928901
"""One-way wave equation mode ABC boundary specification on both sides along a dimension.
929902
@@ -932,15 +905,11 @@ def mode_abc(
932905
plane: Box
933906
Cross-sectional plane in which the absorbed mode will be computed.
934907
mode_spec: ModeSpec = ModeSpec()
935-
Parameters to feed to mode solver which determine modes.
908+
Parameters that determine the modes computed by the mode solver.
936909
mode_index : pd.NonNengativeInt = 0
937910
Mode index.
938911
frequency : Optional[pd.PositiveFloat] = None
939912
Frequency for estimating propagation index of absorbed mode.
940-
small_conductivity_approx : bool = False,
941-
If ``False`` then the effective permettivity ``eps`` in the one-wave equation
942-
is modified such that the equation exactly satisfy wave propagation at the central
943-
frequency.
944913
945914
Example
946915
-------
@@ -953,30 +922,24 @@ def mode_abc(
953922
mode_spec=mode_spec,
954923
mode_index=mode_index,
955924
frequency=frequency,
956-
small_conductivity_approx=small_conductivity_approx,
957925
)
958926
minus = ModeABCBoundary(
959927
plane=plane,
960928
mode_spec=mode_spec,
961929
mode_index=mode_index,
962930
frequency=frequency,
963-
small_conductivity_approx=small_conductivity_approx,
964931
)
965932

966933
return cls(plus=plus, minus=minus)
967934

968935
@classmethod
969-
def mode_abc_from_source(cls, source: ModeSource, small_conductivity_approx: bool = False):
936+
def mode_abc_from_source(cls, source: ModeSource):
970937
"""One-way wave equation mode ABC boundary specification on both sides along a dimension constructed from a mode source.
971938
972939
Parameters
973940
----------
974941
source : :class:`ModeSource`
975942
Mode source.
976-
small_conductivity_approx : bool = False,
977-
If ``False`` then the effective permettivity ``eps`` in the one-wave equation
978-
is modified such that the equation exactly satisfy wave propagation at the central
979-
frequency.
980943
981944
Example
982945
-------
@@ -985,12 +948,8 @@ def mode_abc_from_source(cls, source: ModeSource, small_conductivity_approx: boo
985948
>>> source = ModeSource(size=(1, 1, 0), source_time=pulse, direction='+')
986949
>>> abc = Boundary.mode_abc_from_source(source=source)
987950
"""
988-
plus = ModeABCBoundary.from_source(
989-
source=source, small_conductivity_approx=small_conductivity_approx
990-
)
991-
minus = ModeABCBoundary.from_source(
992-
source=source, small_conductivity_approx=small_conductivity_approx
993-
)
951+
plus = ModeABCBoundary.from_source(source=source)
952+
minus = ModeABCBoundary.from_source(source=source)
994953
return cls(plus=plus, minus=minus)
995954

996955
@classmethod
@@ -999,7 +958,6 @@ def mode_abc_from_monitor(
999958
monitor: Union[ModeMonitor, ModeSolverMonitor],
1000959
mode_index: pd.NonNengativeInt = 0,
1001960
frequency: Optional[pd.PositiveFloat] = None,
1002-
small_conductivity_approx: bool = False,
1003961
):
1004962
"""One-way wave equation mode ABC boundary specification on both sides along a dimension constructed from a mode monitor.
1005963
@@ -1013,13 +971,11 @@ def mode_abc_from_monitor(
1013971
monitor=monitor,
1014972
mode_index=mode_index,
1015973
frequency=frequency,
1016-
small_conductivity_approx=small_conductivity_approx,
1017974
)
1018975
minus = ModeABCBoundary.from_monitor(
1019976
monitor=monitor,
1020977
mode_index=mode_index,
1021978
frequency=frequency,
1022-
small_conductivity_approx=small_conductivity_approx,
1023979
)
1024980
return cls(plus=plus, minus=minus)
1025981

tidy3d/components/simulation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3340,6 +3340,8 @@ def _abc_boundaries_homogeneous(cls, val, values):
33403340
if len(mediums) > 1:
33413341
raise SetupError(
33423342
f"{len(mediums)} different mediums detected on an 'ABCBoundary'. Boundary must be homogeneous."
3343+
"Alternatively, effective permeability and conductivity can be directly provided as "
3344+
"parameters for an 'ABCBoundary', in which case this medium check is skipped."
33433345
)
33443346
# 0 medium, something is wrong
33453347
if len(mediums) < 1:

0 commit comments

Comments
 (0)