University of Wisconsin–Madison — UWPlasma Research Group
LX is a differentiable, JAX-based solver for the Laplace equation inside toroidal domains (such as stellarator or mirror geometries). It computes vacuum magnetic fields
subject to magnetic flux surface boundary conditions
where the surface
LX supports automatic differentiation, allowing exact gradients of objectives (e.g. magnetic field uniformity, quasi-symmetry proxies) with respect to all geometry degrees of freedom.
This makes LX suitable for geometry optimization, shape design, and inverse problems in plasma confinement.
The magnetic field in a current-free region (no plasma currents, no coils) satisfies:
Thus, the field can be expressed as the gradient of a scalar potential:
and the potential satisfies Laplace’s equation:
Inside a toroidal region,
In LX, we model this as:
where:
-
$$G(\mathbf{x},\mathbf{y}) = \frac{1}{4\pi|\mathbf{x}-\mathbf{y}|}$$ is the Laplace Green’s function, -
$$\sigma(\mathbf{y})$$ is the single-layer source density on the boundary$$\Gamma$$ , -
$$\lambda_\text{tor}, \lambda_\text{pol}$$ are uniform strengths of the double-layer potentials over toroidal and poloidal cuts.
Enforcing the Neumann condition
with
The surface
where:
-
$$s \in [0,1)$$ is the arc-length parameter along the axis (periodic), -
$$\alpha \in [0,2\pi)$$ is the poloidal angle, -
$$\mathbf{e}_1, \mathbf{e}_2$$ form a Bishop (parallel-transport) frame [1], -
$$a(s,\alpha)$$
is a cross-section radius function:
All quantities (
The design vector is:
LX uses a Nyström discretization of the boundary integral equation:
- Discretize
$$\Gamma$$ at$$S\times A$$ quadrature points. - Evaluate kernels via vectorized JAX
vmapoperations. - Assemble dense matrices
$$A(p)$$ and right-hand side$$b(p)$$ . - Solve
$$A u = b$$ via least-squares (jax.numpy.linalg.lstsq).
Once
- Autodiff: Every step (geometry construction, kernel evaluation, matrix assembly) is written in pure JAX for exact gradients.
- JIT: Functions are
@jitcompiled for speed. - Vectorization: Kernels are computed with nested
vmapfor optimal GPU/TPU parallelism. - Adjoint Differentiation: The solver uses
custom_vjpto differentiate the implicit linear solve.
Future versions may swap the dense matvec with an FMM (Fast Multipole Method) [2] while preserving the same adjoint.
Run the script directly:
python laplace_solver.pyThe objective flattens
What to Change Parameter Meaning Typical Range S_SAMPLES, A_SAMPLES Surface resolution 40–160 N_CTRL B-spline control points for axis 8–20 M_LIST Cross-section Fourier modes (2,), (2,3,) CUT_NR, CUT_NA Cut resolution (circulation accuracy) 16–64 SEGMENT_FRACTION Portion of the axis for the objective 0.1–0.5 REG_* Regularization weights 1e-3–1e-6
You can modify:
Centerline → change make_design() to start from a straight line or figure-eight.
Cross-section → add Fourier modes for elongation or triangularity.
Cuts → adjust POLOIDAL_ALPHA0 for ribbon orientation.
Objective → define your own function of B, e.g. for quasi-symmetry or mirror shaping.
Improving the Code
Calderón Preconditioning Convert the first-kind integral equation to a second-kind form [3] to improve conditioning.
Fast Multipole Acceleration Replace dense integrals with a JAX-compatible FMM [4].
Higher-Order Quadrature
Use product Gauss–Legendre quadrature in
Additional Harmonic Modes
Replace scalar
Zernike Basis for Inner Surfaces
To represent interior flux surfaces smoothly, fit
Optimization Use jaxopt or optax for differentiable optimization with Adam or L-BFGS-B.
Gotchas & Numerical Tips
The Neumann problem for Laplace’s equation is singular up to an additive constant. Fix it by adding one extra constraint, e.g.,
When S_SAMPLES or A_SAMPLES is small, the Bishop frame may accumulate twist; reorthonormalize if needed.
Avoid self-intersecting geometries: check a0(s) < R(s) for tubular validity.
If the solver fails to converge, lower the number of modes or regularize the system matrix with small Tikhonov damping.
References
[1] Bishop, R. L. (1975). There is more than one way to frame a curve. Amer. Math. Monthly, 82, 246–251. [2] Greengard, L., & Rokhlin, V. (1987). A fast algorithm for particle simulations. J. Comput. Phys., 73, 325–348. [3] Kress, R. (1999). Linear Integral Equations (2nd ed.). Springer. [4] Gumerov, N. A., & Duraiswami, R. (2004). Fast multipole methods for the Helmholtz equation in three dimensions. Elsevier. [5] Dudt, D. W., & Landreman, M. (2020). DESC: A stellarator equilibrium solver using direct variational methods. Phys. Plasmas, 27, 102513. [6] Landreman, M. et al. (2023). Magnetic fields with precise quasisymmetry. J. Plasma Phys., 89, 905890616. [7] Garren, D. A., & Boozer, A. H. (1991). Existence of quasihelically symmetric stellarators. Phys. Fluids B, 3, 2822–2834.
Ways Forward
LX bridges applied mathematics, stellarator optimization, and computational plasma physics:
Integrate with coil design tools (e.g., SIMSOPT ) for differentiable coil optimization.
Extend to Poisson equations for plasma pressure-driven equilibria.
Couple with GR-based metrics for magnetogenesis or curved spacetime plasma simulations.
Enable multi-objective optimization for mirror shaping, magnetic well control, and quasisymmetry tuning.
Maintainers: UWPlasma Research Group, Department of Physics, University of Wisconsin–Madison Contact: uwplasma.github.io