Skip to content

Commit b3e4065

Browse files
committed
Validate that ModeSolver.plane intersects ModeSolver.simulation
1 parent e9fc81b commit b3e4065

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tidy3d/plugins/mode/mode_solver.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,17 @@ def is_plane(cls, val):
9898
_freqs_not_empty = validate_freqs_not_empty()
9999
_freqs_lower_bound = validate_freqs_min()
100100

101+
@pydantic.validator("plane", always=True)
102+
def plane_in_sim_bounds(cls, val, values):
103+
"""Check that the plane is at least partially inside the simulation bounds."""
104+
sim_center = values.get("simulation").center
105+
sim_size = values.get("simulation").size
106+
sim_box = Box(size=sim_size, center=sim_center)
107+
108+
if not sim_box.intersects(val):
109+
raise SetupError("'ModeSolver.plane' must intersect 'ModeSolver.simulation'.")
110+
return val
111+
101112
@cached_property
102113
def normal_axis(self) -> Axis:
103114
"""Axis normal to the mode plane."""

0 commit comments

Comments
 (0)