Skip to content

Commit

Permalink
error message if only one bound is inf
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerflex committed Apr 19, 2022
1 parent 469edc0 commit a1480b1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tidy3d/components/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,17 @@ def get_center(pt_min: float, pt_max: float) -> float:
"""Returns center point based on bounds along dimension."""
if np.isneginf(pt_min) and np.isposinf(pt_max):
return 0.0
if np.isneginf(pt_min) or np.isposinf(pt_max):
raise SetupError(
f"Bounds of ({pt_min}, {pt_max}) supplied along one dimension. "
"We currently don't support supplying a single `inf` value in bounds "
"for the construction of semi-infinite `Box`. "
"Instead, to construct a semi-infinite `Box`, "
"please supply a large number instead of `inf`. "
"For example, if the Box represents the geometry of a `Structure` in a "
"`Simulation`, its bound should extend outside of the `Simulation` domain "
"including PML."
)
return (pt_min + pt_max) / 2.0

center = tuple(get_center(pt_min, pt_max) for pt_min, pt_max in zip(rmin, rmax))
Expand Down

0 comments on commit a1480b1

Please sign in to comment.