From f494a09e4ca79950499946352840f39fb91122e5 Mon Sep 17 00:00:00 2001 From: daniel-dudt Date: Thu, 18 Jul 2024 10:36:13 -0600 Subject: [PATCH 1/5] read VMEC input ZAXIS as ZAXIS_CS --- desc/input_reader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/desc/input_reader.py b/desc/input_reader.py index 62d1da61e3..7ab0821e21 100644 --- a/desc/input_reader.py +++ b/desc/input_reader.py @@ -1335,7 +1335,7 @@ 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 = [ @@ -1354,7 +1354,7 @@ def parse_vmec_inputs(vmec_fname, threshold=0): # noqa: C901 - FIXME: simplify ) 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 = [ From c8ab88fb9c275d5b1032272e25001f1f7dfc88a8 Mon Sep 17 00:00:00 2001 From: Dario Panici Date: Thu, 18 Jul 2024 14:59:43 -0400 Subject: [PATCH 2/5] fix incorrect parantheses --- desc/input_reader.py | 4 ++-- tests/inputs/input.DSHAPE_desc | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/desc/input_reader.py b/desc/input_reader.py index 7ab0821e21..2316c8bd5b 100644 --- a/desc/input_reader.py +++ b/desc/input_reader.py @@ -1335,7 +1335,7 @@ 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(_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 = [ @@ -1354,7 +1354,7 @@ def parse_vmec_inputs(vmec_fname, threshold=0): # noqa: C901 - FIXME: simplify ) inputs["axis"][-1, :] = np.array([n, 0.0, numbers[k]]) 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 = [ diff --git a/tests/inputs/input.DSHAPE_desc b/tests/inputs/input.DSHAPE_desc index 67a5ecaa6d..7a36355930 100644 --- a/tests/inputs/input.DSHAPE_desc +++ b/tests/inputs/input.DSHAPE_desc @@ -1,5 +1,6 @@ # This DESC input file was auto generated from the VMEC input file -# /DESC/tests/inputs/input.DSHAPE +# .//tests//inputs//input.DSHAPE +# on 07/18/2024 at 14:59:15. # For details on the various options see https://desc-docs.readthedocs.io/en/stable/input.html # global parameters From 690524a8da2fef6d0be66f5307d8d7396e5cc8da Mon Sep 17 00:00:00 2001 From: Dario Panici Date: Thu, 18 Jul 2024 15:01:13 -0400 Subject: [PATCH 3/5] undo mistaken change to input file: --- tests/inputs/input.DSHAPE_desc | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/inputs/input.DSHAPE_desc b/tests/inputs/input.DSHAPE_desc index 7a36355930..e7669191cf 100644 --- a/tests/inputs/input.DSHAPE_desc +++ b/tests/inputs/input.DSHAPE_desc @@ -1,6 +1,5 @@ # This DESC input file was auto generated from the VMEC input file # .//tests//inputs//input.DSHAPE -# on 07/18/2024 at 14:59:15. # For details on the various options see https://desc-docs.readthedocs.io/en/stable/input.html # global parameters From faec6545744b909df6f61721d3a9bd1f97221614 Mon Sep 17 00:00:00 2001 From: Dario Panici Date: Thu, 18 Jul 2024 15:02:01 -0400 Subject: [PATCH 4/5] final fix of the input file --- tests/inputs/input.DSHAPE_desc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/inputs/input.DSHAPE_desc b/tests/inputs/input.DSHAPE_desc index e7669191cf..67a5ecaa6d 100644 --- a/tests/inputs/input.DSHAPE_desc +++ b/tests/inputs/input.DSHAPE_desc @@ -1,5 +1,5 @@ # This DESC input file was auto generated from the VMEC input file -# .//tests//inputs//input.DSHAPE +# /DESC/tests/inputs/input.DSHAPE # For details on the various options see https://desc-docs.readthedocs.io/en/stable/input.html # global parameters From fff94cd092189f2dae52295e1ee30d81eb35558e Mon Sep 17 00:00:00 2001 From: daniel-dudt Date: Thu, 18 Jul 2024 13:09:10 -0600 Subject: [PATCH 5/5] fix cc vs cs signs --- desc/input_reader.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/desc/input_reader.py b/desc/input_reader.py index 2316c8bd5b..e59a17eba0 100644 --- a/desc/input_reader.py +++ b/desc/input_reader.py @@ -1335,7 +1335,7 @@ 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 = [ @@ -1343,18 +1343,19 @@ def parse_vmec_inputs(vmec_fname, threshold=0): # noqa: C901 - FIXME: simplify 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 = [ @@ -1362,17 +1363,16 @@ def parse_vmec_inputs(vmec_fname, threshold=0): # noqa: C901 - FIXME: simplify 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)