Skip to content

Commit

Permalink
Merge pull request #711 from PlasmaControl/dp/io-hotfix
Browse files Browse the repository at this point in the history
Continuation _solve_axisym and Surface from_input_file hotfix
  • Loading branch information
dpanici authored Oct 20, 2023
2 parents be530ca + f45bac0 commit b0794c9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion desc/continuation.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _solve_axisym(
L, M, N, L_grid, M_grid, N_grid = eq.L, eq.M, eq.N, eq.L_grid, eq.M_grid, eq.N_grid
spectral_indexing = eq.spectral_indexing

Mi = min(M // 2, mres_step) if mres_step > 0 else M
Mi = min(M, mres_step) if mres_step > 0 else M
Li = int(np.ceil(L / M) * Mi)
Ni = 0
L_gridi = np.ceil(L_grid / L * Li).astype(int)
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) == 1
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

0 comments on commit b0794c9

Please sign in to comment.