Skip to content

Commit 2077675

Browse files
Gregory Robertsgroberts-flex
authored andcommitted
fix: replace infinite dummy source width to prevent overflow warning
1 parent c038f17 commit 2077675

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tidy3d/components/data/sim_data.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from tidy3d.components.structure import Structure
2727
from tidy3d.components.types import Ax, Axis, ColormapType, FieldVal, PlotScale, annotate_type
2828
from tidy3d.components.viz import add_ax_if_none, equal_aspect
29-
from tidy3d.constants import C_0, inf
3029
from tidy3d.exceptions import DataError, FileError, SetupError, Tidy3dKeyError
3130
from tidy3d.log import log
3231

@@ -1175,7 +1174,16 @@ def _process_adjoint_sources(self, adj_srcs: list[SourceType]) -> list[AdjointSo
11751174

11761175
adj_srcs_process_fwidth = self._adjoint_src_width_single(adj_srcs)
11771176

1178-
tmp_src_time = GaussianPulse(freq0=C_0, fwidth=inf)
1177+
min_freq_tmp_src = np.maximum(
1178+
0, np.min([src.source_time.freq0 - src.source_time.fwidth for src in adj_srcs])
1179+
)
1180+
max_freq_tmp_src = np.max(
1181+
[src.source_time.freq0 + src.source_time.fwidth for src in adj_srcs]
1182+
)
1183+
tmp_src_f0 = 0.5 * (min_freq_tmp_src + max_freq_tmp_src)
1184+
tmp_src_fwidth = max_freq_tmp_src - min_freq_tmp_src
1185+
1186+
tmp_src_time = GaussianPulse(freq0=tmp_src_f0, fwidth=tmp_src_fwidth)
11791187
for src in adj_srcs_process_fwidth:
11801188
tmp_src = src.updated_copy(source_time=tmp_src_time)
11811189
tmp_src_hash = tmp_src._hash_self()

0 commit comments

Comments
 (0)