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

Modify vboot loop to be produce consistent solutions #16

Open
jcschmitt opened this issue Aug 27, 2019 · 7 comments
Open

Modify vboot loop to be produce consistent solutions #16

jcschmitt opened this issue Aug 27, 2019 · 7 comments
Assignees

Comments

@jcschmitt
Copy link
Collaborator

This behavior is observed when running stellopt with regcoil in the vboot loop. Even though I'm in the vboot loop, I'm not modifying the boundary coefficients, so I would expect the vboot loop to converge to an identical answer for every iteration of the vboot loop. However, what I observe is that the behavior is mirrored across processors (I'm using 32 procs, so pattern is repeated 32 times):

I would expect that I would be calling the vboot loop multiple times with identical starting points, and I would expect each evaluation of vboot to take 3 loops (vboot iteration 0, 1, and 2).

It appears that something is not being reset to identical starting points, because later calls of vboot on the same processor converge almost immediately.

I would request that we (I) look at how to modify this loop (or make a new version?) that produces the behavior that I describe above, because it effects later calculations, specifically bnorm and anything related to it later in the food chain, (and their derivatives)...

I don't fully understand the loop count totals, either.
31 + 31 + 17 + 1 + 1

Cut-N-Paste

Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00
Vboot iteration 0: ctor= 3.612E+04, vboot convergence factor= 1.000E+00

Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02
Vboot iteration 1: ctor= 3.680E+04, vboot convergence factor= 3.783E-02

Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.
Vboot iteration 2: ctor= 3.682E+04, vboot convergence factor= 4.602E-04. Tolerance achieved.

Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 5.809E-06. Tolerance achieved.

Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 8.841E-08. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 8.841E-08. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 8.841E-08. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 8.841E-08. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 8.841E-08. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 8.841E-08. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 8.841E-08. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 8.841E-08. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 8.841E-08. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 8.841E-08. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 8.841E-08. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 8.841E-08. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 8.841E-08. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 8.841E-08. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 8.841E-08. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 8.841E-08. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 8.841E-08. Tolerance achieved.

Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 1.252E-08. Tolerance achieved.
Vboot iteration 0: ctor= 3.682E+04, vboot convergence factor= 7.318E-09. Tolerance achieved.

@lazersos
Copy link
Collaborator

lazersos commented Sep 2, 2019

@jcschmitt I was just looking at the stellopt_bootsj code. For one (and this was in the original BOOTSJ code itself), it handles small values of NE and TE at the boundary very poorly. I've not changed it so that Te floors to 10 eV and ne floors to 1E17 m^-3. This isn't a perfect solution but avoids a divide by zero problem which was present in the original code. Also we should be careful, because only the master of MPI_COMM_LOCAL will have the correct values of TE, NE, TI and ZEFF each iteration if they're changing due to optimization. BOOTSJ handles this by having master BCAST the relevant internal arrays to the processors.

Attach an input file for the case you're having problems with and I'll try to help out.

@jcschmitt
Copy link
Collaborator Author

Most of the bug fixes shouldn't affect me (afaik), although the *1000 correction to the central Ti/Te seems like something that I should have run into...it must not have been triggered by having constant (non-changning) Te/Ne/Ti/Zeff values.

The bug that I run into (actually, this one: #15 ) seems to be triggered when I leave one or more of the following variables in the OPTIMUM namelist:

NE_TYPE, NE_OPT, TE_TYPE, TE_OPT, TI_TYPE, TI_OPT, BOOTJ_TYPE, BOOTJ_AUX_F, SFINCS_S, SFINCS_MIN_PROCS, VBOOT_TOLERANCE, VBOOT_MAX_ITERATIONS, SFINCS_ER_OPTION

OR, somehting in the one of the bootjs or sfincs namelist.

I've found that I can eliminate the errant behavior by eliminating all of the variables above and the namelist for bootsj and sfincs. Otherwise, some section of code (I haven't traced it to find it yet) in the initialization procedure overwrites AC_AUX_F with bogus information, even with EQUIL_TYPE = VMEC2000 or VMEC2000_ONEEQ.

@jcschmitt
Copy link
Collaborator Author

Will the modification you made change the behavior for profiles that go to identically zero at only the LCFS? i.e, with profiles that go like:
ne = ni = N0 * (1 - s^5)
Te = Ti = T0 * ( 1 - s )
( with N0 .neq. 0 and T0 .neq. 0 )
In other words, will the LCFS density and temp get bumped up by the floor, or only for interior points?

@lazersos
Copy link
Collaborator

lazersos commented Sep 2, 2019

@jcschmitt Your &BOOTIN namelist has TEMPRES=64.0. Unless you want to use the pressure profile as a scaling factor for the temperatures and densities then you should set it to TEMPRES=-1.0. What you have will be really odd. STELLOPT assumes that if you set NE TE and TI you want P to be self-consistent. So the VMEC pressure profile is recomputed before calculating an equilibrium with VMEC. However, the BOOTSJ conventions are to allow inconsistency. By setting tempres >=0 you're telling BOOTSJ to use TEMPRES and the VMEC pressure profile to calculate the temperatures and densities.

To answer your question, the mods I've made (in the ASCOT_INTERFACE branch) will prevent any value on the grid from going below these values.

@jcschmitt
Copy link
Collaborator Author

Hmm. It seems that even with TEMPRES=64, I was getting results that were only off by about 16% (net currrent), and with JBS profiles that weren't strange. The Te, Ti profiles that were reported by bootsj were proportional to the total pressure, but the density was constant. I'm sure it was just a coincidence that the results were so similar. I've fixed it in the input list. (and closed issue #15 ).

bootsj initial run

@lazersos
Copy link
Collaborator

Status?

@jcschmitt
Copy link
Collaborator Author

As far as I know, this is still an issue with vboot/bootsj on 2nd/3rd/4th/etc. iterations. I don't think sfincs suffers from the same problem since the initial profile is initialized differently in the sfincs version of the vboot loop.

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

No branches or pull requests

2 participants