Skip to content

Carry the Jacobian sign in the Mercier volume derivative - #795

Open
CharlesCNorton wants to merge 3 commits into
proximafusion:mainfrom
CharlesCNorton:mercier-jacobian-sign
Open

Carry the Jacobian sign in the Mercier volume derivative#795
CharlesCNorton wants to merge 3 commits into
proximafusion:mainfrom
CharlesCNorton:mercier-jacobian-sign

Conversation

@CharlesCNorton

Copy link
Copy Markdown
Contributor

ComputeMercierStability forms the volume derivative of the first table as the plain half-grid average of vp_real. mercier.f90:191 forms it as

sqs = p5*(vp_real(i) + vp_real(i+1))*sign_jac

and then writes shear(i)/sqs as SHEAR, sqs itself as VP, ip(i)/sqs as ITOR' and presp(i)/sqs as PRES'. The Jacobian sign is therefore carried by all four columns, not only by WELL, which VMEC++ already scales by it at the same site.

With the usual negative Jacobian, which is every bundled case, those four columns come out negated. Measured against the mercier.<case> file educational_VMEC writes, the ratio is -1 to the five significant figures the file carries, on every case, while WELL, IOTA, S, PHI, PRES and ITOR agree:

column ratio before
SHEAR -0.999987
VP -1.000005
ITOR' -0.999999
PRES' -0.999996
WELL 0.999978
IOTA 0.999974

Comparing every column of both Mercier tables against that file across the bundled cases, nine go from four differing columns to all fifteen agreeing: solovev, solovev_no_axis, solovev_analytical, cth_like_fixed_bdy, cth_like_fixed_bdy_iota, cth_like_fixed_bdy_nzeta_37, cth_like_fixed_bdy_spline_pressure, cth_like_free_bdy and li383_low_res. What still differs elsewhere is unrelated to this change: cma carries no current, so its ITOR and ITOR' are round-off around 1e-10; the asymmetric cases differ by the tmult normalisation; and up_down_asymmetric_tokamak sits in a different poloidal gauge.

The second table is unaffected, since Dshear, Dcurr, Dwell and Dgeod are built from the intermediates rather than from this quantity.

CheckMercierStability could not see this. It reproduces the same unsigned average in the test and asserts the first table against it, so the test and the implementation agree with each other and both differ from the reference. The test now applies sign_of_jacobian where it already reads it for the WELL comparison.

Nothing outside the output stage reads these fields.

//vmecpp_large_cpp_tests/vmec/output_quantities:output_quantities_test passes 84 tests, including the six cases of MercierStabilityTest.

@CharlesCNorton

Copy link
Copy Markdown
Contributor Author

Checked independently against the mercier.<case> text file educational_VMEC writes, rather than the dumps: on main the SHEAR, VP, ITOR' and PRES' columns come out with the opposite sign for cth_like_fixed_bdy and solovev, and on this branch all ten columns agree to the five digits the file prints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant