PlasmaControl / DESC

Stellarator Equilibrium and Optimization Suite
MIT License
78 stars 16 forks source link

Incorrect computation on stellarator symmetric surfaces #1101

Open unalmis opened 3 days ago

unalmis commented 3 days ago

We have an inconsistent use of stellarator symmetry (the discrete one) that leads to computing quantities incorrectly. Here is a toroid surface with an elliptic cross section and torsion.

surf = FourierRZToroidalSurface(
    R_lmn=[10, 1, 0.2],
    Z_lmn=[-2, -0.2],
    modes_R=[[0, 0], [1, 0], [0, 1]],
    modes_Z=[[-1, 0], [0, -1]],
)

DESC determines this is stellarator symmetric, and will also, by default, label equilibrium with such a boundary as a symmetric equilibrium. We use the same characteristic to construct computational grids for stellarator symmetry that truncate the poloidal domain from $\theta \in [0, 2 \pi]$ to $\theta \in [0, \pi]$. By doing so, we are assuming that, under stellarator symmetry, the following relation holds $\int_0^{2\pi} f(\theta) d \theta = 2 \int_0^{\pi} f(\theta) d \theta$, which is not true because f is not symmetric.

For example, this quantity is not computed correctly on symmetric objects such as the surface above when integrated along a boundary, so the Elongation and Aspect ratio objectives that target toroid surfaces introduced in #884 have never been correct on master for symmetric surfaces (the equilibrium ones are fine).

One may expect that the same issue exists in the volume computation, and hence the magnetic well, but those also integrate over zeta, and even though their integrands, assuming symmetry, do not satisfy $\int_0^{2\pi} f(\theta) d \theta = 2 \int_0^{\pi} f(\theta) d \theta$, I think they do satisfy $\int_0^{2\pi} \int_0^{2\pi} f(\theta) d \theta d\zeta = 2 \int_0^{2\pi} \int_0^{\pi} f(\theta) d \theta d\zeta$ (one can show analytically they do for above surface), which is why all the other tests for correctness of this work. Still we should review code and review the symmetry condition.

(fyi these results were confirmed/tested with analytic tests using sympy).

unalmis commented 3 days ago

Add sym on off test to compute everything