|
1 | | -# ESSOS |
2 | | - |
3 | | -This project is a Stellarator Coil Optimizer of alpha particles via differentiable JAX code and was developed as the research |
4 | | -work for the New Talents in Physics Fellowship, awarded by the [Calouste Gulbenkian Foundation](https://gulbenkian.pt/en/). |
5 | | - |
6 | | -## Repository Organization |
7 | | - |
8 | | -## Abstract |
9 | | -In magnetic confinement fusion, one of the most promising approaches that allows steady state |
10 | | -operation with no disruptions is the stellarator. A stellarator consists of electromagnetic coils |
11 | | -that create a twisted magnetic field that needs to be optimized to confine a high-performing |
12 | | -plasma. Such optimization is performed over a large set of parameters, typically of the order of |
13 | | -several hundred or more. Furthermore, the target magnetic field is usually a fixed one, that has |
14 | | -been previously obtained using another optimization based on the ideal MHD equations. With |
15 | | -this work, we trace particles directly in the corresponding Biot-Savart magnetic fields stemming |
16 | | -from a set of coils and optimize them to yield a small fraction of lost particles outside of the |
17 | | -confinement region. Furthermore, to replace the need for hundreds of simulations per |
18 | | -optimization step, we make use of automatic differentiation by implementing the guiding-center |
19 | | -equations, magnetic field solver, and optimization routines in JAX. This allows us to streamline |
20 | | -optimization efforts, and create a specialized, but very fast, numerical tool, to optimize force-free |
21 | | -stellarator equilibria. As force-free equilibria are usually the first step in determining the |
22 | | -viability of a device, such optimizations will be able to guide future designs based on ideal |
23 | | -MHD equilibria. |
24 | | - |
25 | | -## How to use the repository |
26 | | -After cloning the repository: |
27 | | -``` |
28 | | -git clone https://github.com/uwplasma/ESSOS.git |
29 | | -``` |
30 | | -The easiest way to run an example script is to create a conda environment. |
31 | | -To install conda run on the terminal: |
| 1 | +<p align="center"> |
| 2 | + <img src="https://raw.githubusercontent.com/uwplasma/ESSOS/refs/heads/main/docs/ESSOS_logo.png" align="center" width="30%"> |
| 3 | +</p> |
| 4 | +<p align="center"> |
| 5 | + <em><code>❯ essos: Stellarator Coil Optimizer of alpha particles via differentiable JAX code</code></em> |
| 6 | +</p> |
| 7 | +<p align="center"> |
| 8 | + <img src="https://img.shields.io/github/license/uwplasma/ESSOS?style=default&logo=opensourceinitiative&logoColor=white&color=0080ff" alt="license"> |
| 9 | + <img src="https://img.shields.io/github/last-commit/uwplasma/ESSOS?style=default&logo=git&logoColor=white&color=0080ff" alt="last-commit"> |
| 10 | + <img src="https://img.shields.io/github/languages/top/uwplasma/ESSOS?style=default&color=0080ff" alt="repo-top-language"> |
| 11 | + <a href="https://github.com/uwplasma/ESSOS/actions/workflows/build_test.yml"> |
| 12 | + <img src="https://github.com/uwplasma/ESSOS/actions/workflows/build_test.yml/badge.svg" alt="Build Status"> |
| 13 | + </a> |
| 14 | + <a href="https://codecov.io/gh/uwplasma/ESSOS"> |
| 15 | + <img src="https://codecov.io/gh/uwplasma/ESSOS/branch/main/graph/badge.svg" alt="Coverage"> |
| 16 | + </a> |
| 17 | + <a href="https://essos.readthedocs.io/en/latest/?badge=latest"> |
| 18 | + <img src="https://readthedocs.org/projects/essos/badge/?version=latest" alt="Documentation Status"> |
| 19 | + </a> |
| 20 | +</p> |
32 | 21 |
|
33 | | -``` |
34 | | -wget https://repo.anaconda.com/archive/Anaconda3-2024.06-1-Linux-x86_64.sh |
35 | | -``` |
36 | | -Or install any other version avalaible on [https://repo.anaconda.com/archive/](https://repo.anaconda.com/archive/). |
37 | | -Then Run: |
38 | | -``` |
39 | | -bash Anaconda3-2024.06-1-Linux-x86_64.sh -b -p ~/anaconda |
40 | | -rm Anaconda3-2024.06-1-Linux-x86_64.sh |
41 | | -echo 'export PATH="~/anaconda/bin:$PATH"' >> ~/.bashrc |
42 | | -``` |
43 | | -To refresh, run |
44 | | -``` |
45 | | -source .bashrc |
46 | | -``` |
47 | | -Then you can create a conda environment with |
48 | | -``` |
49 | | -conda env create -f depenencies_file.yml |
50 | | -``` |
51 | | -where "dependencies_file.yml" can be dependencies_gpu.yml or dependencies_cpu.yml, whether you want to run the scripts on CPU or GPU. |
| 22 | +## Table of Contents |
| 23 | +- [Overview](#overview) |
| 24 | +- [Features](#features) |
| 25 | +- [Project Structure](#project-structure) |
| 26 | +- [Getting Started](#getting-started) |
| 27 | + - [Prerequisites](#prerequisites) |
| 28 | + - [Installation](#installation) |
| 29 | + - [From PyPI](#from-pypi) |
| 30 | + - [From Source](#from-source) |
| 31 | +- [Usage](#usage) |
| 32 | +- [Testing](#testing) |
| 33 | +- [Project Roadmap](#project-roadmap) |
| 34 | +- [Contributing](#contributing) |
| 35 | +- [License](#license) |
| 36 | +- [Acknowledgments](#acknowledgments) |
52 | 37 |
|
| 38 | +## Overview |
| 39 | +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. 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 can be imported in a Python script using the **essos** package, or run directly in the command line as `essos`. To install it, use |
53 | 40 |
|
54 | | -## Without setting an environment,the main pip packages required are: |
55 | | -``` |
56 | | -pip install matplotlib |
57 | | -pip install simsopt |
58 | | -``` |
59 | | -For GPU enable jax use this (it requires cuda12 installation, with the corresponding nvcc, see JAX documentation for more details on this): |
60 | | -``` |
61 | | -pip install -U "jax[cuda12]"==0.4.43 |
62 | | -``` |
63 | | -For CPU only usage use instead: |
64 | | -``` |
65 | | -pip install -U jax==0.4.43 |
66 | | -``` |
67 | | -The following packages need the JAX package above |
68 | | -``` |
69 | | -pip install equinox==0.11.9 |
70 | | -pip install lineax==0.0.6 |
71 | | -pip install optimistix==0.0.8 |
72 | | -pip install diffrax==0.6.0 |
73 | | -``` |
74 | | -## Tracing particles from coils |
75 | | -An example script for tracing particles in a magnetic field generated from coils obtained |
76 | | -from a |
77 | | -``` |
78 | | -bio_savart_opt.json |
79 | | -``` |
80 | | -file of SIMSOPT can be found in the path |
81 | | -``` |
82 | | -ESSOS/examples/trace_particles_from_coils.py |
83 | | -``` |
84 | | -This can be run using the command: |
85 | | -``` |
86 | | -python trace_particles_from_coils.py |
| 41 | + ```sh |
| 42 | + pip install essos |
| 43 | + ``` |
| 44 | + |
| 45 | +Alternatively, you can install the Python dependencies and run the example scripts in the repository after downloading it as |
| 46 | + |
| 47 | + ```sh |
| 48 | + git clone https://github.com/uwplasma/ESSOS |
| 49 | + cd ESSOS |
| 50 | + pip install . |
| 51 | + python examples/trace_particles_from_coils.py |
| 52 | + ``` |
| 53 | + |
| 54 | +The project can be downloaded in its [GitHub repository](https://github.com/uwplasma/ESSOS). |
| 55 | + |
| 56 | +## Features |
| 57 | +- **JAX Integration**: Utilizes JAX for automatic differentiation and efficient numerical computations. |
| 58 | +- **Optimization**: Implements optimization routines for stellarator coil design. |
| 59 | +- **Particle Tracing**: Traces alpha particles in magnetic fields generated by coils. |
| 60 | +- **Fieldline Tracing**: Traces magnetic field lines. |
| 61 | +- **Coils and Near-Axis Fields**: Models and optimizes electromagnetic coils and near-axis magnetic fields. |
| 62 | + |
| 63 | +## Project Structure |
| 64 | +``` |
| 65 | +ESSOS/ |
| 66 | +├── essos/ |
| 67 | +│ ├── __init__.py |
| 68 | +│ ├── __main__.py |
| 69 | +│ ├── coils.py |
| 70 | +│ ├── constants.py |
| 71 | +│ ├── dynamics.py |
| 72 | +│ ├── fields.py |
| 73 | +│ ├── objective_functions.py |
| 74 | +│ ├── optimization.py |
| 75 | +│ ├── plot.py |
| 76 | +│ └── surfaces.py |
| 77 | +├── examples/ |
| 78 | +│ ├── create_stellarator_coils.py |
| 79 | +│ ├── optimize_coils_and_nearaxis.py |
| 80 | +│ ├── optimize_coils_for_nearaxis.py |
| 81 | +│ ├── optimize_coils_particle_confinement_fullorbit.py |
| 82 | +│ ├── optimize_coils_particle_confinement_guidingcenter.py |
| 83 | +│ ├── optimize_coils_vmec_surface.py |
| 84 | +│ ├── trace_fieldlines_coils.py |
| 85 | +│ ├── trace_particles_coils_fullorbit.py |
| 86 | +│ ├── trace_particles_coils_guidingcenter.py |
| 87 | +│ ├── trace_particles_vmec.py |
| 88 | +│ └── comparisons_SIMSOPT/ |
| 89 | +│ └── inputs/ |
| 90 | +│ ├── ESSOS_bio_savart_LandremanPaulQA.json |
| 91 | +│ ├── SIMSOPT_bio_savart_LandremanPaulQA.json |
| 92 | +│ ├── wout_n3are_R7.75B5.7.nc |
| 93 | +│ └── wout_LandremanPaul2021_QA_reactorScale_lowres_reference.nc |
| 94 | +├── tests/ |
| 95 | +│ ├── test_coils.py |
| 96 | +│ ├── test_constants.py |
| 97 | +│ ├── test_dynamics.py |
| 98 | +│ ├── test_fields.py |
| 99 | +├── README.md |
| 100 | +├── LICENSE.md |
| 101 | +├── CODE_OF_CONDUCT.md |
| 102 | +├── CONTRIBUTING.md |
| 103 | +├── setup.py |
| 104 | +├── pyproject.toml |
| 105 | +└── requirements.txt |
87 | 106 | ``` |
88 | | -More details on how to change the different aprameters can be seen inside the script |
| 107 | + |
| 108 | +## Getting Started |
| 109 | + |
| 110 | +### Prerequisites |
| 111 | +- Python 3.8 or higher |
| 112 | + |
| 113 | +### Installation |
| 114 | + |
| 115 | +#### From PyPI |
| 116 | +To install ESSOS from PyPI, run: |
| 117 | +```sh |
| 118 | +pip install essos |
89 | 119 | ``` |
90 | | -trace_particles_from_coils.py |
| 120 | + |
| 121 | +#### From Source |
| 122 | +To install ESSOS from source, clone the repository and install the package: |
| 123 | +```sh |
| 124 | +git clone https://github.com/uwplasma/ESSOS |
| 125 | +cd ESSOS |
| 126 | +pip install . |
91 | 127 | ``` |
92 | | -The bio_savart_opt.json can be found inside the folder ESSOS/examples/inputs and represents a coils set obtained from |
93 | | -a SIMSOPT two-stage coils optimisation using the VMEC configuration represented by the file |
| 128 | + |
| 129 | +## Usage |
| 130 | +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: |
| 131 | +```sh |
| 132 | +python examples/trace_particles_coils_guidingcenter.py |
94 | 133 | ``` |
95 | | -ESSOS/examples/inputs/wout_LandremanPaul2021_QA_reactorScale_lowres_reference.nc |
| 134 | + |
| 135 | +## Testing |
| 136 | +To run the tests, use `pytest`: |
| 137 | +```sh |
| 138 | +pytest . |
96 | 139 | ``` |
97 | 140 |
|
98 | | -## Copyright |
| 141 | +## Project Roadmap |
| 142 | +- [ ] Allow several optimization algorithms |
| 143 | +- [ ] Allow plotly and/or Mayavi visualization |
| 144 | +- [ ] Add DESC and SPEC equilibria for tracing |
| 145 | +- [ ] Add beam injection examples |
| 146 | +- [ ] Add plotting for near-axis expansion |
| 147 | +- [ ] Add particle collisions |
| 148 | + |
| 149 | +## Contributing |
| 150 | +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. |
| 151 | + |
| 152 | +- **💬 [Join the Discussions](https://github.com/uwplasma/ESSOS/discussions)**: Share your insights, provide feedback, or ask questions. |
| 153 | +- **🐛 [Report Issues](https://github.com/uwplasma/ESSOS/issues)**: Submit bugs found or log feature requests for the `ESSOS` project. |
| 154 | +- **💡 [Submit Pull Requests](https://github.com/uwplasma/ESSOS/blob/main/CONTRIBUTING.md)**: Review open PRs, and submit your own PRs. |
| 155 | + |
| 156 | +<details closed> |
| 157 | +<summary>Contributing Guidelines</summary> |
| 158 | + |
| 159 | +1. **Fork the Repository**: Start by forking the project repository to your github account. |
| 160 | +2. **Clone Locally**: Clone the forked repository to your local machine using a git client. |
| 161 | + ```sh |
| 162 | + git clone https://github.com/uwplasma/ESSOS |
| 163 | + ``` |
| 164 | +3. **Create a New Branch**: Always work on a new branch, giving it a descriptive name. |
| 165 | + ```sh |
| 166 | + git checkout -b new-feature-x |
| 167 | + ``` |
| 168 | +4. **Make Your Changes**: Develop and test your changes locally. |
| 169 | +5. **Commit Your Changes**: Commit with a clear message describing your updates. |
| 170 | + ```sh |
| 171 | + git commit -m 'Implemented new feature x.' |
| 172 | + ``` |
| 173 | +6. **Push to github**: Push the changes to your forked repository. |
| 174 | + ```sh |
| 175 | + git push origin new-feature-x |
| 176 | + ``` |
| 177 | +7. **Submit a Pull Request**: Create a PR against the original project repository. Clearly describe the changes and their motivations. |
| 178 | +8. **Review**: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution! |
| 179 | +</details> |
| 180 | + |
| 181 | +<details closed> |
| 182 | +<summary>Contributor Graph</summary> |
| 183 | +<br> |
| 184 | +<p align="left"> |
| 185 | + <a href="https://github.com{/uwplasma/ESSOS/}graphs/contributors"> |
| 186 | + <img src="https://contrib.rocks/image?repo=uwplasma/ESSOS"> |
| 187 | + </a> |
| 188 | +</p> |
| 189 | +</details> |
| 190 | + |
| 191 | +--- |
| 192 | + |
| 193 | +## License |
| 194 | + |
| 195 | +This project is protected under the MIT License. For more details, refer to the [LICENSE](LICENSE) file. |
| 196 | + |
| 197 | +--- |
| 198 | + |
| 199 | +## Acknowledgments |
| 200 | + |
| 201 | +- This project was developed as part of the New Talents in Physics Fellowship, awarded by the [Calouste Gulbenkian Foundation](https://gulbenkian.pt/en/). |
| 202 | +- We acknowledge the help of the whole [UWPlasma](https://rogerio.physics.wisc.edu/) plasma group. |
| 203 | + |
| 204 | +--- |
99 | 205 |
|
100 | | -By Estêvão Gomes ([@EstevaoMGomes](https://github.com/EstevaoMGomes)). |
101 | | -Developed under the supervision of professor Rogério Jorge ([@rogeriojorge](https://github.com/rogeriojorge)). |
|
0 commit comments