-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [Draft] Transport and Covariance Matrices General structure. Co-authored-by: Chad Mitchell <[email protected]> * Update InitElement.cpp Update initialization of LinearMap element. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update LinearMap.H Finish implementation of LinearMap element push. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update InitDistribution.cpp Initialize covariance matrix from distribution parameters. * Add Drift return linear map. * Use LinearMap struct in Drift.H. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Transport/Covariane: Use `SmallMatrix` * Add Python bindings for LinearMap element. * Update elements.cpp Remove unnecessary ,. * Update elements.cpp Correct naming in elements.cpp binding for LinearMap. * Update elements.cpp Correct argument declaration for Python bindings of LinearMap in elements.cpp. * Add LinearMap to 'Named' elements. * Update LinearMap.H Document "Name" parameter in LinearMap. * Modify LinearMap Python bindings. * Update src/initialization/InitDistribution.cpp * Update src/initialization/InitDistribution.cpp * Update InitDistribution.cpp Modify zero-initialization of CovarianceMatrix cv. * Leftover Improvements from first PR * Finalize Python * More Detailed Warning Include element name in output to user. * Start Examples * Start Documentation * Fix Bugs (incl. AMReX) Use parser for inputs. Needs upstream AMReX fix. * Docs Updates * `LinearMap`: `ds` bookkeeping And reference particle pushing (drifting), if thick. * Add thin linear map example. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Document example README. * Update run_map.py Add twiss * Update run_map.py Correct name of Rmat/R. * Update run_map.py Fix naming of R again. * Update input_map.in Fix number of periods. * Apply suggestions from code review Co-authored-by: Chad Mitchell <[email protected]> * Add docs for matrix elements. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Doc Updates * Generalize CMake Args for inputs Taken over from generalized version we merged to WarpX. * Add symplectic warning in app element documentation. * Add symplectic warning in Python element documentation. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Remove runtime warning. * Add support for nonzero ds to app input. * Update examples/CMakeLists.txt * FODO Analysis: Check s and gamma * __repr__: no select entries --------- Co-authored-by: Axel Huebl <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
350565b
commit 5638dfd
Showing
24 changed files
with
1,173 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
.. _examples-fodo-userdef: | ||
|
||
User-Defined Linear Element | ||
=========================== | ||
|
||
This implements the same FODO cell as the :ref:`stable FODO cell example <examples-fodo>`. | ||
However, in the example here we define *additional user-defined, custom linear elements* by providing a custom matrix. | ||
|
||
.. note:: | ||
|
||
Note that generally, if a user-provided linear map is used, the beam transport may not be symplectic. | ||
For an even more general, user-defined element, see :ref:`the FODO Cell example that uses a Programmable Element <examples-fodo-programmable>`. | ||
For more details, see :ref:`this section <usage-workflows-add-element>`. | ||
|
||
The matched Twiss parameters at entry are: | ||
|
||
* :math:`\beta_\mathrm{x} = 2.82161941` m | ||
* :math:`\alpha_\mathrm{x} = -1.59050035` | ||
* :math:`\beta_\mathrm{y} = 2.82161941` m | ||
* :math:`\alpha_\mathrm{y} = 1.59050035` | ||
|
||
We use a 2 GeV electron beam with initial unnormalized rms emittance of 2 nm. | ||
|
||
The second moments of the particle distribution after the FODO cell should coincide with the second moments of the particle distribution before the FODO cell, to within the level expected due to noise due to statistical sampling. | ||
|
||
In this test, the initial and final values of :math:`\lambda_x`, :math:`\lambda_y`, :math:`\lambda_t`, :math:`\epsilon_x`, :math:`\epsilon_y`, and :math:`\epsilon_t` must agree with nominal values. | ||
|
||
|
||
Run | ||
--- | ||
|
||
This example can be run **either** as: | ||
|
||
* **Python** script: ``python3 run_fodo_userdef.py`` or | ||
* ImpactX **executable** using an input file: ``impactx input_fodo_userdef.in`` | ||
|
||
For `MPI-parallel <https://www.mpi-forum.org>`__ runs, prefix these lines with ``mpiexec -n 4 ...`` or ``srun -n 4 ...``, depending on the system. | ||
|
||
.. tab-set:: | ||
|
||
.. tab-item:: Python: Script | ||
|
||
.. literalinclude:: run_fodo_userdef.py | ||
:language: python3 | ||
:caption: You can copy this file from ``examples/fodo_userdef/run_fodo_userdef.py``. | ||
|
||
.. tab-item:: Executable: Input File | ||
|
||
.. literalinclude:: input_fodo_userdef.in | ||
:language: ini | ||
:caption: You can copy this file from ``examples/fodo_userdef/input_fodo_userdef.in``. | ||
|
||
|
||
Analyze | ||
------- | ||
|
||
We run the following script to analyze correctness: | ||
|
||
.. dropdown:: Script ``analysis_fodo.py`` | ||
|
||
.. literalinclude:: analysis_fodo.py | ||
:language: python3 | ||
:caption: You can copy this file from ``examples/fodo_userdef/analysis_fodo.py``. | ||
|
||
|
||
Visualize | ||
--------- | ||
|
||
You can run the following script to visualize the beam evolution over time: | ||
|
||
.. dropdown:: Script ``plot_fodo.py`` | ||
|
||
.. literalinclude:: plot_fodo.py | ||
:language: python3 | ||
:caption: You can copy this file from ``examples/fodo_userdef/plot_fodo.py``. | ||
|
||
.. figure:: https://user-images.githubusercontent.com/1353258/180287840-8561f6fd-278f-4856-abd8-04fbdb78c8ff.png | ||
:alt: focusing, defocusing and preserved emittance in our FODO cell benchmark. | ||
|
||
FODO transversal beam width and emittance evolution | ||
|
||
.. figure:: https://user-images.githubusercontent.com/1353258/180287845-eb0210a7-2500-4aa9-844c-67fb094329d3.png | ||
:alt: focusing, defocusing and phase space rotation in our FODO cell benchmark. | ||
|
||
FODO transversal beam width and phase space evolution |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../fodo/analysis_fodo.py |
Oops, something went wrong.