-
Notifications
You must be signed in to change notification settings - Fork 53
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
[VMEC,SurfaceRZFourier] fix inconsistency regarding mpol #437
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -344,17 +344,22 @@ def __init__(self, | |
# object, but the mpol/ntor values of either the vmec object | ||
# or the boundary surface object can be changed independently | ||
# by the user. | ||
# `vi.mpol` comes from VMEC, but VMEC only uses `m=0, 1, ..., (mpol-1)`, | ||
# but `SurfaceRZFourier` includes `m=mpol`, so we have to | ||
# initialize `SurfaceRZFourier` with the highest poloidal mode | ||
# that VMEC uses, which is `vi.mpol-1`. | ||
self._boundary = SurfaceRZFourier.from_nphi_ntheta(nfp=vi.nfp, | ||
stellsym=not vi.lasym, | ||
mpol=vi.mpol, | ||
mpol=vi.mpol - 1, | ||
ntor=vi.ntor, | ||
ntheta=ntheta, | ||
nphi=nphi, | ||
range=range_surface) | ||
self.free_boundary = bool(vi.lfreeb) | ||
|
||
# Transfer boundary shape data from fortran to the ParameterArray: | ||
for m in range(vi.mpol + 1): | ||
# The highest mode number relevant to VMEC in its input is `vi.mpol-1`. | ||
for m in range(vi.mpol): | ||
for n in range(-vi.ntor, vi.ntor + 1): | ||
self._boundary.rc[m, n + vi.ntor] = vi.rbc[101 + n, m] | ||
self._boundary.zs[m, n + vi.ntor] = vi.zbs[101 + n, m] | ||
|
@@ -523,7 +528,9 @@ def set_indata(self): | |
mpol_capped = np.min([boundary_RZFourier.mpol, 101]) | ||
ntor_capped = np.min([boundary_RZFourier.ntor, 101]) | ||
# Transfer boundary shape data from the surface object to VMEC: | ||
for m in range(mpol_capped + 1): | ||
# The highest mode number that VMEC can use is `m=100` | ||
# if the max resolution is `mpol=101`. | ||
for m in range(mpol_capped): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't seem correct to remove the +1 here. mpol_capped is essentially mpol of a SurfaceRZFourier object (via |
||
for n in range(-ntor_capped, ntor_capped + 1): | ||
vi.rbc[101 + n, m] = boundary_RZFourier.get_rc(m, n) | ||
vi.zbs[101 + n, m] = boundary_RZFourier.get_zs(m, n) | ||
|
@@ -756,7 +763,7 @@ def run(self): | |
os.remove(filename) | ||
except FileNotFoundError: | ||
logger.debug(f"Tried to delete the file {filename} but it was not found") | ||
|
||
self.files_to_delete = [] | ||
|
||
# Record the latest output file to delete if we run again: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this -1 should be here. mpol here is SurfaceRZFourier's mpol, so it should equal the maximum m.