diff --git a/python/gvec/util/params.py b/python/gvec/util/params.py index 9242ebb2..381f6da6 100644 --- a/python/gvec/util/params.py +++ b/python/gvec/util/params.py @@ -722,7 +722,9 @@ def power_series(kind: str) -> bool: if not np.isnan(v) and v != 0.0: params[gvec_key][m, n] = values[m - m0, n - n0] - if "rbs" in nml or "zbc" in nml: + # LASYM = T lets the equilibrium break the symmetry even from a symmetric initial boundary, + # e.g. a free boundary in an up-down asymmetric coil field + if "rbs" in nml or "zbc" in nml or not stellsym: if stellsym: logger.warning( "VMEC namelist contains 'RBS' or 'ZBC' but is supposed to be stellarator symmetric. Assuming asymmetry." @@ -731,10 +733,6 @@ def power_series(kind: str) -> bool: params["X2_sin_cos"] = "_sincos_" params["LA_sin_cos"] = "_sincos_" else: - if not stellsym: - logger.warning( - "VMEC namelist does not contain 'RBS' or 'ZBC' but is supposed to be non-stellarator symmetric. Assuming symmetry." - ) params["X1_sin_cos"] = "_cos_" params["X2_sin_cos"] = "_sin_" params["LA_sin_cos"] = "_sin_" diff --git a/test-CI/unit-pygvec/test_util.py b/test-CI/unit-pygvec/test_util.py index 8d702476..e57cef4a 100644 --- a/test-CI/unit-pygvec/test_util.py +++ b/test-CI/unit-pygvec/test_util.py @@ -236,6 +236,20 @@ def test_parameters_from_vmec_accepts_sparse_boundary_arrays(): } +def test_parameters_from_vmec_lasym_with_symmetric_boundary(): + """LASYM = T keeps the asymmetric modes when the initial boundary is symmetric.""" + import f90nml + + nml = f90nml.reads( + "&INDATA\n LASYM = T\n RBC(0, 0) = 1.7 RBC(0, 1) = 0.6 ZBS(0, 1) = 1.0\n/\n" + )["indata"] + + parameters = util.parameters_from_vmec(nml, "lasym") + + for q in ("X1", "X2", "LA"): + assert parameters[f"{q}_sin_cos"] == "_sincos_" + + def test_parameters_from_vmec_reads_legacy_and_scalar_axis(): """VMEC copies nonzero RAXIS and ZAXIS entries into RAXIS_CC and ZAXIS_CS.""" import f90nml