# pyAQSC
This code constructs globally quasi-symmetric stellarator equilibria with
anisotropic pressure near axis expansion to any order.

## Dependencies
The python codes requires Numpy, Matplotlib, and JAX.

The Maxima notebooks requires wxMaxima to view. The notebooks are not required to
run the main code, but contains source expressions much of code is parsed from.


## Repository structure and files
```
├── README.MD
├── test_data_eduardo/              -> Known leading order terms for some equilibria.
├── docs/                           -> Documentations
├── dist/                           -> Built python package
├── examples/                       -> Jupyter notebooks with use cases for the code.
├── magnetic_recursion_relations/   -> Maxima notebooks for iterating the
│   │                                  magnetic equations
│   ├── <Quantity name>.wxmx        -> Maxima notebooks for the recursion relations.
│   └── general_formulae/           -> Maxima notebooks directly expanding
│                                      the governing equations. for reference only.
├── MHD_recursion_relations/        -> Maxima notebooks for iterating the
│   │                                  magnetic and force balance equations
│   ├── looped.lisp                 -> Variables associated with the "looped equation"[2].
│   │                                  see Looped.wxmx and Looped study simplified.wxmx
│   │                                  see for details.
│   ├── <Quantity name>.wxmx        -> ...
│   └── general_formulae/           -> ...
│                                  
├── maxima_scripts/                 -> Maxima libraries
│   ├── near_axis_expansion.mac     -> Stores the governing equations and
│   │                                  variable dependencies.
│   ├── power_mode_matching/        -> A standalone, symbolic infinite/finite
│   │   │                              power/Fourier series order/mode matcher.
│   │   ├── power_matching.mac      -> The power series order matcher
│   │   └── trig_fourier_or... .mac -> The Fourier series mode matcher
│   ├── python_parser.mac           -> A code translating maxima summations
│   │                                  to python codes. Works with
│   │                                  python_source/math_utilities.py
│   ├── sbatch_maxima.mac           -> A code generating slurm jobscripts for
│   │                                  evaluating maxima expressions in parallel
│   └── test_cases/                 -> Test cases for Maxima scripts.
└── src/aqsc/                       -> Python source for the main code.
    ├── __init__.py                 
    ├── config.py                   -> Configurations. (numerical, run-time, ...)
    ├── equilibrium.py              -> Contains the Equilibrium object that manages
    │                                  the iteration of an equilibrium represented
    │                                  by near axis expansion. Also contains wrappers
    │                                  for methods in parsed/ and MHD_parsed/.
    ├── chiphiepsfunc.py            -> A list-like data structure for storing power coeffs.
    ├── chiphifunc.py               -> A data structure representing f(chi,phi)
    │                                  as chi Fourier coeffs on phi grids, implementation
    │                                  for operators, and some solvers/utilities.
    ├── chiphifunc_test_suite.py    -> Useful functions for testing and plotting.
    ├── math_utilities.py           -> More numerical operations needed to run
    │                                  python methods in python_source/parsed/
    ├── looped_solver.py            -> Solver for the "looped equations" [2, 3]
    ├── parsed/                     -> Parsed expressions for the magnetic-only
    │                                  recursion relations [1]. All generated by notebooks
    ├── looped_coefs/               -> Coefficients in the looped equations.
    └── MHD_parsed/                 -> Parsed expressions for the full (magnetic and
                                               force balance) recursion relations [2]. All
                                               generated by notebooks in MHD_recursion_relations/

```

## References
1. [Weakly Quasisymmetric Near-Axis Solutions to all Orders](https://doi.org/10.1063/5.0076583)
2. [Solving the problem of overdetermination of quasisymmetric equilibrium solutions by near-axis expansions. I. Generalized force balance](https://doi.org/10.1063/5.0027574)
3. [Solving the problem of overdetermination of quasisymmetric equilibrium solutions by near-axis expansions. II. Circular axis stellarator solutions](https://aip.scitation.org/doi/10.1063/5.0027575)
4. [pyQSC](https://github.com/landreman/pyQSC)
