How to use the plasmapy.formulary.parameters function in plasmapy

To help you get started, we’ve selected a few plasmapy 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 PlasmaPy / PlasmaPy / plasmapy / formulary / collisions.py View on Github external
if np.any(V == 0):
        raise utils.PhysicsError("You cannot have a collision for zero velocity!")
    # getting thermal velocity of system if no velocity is given
    if V is None:
        V = parameters.thermal_speed(T, mass=m)
    elif np.any(np.isnan(V)):
        if np.isscalar(V.value) and np.isscalar(T.value):
            V = parameters.thermal_speed(T, mass=m)
        elif np.isscalar(V.value):
            V = parameters.thermal_speed(T, mass=m)
        elif np.isscalar(T.value):
            V = V.copy()
            V[np.isnan(V)] = parameters.thermal_speed(T, mass=m)
        else:
            V = V.copy()
            V[np.isnan(V)] = parameters.thermal_speed(T[np.isnan(V)], mass=m)
    return V
github PlasmaPy / PlasmaPy / plasmapy / formulary / distribution.py View on Github external
>>> Maxwellian_1D(v=v, T=30000 * u.K, particle='e', v_drift=0 * u.m / u.s)
    
    """

    if units == "units":
        # unit checks and conversions
        # checking velocity units
        v = v.to(u.m / u.s)
        # Catching case where drift velocities have default values, they
        # need to be assigned units
        v_drift = _v_drift_units(v_drift)
        # convert temperature to Kelvins
        T = T.to(u.K, equivalencies=u.temperature_energy())
        if np.isnan(vTh):
            # get thermal velocity and thermal velocity squared
            vTh = parameters.thermal_speed(T, particle=particle, method="most_probable")
        elif not np.isnan(vTh):
            # check units of thermal velocity
            vTh = vTh.to(u.m / u.s)
    elif np.isnan(vTh) and units == "unitless":
        # assuming unitless temperature is in Kelvins
        vTh = (
            parameters.thermal_speed(T * u.K, particle=particle, method="most_probable")
        ).si.value
    # Get thermal velocity squared
    vThSq = vTh ** 2
    # Get square of relative particle velocity
    vSq = (v - v_drift) ** 2
    # calculating distribution function
    coeff = (vThSq * np.pi) ** (-1 / 2)
    expTerm = np.exp(-vSq / vThSq)
    distFunc = coeff * expTerm
github PlasmaPy / PlasmaPy / plasmapy / formulary / dimensionless.py View on Github external
Examples
    --------
    >>> import astropy.units as u
    >>> beta(1*u.eV, 1e20*u.m**-3, 1*u.T)
    
    >>> beta(8.8e3*u.eV, 1e20*u.m**-3, 5.3*u.T)
    

    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
github PlasmaPy / PlasmaPy / plasmapy / formulary / collisions.py View on Github external
def _replaceNanVwithThermalV(V, T, m):
    """
    Get thermal velocity of system if no velocity is given, for a given mass.
    Handles vector checks for V, you must already know that T and m are okay.
    """
    if np.any(V == 0):
        raise utils.PhysicsError("You cannot have a collision for zero velocity!")
    # getting thermal velocity of system if no velocity is given
    if V is None:
        V = parameters.thermal_speed(T, mass=m)
    elif np.any(np.isnan(V)):
        if np.isscalar(V.value) and np.isscalar(T.value):
            V = parameters.thermal_speed(T, mass=m)
        elif np.isscalar(V.value):
            V = parameters.thermal_speed(T, mass=m)
        elif np.isscalar(T.value):
            V = V.copy()
            V[np.isnan(V)] = parameters.thermal_speed(T, mass=m)
        else:
            V = V.copy()
            V[np.isnan(V)] = parameters.thermal_speed(T[np.isnan(V)], mass=m)
    return V
github PlasmaPy / PlasmaPy / plasmapy / formulary / dielectric.py View on Github external
>>> n = [1e18*u.m**-3, 1e18*u.m**-3]
    >>> omega = 3.7e9*(2*pi)*(u.rad/u.s)
    >>> permittivity = S, D, P = cold_plasma_permittivity_SDP(B, species, n, omega)
    >>> S
    
    >>> permittivity.sum   # namedtuple-style access
    
    >>> D
    
    >>> P
    
    """
    S, D, P = 1, 0, 1

    for s, n_s in zip(species, n):
        omega_c = parameters.gyrofrequency(B=B, particle=s, signed=True)
        omega_p = parameters.plasma_frequency(n=n_s, particle=s)

        S += -(omega_p ** 2) / (omega ** 2 - omega_c ** 2)
        D += omega_c / omega * omega_p ** 2 / (omega ** 2 - omega_c ** 2)
        P += -(omega_p ** 2) / omega ** 2
    return StixTensorElements(S, D, P)
github PlasmaPy / PlasmaPy / plasmapy / formulary / distribution.py View on Github external
# catching case where drift velocities have default values, they
        # need to be assigned units
        vx_drift = _v_drift_units(vx_drift)
        vy_drift = _v_drift_units(vy_drift)
        vz_drift = _v_drift_units(vz_drift)
        # convert temperature to Kelvins
        T = T.to(u.K, equivalencies=u.temperature_energy())
        if np.isnan(vTh):
            # get thermal velocity and thermal velocity squared
            vTh = parameters.thermal_speed(T, particle=particle, method="most_probable")
        elif not np.isnan(vTh):
            # check units of thermal velocity
            vTh = vTh.to(u.m / u.s)
    elif np.isnan(vTh) and units == "unitless":
        # assuming unitless temperature is in Kelvins
        vTh = parameters.thermal_speed(
            T * u.K, particle=particle, method="most_probable"
        ).si.value
    # accounting for thermal velocity in 3D
    vThSq = vTh ** 2
    # Get square of relative particle velocity
    vSq = (vx - vx_drift) ** 2 + (vy - vy_drift) ** 2 + (vz - vz_drift) ** 2
    # calculating distribution function
    coeff = (vThSq * np.pi) ** (-3 / 2)
    expTerm = np.exp(-vSq / vThSq)
    distFunc = coeff * expTerm
    if units == "units":
        return distFunc.to((u.s / u.m) ** 3)
    elif units == "unitless":
        return distFunc
github PlasmaPy / PlasmaPy / plasmapy / formulary / dimensionless.py View on Github external
Examples
    --------
    >>> import astropy.units as u
    >>> beta(1*u.eV, 1e20*u.m**-3, 1*u.T)
    
    >>> beta(8.8e3*u.eV, 1e20*u.m**-3, 5.3*u.T)
    

    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
github PlasmaPy / PlasmaPy / plasmapy / formulary / collisions.py View on Github external
----------
    .. [1] Dense plasma temperature equilibration in the binary collision
       approximation. D. O. Gericke et. al. PRE,  65, 036418 (2002).
       DOI: 10.1103/PhysRevE.65.036418
    """
    # boiler plate checks
    T, masses, charges, reduced_mass, V = _boilerPlate(T=T, species=species, V=V)
    # catching error where mean charge state is not given for non-classical
    # methods that require the ion density
    if method in ("GMS-2", "GMS-5", "GMS-6"):
        if np.isnan(z_mean):
            raise ValueError(
                "Must provide a z_mean for GMS-2, GMS-5, and GMS-6 methods."
            )
    # Debye length
    lambdaDe = parameters.Debye_length(T, n_e)
    # deBroglie wavelength
    lambdaBroglie = hbar / (2 * reduced_mass * V)
    # distance of closest approach in 90 degree Coulomb collision
    bPerp = impact_parameter_perp(T=T, species=species, V=V)
    # obtaining minimum and maximum impact parameters depending on which
    # method is requested
    if method == "classical":
        bmax = lambdaDe
        # Coulomb-style collisions will not happen for impact parameters
        # shorter than either of these two impact parameters, so we choose
        # the larger of these two possibilities. That is, between the
        # deBroglie wavelength and the distance of closest approach.
        # ARRAY NOTES
        # T and V should be guaranteed to be same size inputs from _boilerplate
        # therefore, lambdaBroglie and bPerp are either both scalar or both array
        # if np.isscalar(bPerp.value) and np.isscalar(lambdaBroglie.value):  # both scalar
github PlasmaPy / PlasmaPy / plasmapy / formulary / dielectric.py View on Github external
>>> omega = 3.7e9*(2*pi)*(u.rad/u.s)
    >>> permittivity = S, D, P = cold_plasma_permittivity_SDP(B, species, n, omega)
    >>> S
    
    >>> permittivity.sum   # namedtuple-style access
    
    >>> D
    
    >>> P
    
    """
    S, D, P = 1, 0, 1

    for s, n_s in zip(species, n):
        omega_c = parameters.gyrofrequency(B=B, particle=s, signed=True)
        omega_p = parameters.plasma_frequency(n=n_s, particle=s)

        S += -(omega_p ** 2) / (omega ** 2 - omega_c ** 2)
        D += omega_c / omega * omega_p ** 2 / (omega ** 2 - omega_c ** 2)
        P += -(omega_p ** 2) / omega ** 2
    return StixTensorElements(S, D, P)