Skip to content

Instantly share code, notes, and snippets.

@tmiethlinger
Last active March 12, 2022 11:59
Show Gist options
  • Save tmiethlinger/a121fc1e2b025a85898d835052fc8da0 to your computer and use it in GitHub Desktop.
Save tmiethlinger/a121fc1e2b025a85898d835052fc8da0 to your computer and use it in GitHub Desktop.
Relativistic kinetic energy from Smilei output
def ekin(p_r, m_r = 1, to_MeV = True):
""" compute relativistic kinetic energy from Smilei momentum and mass
Parameters
----------
p_r : float
particle momentum in reduced units.
m_r : float, optional
particle mass in reduced units, default value is hydrogen mass.
to_MeV : bool, optional
computes energy in MeV if true, otherwise in E_r (reduced energy units).
Returns
-------
ekin
relativistic kinetic energy, float.
"""
if to_MeV:
return (gamma(p_r, m_r) - 1) * m_r * 0.51122
else:
return (gamma(p_r, m_r) - 1) * m_r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment