示例#1
0
def test_mass_function():

    # Mass function
    # RHS of Eqn. 8.34 in Lorimer & Kramer (2008)
    # this should be 4* pi**2 * x**3 / (G * Pb**2)
    # in appropriate units
    assert np.isclose(mass_funct(1.0 * u.d, 2.0 * pint.ls),
                      0.008589595519643776 * u.solMass)
示例#2
0
def test_psr_utils():

    from pint.utils import (
        mass_funct,
        mass_funct2,
        pulsar_mass,
        companion_mass,
        pulsar_age,
        pulsar_edot,
        pulsar_B,
        pulsar_B_lightcyl,
    )

    pb = 1.0 * u.d
    x = 2.0 * pint.ls

    # Mass function
    assert np.isclose(mass_funct(pb, x), 0.008589595519643776 * u.solMass)

    # Mass function, second form
    assert np.isclose(
        mass_funct2(1.4 * u.solMass, 0.2 * u.solMass, 60.0 * u.deg),
        0.0020297470401197783 * u.solMass,
    )

    # Characteristic age
    assert np.isclose(
        pulsar_age(0.033 * u.Hz, -2.0e-15 * u.Hz / u.s), 261426.72446573884 * u.yr
    )

    # Edot
    assert np.isclose(
        pulsar_edot(0.033 * u.Hz, -2.0e-15 * u.Hz / u.s),
        2.6055755618875905e30 * u.erg / u.s,
    )

    # B
    assert np.isclose(
        pulsar_B(0.033 * u.Hz, -2.0e-15 * u.Hz / u.s), 238722891596281.66 * u.G
    )

    # B_lc
    assert np.isclose(
        pulsar_B_lightcyl(0.033 * u.Hz, -2.0e-15 * u.Hz / u.s),
        0.07774704753236616 * u.G,
    )
示例#3
0
def test_mass_function_error_without_quantity_pb():

    # Mass function
    with pytest.raises(ValueError):
        mass_funct(1.0, 2.0 * pint.ls)
示例#4
0
def test_mass_function_error_without_quantity_x():
    # Mass function
    with pytest.raises(ValueError):
        mass_funct(1.0 * u.d, 2.0)