def test_negative_area(): r"""Test error upon negative probe area""" with pytest.raises(ValueError): with pytest.warns(FutureWarning): langmuir.swept_probe_analysis(characteristic, -1 * u.cm**2, "Ar-40 1+")
def test_nan_area(): r"""Test error upon NaN area""" with pytest.raises(ValueError): langmuir.swept_probe_analysis( characteristic, np.nan * u.cm ** 2, "Ar-40 1+" )
def test_unit_conversion_error(): r"""Test error upon incorrect probe area unit""" with pytest.raises(u.UnitTypeError): with pytest.warns(FutureWarning): langmuir.swept_probe_analysis(characteristic, 1 * u.cm, "Ar-40 1+")
def test_ion_mass_unit(): r"""Test equality of float and a.m.u. ion mass""" sim = characteristic_simulated() sim_result1 = swept_probe_analysis(sim, 1 * u.cm**2, 40) sim_result2 = swept_probe_analysis(sim, 1 * u.cm**2, 40 * u.u) errStr = (f"`swept_probe_analysis` should accept both floats and " f"a.m.u. Quantities as atomic gas mass input.") for key in sim_result1: assert (sim_result1[key] == sim_result2[key]).all(), errStr
def test_ordering_invariance(bimaxwellian, characteristic_simulated): r"""Test invariance to ordering of the bias and current values""" sim_result = langmuir.swept_probe_analysis(characteristic_simulated, 1 * u.cm**2, 'Ar-40 1+', bimaxwellian=bimaxwellian) sim_result_shuffled = langmuir.swept_probe_analysis( shuffle_characteristic(characteristic_simulated), 1 * u.cm**2, 'Ar-40 1+', bimaxwellian=bimaxwellian) errStr = (f"Analysis should be invariant to the ordering of the " f"input data.") for key in sim_result: assert (sim_result[key] == sim_result_shuffled[key]).all(), errStr
def test_ordering_invariance(bimaxwellian, characteristic_simulated): r"""Test invariance to ordering of the bias and current values""" with pytest.warns(FutureWarning): sim_result = langmuir.swept_probe_analysis( characteristic_simulated, 1 * u.cm**2, "Ar-40 1+", bimaxwellian=bimaxwellian, ) with pytest.warns(FutureWarning): sim_result_shuffled = langmuir.swept_probe_analysis( shuffle_characteristic(characteristic_simulated), 1 * u.cm**2, "Ar-40 1+", bimaxwellian=bimaxwellian, ) errStr = "Analysis should be invariant to the ordering of the input data." for key in sim_result: assert (sim_result[key] == sim_result_shuffled[key]).all(), errStr
np.array(current) * 1e3 * u.mA) # 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. print( swept_probe_analysis(characteristic, probe_area, 'He-4+', visualize=True, plot_EEDF=True)) ###################################################### # The cyan and yellow lines indicate the fitted electron and ion currents, # respectively. The green line is the sum of these and agrees nicely with the # data. This indicates a successful analysis. ###################################################### # The next sample probe data is provided by David Pace. It is also obtained # from a low relatively ion temperature and density plasma, in Argon. # Load the data from a file and create the Characteristic object path = os.path.join("langmuir_samples", "Pace2015.npy") bias, current = np.load(path)
np.array(current) * 1e3 * u.mA) # 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. print( swept_probe_analysis(characteristic, probe_area, 4 * u.u, visualize=True, plot_EEDF=True)) ###################################################### # The cyan and yellow lines indicate the fitted electron and ion currents, # respectively. The green line is the sum of these and agrees nicely with the # data. This indicates a succesfull analysis. ###################################################### # The next sample probe data is provided by David Pace. It is also obtained # from a low relatively ion temperature and density plasma, in Argon. # Load the data from a file and create the Characteristic object path = os.path.join("langmuir_samples", "Pace2015.npy") bias, current = np.load(path)
def test_negative_area(): r"""Test error upon negative probe area""" with pytest.raises(ValueError): swept_probe_analysis(characteristic, -1 * u.cm**2, 40 * u.u)
def test_unit_conversion_error(): r"""Test error upon incorrect probe area unit""" with pytest.raises(u.UnitConversionError): swept_probe_analysis(characteristic, 1 * u.cm, 40 * u.u)
def test_nan_area(): r"""Test error upon NaN area""" with pytest.raises(ValueError): swept_probe_analysis(characteristic, np.nan * u.cm**2, 40 * u.u)