How to use the plasmapy.diagnostics.langmuir.Characteristic 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 / diagnostics / langmuir.py View on Github external
I_e = I_{es} \textrm{exp} \left(
        -\frac{e\left(V_P - V \right)}{T_e} \right).

    In log space the current in this region should be a straight line if the
    plasma electrons are fully Maxwellian, or exhibit a knee in a
    bi-Maxwellian case. The slope is inversely proportional to the
    temperature of the respective electron population:

    .. math::
        \textrm{log} \left(I_e \right ) \propto \frac{1}{T_e}.

    """

    if not isinstance(exponential_section, Characteristic):
        raise TypeError(
            f"For 'probe_characteristic' expected type "
            f"{Characteristic.__module__ + '.' + Characteristic.__qualname__} "
            f"and got {type(exponential_section)}"
        )

    # Remove values in the section with a current equal to or smaller than
    # zero.
    exponential_section = exponential_section[
        exponential_section.current.to(u.A).value > 0
    ]

    initial_guess = None  # for fitting

    bounds = (-np.inf, np.inf)

    # Instantiate the correct fitting equation, initial values and bounds.
    if bimaxwellian:
github PlasmaPy / PlasmaPy / plasmapy / diagnostics / langmuir.py View on Github external
f"{Characteristic.__module__ + '.' + Characteristic.__qualname__} "
            f"and got {type(probe_characteristic)}"
        )

    if bimaxwellian:
        fit_func = _fit_func_double_lin_inverse
    else:
        fit_func = _fit_func_lin_inverse

    electron_current = (
        np.exp(fit_func(probe_characteristic.bias.to(u.V).value, *fit)) * u.A
    )

    electron_current[electron_current > np.max(probe_characteristic.current)] = np.NaN

    electron_characteristic = Characteristic(
        probe_characteristic.bias, electron_current
    )

    if visualize:  # coverage: ignore
        try:
            import matplotlib.pyplot as plt
        except (ImportError, ModuleNotFoundError) as e:
            from plasmapy.optional_deps import mpl_import_error

            raise mpl_import_error from e

        with quantity_support():
            plt.figure()
            plt.scatter(
                probe_characteristic.bias,
                probe_characteristic.current.to(u.mA),
github PlasmaPy / PlasmaPy / plasmapy / examples / plot_langmuir_analysis.py View on Github external
import os
from pprint import pprint

######################################################
# The first characteristic we analyze is a simple single-probe measurement in
# a low (ion) temperature, low density plasma with a cylindrical probe. This
# allows us to utilize OML theory implemented in `swept_probe_analysis`.
# The data has been preprocessed with some smoothing, which allows us to obtain
# a Electron Energy Distribution Function (EEDF) as well.

# Load the bias and current values stored in the .p pickle file.
path = os.path.join("langmuir_samples", "Beckers2017.npy")
bias, current = np.load(path)

# Create the Characteristic object, taking into account the correct units
characteristic = Characteristic(u.Quantity(bias,  u.V),
                                u.Quantity(current, u.A))

# Calculate the cylindrical probe surface area
probe_length = 1.145 * u.mm
probe_diameter = 1.57 * u.mm
probe_area = (probe_length * np.pi * probe_diameter +
              np.pi * 0.25 * probe_diameter**2)

######################################################
# Now we can actually perform the analysis. Since the plasma is in Helium an
# ion mass number of 4 is entered. The results are visualized and the obtained
# EEDF is also shown.
pprint(swept_probe_analysis(characteristic,
                           probe_area, 'He-4+',
                           visualize=True,
                           plot_EEDF=True))
github PlasmaPy / PlasmaPy / plasmapy / diagnostics / langmuir.py View on Github external
[druyvesteyn-1930]_:

    .. math::
        N_e \left( \epsilon \right) =
        \frac{2}{A_pe^2} \sqrt{\frac{2 m \epsilon}{e}}
        \frac{\textrm{d}^2 I}{\textrm{d} V^2}

    References
    ----------
    .. [druyvesteyn-1930] Druyvesteyn, M.J. Z. Physik (1930) 64: 781

    """

    if not isinstance(probe_characteristic, Characteristic):
        raise TypeError(
            f"For 'probe_characteristic' expected type "
            f"{Characteristic.__module__ + '.' + Characteristic.__qualname__} "
            f"and got {type(probe_characteristic)}"
        )

    probe_characteristic.sort()

    V_F = get_floating_potential(probe_characteristic)

    V_P = get_plasma_potential(probe_characteristic)

    probe_bias = probe_characteristic.bias
    probe_current = probe_characteristic.current

    # Obtain the correct EEDF energy range from the probe characteristic.
    _filter = (probe_bias > V_F) & (probe_bias < V_P)
    energy = const.e * (V_P - probe_bias[_filter])
github PlasmaPy / PlasmaPy / plasmapy / diagnostics / langmuir.py View on Github external
if not isinstance(probe_characteristic, Characteristic):
        raise TypeError(
            f"For 'probe_characteristic' expected type "
            f"{Characteristic.__module__ + '.' + Characteristic.__qualname__} "
            f"and got {type(probe_characteristic)}"
        )

    slope = fit[0] * u.mA ** 2 / u.V
    offset = fit[1] * u.mA ** 2

    ion_current = -np.sqrt(
        np.clip(slope * probe_characteristic.bias + offset, 0.0, None)
    )

    ion_characteristic = Characteristic(probe_characteristic.bias, ion_current)

    if visualize:  # coverage: ignore
        try:
            import matplotlib.pyplot as plt
        except (ImportError, ModuleNotFoundError) as e:
            from plasmapy.optional_deps import mpl_import_error

            raise mpl_import_error from e

        with quantity_support():
            plt.figure()
            plt.scatter(
                probe_characteristic.bias,
                probe_characteristic.current.to(u.mA),
                marker=".",
                c="k",
github PlasmaPy / PlasmaPy / plasmapy / diagnostics / langmuir.py View on Github external
Returns
    -------
    exponential_section : ~plasmapy.diagnostics.langmuir.Characteristic
        The exponential electron current growth section.

    Notes
    -----
    This function extracts the region of exponential electron growth from the
    probe characteristic under the assumption that this bias region is bounded
    by the floating and plasma potentials. Additionally, an improvement in
    accuracy can be made when the electron temperature is supplied.

    """

    if not isinstance(probe_characteristic, Characteristic):
        raise TypeError(
            f"For 'probe_characteristic' expected type "
            f"{Characteristic.__module__ + '.' + Characteristic.__qualname__} "
            f"and got {type(probe_characteristic)}"
        )

    V_F = get_floating_potential(probe_characteristic)

    V_P = get_plasma_potential(probe_characteristic)

    if T_e is not None:

        # If a bi-Maxwellian electron temperature is supplied grab the first
        # (cold) temperature
        if np.array(T_e).size > 1:
            T_e = np.min(T_e)
github PlasmaPy / PlasmaPy / plasmapy / diagnostics / langmuir.py View on Github external
f"({len(self.current)})."
            )

        bias_unique = np.unique(self.bias)
        current_unique = []
        for bias in bias_unique:
            current_unique = np.append(
                current_unique, np.mean(self.current[self.bias == bias].to(u.A).value)
            )
        current_unique *= u.A

        if inplace:
            self.bias = bias_unique
            self.current = current_unique
        else:
            return Characteristic(bias_unique, current_unique)