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 correlated energy spread #446

Merged
merged 5 commits into from
Mar 29, 2021
Merged

Conversation

SeverinDiederichs
Copy link
Member

@SeverinDiederichs SeverinDiederichs commented Mar 28, 2021

This PR adds the possibility to add a chirp to the beam.

The relative correlated energy spread beam_name.duz_per_uz0_dzeta adds duz_per_uz0_dzeta * z * uz_mean to uz of the beam. z is hereby the relative longitudinal position w.r.t. the mean longitudinal position of the beam.

  • Small enough (< few 100s of lines), otherwise it should probably be split into smaller PRs
  • Tested (describe the tests in the PR description)
  • Runs on GPU (basic: the code compiles and run well with the new module)
  • Contains an automated test (checksum and/or comparison with theory)
  • Documented: all elements (classes and their members, functions, namespaces, etc.) are documented
  • Constified (All that can be const is const)
  • Code is clean (no unwanted comments, )
  • Style and code conventions are respected at the bottom of https://github.com/Hi-PACE/hipace
  • Proper label and GitHub project, if applicable

Copy link
Member

@MaxThevenet MaxThevenet left a comment

Choose a reason for hiding this comment

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

Thanks for this PR! See comment.

Comment on lines 36 to 54
/** \brief Get the momentum for a beam particle
* \param[in,out] ux momentum in x, modified by this function
* \param[in,out] uy momentum in y, modified by this function
* \param[in,out] uz momentum in z, modified by this function
* \param[in] z position in z
* \param[in] duz_per_uz0_dzeta correlated energy spread
*/
void operator() (amrex::Real& ux, amrex::Real& uy, amrex::Real& uz, const amrex::Real z,
const amrex::Real duz_per_uz0_dzeta) const
{
amrex::Real u[3] = {ux,uy,uz};
if (m_momentum_profile == BeamMomentumType::Gaussian){
ParticleUtil::get_gaussian_random_momentum(u, m_u_mean, m_u_std);
}
ux = u[0];
uy = u[1];
uz = u[2] + z*duz_per_uz0_dzeta*m_u_mean[2];
}

Copy link
Member

Choose a reason for hiding this comment

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

Could we try using default values instead of duplicating (copy-paste) the whole function? For instance, could we just replace the function prototype

    void operator() (amrex::Real& ux, amrex::Real& uy, amrex::Real& uz) const

by

    void operator() (amrex::Real& ux, amrex::Real& uy, amrex::Real& uz, const amrex::Real z=0.,
                      const amrex::Real duz_per_uz0_dzeta=0.) const

?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. Thanks for the suggestion!

@MaxThevenet MaxThevenet merged commit 744d750 into development Mar 29, 2021
@MaxThevenet MaxThevenet deleted the add_correlated_energy_spread branch March 29, 2021 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants