Skip to content

Commit

Permalink
read VMEC input ZAXIS as ZAXIS_CS (#1134)
Browse files Browse the repository at this point in the history
Resolves #1120
  • Loading branch information
ddudt authored Jul 19, 2024
2 parents 23a4ce8 + 1c37f49 commit 9c63c54
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions desc/input_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,44 +1335,44 @@ def parse_vmec_inputs(vmec_fname, threshold=0): # noqa: C901 - FIXME: simplify
)
inputs["axis"][-1, :] = np.array([n, -numbers[k], 0.0])
match = re.search(
r"ZAXIS(_CC)?\s*=(\s*" + num_form + r"\s*,?)*", command, re.IGNORECASE
r"ZAXIS(_CS)?\s*=(\s*" + num_form + r"\s*,?)*", command, re.IGNORECASE
)
if match:
numbers = [
float(x)
for x in re.findall(num_form, match.group(0))
if re.search(r"\d", x)
]
for k in range(len(numbers)):
n = k
# ignore the n=0 since it should always be zero for sin terms
for k in range(1, len(numbers)):
n = -k
idx = np.where(inputs["axis"][:, 0] == n)[0]
if np.size(idx):
inputs["axis"][idx[0], 2] = numbers[k]
inputs["axis"][idx[0], 2] = -numbers[k]
else:
inputs["axis"] = np.pad(
inputs["axis"], ((0, 1), (0, 0)), mode="constant"
)
inputs["axis"][-1, :] = np.array([n, 0.0, numbers[k]])
inputs["axis"][-1, :] = np.array([n, 0.0, -numbers[k]])
match = re.search(
r"ZAXIS_CS\s*=(\s*" + num_form + r"\s*,?)*", command, re.IGNORECASE
r"ZAXIS_CC\s*=(\s*" + num_form + r"\s*,?)*", command, re.IGNORECASE
)
if match:
numbers = [
float(x)
for x in re.findall(num_form, match.group(0))
if re.search(r"\d", x)
]
# ignore the n=0 since it should always be zero for sin terms
for k in range(1, len(numbers)):
n = -k
for k in range(len(numbers)):
n = k
idx = np.where(inputs["axis"][:, 0] == n)[0]
if np.size(idx):
inputs["axis"][idx[0], 2] = -numbers[k]
inputs["axis"][idx[0], 2] = numbers[k]
else:
inputs["axis"] = np.pad(
inputs["axis"], ((0, 1), (0, 0)), mode="constant"
)
inputs["axis"][-1, :] = np.array([n, 0.0, -numbers[k]])
inputs["axis"][-1, :] = np.array([n, 0.0, numbers[k]])

# boundary shape
# RBS*sin(m*t-n*p) = RBS*sin(m*t)*cos(n*p) - RBS*cos(m*t)*sin(n*p)
Expand Down

0 comments on commit 9c63c54

Please sign in to comment.