Skip to content

Commit

Permalink
numerical gradients working for cylinder to 0.1% error
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerflex committed Aug 22, 2024
1 parent b788d2e commit 8bc6705
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tests/test_components/test_autograd.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def make_structures(params: anp.ndarray) -> dict[str, td.Structure]:
custom_med_pole_res = td.CustomPoleResidue(eps_inf=eps_inf, poles=[(a1, c1), (a2, c2)])
custom_pole_res = td.Structure(geometry=box, medium=custom_med_pole_res)

radius = 1 + anp.abs(vector @ params)
radius = 0.6 * (1 + anp.abs(vector @ params))
cyl_center_y = vector @ params
cyl_center_z = -vector @ params
cylinder_geo = td.Cylinder(
Expand Down Expand Up @@ -599,7 +599,7 @@ def test_polyslab_axis_ops(axis):


@pytest.mark.skipif(not RUN_NUMERICAL, reason="Numerical gradient tests runs through web API.")
@pytest.mark.parametrize("structure_key, monitor_key", (("medium", "mode"),))
@pytest.mark.parametrize("structure_key, monitor_key", (("cylinder", "mode"),))
def test_autograd_numerical(structure_key, monitor_key):
"""Test an objective function through tidy3d autograd."""

Expand All @@ -623,7 +623,7 @@ def objective(*args):
assert anp.all(grad != 0.0), "some gradients are 0"

# numerical gradients
delta = 1e-1
delta = 1e-3
sims_numerical = {}

params_num = np.zeros((N_PARAMS, N_PARAMS))
Expand Down
2 changes: 1 addition & 1 deletion tidy3d/components/geometry/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
_N_SHAPELY_QUAD_SEGS = 200

# number of points to discretize polyslab used to represent cylinder in `Cylinder.to_polyslab()`
N_PTS_CYLINDER_POLYSLAB = 101
N_PTS_CYLINDER_POLYSLAB = 201


class Sphere(base.Centered, base.Circular):
Expand Down

0 comments on commit 8bc6705

Please sign in to comment.