Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VMEC initializer #171

Open
zhucaoxiang opened this issue Jun 30, 2022 · 2 comments
Open

VMEC initializer #171

zhucaoxiang opened this issue Jun 30, 2022 · 2 comments

Comments

@zhucaoxiang
Copy link
Collaborator

We should implement methods to initialize SPEC with a VMEC equilibrium. Zhisong has a Matlab script. I guess we can mimic a python one and one step further, we can link SPEC with LIBSTELL so it can initialize from VMEC itself (put a preprocess flag #ifdef LIBSTELL to make this optional).

Some useful notes from Stuart.

  1. In trying to obtain similar equilibria from SPEC and VMEC, we can match the boundary, toroidal flux, and iota at the volume interfaces in SPEC. Any suggestions on the values to use for mu, helicity and pflux? I know these values will change as it works towards a solution but having a good initial guess would be useful.

The easiest way to get SPEC inputs that match a given VMEC equilibrium is to take the rotational transform profile as the input profile. If I recall, this is achieved by using Lconstraint=1. Just choose a value for Nvol, then choose the toroidal flux values and then take the rotational transform from the VMEC output. In this case, the values of mu and helicity are not really required as inputs. When I say "not really", a reasonable initial guess for mu and pflux are required but only as initial guesses. SPEC will iterate on mu and pflux until the correct value for the rotational transform is obtained. Keep in mind that it is required to specify both \iota and \oita for the rotational transform, which are the rotational transform on the immediate inside and the immediate outside of the interfaces. Usually, we might require that the rotational transform is continuous across the interfaces, so \oita = \iota, but generally SPEC can accommodate discontinuous rotational transform profiles. Usually I would just guess some values for mu and pflux, but I imagine that we could use the relation \iota = d pflux / d tflux, which is true for ideal equilibria with nested surfaces to provide a good guess. Also, mu is related to the parallel current, which I imagine could be extracted from the VMEC output. (I am sorry, but I don't know what units are used in VMEC, and I am kind of ashamed to say that I don't know what units are being used in SPEC.)

Another approach may be to distribute the VMEC equilibrium that you want to compare to SPEC. If you send the VMEC input to all those on this email, perhaps someone might prepare the input for you :-) I haven't run SPEC or VMEC for some time, but I am trying to get back into these calculations, and now is as good a time as any for me to dust off my old routines for doing this . . .

@zhucaoxiang
Copy link
Collaborator Author

Sam had the Fortran converter VMEC2SPEC(https://github.com/PrincetonUniversity/STELLOPT/tree/develop/VMEC2SPEC), but it hasn't been updated for a long time and it does not compute the helicity information (as far as I know).

@smiet
Copy link
Collaborator

smiet commented Oct 27, 2023

@zhisong Do you still have access to this script, if you do; could you upload it here for someone to continue on?

@zhucaoxiang: I think we should keep it minimal and focus on the python script first.

The matlab script is probably the easiest to convert. It should live in py_spec.input.SPECnamelist.fromVMEC()

(which itself could be updated so calling it empty returns a circular cross section 1 volume vacuum case, and classmethods to initialize from_input_file() and from_SPECout(). Is this a good idea or would it break existing scripts and be an annoyance?)

I'll get on it if I have the matlab script (and probably after simons' Australia retreat)

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

No branches or pull requests

2 participants