Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continuation _solve_axisym and Surface from_input_file hotfix #711

Merged
merged 7 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion desc/continuation.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _solve_axisym(

ii = 0
stop = False
while ii < mres_steps and not stop:
while ii <= mres_steps and not stop:
timer.start("Iteration {} total".format(ii + 1))

if ii > 0:
Expand Down
7 changes: 6 additions & 1 deletion desc/geometry/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,12 @@ def from_input_file(cls, path):

"""
f = open(path)
if "&INDATA" in f.readlines()[0].upper(): # vmec input, convert to desc
isVMEC = False
for line in f.readlines():
if "&INDATA" in line.upper():
isVMEC = True
break
if isVMEC: # vmec input, convert to desc
inputs = InputReader.parse_vmec_inputs(f)[-1]
else:
inputs = InputReader().parse_inputs(f)[-1]
Expand Down
1 change: 1 addition & 0 deletions tests/inputs/input.DSHAPE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
! Comment line before INDATA start
&indata
! DSHAPE Tokamak from Hirshman and Whitson 1983
MGRID_FILE = 'none'
Expand Down
11 changes: 10 additions & 1 deletion tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from qsc import Qsc

import desc.examples
from desc.continuation import solve_continuation_automatic
from desc.continuation import _solve_axisym, solve_continuation_automatic
from desc.equilibrium import EquilibriaFamily, Equilibrium
from desc.geometry import FourierRZToroidalSurface
from desc.grid import LinearGrid
Expand Down Expand Up @@ -52,6 +52,15 @@ def test_SOLOVEV_vacuum(SOLOVEV_vac):
np.testing.assert_allclose(data["iota"], 0, atol=1e-16)
np.testing.assert_allclose(data["|J|"], 0, atol=3e-3)

# test that solving with the continuation method works correctly
# when eq resolution is lower than the mres_step
eq.change_resolution(L=3, M=3)
eqf = _solve_axisym(eq, mres_step=6)
assert len(eqf) == 2
assert eqf[-1].L == eq.L
assert eqf[-1].M == eq.M
assert eqf[-1].N == eq.N


@pytest.mark.regression
@pytest.mark.solve
Expand Down