Skip to content

Commit

Permalink
Printing more info to debug test
Browse files Browse the repository at this point in the history
  • Loading branch information
landreman committed Jan 17, 2025
1 parent 06cee79 commit 89203c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,9 @@ jobs:
# run: pip install -v ".[MPI,SPEC,VIS]"
run: pip install -v "."

- name: Run tests on 1 process using coverage
if: contains(matrix.test-type, 'unit')
- name: Run tests on 1 process using coverage
run: |
cd tests
python -m unittest geo.test_curve_optimizable.Testing
python -m unittest geo.test_boozersurface.BoozerSurfaceTests.test_boozer_surface_optimisation_convergence
python -m unittest geo.test_boozersurface.BoozerSurfaceTests.test_convergence_cpp_and_notcpp_same
6 changes: 5 additions & 1 deletion src/simsopt/geo/boozersurface.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ def minimize_boozer_penalty_constraints_newton(self, tol=1e-12, maxiter=10, cons
val, dval, d2val = fun_name(x, derivatives=2, constraint_weight=constraint_weight, optimize_G=G is not None, weight_inv_modB=weight_inv_modB)

norm = np.linalg.norm(dval)
print(f"minimize_boozer_penalty_constraints_newton iter: {i} val: {val} norm: {norm}", flush=True)
while i < maxiter and norm > tol:
d2val += stab*np.identity(d2val.shape[0])
dx = np.linalg.solve(d2val, dval)
Expand All @@ -502,6 +503,7 @@ def minimize_boozer_penalty_constraints_newton(self, tol=1e-12, maxiter=10, cons
val, dval, d2val = fun_name(x, derivatives=2, constraint_weight=constraint_weight, optimize_G=G is not None, weight_inv_modB=weight_inv_modB)
norm = np.linalg.norm(dval)
i = i+1
print(f"minimize_boozer_penalty_constraints_newton iter: {i} val: {val} norm: {norm}", flush=True)

r = self.boozer_penalty_constraints(
x, derivatives=0, constraint_weight=constraint_weight, scalarize=False, optimize_G=G is not None, weight_inv_modB=weight_inv_modB)
Expand Down Expand Up @@ -583,7 +585,7 @@ def minimize_boozer_penalty_constraints_ls(self, tol=1e-12, maxiter=10, constrai
x, derivatives=0, constraint_weight=constraint_weight, scalarize=False, optimize_G=G is not None)
jac = lambda x: self.boozer_penalty_constraints(
x, derivatives=1, constraint_weight=constraint_weight, scalarize=False, optimize_G=G is not None)[1]
res = least_squares(fun, x, jac=jac, method=method, ftol=tol, xtol=tol, gtol=tol, x_scale=1.0, max_nfev=maxiter)
res = least_squares(fun, x, jac=jac, method=method, ftol=tol, xtol=tol, gtol=tol, x_scale=1.0, max_nfev=maxiter, verbose=2)
resdict = {
"info": res, "residual": res.fun, "gradient": res.grad, "jacobian": res.jac, "success": res.status > 0,
"G": None,
Expand Down Expand Up @@ -636,6 +638,7 @@ def minimize_boozer_exact_constraints_newton(self, tol=1e-12, maxiter=10, iota=0
val, dval = self.boozer_exact_constraints(xl, derivatives=1, optimize_G=G is not None)
norm = np.linalg.norm(val)
i = 0
print(f"minimize_boozer_exact_constraints_newton iter: {i} val: {val} norm: {norm}", flush=True)
while i < maxiter and norm > tol:
if s.stellsym:
A = dval[:-1, :-1]
Expand All @@ -652,6 +655,7 @@ def minimize_boozer_exact_constraints_newton(self, tol=1e-12, maxiter=10, iota=0
val, dval = self.boozer_exact_constraints(xl, derivatives=1, optimize_G=G is not None)
norm = np.linalg.norm(val)
i = i + 1
print(f"minimize_boozer_exact_constraints_newton iter: {i} val: {val} norm: {norm}", flush=True)

if s.stellsym:
lm = xl[-2]
Expand Down

0 comments on commit 89203c4

Please sign in to comment.