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

deprecation of search direction if VMEC fails #60

Closed
pomphrey opened this issue May 21, 2020 · 9 comments
Closed

deprecation of search direction if VMEC fails #60

pomphrey opened this issue May 21, 2020 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@pomphrey
Copy link

When running STELLOPT in free-boundary mode, it appears that either (a) a search direction is not deprecated by returning a large Chisq if VMEC fails to converge or (b) input files at the end of a major iteration step when using lmdif do not list the actual value of DELT and boundary fourier coefficients (in the VMEC namelist) that were used to calculate the equilibrium during the STELLOPT run. This is evidenced by my failure to reconstruct an equilibrium using input file input.RUN7.00318 with mgrid file mgrid_RUN7.00381.nc. However, when I decrease DELT to 0.2 from 0.4 the equilibrium DOES converge. It is quite possible that (b) is the problem and not (a)!
Also, at the end of each major iteration, the name of the mgrid file referenced in the input file should be changed from one that contains an _opt string (eg mgrid_RUN7_opt0.nc for the case of the 1st iteration) to a string such as mgrid_RUN7.00000.nc that corresponds to the saved mgrid file, and the boundary fourier coefficients in the VMEC namelist should change from the input 'guess' to the values calculated for the actual free-boundary equilibrium shape.
Code execution was in /p/stellopt/ANALYSIS/Pomphrey/LDRD20/STELLCOPT_RUNSwTF/RUN7

input.RUN7.txt

@lazersos lazersos self-assigned this May 22, 2020
@lazersos lazersos added the bug Something isn't working label May 22, 2020
@lazersos
Copy link
Collaborator

@jbreslau Could you handle the MGRID issue? I'll look into this run and figure out what's happening with the input namelist. I also suspect (b) is the issue as @pomphrey suspects.

@jbreslau jbreslau self-assigned this May 23, 2020
@jbreslau
Copy link
Collaborator

The latest push to the stellcopt branch resolves the MGRID issue. Would you like me to rebase it and repeat the pull request?

@lazersos
Copy link
Collaborator

@pomphrey So we no longer set chisq to a large value when a search direction fails. The LMDIF algorithm does print the number but instead the search direction is explicitly removed from the Jacobian. This was done because setting chi-squared to a large number results in the individual chi's being smaller. The resulting Jacobian array would produce unexpected results when inverted. So the correct method of reducing the space dimensionality was implemented. The search direction are explicitly deprecated now.

The input files output after the major iterations do output the value which they had at the time VMEC was run. This way they should reproduce any VMEC run when used. However, when I try to run your test case something weird is happening. For some reason the code isn't running in free boundary. Can you upload a full test case for us (input, cws, coil and mgrid parameters to produce the first mgrid file)?

@pomphrey
Copy link
Author

@lazersos Please copy the following files from /p/stellopt/ANALYSIS/Pomphrey/LDRD20/STELLCOPT_RUNSwTF/RUN7

input.RUN7, cws, COILS.RUN7.00000, TFcoils, terpsichore_input_00, terpsichore_input_01

If you don't want to run with terpsichore, set the two SIGMA_KINK values in the input file input.RUN7 equal to 1.e30. The mgrid parameters appear at the end of input.RUN7 under &MGRID_NLI. Otherwise, you can simply copy mgrid_RUN7.00000.nc in which case you don't need to copy the coilsfile.

I think the reason the code is running in fixed boundary mode is that it was unable to find the mgrid file.
You had made an earlier comment / suggestion that an initial mgrid file should not be needed if we are in a mode of designing coils where the coil shapes are allowed to vary. I agree with that. There should probably be a logical variable in the input file that is set to T if we are varying coil geometry. In such a case, the input file will contain the spline representation of the coils (which the present input file has) and the code should first calculate the mgrid file from the spline representation. That can be done in the future.

@pomphrey pomphrey reopened this Jun 11, 2020
@lazersos
Copy link
Collaborator

@zhucaoxiang can you upload the files? I don't have access to the PPPL cluster.

@zhucaoxiang
Copy link
Collaborator

@lazersos Here it is. The MGRID file is too large to exceed the size limit.

STELLCOPT.zip

@lazersos
Copy link
Collaborator

@pomphrey I've been able to run this case now on Marconi using the stellcopt branch. I've got a couple of notes:

I can confirm that the input files are not updating the RBC/ZBS values. However, this is by design. The RBC/ZBS values in free boundary are only initial conditions for the free boundary simulations. In the old version of STELLOPT these would be updated to be whatever the free boundary simulation had found. However, this caused two problems. First it was possible that if you took that input file and tried to run it, VMEC would fail to converge. This is because the input file no longer contained the initial condition for the run. This led to the second problem which was that overly detailed boundary specifications would fail to converge when simpler boundaries would in fact converge. This is less to do with the boundary and more to do with the multi-grid behavior of VMEC. It's a trivial matter to output the RBC/ZBS harmonics from the wout file.

I would nominally propose that we include an option LBOUND_UPDATE which when set to T will overwrite the RBC/ZBS values in vmec_input with the values from the WOUT file. The source to do this is actually commented out in stellopt_load_equil.f90 so implementation would be simple.

Regarding the DELT problem. Nothing in the VMEC input namelist should be changing from run to run unless the optimizer is changing the value. So if you set DELT=0.4 then it should always be 0.4 in the files.

@pomphrey
Copy link
Author

pomphrey commented Jun 12, 2020 via email

@lazersos
Copy link
Collaborator

I'm closing this bug, as I've opened a enhancement issue #83 which tracks this since I believe the original bug has been addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants