-
Notifications
You must be signed in to change notification settings - Fork 17
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
Conversation
There was a problem hiding this 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.
/** \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]; | ||
} | ||
|
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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!
This PR adds the possibility to add a chirp to the beam.
The relative correlated energy spread
beam_name.duz_per_uz0_dzeta
addsduz_per_uz0_dzeta * z * uz_mean
touz
of the beam.z
is hereby the relative longitudinal position w.r.t. the mean longitudinal position of the beam.const
isconst
)