Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add beam eigenemittances to reduced diagnostics. #702

Merged
merged 54 commits into from
Oct 10, 2024

Conversation

cemitch99
Copy link
Member

@cemitch99 cemitch99 commented Sep 13, 2024

This PR adds calculation of the 3 eigenemittances (or mode emittances) of the 6D beam distribution from particle data as an additional reduced diagnostic. Addresses Issue #663.

  • implement auxiliary math routines needed to evaluate the characteristic polynomial and find its roots
  • implement calculation of eigenemittances from a covariance matrix
  • add additional required moment calculations in ReducedBeamCharacteristics.cpp
    • skip eigenemittance columns from CSV output if not enabled
    • add normalized emittance independently (always)
  • make reduced diagnostic calculation optional, and add print to output
  • add numerical benchmark example
  • add ParmParse statement to enable/disable calculation
  • check numerical precision for special degenerate cases (zero discriminant)
  • add documentation
    • document user-facing inputs/python control
  • fix pytest using test_transformation.py
  • add liteature citations

Comment benchmarking call to Eigenemittance to avoid unused variable errors.
@cemitch99
Copy link
Member Author

This works, but suffers a loss of precision in certain cases (eg, uncoupled beams with et << ex = ey) due to the appearance of a small discriminant in Cardano's formula. A fix for this is under investigation.

Some tests failing for unrelated reasons due to pytest.

Copy link
Member

@ax3l ax3l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!!

I took a quick first look and added first inline suggestions. More thorough tomorrow :)

src/particles/diagnostics/CovarianceMatrixMath.H Outdated Show resolved Hide resolved
src/particles/diagnostics/CovarianceMatrixMath.H Outdated Show resolved Hide resolved
src/particles/diagnostics/CovarianceMatrixMath.H Outdated Show resolved Hide resolved
src/particles/diagnostics/EmittanceInvariants.H Outdated Show resolved Hide resolved
src/particles/diagnostics/EmittanceInvariants.cpp Outdated Show resolved Hide resolved
src/particles/diagnostics/EmittanceInvariants.cpp Outdated Show resolved Hide resolved
examples/coupled_optics/README.rst Outdated Show resolved Hide resolved
cemitch99 and others added 4 commits September 25, 2024 17:24
Use math functions from std::  (sqrt, pow, sin, cos, etc) -> (std::sqrt, std::pow, std::sin, std::cos, etc).
Remove std::math for complex functions.
Copy link
Member

@ax3l ax3l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

examples/CMakeLists.txt Outdated Show resolved Hide resolved
src/particles/diagnostics/CovarianceMatrixMath.H Outdated Show resolved Hide resolved
src/particles/diagnostics/CovarianceMatrixMath.H Outdated Show resolved Hide resolved
src/particles/diagnostics/CovarianceMatrixMath.H Outdated Show resolved Hide resolved
src/particles/diagnostics/EmittanceInvariants.cpp Outdated Show resolved Hide resolved
src/particles/diagnostics/EmittanceInvariants.cpp Fixed Show resolved Hide resolved
src/particles/diagnostics/EmittanceInvariants.H Outdated Show resolved Hide resolved
src/particles/diagnostics/EmittanceInvariants.cpp Outdated Show resolved Hide resolved
tests/python/test_transformation.py Outdated Show resolved Hide resolved
Copy link
Member

@ax3l ax3l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid copies of matrices

ax3l pushed a commit to AMReX-Codes/amrex that referenced this pull request Oct 3, 2024
Add amrex::SmallMatrix class with compile time size.

Useful for, e.g.:
- ECP-WarpX/impactx#714
- ECP-WarpX/impactx#702
cemitch99 and others added 2 commits October 8, 2024 11:43
Update treatment of warnings.
Changes to test_transformation.py were not intentional.  These were reversed per code review.

Co-authored-by: Axel Huebl <[email protected]>
Copy link
Member

@ax3l ax3l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, that looks great!

@ax3l ax3l enabled auto-merge (squash) October 10, 2024 04:10
@ax3l ax3l merged commit 035ea82 into ECP-WarpX:development Oct 10, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: diagnostics all types of outputs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants