How to use the plasmapy.particles.particle_mass 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 / quantum.py View on Github external
"""

    V = np.abs(V)

    if np.any(V >= c):
        raise RelativityError(
            "Velocity input in deBroglie_wavelength cannot "
            "be greater than or equal to the speed of "
            "light."
        )

    if not isinstance(particle, u.Quantity):
        try:
            # TODO: Replace with more general routine!
            m = particles.particle_mass(particle)
        except Exception:
            raise ValueError("Unable to find particle mass.")
    else:
        try:
            m = particle.to(u.kg)
        except Exception:
            raise u.UnitConversionError(
                "The second argument for deBroglie"
                " wavelength must be either a "
                "representation of a particle or a"
                " Quantity with units of mass."
            )

    if V.size > 1:

        lambda_dBr = np.ones(V.shape) * np.inf * u.m
github PlasmaPy / PlasmaPy / plasmapy / formulary / parameters.py View on Github external
>>> gyrofrequency(0.01*u.T, 'p', signed=True)
    
    >>> gyrofrequency(0.01*u.T, particle='T+')
    
    >>> gyrofrequency(0.01*u.T, particle='T+', to_hz=True)
    
    >>> omega_ce = gyrofrequency(0.1*u.T)
    >>> print(omega_ce)
    1758820... rad / s
    >>> f_ce = omega_ce.to(u.Hz, equivalencies=[(u.cy/u.s, u.Hz)])
    >>> print(f_ce)
    279924... Hz

    """
    m_i = particles.particle_mass(particle)
    Z = _grab_charge(particle, Z)
    if not signed:
        Z = abs(Z)

    omega_ci = u.rad * (Z * e * np.abs(B) / m_i).to(1 / u.s)

    return omega_ci
github PlasmaPy / PlasmaPy / plasmapy / formulary / parameters.py View on Github external
>>> k_1 = 3e1*u.m**-1
    >>> k_2 = 3e7*u.m**-1
    >>> ion_sound_speed(T_e=5e6*u.K, T_i=0*u.K, ion='p', gamma_e=1, gamma_i=3)
    
    >>> ion_sound_speed(T_e=5e6*u.K, T_i=0*u.K, n_e=n, k=k_1, ion='p', gamma_e=1, gamma_i=3)
    
    >>> ion_sound_speed(T_e=5e6*u.K, T_i=0*u.K, n_e=n, k=k_2, ion='p', gamma_e=1, gamma_i=3)
    
    >>> ion_sound_speed(T_e=5e6*u.K, T_i=0*u.K, n_e=n, k=k_1)
    
    >>> ion_sound_speed(T_e=500*u.eV, T_i=200*u.eV, n_e=n, k=k_1, ion='D+')
    

    """

    m_i = particles.particle_mass(ion)
    Z = _grab_charge(ion, z_mean)

    for gamma, species in zip([gamma_e, gamma_i], ["electrons", "ions"]):
        if not isinstance(gamma, (numbers.Real, numbers.Integral)):
            raise TypeError(
                f"The adiabatic index gamma for {species} must be a float or int"
            )
        if gamma < 1:
            raise PhysicsError(
                f"The adiabatic index for {species} must be between "
                f"one and infinity"
            )

    # Assume non-dispersive limit if values for n_e (or k) are not specified
    klD2 = 0.0
    if (n_e is None) ^ (k is None):
github PlasmaPy / PlasmaPy / plasmapy / formulary / collisions.py View on Github external
>>> fundamental_ion_collision_freq(100 * u.eV, 1e20 / u.m ** 3, 'p')
    
    >>> fundamental_ion_collision_freq(100 * u.eV, 1e20 / u.m ** 3, 'p', coulomb_log_method='GMS-1')
    
    >>> fundamental_ion_collision_freq(100 * u.eV, 1e20 / u.m ** 3, 'p', V = c / 100)
    
    >>> fundamental_ion_collision_freq(100 * u.eV, 1e20 / u.m ** 3, 'p', coulomb_log=20)
    

    See Also
    --------
    collision_frequency
    fundamental_electron_collision_freq
    """
    m_i = particles.particle_mass(ion)
    species = [ion, ion]

    # specify to use ion thermal velocity (most probable), not based on reduced mass
    V = _replaceNanVwithThermalV(V, T_i, m_i)

    Z_i = particles.integer_charge(ion)

    nu = collision_frequency(
        T_i, n_i, species, z_mean=Z_i, V=V, method=coulomb_log_method
    )
    # factor of 4 due to reduced mass in bperp and the rest is
    # due to differences in definitions of collisional frequency
    coeff = np.sqrt(8 / np.pi) / 3 / 4

    # accounting for when a Coulomb logarithm value is passed
    if np.any(coulomb_log):
github PlasmaPy / PlasmaPy / plasmapy / formulary / parameters.py View on Github external
>>> from astropy import units as u
    >>> plasma_frequency(1e19*u.m**-3, particle='p')
    
    >>> plasma_frequency(1e19*u.m**-3, particle='p', to_hz=True)
    
    >>> plasma_frequency(1e19*u.m**-3, particle='D+')
    
    >>> plasma_frequency(1e19*u.m**-3)
    
    >>> plasma_frequency(1e19*u.m**-3, to_hz=True)
    

    """

    try:
        m = particles.particle_mass(particle)
        if z_mean is None:
            # warnings.warn("No z_mean given, defaulting to atomic charge",
            #               PhysicsWarning)
            try:
                Z = particles.integer_charge(particle)
            except Exception:
                Z = 1
        else:
            # using user provided average ionization
            Z = z_mean
        Z = np.abs(Z)
        # TODO REPLACE WITH Z = np.abs(_grab_charge(particle, z_mean)), some bugs atm
    except Exception:
        raise ValueError(f"Invalid particle, {particle}, in plasma_frequency.")

    omega_p = u.rad * Z * e * np.sqrt(n / (eps0 * m))