Skip to content

Commit cc75b13

Browse files
PR comments
1 parent 688f30f commit cc75b13

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
@@ -55,36 +55,34 @@ class PMCBoundary(BoundaryEdge):
5555
class AbstractABCBoundary(BoundaryEdge, ABC):
5656
"""One-way wave equation absorbing boundary conditions abstract base class."""
5757

58-
small_conductivity_approx: bool = pd.Field(
59-
True,
60-
title="Small Conductivity Approximation",
61-
description="If ``False`` then the effective permettivity ``eps`` in the one-wave equation"
62-
" is modified such that the equation exactly satisfy wave propagation at the central "
63-
"frequency.",
64-
)
65-
6658

6759
class ABCBoundary(AbstractABCBoundary):
68-
"""One-way wave equation absorbing boundary conditions."""
60+
"""One-way wave equation absorbing boundary conditions.
61+
See, for example, John B. Schneider, Understanding the Finite-Difference Time-Domain Method, Chapter 6.
62+
"""
6963

7064
permittivity: Optional[pd.PositiveFloat] = pd.Field(
7165
None,
7266
title="Effective Permittivity",
73-
description="Enforced effective permittivity.",
67+
description="Effective permittivity for determining propagation constant. "
68+
"If ``None``, this value will be automatically inferred from the medium at "
69+
"the domain boundary and the central frequency of the source.",
7470
)
7571

7672
conductivity: Optional[pd.NonNegativeFloat] = pd.Field(
7773
None,
7874
title="Effective Conductivity",
79-
description="Enforced effective conductivity.",
75+
description="Effective conductivity for determining propagation constant."
76+
"If ``None``, this value will be automatically inferred from the medium at "
77+
"the domain boundary and the central frequency of the source.",
8078
)
8179

8280
@pd.validator("conductivity", always=True)
8381
@skip_if_fields_missing(["permittivity"])
8482
def _conductivity_only_with_float_permittivity(cls, val, values):
8583
"""Validate that conductivity can be provided only with float permittivity."""
8684
perm = values["permittivity"]
87-
if val is not None and not isinstance(perm, float):
85+
if val is not None and perm is None:
8886
raise ValidationError(
8987
"Field 'conductivity' in 'ABCBoundary' can only be provided "
9088
"simultaneously with 'permittivity'."
@@ -95,25 +93,17 @@ def _conductivity_only_with_float_permittivity(cls, val, values):
9593
class ModeABCBoundary(AbstractABCBoundary):
9694
"""One-way wave equation absorbing boundary conditions for absorbing a waveguide mode."""
9795

98-
small_conductivity_approx: bool = pd.Field(
99-
False,
100-
title="Small Conductivity Approximation",
101-
description="If ``False`` then the effective permettivity ``eps`` in the one-wave equation"
102-
" is modified such that the equation exactly satisfy wave propagation at the central"
103-
" frequency.",
104-
)
105-
10696
mode_spec: ModeSpec = pd.Field(
10797
ModeSpec(),
10898
title="Mode Specification",
109-
description="Parameters to feed to mode solver which determine modes.",
99+
description="Parameters that determine the modes computed by the mode solver.",
110100
)
111101

112102
mode_index: pd.NonNegativeInt = pd.Field(
113103
0,
114104
title="Mode Index",
115105
description="Index into the collection of modes returned by mode solver. "
116-
" Specifies which mode to absorbed using these boundary conditions. "
106+
"The absorbing boundary conditions are configured to absorb the specified mode. "
117107
"If larger than ``mode_spec.num_modes``, "
118108
"``num_modes`` in the solver will be set to ``mode_index + 1``.",
119109
)
@@ -140,19 +130,13 @@ def is_plane(cls, val):
140130
return val
141131

142132
@classmethod
143-
def from_source(
144-
cls, source: ModeSource, small_conductivity_approx: bool = False
145-
) -> ModeABCBoundary:
133+
def from_source(cls, source: ModeSource) -> ModeABCBoundary:
146134
"""Instantiate from a ``ModeSource``.
147135
148136
Parameters
149137
----------
150138
source : :class:`ModeSource`
151139
Mode source.
152-
small_conductivity_approx : bool = False,
153-
If ``False`` then the effective permettivity ``eps`` in the one-wave equation
154-
is modified such that the equation exactly satisfy wave propagation at the central
155-
frequency.
156140
157141
Returns
158142
-------
@@ -172,7 +156,6 @@ def from_source(
172156
mode_spec=source.mode_spec,
173157
mode_index=source.mode_index,
174158
frequency=source.source_time.freq0,
175-
small_conductivity_approx=small_conductivity_approx,
176159
)
177160

178161
@classmethod
@@ -181,7 +164,6 @@ def from_monitor(
181164
monitor: Union[ModeMonitor, ModeSolverMonitor],
182165
mode_index: pd.NonNengativeInt = 0,
183166
frequency: Optional[pd.PositiveFloat] = None,
184-
small_conductivity_approx: bool = False,
185167
) -> ModeABCBoundary:
186168
"""Instantiate from a ``ModeMonitor`` or ``ModeSolverMonitor``.
187169
@@ -193,10 +175,6 @@ def from_monitor(
193175
Mode index.
194176
frequency : Optional[pd.PositiveFloat] = None
195177
Frequency for estimating propagation index of absorbed mode.
196-
small_conductivity_approx : bool = False,
197-
If ``False`` then the effective permettivity ``eps`` in the one-wave equation
198-
is modified such that the equation exactly satisfy wave propagation at the central
199-
frequency.
200178
201179
Returns
202180
-------
@@ -215,7 +193,6 @@ def from_monitor(
215193
mode_spec=monitor.mode_spec,
216194
mode_index=mode_index,
217195
frequency=frequency,
218-
small_conductivity_approx=small_conductivity_approx,
219196
)
220197

221198

@@ -859,7 +836,6 @@ def abc(
859836
cls,
860837
permittivity: Optional[pd.PositiveFloat] = None,
861838
conductivity: Optional[pd.NonNegativeFloat] = None,
862-
small_conductivity_approx: bool = True,
863839
):
864840
"""ABC boundary specification on both sides along a dimension.
865841
@@ -870,12 +846,10 @@ def abc(
870846
plus = ABCBoundary(
871847
permittivity=permittivity,
872848
conductivity=conductivity,
873-
small_conductivity_approx=small_conductivity_approx,
874849
)
875850
minus = ABCBoundary(
876851
permittivity=permittivity,
877852
conductivity=conductivity,
878-
small_conductivity_approx=small_conductivity_approx,
879853
)
880854
return cls(plus=plus, minus=minus)
881855

@@ -886,7 +860,6 @@ def mode_abc(
886860
mode_spec: ModeSpec = ModeSpec(),
887861
mode_index: pd.NonNegativeInt = 0,
888862
frequency: Optional[pd.PositiveFloat] = None,
889-
small_conductivity_approx: bool = False,
890863
):
891864
"""One-way wave equation mode ABC boundary specification on both sides along a dimension.
892865
@@ -895,15 +868,11 @@ def mode_abc(
895868
plane: Box
896869
Cross-sectional plane in which the absorbed mode will be computed.
897870
mode_spec: ModeSpec = ModeSpec()
898-
Parameters to feed to mode solver which determine modes.
871+
Parameters that determine the modes computed by the mode solver.
899872
mode_index : pd.NonNengativeInt = 0
900873
Mode index.
901874
frequency : Optional[pd.PositiveFloat] = None
902875
Frequency for estimating propagation index of absorbed mode.
903-
small_conductivity_approx : bool = False,
904-
If ``False`` then the effective permettivity ``eps`` in the one-wave equation
905-
is modified such that the equation exactly satisfy wave propagation at the central
906-
frequency.
907876
908877
Example
909878
-------
@@ -916,30 +885,24 @@ def mode_abc(
916885
mode_spec=mode_spec,
917886
mode_index=mode_index,
918887
frequency=frequency,
919-
small_conductivity_approx=small_conductivity_approx,
920888
)
921889
minus = ModeABCBoundary(
922890
plane=plane,
923891
mode_spec=mode_spec,
924892
mode_index=mode_index,
925893
frequency=frequency,
926-
small_conductivity_approx=small_conductivity_approx,
927894
)
928895

929896
return cls(plus=plus, minus=minus)
930897

931898
@classmethod
932-
def mode_abc_from_source(cls, source: ModeSource, small_conductivity_approx: bool = False):
899+
def mode_abc_from_source(cls, source: ModeSource):
933900
"""One-way wave equation mode ABC boundary specification on both sides along a dimension constructed from a mode source.
934901
935902
Parameters
936903
----------
937904
source : :class:`ModeSource`
938905
Mode source.
939-
small_conductivity_approx : bool = False,
940-
If ``False`` then the effective permettivity ``eps`` in the one-wave equation
941-
is modified such that the equation exactly satisfy wave propagation at the central
942-
frequency.
943906
944907
Example
945908
-------
@@ -948,12 +911,8 @@ def mode_abc_from_source(cls, source: ModeSource, small_conductivity_approx: boo
948911
>>> source = ModeSource(size=(1, 1, 0), source_time=pulse, direction='+')
949912
>>> abc = Boundary.mode_abc_from_source(source=source)
950913
"""
951-
plus = ModeABCBoundary.from_source(
952-
source=source, small_conductivity_approx=small_conductivity_approx
953-
)
954-
minus = ModeABCBoundary.from_source(
955-
source=source, small_conductivity_approx=small_conductivity_approx
956-
)
914+
plus = ModeABCBoundary.from_source(source=source)
915+
minus = ModeABCBoundary.from_source(source=source)
957916
return cls(plus=plus, minus=minus)
958917

959918
@classmethod
@@ -962,7 +921,6 @@ def mode_abc_from_monitor(
962921
monitor: Union[ModeMonitor, ModeSolverMonitor],
963922
mode_index: pd.NonNengativeInt = 0,
964923
frequency: Optional[pd.PositiveFloat] = None,
965-
small_conductivity_approx: bool = False,
966924
):
967925
"""One-way wave equation mode ABC boundary specification on both sides along a dimension constructed from a mode monitor.
968926
@@ -976,13 +934,11 @@ def mode_abc_from_monitor(
976934
monitor=monitor,
977935
mode_index=mode_index,
978936
frequency=frequency,
979-
small_conductivity_approx=small_conductivity_approx,
980937
)
981938
minus = ModeABCBoundary.from_monitor(
982939
monitor=monitor,
983940
mode_index=mode_index,
984941
frequency=frequency,
985-
small_conductivity_approx=small_conductivity_approx,
986942
)
987943
return cls(plus=plus, minus=minus)
988944

tidy3d/components/simulation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3299,6 +3299,8 @@ def _abc_boundaries_homogeneous(cls, val, values):
32993299
if len(mediums) > 1:
33003300
raise SetupError(
33013301
f"{len(mediums)} different mediums detected on an 'ABCBoundary'. Boundary must be homogeneous."
3302+
"Alternatively, effective permeability and conductivity can be directly provided as "
3303+
"parameters for an 'ABCBoundary', in which case this medium check is skipped."
33023304
)
33033305
# 0 medium, something is wrong
33043306
if len(mediums) < 1:

0 commit comments

Comments
 (0)