How to use the hepunits.units.MeV function in hepunits

To help you get started, we’ve selected a few hepunits examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scikit-hep / particle / tests / particle / test_kinematics.py View on Github external
def test_valid_width_lifetime_conversions():
    assert lifetime_to_width(1.5 * ps) / GeV == approx(4.388079676311604e-13)
    assert 1.5 * ps * lifetime_to_width(1.5 * ps) == hbar
    assert width_to_lifetime(hbar) == 1 * MeV
github scikit-hep / scikit-hep / skhep / math / kinematics.py View on Github external
Parameters
    ----------
    Gamma : float > 0
        Particle decay width, typically in MeV (any HEP energy unit is OK).

    Returns
    -------
    Particle lifetime, in the HEP standard time unit ns.
    """

    if Gamma <= 0.:
        raise ValueError( 'Input provided, %s <= 0!'.format(Gamma) )

    # Just need to first make sure that the width is in the standard unit MeV
    return hbar / float(Gamma / MeV)
github scikit-hep / particle / src / particle / particle / kinematics.py View on Github external
0.001520119980246514
    >>>
    >>> width_to_lifetime(4.33e-4*eV)   # result again returned in ns
    0.001520119980246514
    >>>
    >>> width_to_lifetime(4.33e-10*MeV)/ps   # result converted to ps
    1.520119980246514
    """

    if Gamma < 0.0:
        raise ValueError("Input provided, {0} <= 0!".format(Gamma))
    elif Gamma == 0:
        return float("inf")

    # Just need to first make sure that the width is in the standard unit MeV
    return hbar / float(Gamma / MeV)

hepunits

Units and constants in the HEP system of units

BSD-3-Clause
Latest version published 2 months ago

Package Health Score

72 / 100
Full package analysis

Similar packages