def test_three_species(self): """ Test with three species (2 ions): D plasma with 5%H minority fraction """ n_3 = np.array([1, 1, 5 / 100]) * 1e19 / u.m**3 S, D, P = cold_plasma_permittivity_SDP(B, three_species, n_3, omega) assert np.isclose(S, -11753.3) assert np.isclose(D, 13408.99181054283) assert np.isclose(P, -10524167.9)
def test_numpy_array_workflow(self): """ As per @jhillairet at: https://github.com/PlasmaPy/PlasmaPy/issues/539#issuecomment-425337810 """ ns = np.logspace(17, 19, 50) / u.m ** 3 B0 = 4 * u.T omega_RF = 2 * np.pi * 50e6 * (u.rad / u.s) S, D, P = cold_plasma_permittivity_SDP( B=B0, species=["e", "D+"], n=[ns, ns], omega=omega_RF ) assert S.shape == D.shape == P.shape == (50,)
def test_SD_to_LR_relationships(self): """ Test the relationships between (S, D, P) notation in Stix basis and (L, R, P) notation in the rotating basis, ie test: S = (R+L)/2 and D = (R-L)/2 and R = S+D and L = S-D """ # test with a single species S, D, _ = cold_plasma_permittivity_SDP(B, single_species, n, omega) L, R, _ = cold_plasma_permittivity_LRP(B, single_species, n, omega) assert np.isclose(R, S + D) assert np.isclose(L, S - D) assert np.isclose(S, (R + L) / 2) assert np.isclose(D, (R - L) / 2)
def test_proton_electron_plasma(self): """ Test proton-electron plasma against the (approximate) analytical formulas """ B = 1 * u.T n = [1, 1] * 1 / u.m ** 3 omega = 1 * u.rad / u.s omega_ce = gyrofrequency(B, particle="e", signed=True) omega_pe = plasma_frequency(n[0], particle="e") omega_cp = abs(omega_ce) / 1860 omega_pp = omega_pe / 43 S_analytical = ( 1 - omega_pe ** 2 / (omega ** 2 - omega_ce ** 2) - omega_pp ** 2 / (omega ** 2 - omega_cp ** 2) ) D_analytical = +omega_ce / omega * omega_pe ** 2 / ( omega ** 2 - omega_ce ** 2 ) + omega_cp / omega * omega_pp ** 2 / (omega ** 2 - omega_cp ** 2) P_analytical = 1 - (omega_pe ** 2 + omega_pp ** 2) / omega ** 2 species = ["e", "p"] S, D, P = tuple_result = cold_plasma_permittivity_SDP(B, species, n, omega) assert tuple_result.sum is S assert tuple_result.difference is D assert tuple_result.plasma is P assert isinstance(tuple_result, StixTensorElements) assert np.isclose(S, S_analytical) assert np.isclose(D, D_analytical) assert np.isclose(P, P_analytical) L, R, P = rotating_tuple_result = cold_plasma_permittivity_LRP( B, species, n, omega ) assert rotating_tuple_result.left is L assert rotating_tuple_result.right is R assert rotating_tuple_result.plasma is P assert isinstance(rotating_tuple_result, RotatingTensorElements)