Skip to content

Commit

Permalink
adding missing packages for github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgiuliani committed Apr 19, 2024
1 parent 2cfe3a1 commit cda2234
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/non_simd_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
- name: Install python dependencies
run: |
sudo apt-get install graphviz graphviz-dev
pip install wheel numpy scipy f90nml h5py scikit-build cmake qsc sympy pyevtk matplotlib ninja plotly networkx pygraphviz
pip install wheel numpy scipy f90nml h5py scikit-build cmake qsc sympy pyevtk matplotlib ninja plotly networkx pygraphviz ground bentley_ottmann
- name: Install booz_xform
run: pip install -v git+https://github.com/hiddenSymmetries/booz_xform
Expand Down
36 changes: 8 additions & 28 deletions tests/geo/test_boozersurface.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ def test_boozer_penalty_constraints_gradient(self):
stellsym=stellsym,
optimize_G=optimize_G,
vectorize=vectorize):
self.subtest_boozer_penalty_constraints_gradient(
surfacetype, stellsym, optimize_G, vectorize)
self.subtest_boozer_penalty_constraints_gradient(surfacetype, stellsym, optimize_G, vectorize)

def test_boozer_penalty_constraints_hessian(self):
"""
Expand Down Expand Up @@ -97,32 +96,21 @@ def subtest_boozer_penalty_constraints_gradient(self, surfacetype, stellsym,

tf_target = 0.1
boozer_surface = BoozerSurface(bs, s, tf, tf_target)
fun = boozer_surface.boozer_penalty_constraints_vectorized if vectorize else boozer_surface.boozer_penalty_constraints

iota = -0.3
x = np.concatenate((s.get_dofs(), [iota]))
if optimize_G:
x = np.concatenate((x, [2.*np.pi*current_sum*(4*np.pi*10**(-7)/(2 * np.pi))]))
if vectorize:
f0, J0 = boozer_surface.boozer_penalty_constraints_vectorized(
x, derivatives=1, constraint_weight=weight, optimize_G=optimize_G)
else:
f0, J0 = boozer_surface.boozer_penalty_constraints(
x, derivatives=1, constraint_weight=weight, optimize_G=optimize_G)
f0, J0 = fun(x, derivatives=1, constraint_weight=weight, optimize_G=optimize_G)
h = np.random.uniform(size=x.shape)-0.5
Jex = J0@h

err_old = 1e9
epsilons = np.power(2., -np.asarray(range(7, 20)))
print("###############################################################")
for eps in epsilons:
if vectorize:
f1 = boozer_surface.boozer_penalty_constraints_vectorized(
x + eps*h, derivatives=0, constraint_weight=weight,
optimize_G=optimize_G)
else:
f1 = boozer_surface.boozer_penalty_constraints(
x + eps*h, derivatives=0, constraint_weight=weight,
optimize_G=optimize_G)
f1 = fun(x + eps*h, derivatives=0, constraint_weight=weight, optimize_G=optimize_G)
Jfd = (f1-f0)/eps
err = np.linalg.norm(Jfd-Jex)/np.linalg.norm(Jex)
print(err/err_old, f0, f1)
Expand All @@ -146,18 +134,15 @@ def subtest_boozer_penalty_constraints_hessian(self, surfacetype, stellsym,

tf_target = 0.1
boozer_surface = BoozerSurface(bs, s, tf, tf_target)
fun = boozer_surface.boozer_penalty_constraints_vectorized if vectorize else boozer_surface.boozer_penalty_constraints

iota = -0.3
x = np.concatenate((s.get_dofs(), [iota]))
if optimize_G:
x = np.concatenate(
(x, [2.*np.pi*current_sum*(4*np.pi*10**(-7)/(2 * np.pi))]))
if vectorize:
f0, J0, H0 = boozer_surface.boozer_penalty_constraints_vectorized(
x, derivatives=2, optimize_G=optimize_G)
else:
f0, J0, H0 = boozer_surface.boozer_penalty_constraints(
x, derivatives=2, optimize_G=optimize_G)

f0, J0, H0 = fun(x, derivatives=2, optimize_G=optimize_G)
h1 = np.random.uniform(size=x.shape)-0.5
h2 = np.random.uniform(size=x.shape)-0.5
d2f = h1 @ H0 @ h2
Expand All @@ -166,12 +151,7 @@ def subtest_boozer_penalty_constraints_hessian(self, surfacetype, stellsym,
epsilons = np.power(2., -np.asarray(range(10, 20)))
print("###############################################################")
for eps in epsilons:
if vectorize:
fp, Jp = boozer_surface.boozer_penalty_constraints_vectorized(
x + eps*h1, derivatives=1, optimize_G=optimize_G)
else:
fp, Jp = boozer_surface.boozer_penalty_constraints(
x + eps*h1, derivatives=1, optimize_G=optimize_G)
fp, Jp = fun(x + eps*h1, derivatives=1, optimize_G=optimize_G)
d2f_fd = (Jp@h2-J0@h2)/eps
err = np.abs(d2f_fd-d2f)/np.abs(d2f)
print(err/err_old)
Expand Down

0 comments on commit cda2234

Please sign in to comment.