Skip to content

Commit

Permalink
fixes bug if traced cylinders are inovled in intersections
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerflex committed Aug 26, 2024
1 parent 1c76897 commit 22219ee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/test_components/test_autograd.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ def objective(*params):
sim_fields = sim_full_traced.strip_traced_fields()

# note: there is one traced structure in SIM_FULL already with 6 fields + 1 = 7
assert len(sim_fields) == 7
assert len(sim_fields) == 10

sim_traced = sim_full_static.insert_traced_fields(sim_fields)

Expand Down
5 changes: 5 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,11 @@ def make_custom_data(lims, unstructured):
size=(8.0, 8.0, 8.0),
run_time=1e-12,
structures=[
td.Structure(
geometry=td.Cylinder(length=1, center=(-1 * tracer, 0, 0), radius=tracer, axis=2),
medium=td.Medium(permittivity=1 + tracer, name="dieletric"),
name="traced_dieletric_cylinder",
),
td.Structure(
geometry=td.Box(size=(1, tracer, tracer), center=(-1 * tracer, 0, 0)),
medium=td.Medium(permittivity=1 + tracer, name="dieletric"),
Expand Down
6 changes: 4 additions & 2 deletions tidy3d/components/geometry/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,13 +486,15 @@ def _intersections_normal(self, z: float):
`Shapely's Documentation <https://shapely.readthedocs.io/en/stable/project.html>`_.
"""

static_self = self.to_static()

# radius at z
radius_offset = self._radius_z(z)
radius_offset = static_self._radius_z(z)

if radius_offset <= 0:
return []

_, (x0, y0) = self.pop_axis(self.center, axis=self.axis)
_, (x0, y0) = self.pop_axis(static_self.center, axis=self.axis)
return [shapely.Point(x0, y0).buffer(radius_offset, quad_segs=_N_SHAPELY_QUAD_SEGS)]

def _intersections_side(self, position, axis):
Expand Down

0 comments on commit 22219ee

Please sign in to comment.