Skip to content

Instantly share code, notes, and snippets.

@rogeriojorge
Last active March 25, 2024 21:54
Show Gist options
  • Save rogeriojorge/cdac731a8b8ccc4dc0cc8ecea71b8b7a to your computer and use it in GitHub Desktop.
Save rogeriojorge/cdac731a8b8ccc4dc0cc8ecea71b8b7a to your computer and use it in GitHub Desktop.

This is a list of research projects and associated info for coil optimization in fusion devices.

Use of B-Splines to represent coils

b-Splines can represent straight sections using fewer parameters than Fourier methods H. Yamaguchi references

Coil Simplification using Permanent Magnets

Take Miguel Madeira's master's thesis idea and see how far one can put coils using permanent magnets. GitHub repository for that: https://github.com/rogeriojorge/W7X_ECM


Particle Orbits in Magnetic Islands

Magnetic islands are a naturally occurring phenomenon in both tokamaks and stellarators. In tokamaks, it can be due to tearing modes at resonant surfaces. In stellarators, they are present

  • If the optimization was not good enough to find a set of nested flux surfaces from the axis to the boundary.
  • If, even for nested surfaces, the coils are not able to exactly replicate the target magnetic field.
  • On purpose at the divertor to spread the heat load. The behavior of the plasma at such islands is then extremely important. Magnetic islands can be present in any magnetic field but can be replicated analytically using fields such as
  • Reiman & Greenside (Comput. Phys. Commun., vol. 43, issue 1, 1986, pp. 157–167)
  • Dommaschk (Comput. Phys. Commun., vol. 40, issue 2-3, 1986, pp. 203–218) Using the NEAT code (https://github.com/rogeriojorge/NEAT), completing the Pull Request in rogeriojorge/NEAT#19 we vary the input parameters of the Dommaschk potentials and study the location where particles are deposited for varying shapes of the magnetic islands.

Work related to this project

  • Use Reiman & Greenside magnetic fields to vary the magnetic island width directly instead of arbitrary Dommaschk potential parameters

Optimization in GC vs Full Orbit

Will the optimizer reach different solutions? Maybe near axis fields in gyronimo


Alfven Eigenmodes in Near-Axis Equilibria

Solve the linear MHD time-dependent equation in near-axis equilibria to get the Alfven Eigenmodes. Optimize for those modes. Solve guiding-center orbits in such fields.

Extra: Can moment models help with Alfven Eigenmodes and kinetic effects from coupling with fast ions? Take a look at fast ions and landau closure models literature.


General Relativistic Gyrokinetics

In intense gravitational fields, such as accretion disks around compact gravitating bodies, general relativistic effects become important. When talking about plasmas in strong magnetic fields, we can use the framework of gyrokinetics. A recent study was done here: Trent et al, arXiv 2309.07231 but previous studies have been done that called this framework general relativistic gyrokinetics. One way to start is to connect the recent arXiv study of Trent et al to gyrokinetics, and its small Larmor radius limit, drift-kinetics, in curved spacetimes. With the new equations of motion in place, we can solve them in a particle tracer such as NEAT https://github.com/rogeriojorge/NEAT and assess the differences between particle geometries in curved and flat spacetimes.


Variational Autoencoders

In stellarator optimization, we work with a large number of input parameters that, when solved using the ideal MHD equation, result in a few output parameters that dictate how good is the solution. Using ideal MHD codes such as DESC and VMEC, the input parameters can be ~50-100, while using the near-axis expansion, the input parameters can be ~8-16.

One should be able to reduce the dimensionality of the system using variational autoencoders.

Work related to this project

  • To generate new configurations, we could leverage conditional variational autoencoders

Surrogate Models for Forward and Inverse Near-Axis Expansion

Using the qsc code https://github.com/landreman/qsc We can create large databases of stellarator configurations. This code uses the near-axis expansion as a simplified model of stellarator ideal MHD equilibria. Taking such database, we can train a neural network to solve both the forward and inverse solver.

  • By forward solver, we mean obtaining the magnetic field configuration (X, Y, Z, elongation, B20, iota, r_singularity) from the axis shape and the near-axis parameters nfp, etabar, B2c and p2.
  • By inverse solver, we mean finding the near-axis parameters from a desirable magnetic field configuration (providing, for example, only iota and elongation) Such a neural network would need to be tailored for this specific problem by performing hyperparameter optimization of the neural network parameters (batch size, learning rate, epochs, etc). We can then save the neural network results in a given folder for different numbers of nfp's.

Work related to this project

  • Plot t-SNE and clusters of the configurations in the database
  • Add loss fraction to database of x_samples using SIMPLE (useful for pyQIC)
  • Add neural network to get near-axis configurations from VMEC and vice-versa. This would simplify the workflow between codes. An idea to do this would be to have a larger database where each near-axis configuration has the corresponding RBC, ZBS for VMEC
  • Can Conditional Density Estimation with Neural Networks help with the inverse solver? (arXiv:1903.00954)

Physics-Informed Neural Network for Ideal MHD

The idea of Physics-Informed Neural Networks (PINN's) is that we can replace the traditional solution of a differential equation with a neural network. This allows us to find solutions must faster than previously, but may lack generalization to points far from where the neural network was trained. More info here: https://arxiv.org/abs/2308.08468 Here, we would like to solve the ideal MHD equation -> J x B = grad P, where J=curl B is the plasma current and P is the plasma pressure to find the magnetic field B. This would replace ideal MHD solvers such as DESC and VMEC.

Then we would like to evolve the magnetic field in time to find the non-linear evolution of the magnetic field by solving rho dv/dt = J x B- grad p where now rho and v are connected via the continuity equation. These equations can be turned into a coupled system of 2 PDE's in the incompressible MHD approach.

A simplification, which may be the first step in the project, would be to use the near-axis expansion https://arxiv.org/abs/1908.10253 and create a PINN for the solution of sigma (at first order) from Eq. (A 26) of that paper.

Use Hyper PINN instead of only PINN

Work related to this project

  • Can the physics-informed neural network help create an inverse VMEC solver? or an inverse pyQSC solver?

Stellarator Image Classification using Machine Learning

The stellarator is a type of fusion energy machine that is now considered by several universities and startups as one of the most promising ways of getting fusion.

Using standard machine learning tools for image classification https://developers.google.com/machine-learning/practica/image-classification https://www.tensorflow.org/tutorials/images/classification Classify stellarator configurations based on their number of field periods, properties of the plasma, the magnetic field, and the boundary. The database of stellarator images will consist of PNGs created using the DESC code https://github.com/PlasmaControl/DESC and, later with images scrapped from Google. The goal is to be able to feed any representation of a stellarator to the classifier and obtain its properties without needing to run it through an extra diagnostic code or ask an expert.


Use Stable Diffusion to Generate New Stellarators

Having a stellarator database that can find some stellarators with good coils, some with good particle transport, and some with good quasisymmetry, using stable diffusion models such as https://github.com/taesungp/contrastive-unpaired-translation to generate a configuration that is good at everything. Usually, such models are optimized for images, but we can change the input/output parameters to make them suitable for stellarators. Another example model is this one: https://arxiv.org/pdf/2103.08827.pdf


Classification of orbits using supervised models

The classification of trapped particles into confined or lost usually requires long simulations of their guiding centers for proper classification. With a machine learning model trained on a database of simulations, we can have a fast surrogate model that, with only a fraction of the simulated time, can tell us if particles will be lost or not. Classifiers as the one in SIMPLE have many rules, but an ML model would just learn those rules. Ask Manuel Assunção for his database or apply SIMPLE to QUASR


VMEC Database and Surrogate Model

1. Building the Database

Future requirements

  • Visualization
  • Use of machine learning models Size of database

Próximos passos:

  • Definir colunas da tabela e tipos de dados das colunas:
    • x - RBC (float16), ZBS (float16), nfp (4bit, inteiro)
    • y - parâmetros que vêm do SIMSOPT
  • Definir metadados da procura
    • Algoritmo da procura (random search vs grid search)
    • Bounds dos dados
  • Primeiro código simples que funcione num laptop
  • Segundo - correr em vários nós/sistemas distribuídos
  • Base de dados local (embeded) em SQLite

This is a list of research projects and associated info for Magnetic Mirrors.

Project 1: Plasma and Coil Optimization

Main reference: https://arxiv.org/abs/2302.10622

Construction of plasma equilibria for fusion devices and electromagnetic coils that accurately reproduce such equilibria

Project 2: Optimization of Alpha Particles

Main reference: https://github.com/rogeriojorge/NEAT

Tracing of energetic particles from fusion reactions in a plasma and minimizing their heat loads on the wall of a reactor.

Project 3: Near-Axis Expansion Formalism

Main references: https://arxiv.org/abs/1911.02659 and https://arxiv.org/abs/2008.09057

Development of a theoretical formalism to describe fusion energy devices.

Project 4: Deep Neural Networks for Stellarator Optimization

Main reference: https://github.com/JoaoAGCandido/PICNeuralNetworkQuasisymmetricStellarator/

Fast generation of initial conditions for stellarator optimization based on neural networks that reproduce close to optimized equilibria.

Project 5: Permanent Magnets and Fusion Energy

Main reference: https://simsopt.readthedocs.io/en/latest/example_permanent_magnets.html

Possibility of the use of permanent magnets (or small magnetic dipoles) to decrease error fields from electromagnetic coils, or to produce stellarator from tokamak coil configurations.


Single Stage Near-Axis Expansion

Andrew Giuliani et al have constructed a method to create coils very efficiently directly from the near-axis expansion https://arxiv.org/abs/2010.02033 It uses the Python script https://github.com/florianwechsung/PyPlasmaOpt In this project, we intend to build on this model and perform the following:

  1. Add a penalty for L_grad B in order to make coils simpler (similar to https://arxiv.org/abs/2309.11342)
  2. Merge the single-stage near-axis approach into the SIMSOPT code (https://github.com/hiddenSymmetries/simsopt/)
  3. Compute the magnetic axis from a magnetic field in SIMSOPT
  4. Use a JAX version of pyQSC to compute gradients instead of having analytical expressions

Differentiable Near-Axis Stellarator Optimization Code

The near-axis expansion framework is now able to create viable configurations for fusion reactors (example: https://arxiv.org/abs/2209.11849) Although it is a fast analytic model, it still requires optimization to be able to find good solutions.

The goal here is to make the near-axis expansion codes differentiable, both pyQSC and pyQIC

1 - pyQSC original: https://github.com/landreman/pyQSC initial JAX version: https://github.com/rogeriojorge/pyNACX

2 - pyQIC original: https://github.com/rogeriojorge/pyQIC paper to be reproduced using JAX pyQIC version: https://arxiv.org/abs/2205.05797 This will allow optimization to be much faster, and the creation of machine-learning based surrogate models.

Such models could be classical machine learning models trained using a database of configurations or using physics-based deep learning - https://physicsbaseddeeplearning.org/intro.html

Work related to this project

  • Give the possibility of JAX, Tensorflow, and PyTorch variants
  • Create optimization scripts for stellarators with high iota and low elongation that take the auto-differentiation capability into account

Near-Axis Quasi-Isodynamic Stellarators in Mercier Coordinates

The near-axis expansion allows stellarator configurations to be constructed in a much faster manner when compared to full MHD solutions. Optimized stellarators, also called omnigeneous, can come in different flavours. One flavour is quasisymmetry, where the near-axis expansion using Mercier coordinates (also called direct approach) has been applied - https://arxiv.org/abs/2003.06388 Another flavor is quasi-isodynamic stellarators: https://arxiv.org/abs/2303.06038 this has had some numerical solutions: https://arxiv.org/abs/2205.05797 but it never had Mercier coordinates applied to it: https://arxiv.org/abs/1911.02659 The goal would be to describe quasi-isodynamic stellarators under the framework of the direct coordinate approach using Mercier coordinates.


Ballooning stability in near-axis magnetic fields

Use the near-axis expansion formalism to write formula (9) in https://doi.org/10.1515/zna-1978-0706 at the lowest order near the axis. Find then a fast method to compute the ballooning stability of stellarators using a stability criterion method in the presence of shear. Verify if it applies to the resistive ballooning case of https://doi.org/10.1515/zna-1982-0818


pyQIC code

Create documentation Merge half-helicity branch from Katia into main Merge splines branch from Eduardo into main Make differentiable JAX version Create database of near-axis QI stellarators


General near-axis questions

  • What is a good practical numerical procedure to solve for the axis shape?
  • Get quasisymmetry at an off-axis surface by balancing B20 against B0 at some r.
  • Understand why stellarators have concave bean shapes.
  • Compute the symmetry-breaking B3
  • How to handle sqrt(r) in bootstrap current?
  • Bootstrap current ‘geometric factor’ for non-quasisymmetric configurations
  • eff for non-quasisymmetric configurations
  • O(r2) omnigenity (E. Rodriguez formulas on pyQIC)
  • Generalizations like “Property X”, pseudosymmetry?

QI MUSE: 1 Machine, 2 configuration types

  • The MUSE magnet grid and coils are available in Simsopt. The MUSE Vacuum Vessel grid dimensions are explained in the engineering article.
  • Find a QI equilibrium with iota as close to MUSE’s as possible (hopefully < 0.3) that fits the vessel
  • Use AI methods?
  • Permanent magnet opt using the same grid of radially oriented magnets
  • Easy to do with Simsopt (GPMO backtracking)
  • Possible application of the new method from https://arxiv.org/abs/2309.17244

MUSE - 2-period Quasi-Axisymmetric Stellarator

  • R = 30.5cm, aspect ratio=7.9, a = 3.86cm, max B = 0.15T

Optimize AriesCS with dipoles

  • Permanent Magnets are likely not good enough for reactor scale machines - I did some preliminary optimizations although for a different equilibrium and that should be redone more carefully;
  • Calculate how strong a dipole made of superconducting tiles and/or superconducting saddle coils could be;
  • Evaluate if it enables building a dipole stellarator -> Are designs from startups in this area similar? Short paper addressing its viability

Permanent Magnets for Error Field Correction

  • From my thesis results it seems feasible to use PMs for error field correction in W7-X;
  • Upgrade my grids to a more realistic grid - use MAGPIE with the qhex design. Find the real dimensions of the VV; Likely best to try and use 5 coils per half field period but reduce the complexity instead of reducing the number of coils (my approach); Use the real coils as a starting point. (Available in Simsopt);
  • Single Stage PM and coil optimization that builds the grid based on the found coils.
  • Include demagnetization effects in the optimization.
  • Add Ports (add what was done for Miguel's master's thesis). Likely impossible to use W7-X’s ports (there are hundreds) but at least include some dummy ports;
  • Perturb the coils and evaluate if the tolerances are reduced when compared to W7-X
  • Permanent Magnets and coil single stage;
  • Permanent Magnets for error field correction of a W7-X equilibrium;
  • Reduced W7-X coil tolerances with PMs

This is a list of research projects and associated info for Plasma Astrophysics.


Differentiable plasma fluid turbulence code

Using Python and the Phi Flow library https://github.com/tum-pbs/PhiFlow implement the 2D fluid equations (1) and (2) (at constant temperature) in https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.100.225002 to have the first differentiable turbulence code for the edge of fusion devices. Such equations regulate how much power hits the wall, one of the crucial problems in fusion right now. The goal is to aid machine design using such a code, namely the design of divertors and the scrape-off layer region.


Differentiable Kinetic Plasma Code in JAX

The JAX library (Python) allows us to run parallelized CPU and GPU simulations extremely efficiently, while retaining their differentiability, which is important for physical applications, optimization, and machine learning.

This project project aims to:

1 - Study 1D PIC simulations as this Bachelor’s thesis https://corescholar.libraries.wright.edu/etd_all/2395/ but implementing it into JAX instead of Matlab. A JAX implementation in 3D (with references) that can serve as a benchmark is here: https://github.com/SeanLim2101/PiC-Code-Jax

Example PIC code here https://github.com/pmocz/pic-python

2 - Study 1D Vlasov-Poisson simulations as in VlaPy https://joss.theoj.org/papers/10.21105/joss.02182 but using JAX, similar to what is proposed here https://www.jogar.ch/post/kinetic-plasma-physics-using-jax/

Work related to this project


JAX-Based Moment Model

Moment models allow us to evolve simplified fluid-like equations while retaining kinetic effects. This project will use JAX to speed further speed up moment-hierarchy calculations and obtain derivatives of the resulting moments to the input parameters. This may allow for a better understanding of closures and allow for dynamically change the number of moments being simulated. An initial project would be to visualize Landau damping with the Hermite-Fourier algorithm used in
https://arxiv.org/abs/2004.06484
https://arxiv.org/abs/1407.1932
The difference would be that the project would implement the linear part only (neglect non-linear part) and implement it in Python using JAX: https://jax.readthedocs.io/en/latest/


Optimization for Good Flux Surface Quality (Small Greene's Residue)

The Greene's residue https://pubs.aip.org/aip/jmp/article/20/6/1183/449401/A-method-for-determining-a-stochastic-transition has been used to improve magnetic flux surface quality in stellarators https://pubs.aip.org/aip/pop/article/29/4/042505/2843486/Stellarator-optimization-for-nested-magnetic and have a set of nested flux surfaces.

Following the initial project in https://github.com/rogeriojorge/Dommaschk_SIMSOPT we wish to optimize Dommaschk magnetic fields (Dommaschk, Comput. Phys. Commun., vol. 40, issue 2-3, 1986, pp. 203–218) to obtain input parameters with good flux surface quality.

Then, we would like to take this approach to Biot-Savart magnetic fields (from coils) and others. One way of doing this was to create a differentiable code in JAX that can compute Greene's residue and its derivatives for the input magnetic field directly.


Implicit Filtering for Noisy Stellarator Optimization

In stellarator optimization, there are important objective functions that may have large variations for a small difference in the parameters, that is, they are noisy. These may include turbulent heat flux and particle loss functions. Typical optimization methods rely on gradient descent, which goes along the direction of the derivatives. However, for noisy objective functions, this invariably leads to the optimizer being stuck in local minima far from the global minima. Using implicit filtering: https://ctk.math.ncsu.edu/iffco.html we may be able to find much better global minima. The goal would be to add implicit filtering to stellarator optimization codes, namely SIMSOPT https://github.com/hiddenSymmetries/simsopt

Axisymmetric coil winding surfaces for non-axisymmetric nuclear fusion devices

Stellarators are nuclear fusion devices that confine plasma through non-axisymmetric magnetic fields. To create such fields, we need complex and precise coils, which are hard to build and expensive. To simplify the configuration of Stellarator coils a possible method is to create coil curves bounded to a coil winding surface (CWS), with the parametrization of the curve being the sum of a secular linear term with a Fourier series. Using this method, we can study the individual optimization of coils parametrized to fixed winding surfaces. The degrees of freedom used in the optimization are the coefficient of the linear term and the Fourier coefficients of each coil parameterization equation along with the currents in each coil. This approach can be used to study the viability of using a CWS resulting from rescaling the plasma boundary surface and comparing it with using a circular toroidal CWS with the same dimensions.


Stellarator Asymmetry

Find QA, QH and QI stellarators with stellarator asymmetry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment