Skip to content

Commit

Permalink
updated to latest API of guide_anyshape_gravity: tests/components/opt…
Browse files Browse the repository at this point in the history
…ics/test_guide_anyshape_gravity.py
  • Loading branch information
yxqd committed Jun 20, 2024
1 parent 15091c9 commit 6d295d1
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions tests/components/optics/test_guide_anyshape_gravity.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ def test_intersect():
gravity = np.array([0, -9.8, 0])
center = np.array([0,0,0])
normal = np.array([0,1,0])
t = guide_anyshape_gravity.intersect_plane(
out = np.zeros(2)
guide_anyshape_gravity.intersect_plane(
neutron[:3], neutron[3:6], gravity,
center, normal
center, normal, out,
)
assert np.isclose(t, 0.009552841750957684)
assert np.isclose(out[0], 0.009552841750957684)
return

@pytest.mark.skipif(not test.USE_CUDASIM, reason='no CUDASIM')
Expand All @@ -50,33 +51,38 @@ def test_propagate():
[1, 0, 0],
[0, 1, 0],
]])
z_max = 1
R0=0.99; Qc=0.0219; alpha=3; m=2; W=0.003
faces2d = np.array([[
[-1, -1],
[-1, 1],
[1, 1],
[1, -1],
]])
bounds2d = np.array([[
[-1, -1],
[1, 1],
]])
tmp1 = np.zeros(3)
tmp2 = np.zeros(3)
tmp3 = np.zeros(3)
tmp_neutron = np.zeros(10)
nfaces = len(faces)
intersections = np.zeros(nfaces, dtype=np.float64)
face_indexes = np.zeros(nfaces, dtype=np.int)
guide_anyshape_gravity._propagate(
in_neutron,
faces, centers, unitvecs, faces2d,
R0, Qc, alpha, m, W,
intersections, face_indexes, gravity,
tmp1, tmp2, tmp3,
)
assert np.allclose(
in_neutron,
[
0., 0., 6.16280534e-02,
0., -3.97542451, 8000,
0, 0,
2.50770351e-03, 0.99
]
faces, centers, unitvecs, faces2d, bounds2d,
z_max, R0, Qc, alpha, m, W,
intersections, face_indexes,
gravity,
tmp1, tmp2, tmp3, tmp_neutron,
)
expected = np.array([
0., -4.6637077E-4, 1,
0., -3.97542451-9.8*(1-6.16280534E-2)/8000, 8000,
0, 0,
21/8000, 0.99
])
assert np.allclose(in_neutron, expected)
return

0 comments on commit 6d295d1

Please sign in to comment.