コード例 #1
0
ファイル: test_langmuir.py プロジェクト: zhishang80/PlasmaPy
    def test_unequal_arrays(self):
        r"""Test errors upon unequal array lengths"""

        with pytest.raises(ValueError):
            langmuir.Characteristic(self.bias_longarr, current_arr)

        with pytest.raises(ValueError):
            langmuir.Characteristic(bias_arr, self.current_longarr)
コード例 #2
0
ファイル: test_langmuir.py プロジェクト: zhishang80/PlasmaPy
    def test_addition(self):
        r"""Test addition of characteristic objects"""

        a = langmuir.Characteristic(bias_arr, current_arr)
        b = langmuir.Characteristic(bias_arr, self.current_arr2)

        ab_sum = a + b

        errStr = f"Addition of characteristic objects is not behaving as it " f"should."
        assert (a.current + b.current == ab_sum.current).all(), errStr
コード例 #3
0
    def test_subtraction(self):
        r"""Test addition of characteristic objects"""

        a = langmuir.Characteristic(bias_arr, current_arr)
        b = langmuir.Characteristic(bias_arr, self.current_arr2)

        ab_sub = a - b

        errStr = f"Subtraction of characteristic objects is not behaving as it should."
        assert (a.current - b.current == ab_sub.current).all(), errStr
コード例 #4
0
    def test_subtraction(self):
        r"""Test addition of characteristic objects"""

        with pytest.warns(FutureWarning):
            a = langmuir.Characteristic(bias_arr, current_arr)
        with pytest.warns(FutureWarning):
            b = langmuir.Characteristic(bias_arr, self.current_arr2)

        ab_sub = a - b

        errStr = "Subtraction of characteristic objects is not behaving as it should."
        assert (a.current - b.current == ab_sub.current).all(), errStr
コード例 #5
0
ファイル: test_langmuir.py プロジェクト: zhishang80/PlasmaPy
def characteristic_simulated():
    r""""Create a simulated probe characteristic (provisional)"""

    T_e_sim = 1 * u.eV
    n_e_sim = 1e18 * u.m**-3
    probe_area_sim = 1 * u.cm**2
    I_es_sim = (n_e_sim * probe_area_sim * const.e *
                np.sqrt(T_e_sim / (2 * np.pi * const.m_e)))

    # Create bias array
    bias_simarr = np.arange(-20, 15, 0.1) * u.V

    # Calculate electron current and limit to electron saturation current
    current_simarr = np.exp(const.e * bias_simarr / T_e_sim) * u.A
    current_simarr[current_simarr > I_es_sim] = I_es_sim

    # Add simulated linear sheath expansion current
    current_simarr[current_simarr == I_es_sim] += (
        bias_simarr[current_simarr == I_es_sim] * 5e-4 * u.A / u.V)

    # Add simulated linear ion collection current
    current_simarr[current_simarr < I_es_sim] += (
        bias_simarr[current_simarr < I_es_sim] * 1e-4 * u.A / u.V)

    return langmuir.Characteristic(bias_simarr, current_simarr)
コード例 #6
0
    def test_invalid_dimensions(self):
        r"""Test 2D arrays work with Characteristic class"""

        # `Characteristic.get_unique_bias` runs during initialization
        # which prevents an exception from being raised..
        with pytest.warns(FutureWarning):
            langmuir.Characteristic(self.bias_2darr, self.current_2darr)
コード例 #7
0
ファイル: test_langmuir.py プロジェクト: zhishang80/PlasmaPy
def shuffle_characteristic(characteristic):
    r""""Shuffle a given characteristic"""

    _shuffle = sorted(np.arange(len(characteristic.bias)),
                      key=lambda k: np.random.random())
    U_shuffled = characteristic.bias[_shuffle]
    I_shuffled = characteristic.current[_shuffle]
    return langmuir.Characteristic(U_shuffled, I_shuffled)
コード例 #8
0
ファイル: test_langmuir.py プロジェクト: zhishang80/PlasmaPy
def test_get_EEDF():
    """Test the obtained EEDF"""

    char = langmuir.Characteristic(bias_arr[:17], current_arr[:17])
    energy, probability = langmuir.get_EEDF(char, visualize=False)

    expect_energy = (0.14118696, 0.05293109, 0.00709731)
    expect_probability = (8.64838751, 8.05295503, 3.42348436)

    assert np.allclose(energy.to(u.eV).value, np.array(expect_energy))
    assert np.allclose(probability, np.array(expect_probability))
コード例 #9
0
ファイル: test_langmuir.py プロジェクト: zhishang80/PlasmaPy
    def test_infinite_U(self):
        r"""Test error upon an infinite bias value"""

        with pytest.raises(ValueError):
            langmuir.Characteristic(self.bias_infarr, current_arr)
コード例 #10
0
ファイル: test_langmuir.py プロジェクト: zhishang80/PlasmaPy
    def test_infinite_I(self):
        r"""Test error upon an infinite current value"""

        with pytest.raises(ValueError):
            langmuir.Characteristic(bias_arr, self.current_infarr)
コード例 #11
0
ファイル: test_langmuir.py プロジェクト: zhishang80/PlasmaPy
def characteristic():
    r""""Create a dummy characteristic with random values"""

    return langmuir.Characteristic(bias_arr, current_arr)
コード例 #12
0
def characteristic():
    r"""Create a dummy characteristic with random values"""

    with pytest.warns(FutureWarning):
        return langmuir.Characteristic(bias_arr, current_arr)