How to use the plasmapy.utils.PhysicsError 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 / braginskii.py View on Github external
)

        if coulomb_log_ii is not None:
            self.coulomb_log_ii = coulomb_log_ii
        else:
            self.coulomb_log_ii = Coulomb_logarithm(
                T_i,
                n_e,  # this is not a typo!
                (self.ion, self.ion),
                V_ii,
                method=coulomb_log_method,
            )

        if self.coulomb_log_ii < 1:
            # TODO discuss whether this is not too strict
            raise PhysicsError(
                f"Coulomb logarithm is {coulomb_log_ii} (below 1),"
                "this is probably not physical!"
            )
        elif self.coulomb_log_ii < 4:
            warnings.warn(
                f"Coulomb logarithm is {coulomb_log_ii},"
                f" you might have strong coupling effects",
                utils.CouplingWarning,
            )

        # calculate Hall parameters if not forced in input
        if hall_e is not None:
            self.hall_e = hall_e
        else:
            self.hall_e = Hall_parameter(
                n_e,
github PlasmaPy / PlasmaPy / plasmapy / formulary / parameters.py View on Github external
>>> 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):
        warnings.warn(
            "The non-dispersive limit has been assumed for "
            "this calculation. To prevent this, values must "
            "be specified for both n_e and k.",
            PhysicsWarning,
        )
    elif n_e is not None and k is not None:
        lambda_D = Debye_length(T_e, n_e)
        klD2 = (k * lambda_D) ** 2