Ejemplo n.º 1
0
def beta(T: u.K, n: u.m**-3, B: u.T) -> u.dimensionless_unscaled:
    """
    The ratio of thermal pressure to magnetic pressure.

    Parameters
    ----------
    T : ~astropy.units.Quantity
        The temperature of the plasma.
    n : ~astropy.units.Quantity
        The particle density of the plasma.
    B : ~astropy.units.Quantity
        The magnetic field in the plasma.

    Examples
    --------
    >>> import astropy.units as u
    >>> beta(1*u.eV, 1e20*u.m**-3, 1*u.T)
    <Quantity 4.02670904e-05>
    >>> beta(8.8e3*u.eV, 1e20*u.m**-3, 5.3*u.T)
    <Quantity 0.01261482>

    Returns
    -------
    beta: ~astropy.units.Quantity
        Dimensionless quantity.

    """
    thermal_pressure = parameters.thermal_pressure(T, n)
    magnetic_pressure = parameters.magnetic_pressure(B)
    return thermal_pressure / magnetic_pressure
Ejemplo n.º 2
0
def calculate_thermal_pressure(form):
    r''' Returns 
        --------
        Quantity 
            Thermal pressure in Pascal (Pa) 

        Parameters
        ---------- 
        `form`: The calculator form from the HTML page where the user enters data for calculation.
    '''
    num1 = form['temp']  # Get temperature
    num2 = form['density']  # Get density
    u1 = form['unitsT']
    u2 = form['unitsN']

    if num1 == "" or num2 == "" or u1 == 'select' or u2 == 'select':
        return -1

    # Convert units of temperature and density into Unit objects, and use them to make Quantity objects
    unit1 = u.Unit(u1)
    q1 = u.Quantity(num1, unit1)
    unit2 = u.Unit(u2)
    q2 = u.Quantity(num2, unit2)

    sum = pfp.thermal_pressure(q1, q2)
    return sum
def calculate_thermal_pressure(form):
    num1 = form['temp']
    num2 = form['density']

    unit1 = u.Unit(form['unitsT'])
    q1 = u.Quantity(num1, unit1)
    unit2 = u.Unit(form['unitsN'])
    q2 = u.Quantity(num2, unit2)
    sum = pfp.thermal_pressure(q1, q2)
    return sum
Ejemplo n.º 4
0
def beta(T: u.K, n: u.m**-3, B: u.T) -> u.dimensionless_unscaled:
    r"""
    Compute the ratio of thermal pressure to magnetic pressure.

    The beta (:math:`β`) of a plasma is defined by

    .. math::
        β = \frac{p_{th}}{p_{mag}}

    where :math:`p_{th}` is the thermal pressure of the plasma
    and :math:`p_{mag}` is the magnetic pressure of the plasma.

    Parameters
    ----------
    T : `~astropy.units.Quantity`
        The temperature of the plasma.

    n : `~astropy.units.Quantity`
        The particle density of the plasma.

    B : `~astropy.units.Quantity`
        The magnetic field in the plasma.

    Examples
    --------
    >>> import astropy.units as u
    >>> beta(1*u.eV, 1e20*u.m**-3, 1*u.T)
    <Quantity 4.0267...e-05>
    >>> beta(8.8e3*u.eV, 1e20*u.m**-3, 5.3*u.T)
    <Quantity 0.01261...>

    Returns
    -------
    beta: `~astropy.units.Quantity`
        Dimensionless quantity.

    See Also
    --------
    ~plasmapy.formulary.parameters.thermal_pressure
    ~plasmapy.formulary.parameters.magnetic_pressure
    """
    thermal_pressure = parameters.thermal_pressure(T, n)
    magnetic_pressure = parameters.magnetic_pressure(B)
    return thermal_pressure / magnetic_pressure
Ejemplo n.º 5
0
def test_thermal_pressure():
    assert thermal_pressure(T_e, n_i).unit.is_equivalent(u.Pa)

    # TODO: may be array issues with arg "mass"
    assert_can_handle_nparray(thermal_pressure)
Ejemplo n.º 6
0
 def time_thermal_pressure(self):
     thermal_pressure(1 * u.eV, 1e20 / u.m**3)