PlasmaControl / DESC

Stellarator Equilibrium and Optimization Suite
MIT License
86 stars 22 forks source link

Sign difference in buco when writing a vmec input file vs writing a vmec wout file #915

Closed aaroncbader closed 6 months ago

aaroncbader commented 6 months ago

To reproduce

Load a desc equilibrium that contains finite toroidal current

write a vmec wout file using VMECIO.save(eq, "wout_from_desc.nc")

write a vmec input file using VMECIO.write_vmec_input(eq, "input.vmec_from_desc")

run VMEC externally

The sign of buco will be flipped in the two instances. However this is not so bad because the value of iota will agree in the two cases.

ddudt commented 6 months ago

Do you know what happens if you start with a VMEC input file, run DESC from it, generate a wout file from the DESC result, and compare that to the original VMEC output? Does the sign of buco agree in that case?

We have tests for these VMEC utilities but only using a tokamak example; it's possible there could be a sign convention error in either VMECIO.save or VMECIO.write_vmec_input.

aaroncbader commented 6 months ago

I have not tried running from a VMEC input file. Not sure if I have the tools for that.

I did do a batch of benchmark testing of both wout files on many advanced metrics (stuff like epsilon effective and gamma c) and found very good agreement between the results. So whatever change is causing the flipped sign is purely a cosmetic one and doesn't seem to affect the underlying equilibrium.

ddudt commented 6 months ago

I did some more testing and I think this issue is related to the difference in coordinate Jacobian sign conventions between VMEC and DESC. In that case we do need to flip the sign of buco when saving the wout file in DESC.

However, the VMEC files I've tested with all have buco and bvco positive. @aaroncbader do you know of any examples where they can be negative? Otherwise we can always save the absolute value.