Skip to content

Commit 6a81711

Browse files
shashwat-shmomchil-flex
authored andcommitted
warning instead of error for bloch + planewave check; use abs val for comparison; add comments
1 parent 5b0907c commit 6a81711

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

tidy3d/components/simulation.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,6 @@ def plane_wave_boundaries(cls, val, values):
251251
size = values.get("size")
252252
sim_medium = values.get("medium")
253253
structures = values.get("structures")
254-
255-
# tolerance to use for comparisons
256-
tol = 1e-6
257-
258254
for src_idx, source in enumerate(sources):
259255
if not isinstance(source, PlaneWave):
260256
continue
@@ -285,10 +281,10 @@ def plane_wave_boundaries(cls, val, values):
285281
expected_bloch_vec = dummy_bnd.bloch_vec
286282

287283
if boundary[0].bloch_vec != expected_bloch_vec:
288-
test_val = np.real(expected_bloch_vec - boundary[0].bloch_vec)
289-
if np.isclose(test_val % 1, 0, atol=tol) and not np.isclose(
290-
test_val, 0, atol=tol
291-
):
284+
test_val = np.abs(expected_bloch_vec - boundary[0].bloch_vec)
285+
286+
if np.isclose(test_val % 1, 0) and not np.isclose(test_val, 0):
287+
# the given Bloch vector is offset by an integer
292288
log.warning(
293289
f"The wave vector of source at index {src_idx} along dimension "
294290
f"{tan_dir} is equal to the Bloch vector of the simulation "
@@ -297,7 +293,9 @@ def plane_wave_boundaries(cls, val, values):
297293
"order 0 will not correspond to the angle of propagation "
298294
"of the source. Consider using ``BlochBoundary.from_source()``."
299295
)
300-
elif not np.isclose(test_val % 1, 0, atol=tol):
296+
elif not np.isclose(test_val % 1, 0):
297+
# the given Bloch vector is neither equal to the expected value, nor
298+
# off by an integer
301299
log.warning(
302300
f"The Bloch vector along dimension {tan_dir} may be incorrectly "
303301
f"set with respect to the source at index {src_idx}. The absolute "

0 commit comments

Comments
 (0)