❯ ESSOS: e-Stellarator Simulation and Optimization Suite
- Overview
- Features
- Project Structure
- Getting Started
- Usage
- Testing
- Project Roadmap
- Contributing
- License
- Acknowledgments
ESSOS is an open-source project in Python that uses JAX to optimize stellarator coils. Optimization can be applied to several objectives, such as alpha particle confinement, plasma boundaries and magnetic field equilibria (including near-axis expansions). It leverages automatic differentiation and efficient numerical methods to streamline optimization efforts, creating a specialized and fast numerical tool for optimizing force-free stellarator equilibria. It is parallelized using JAX's sharding tools. It can be imported in a Python script using the essos package, or run directly in the command line as essos. To install it, use
pip install essosAlternatively, you can download it and run the example scripts in the repository after downloading it as
git clone https://github.com/uwplasma/ESSOS
cd ESSOS
pip install .
python examples/trace_particles_from_coils.pyThe project can be downloaded in its GitHub repository.
- JAX Integration: Utilizes JAX for automatic differentiation and efficient numerical computations.
- Optimization: Implements optimization routines for stellarator coil design.
- Particle Tracing: Traces alpha particles in magnetic fields generated by coils.
- Fieldline Tracing: Traces magnetic field lines.
- Coils and Near-Axis Fields: Models and optimizes electromagnetic coils and near-axis magnetic fields.
- Stellarator Surfaces: Representation of toroidal surfaces using a spectral Fourier decomposition.
ESSOS/
├── essos/
│ ├── __init__.py
│ ├── __main__.py
│ ├── coils.py
│ ├── constants.py
│ ├── dynamics.py
│ ├── fields.py
│ ├── objective_functions.py
│ ├── optimization.py
│ ├── plot.py
│ └── surfaces.py
├── examples/
│ ├── create_stellarator_coils.py
│ ├── optimize_coils_and_nearaxis.py
│ ├── optimize_coils_for_nearaxis.py
│ ├── optimize_coils_particle_confinement_fullorbit.py
│ ├── optimize_coils_particle_confinement_guidingcenter.py
│ ├── optimize_coils_vmec_surface.py
│ ├── trace_fieldlines_coils.py
│ ├── trace_particles_coils_fullorbit.py
│ ├── trace_particles_coils_guidingcenter.py
│ ├── trace_particles_vmec.py
│ └── comparisons_SIMSOPT/
│ └── inputs/
│ ├── ESSOS_bio_savart_LandremanPaulQA.json
│ ├── SIMSOPT_bio_savart_LandremanPaulQA.json
│ ├── wout_n3are_R7.75B5.7.nc
│ └── wout_LandremanPaul2021_QA_reactorScale_lowres.nc
├── tests/
│ ├── test_coils.py
│ ├── test_constants.py
│ ├── test_dynamics.py
│ ├── test_fields.py
├── README.md
├── LICENSE.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── setup.py
├── pyproject.toml
└── requirements.txt
- Python 3.8 or higher
To install ESSOS from PyPI, run:
pip install essosTo install ESSOS from source, clone the repository and install the package:
git clone https://github.com/uwplasma/ESSOS
cd ESSOS
pip install .ESSOS can be run directly in the command line as essos, or by following one of the examples in the examples folder. For example, to trace particles in a magnetic field generated from coils, run:
python examples/trace_particles_coils_guidingcenter.pyVMEC guiding-center trajectories use flux coordinates (s, theta, phi, ...),
where s is normalized toroidal flux. The poloidal angle is not defined on the
magnetic axis, and continuing the VMEC representation to negative s can make a
trace stiff or non-finite. ESSOS therefore stops a VMEC guiding-center trace when
s <= axis_threshold (default 1e-6) and records that numerical termination
separately from a loss at s >= 1:
tracing = Tracing(
field=vmec,
model="GuidingCenterAdaptative",
particles=particles,
axis_threshold=1e-6,
)
print(tracing.axis_hits) # one boolean per particle
print(tracing.boundary_hits) # LCFS termination mask
print(tracing.total_particles_unresolved) # number of axis terminationsPost-event output slots for axis-terminated trajectories are filled with the
last finite in-domain saved state so plotting and diagnostics do not receive
Diffrax's inf padding or a saved state beyond the axis threshold. Axis
terminations are not counted as particle losses. This
safeguard is applied to fixed- and adaptive-step VMEC guiding-center models,
including the collision/SDE variants. It is not applied to full-orbit/Boris
models or coil-field traces, whose positions are Cartesian and can cross the
physical magnetic axis without this flux-coordinate singularity. Supplying a
custom condition replaces the automatic VMEC axis and boundary events.
This is a numerical safeguard, not a physical continuation through the axis. A trajectory that must continue across the axis requires a regular coordinate chart (for example, pseudo-Cartesian flux coordinates) or a Cartesian/full-orbit handoff.
To run the tests, use pytest:
pytest .- Allow several optimization algorithms
- Allow plotly and/or Mayavi visualization
- Add DESC and SPEC equilibria for tracing
- Add beam injection examples
- Add plotting for near-axis expansion
- Add particle collisions
Contributions are welcome! Please fork the repository and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.
- 💬 Join the Discussions: Share your insights, provide feedback, or ask questions.
- 🐛 Report Issues: Submit bugs found or log feature requests for the
ESSOSproject. - 💡 Submit Pull Requests: Review open PRs, and submit your own PRs.
Contributing Guidelines
- Fork the Repository: Start by forking the project repository to your github account.
- Clone Locally: Clone the forked repository to your local machine using a git client.
git clone https://github.com/uwplasma/ESSOS
- Create a New Branch: Always work on a new branch, giving it a descriptive name.
git checkout -b new-feature-x
- Make Your Changes: Develop and test your changes locally.
- Commit Your Changes: Commit with a clear message describing your updates.
git commit -m 'Implemented new feature x.' - Push to github: Push the changes to your forked repository.
git push origin new-feature-x
- Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
- Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
This project is protected under the MIT License. For more details, refer to the LICENSE file.
- This project was developed as part of the New Talents in Physics Fellowship, awarded by the Calouste Gulbenkian Foundation.
- We acknowledge the help of the whole UWPlasma plasma group.
