diff --git a/tests/geo/surface_test_helpers.py b/tests/geo/surface_test_helpers.py index fe9c12933..6b0d6205b 100644 --- a/tests/geo/surface_test_helpers.py +++ b/tests/geo/surface_test_helpers.py @@ -74,7 +74,7 @@ def get_exact_surface(surface_type='SurfaceXYZFourier'): return s -def get_boozer_surface(label="Volume", nphi=None, ntheta=None, boozer_type='exact', optimize_G=True): +def get_boozer_surface(label="Volume", nphi=None, ntheta=None, boozer_type='exact', optimize_G=True, converge=True, stellsym=True): """ Returns a boozer surface that will be used in unit tests. """ @@ -90,7 +90,6 @@ def get_boozer_surface(label="Volume", nphi=None, ntheta=None, boozer_type='exac ## RESOLUTION DETAILS OF SURFACE ON WHICH WE OPTIMIZE FOR QA mpol = 6 if boozer_type == 'exact' else 3 ntor = 6 if boozer_type == 'exact' else 3 - stellsym = True nfp = 3 if boozer_type == 'exact': @@ -122,9 +121,7 @@ def get_boozer_surface(label="Volume", nphi=None, ntheta=None, boozer_type='exac ## COMPUTE THE SURFACE cw = None if boozer_type == 'exact' else 100. boozer_surface = BoozerSurface(bs, s, lab, lab_target, constraint_weight=cw) - boozer_surface.run_code(boozer_type, iota, G=G0, verbose=True) - - #res = boozer_surface.solve_residual_equation_exactly_newton(tol=1e-13, maxiter=20, iota=iota, G=G0) - #print(f"NEWTON {res['success']}: iter={res['iter']}, iota={res['iota']:.3f}, vol={s.volume():.3f}") + if converge: + boozer_surface.run_code(boozer_type, iota, G=G0, verbose=True) return bs, boozer_surface diff --git a/tests/geo/test_surface_objectives.py b/tests/geo/test_surface_objectives.py index 5e3d184b7..42d8545d0 100644 --- a/tests/geo/test_surface_objectives.py +++ b/tests/geo/test_surface_objectives.py @@ -385,11 +385,15 @@ def df(dofs): class LabelTests(unittest.TestCase): def test_label_surface_derivative1(self): for label in ["Volume", "ToroidalFlux", "Area", "AspectRatio"]: - with self.subTest(label=label): - self.subtest_label_derivative1(label) - - def subtest_label_derivative1(self, label): - bs, boozer_surface = get_boozer_surface(label=label, nphi=13, ntheta=14) + for stellsym in stellsym_list: + for nphi, ntheta in [(13, 14), (None, None), (13, None), (None, 14)]: + with self.subTest(label=label, stellsym=stellsym, converge=stellsym): + # don't converge the BoozerSurface when stellsym=False because it takes a long time + # for a unit test + self.subtest_label_derivative1(label, stellsym=stellsym, converge=stellsym, nphi=nphi, ntheta=ntheta) + + def subtest_label_derivative1(self, label, stellsym, converge, nphi, ntheta): + bs, boozer_surface = get_boozer_surface(label=label, nphi=nphi, ntheta=ntheta, converge=converge, stellsym=stellsym) surface = boozer_surface.surface label = boozer_surface.label coeffs = surface.x @@ -406,7 +410,7 @@ def df(dofs): epsilons=np.power(2., -np.asarray(range(13, 19)))) def test_label_surface_derivative2(self): - for label in ["Volume", "ToroidalFlux", "Area"]: + for label in ["Volume", "ToroidalFlux", "Area", "AspectRatio"]: with self.subTest(label=label): self.subtest_label_derivative2(label)