Skip to content

Commit

Permalink
Added test for A_cyl
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Landreman committed Feb 23, 2024
1 parent 7668654 commit f81c54e
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/field/test_magneticfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,44 @@ def test_reiman_dBdX_taylortest(self):
with self.subTest(idx=idx):
self.subtest_reiman_dBdX_taylortest(idx)

def test_cyl_versions(self):
R0test = 1.5
B0test = 0.8
B0 = ToroidalField(R0test, B0test)

curves, currents, ma = get_ncsx_data()
nfp = 3
coils = coils_via_symmetries(curves, currents, nfp, True)
bs = BiotSavart(coils)
btotal = bs + B0
rmin = 1.5
rmax = 1.7
phimin = 0
phimax = 2*np.pi/nfp
zmax = 0.1
N = 1000
points = np.random.uniform(size=(N, 3))
points[:, 0] = points[:, 0]*(rmax-rmin) + rmin
points[:, 1] = points[:, 1]*(nfp*phimax-phimin) + phimin
points[:, 2] = points[:, 2]*(2*zmax) - zmax
btotal.set_points_cyl(points)

dB = btotal.GradAbsB()
B = btotal.B()
A = btotal.A()
dB_cyl = btotal.GradAbsB_cyl()
B_cyl = btotal.B_cyl()
A_cyl = btotal.A_cyl()

for j in range(N):
phi = points[j, 1]
rotation = np.array([[np.cos(phi), np.sin(phi), 0],
[-np.sin(phi), np.cos(phi), 0],
[0, 0, 1]])
np.testing.assert_allclose(rotation @ B[j, :], B_cyl[j, :])
np.testing.assert_allclose(rotation @ dB[j, :], dB_cyl[j, :])
np.testing.assert_allclose(rotation @ A[j, :], A_cyl[j, :])

def test_interpolated_field_close_with_symmetries(self):
R0test = 1.5
B0test = 0.8
Expand Down

0 comments on commit f81c54e

Please sign in to comment.