PlasmaControl / DESC

Stellarator Equilibrium and Optimization Suite
MIT License
96 stars 27 forks source link

`AxisRSelfConsistency` and `AxisZSelfConsistency` can cause the equilibrium to go unnested after application of Linear constraints if `eq.axis` is outside of the boundary #1084

Open dpanici opened 3 months ago

dpanici commented 3 months ago

For a normal fixed-boundary solve the constraints AxisRSelfConsistency and AxisZSelfConsistency are simply meant to tie the extra attributes of the eq Ra_n and Za_n to be equal to the R,Z FourierZernike basis evaluates at rho=0.

However, I have found at least one case where the application of the constraints causes the equilibrium to go un-nested. The problem seems to be solved if I set the equilibrium axis to be where the actual axis is according to the R,Z evaluated at rho=0 with eq.axis=eq.get_axis(), as then after the linear constraint application the eq stays nested.

eq boundary, eq.axis location (given from NAE as axis from NAE), and eq.compute(["R","Z"]) at rho=0 plotted for the initial equilibrium, you can see the axis is outside the boundary

image

After applying the linear constraints (I just did eq.solve(maxiter=0)), the equilibrium is unnested as the particular solution seems to pull the R_lmn and Z_lmn to match the Ra_n and Za_n (instead of the opposite)

image

image

For a simpler case I do not see this behavior, so it could be that this is only an for more complicated cases, but wanted to make the issue to document and think if there is something deeper going on

dpanici commented 3 months ago

This might be due to precision issues when the modenumbers are too large. This eq has N=30 and was a fit to an NAE equilibrium. if I plot the coefficients of eq.get_axis() versus N, I find that the 2nd largest coefficients is at N=30, and I get the same thing if I change the eq resolution to N=29

image

If I set N=28 then I don't get the spurious large modenumber amplitude

image

get_axis() does not do any fit, just sums up the FourierZernikeBasis coefficients at rho=0, so the issue here is likely that the initial equilibrium fit of the NAE surfaces had these coefficients being large at these large modenumbers

image

f0uriest commented 3 months ago

shouldn't this have thrown an error when checking consistency of the linear constraints?