Skip to content

Commit

Permalink
adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanschilling committed Jul 17, 2024
1 parent 89857f5 commit ec5be5c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
34 changes: 21 additions & 13 deletions tests/geo/test_surface_rzfourier.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,13 @@ def test_from_vmec_2_ways(self):
filename2 = TEST_DIR / 'wout_li383_low_res_reference.nc'
s1 = SurfaceRZFourier.from_vmec_input(filename1)
s2 = SurfaceRZFourier.from_wout(filename2)
mpol = min(s1.mpol, s2.mpol)
ntor = min(s1.ntor, s2.ntor)
places = 13
self.assertEqual(s1.mpol, s2.mpol)
self.assertEqual(s1.ntor, s2.ntor)
self.assertEqual(s1.nfp, s2.nfp)
self.assertEqual(s1.stellsym, s2.stellsym)
mpol = s1.mpol
ntor = s1.ntor
places = 13
for m in range(mpol + 1):
nmin = 0 if m == 0 else -ntor
for n in range(nmin, ntor + 1):
Expand Down Expand Up @@ -266,8 +268,10 @@ def test_from_vmec_2_ways(self):
# coordinate-independent properties like the volume and area.
self.assertAlmostEqual(np.abs(s1.volume()), np.abs(s2.volume()), places=13)
self.assertAlmostEqual(s1.area(), s2.area(), places=7)
mpol = min(s1.mpol, s2.mpol)
ntor = min(s1.ntor, s2.ntor)
self.assertEqual(s1.mpol, s2.mpol)
self.assertEqual(s1.ntor, s2.ntor)
mpol = s1.mpol
ntor = s1.ntor
places = 13
for m in range(mpol + 1):
nmin = 0 if m == 0 else -ntor
Expand All @@ -290,11 +294,13 @@ def test_get_and_write_nml(self):
with ScratchDir("."):
s1.write_nml(new_filename)
s2 = SurfaceRZFourier.from_vmec_input(new_filename)
mpol = min(s1.mpol, s2.mpol)
ntor = min(s1.ntor, s2.ntor)
places = 13
self.assertEqual(s1.nfp, s2.nfp)
self.assertEqual(s1.stellsym, s2.stellsym)
self.assertEqual(s1.mpol, s2.mpol)
self.assertEqual(s1.ntor, s2.ntor)
mpol = s1.mpol
ntor = s1.ntor
places = 13
for m in range(mpol + 1):
nmin = 0 if m == 0 else -ntor
for n in range(nmin, ntor + 1):
Expand All @@ -310,11 +316,13 @@ def test_get_and_write_nml(self):
with open(new_filename, 'w') as f:
f.write(nml_str)
s2 = SurfaceRZFourier.from_vmec_input(new_filename)
mpol = min(s1.mpol, s2.mpol)
ntor = min(s1.ntor, s2.ntor)
places = 13
self.assertEqual(s1.nfp, s2.nfp)
self.assertEqual(s1.stellsym, s2.stellsym)
self.assertEqual(s1.mpol, s2.mpol)
self.assertEqual(s1.ntor, s2.ntor)
mpol = s1.mpol
ntor = s1.ntor
places = 13
for m in range(mpol + 1):
nmin = 0 if m == 0 else -ntor
for n in range(nmin, ntor + 1):
Expand Down Expand Up @@ -743,10 +751,10 @@ def test_fourier_transform_scalar(self):

# Create the grid of quadpoints:
phi2d, theta2d = np.meshgrid(2 * np.pi * s.quadpoints_phi,
2 * np.pi * s.quadpoints_theta,
2 * np.pi * s.quadpoints_theta,
indexing='ij')

# create a test field where only Fourier elements [m=2, n=3]
# create a test field where only Fourier elements [m=2, n=3]
# and [m=4,n=5] are nonzero:
field = 0.8 * np.sin(2*theta2d - 3*s.nfp*phi2d) + 0.2*np.sin(4*theta2d - 5*s.nfp*phi2d)+ 0.7*np.cos(3*theta2d - 3*s.nfp*phi2d)

Expand Down
12 changes: 8 additions & 4 deletions tests/mhd/test_vmec.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,10 @@ def test_surface_4_ways(self):

def compare_surfaces_sym(s1, s2):
logger.debug('compare_surfaces_sym called')
mpol = min(s1.mpol, s2.mpol)
ntor = min(s1.ntor, s2.ntor)
self.assertEqual(s1.mpol, s2.mpol)
self.assertEqual(s1.ntor, s2.ntor)
mpol = s1.mpol
ntor = s1.ntor
places = 13
for m in range(mpol + 1):
nmin = 0 if m == 0 else -ntor
Expand All @@ -243,8 +245,10 @@ def compare_surfaces_asym(s1, s2, places):
logger.debug('compare_surfaces_asym called')
self.assertAlmostEqual(np.abs(s1.volume()), np.abs(s2.volume()), places=13)
self.assertAlmostEqual(s1.area(), s2.area(), places=7)
mpol = min(s1.mpol, s2.mpol)
ntor = min(s1.ntor, s2.ntor)
self.assertEqual(s1.mpol, s2.mpol)
self.assertEqual(s1.ntor, s2.ntor)
mpol = s1.mpol
ntor = s1.ntor
for m in range(mpol + 1):
nmin = 0 if m == 0 else -ntor
for n in range(nmin, ntor + 1):
Expand Down

0 comments on commit ec5be5c

Please sign in to comment.