|
| 1 | +.. _examples-ml-surrogate: |
| 2 | + |
| 3 | +9 Stage Laser-Plasma Accelerator Surrogate |
| 4 | +========================================== |
| 5 | + |
| 6 | +This example models an electron beam accelerated through nine stages of laser-plasma accelerators with ideal plasma lenses providing the focusing between stages. |
| 7 | +For more details, see: |
| 8 | + |
| 9 | + |
| 10 | +- Sandberg R T, Lehe R, Mitchell C E, Garten M, Qiang J, Vay J-L and Huebl A. |
| 11 | + **Synthesizing Particle-in-Cell Simulations Through Learning and GPU Computing for Hybrid Particle Accelerator Beamlines**. |
| 12 | + Proc. of Platform for Advanced Scientific Computing (PASC'24), *submitted*, 2024. |
| 13 | +- Sandberg R T, Lehe R, Mitchell C E, Garten M, Qiang J, Vay J-L and Huebl A. |
| 14 | + **Hybrid Beamline Element ML-Training for Surrogates in the ImpactX Beam-Dynamics Code**. |
| 15 | + 14th International Particle Accelerator Conference (IPAC'23), WEPA101, 2023. |
| 16 | + `DOI:10.18429/JACoW-IPAC2023-WEPA101 <https://doi.org/10.18429/JACoW-IPAC2023-WEPA101>`__ |
| 17 | + |
| 18 | +A schematic with more information can be seen in the figure below: |
| 19 | + |
| 20 | +.. figure:: https://user-images.githubusercontent.com/10621396/289956389-c7463b99-fb56-490a-8511-22c43f45cdf8.png |
| 21 | + :alt: [fig:lpa_schematic] Schematic of the 9 stages of laser-plasma accelerators. |
| 22 | + |
| 23 | + [fig:lpa_schematic] Schematic of the 9 stages of laser-plasma accelerators. |
| 24 | + |
| 25 | +The laser-plasma accelerator elements are modeled with neural network surrogates, |
| 26 | +previously trained and included in ``models``. |
| 27 | +The neural networks require normalized input data; the normalizations can be found in ``datasets``. |
| 28 | + |
| 29 | +We use a 1 GeV electron beam with initial normalized rms emittance of 1 mm-mrad. |
| 30 | + |
| 31 | +In this test, the initial and final values of :math:`\sigma_x`, :math:`\sigma_y`, :math:`\sigma_t`, :math:`\epsilon_x`, :math:`\epsilon_y`, and :math:`\epsilon_t` must agree with nominal values. |
| 32 | + |
| 33 | +Run |
| 34 | +--- |
| 35 | + |
| 36 | +This example can be **only** be run with **Python**: |
| 37 | + |
| 38 | +* **Python** script: ``python3 run_ml_surrogate.py`` |
| 39 | + |
| 40 | +For `MPI-parallel <https://www.mpi-forum.org>`__ runs, prefix these lines with ``mpiexec -n 4 ...`` or ``srun -n 4 ...``, depending on the system. |
| 41 | + |
| 42 | +.. literalinclude:: run_ml_surrogate.py |
| 43 | + :language: python |
| 44 | + :caption: You can copy this file from ``examples/pytorch_surrogate_model/run_ml_surrogate.py``. |
| 45 | + |
| 46 | +Analyze |
| 47 | +------- |
| 48 | + |
| 49 | +We run the following script to analyze correctness: |
| 50 | + |
| 51 | +.. dropdown:: Script ``analyze_ml_surrogate.py`` |
| 52 | + |
| 53 | + .. literalinclude:: analyze_ml_surrogate.py |
| 54 | + :language: python |
| 55 | + :caption: You can copy this file from ``examples/pytorch_surrogate_model/analyze_ml_surrogate.py``. |
| 56 | + |
| 57 | +Visualize |
| 58 | +--------- |
| 59 | + |
| 60 | +You can run the following script to visualize the beam evolution over time: |
| 61 | + |
| 62 | +.. dropdown:: Script ``visualize_ml_surrogate.py`` |
| 63 | + |
| 64 | + .. literalinclude:: visualize_ml_surrogate.py |
| 65 | + :language: python |
| 66 | + :caption: You can copy this file from ``examples/pytorch_surrogate_model/visualize_ml_surrogate.py``. |
| 67 | + |
| 68 | +.. figure:: https://user-images.githubusercontent.com/10621396/289976300-6f861d19-5a5c-42eb-9435-9f57bd2010bf.png |
| 69 | + :alt: Evolution of beam moments through 9 stage LPA via neural network surrogates. |
| 70 | + |
| 71 | + Evolution of electron beam moments through 9 stages of LPAs (via neural network surrogates). |
| 72 | + |
| 73 | +.. figure:: https://user-images.githubusercontent.com/10621396/289956805-49e0a94a-454f-4b48-b448-7ac772edf95a.png |
| 74 | + :alt: Initial phase space projections |
| 75 | + |
| 76 | + Initial phase space projections going into 9 stage LPA (via neural network surrogates) simulation. Top row: spatial projections, middle row: momentum projections, bottom row: phase spaces. |
| 77 | + |
| 78 | +.. figure:: https://user-images.githubusercontent.com/10621396/289975961-7d389864-9106-4446-8556-b0ea4bb28145.png |
| 79 | + :alt: Final phase space projections after 9 stage LPA (via neural network surrogates) simulation |
| 80 | + |
| 81 | + Final phase space projections after 9 stage LPA (via neural network surrogates) simulation. Top row: spatial projections, middle row: momentum projections, bottom row: phase spaces. |
0 commit comments