Beispiel #1
0
 def test_number_of_returns(self, model, attr_name, field_orientation,
                            expected):
     with pytest.warns(RelativityWarning):
         ct2 = ClassicalTransport(T_e=self.T_e,
                                  n_e=self.n_e,
                                  T_i=self.T_i,
                                  n_i=self.n_i,
                                  ion=self.ion,
                                  model=model,
                                  field_orientation=field_orientation)
         attr_to_test = getattr(ct2, attr_name)
         testTrue = np.size(attr_to_test) == expected
         errStr = (f"{attr_name} in {model} model returns "
                   f"{np.size(attr_to_test)} objects. "
                   f"Expected to return {expected} objects.")
     assert testTrue, errStr
Beispiel #2
0
 def test_precalculated_parameters(self):
     with pytest.warns(RelativityWarning):
         ct2 = ClassicalTransport(T_e=self.T_e,
                                  n_e=self.n_e,
                                  T_i=self.T_i,
                                  n_i=self.n_i,
                                  ion=self.ion,
                                  hall_i=0,
                                  hall_e=0)
         testTrue = np.isclose(ct2.resistivity,
                               2.8184954e-8 * u.Ohm * u.m,
                               atol=1e-6 * u.Ohm * u.m)
         errStr = (
             f"Resistivity should be close to "
             f"{2.8184954e-8 * u.Ohm * u.m} and not {ct2.resistivity}.")
     assert testTrue, errStr
Beispiel #3
0
 def test_ion_viscosity_by_model(self, model, expected):
     with pytest.warns(RelativityWarning):
         ct2 = ClassicalTransport(
             T_e=self.T_e,
             n_e=self.n_e,
             T_i=self.T_i,
             n_i=self.n_i,
             ion=self.ion,
             model=model,
         )
         testTrue = np.allclose(ct2.ion_viscosity, expected, atol=1e-6 * u.Pa * u.s)
         errStr = (
             f"Electron viscosity in {model} model should be close to "
             f"{expected} and not {ct2.electron_viscosity}"
         )
     assert testTrue, errStr
Beispiel #4
0
 def test_resistivity_by_model(self, model, expected):
     with pytest.warns(RelativityWarning):
         ct2 = ClassicalTransport(
             T_e=self.T_e,
             n_e=self.n_e,
             T_i=self.T_i,
             n_i=self.n_i,
             ion=self.ion,
             model=model,
         )
         testTrue = np.isclose(ct2.resistivity, expected, atol=1e-6 * u.Ohm * u.m)
         errStr = (
             f"Resistivity in {model} model should be "
             f"close to {expected} and not {ct2.resistivity}."
         )
     assert testTrue, errStr
Beispiel #5
0
 def test_ion_thermal_conductivity_by_model(self, model, expected):
     with pytest.warns(RelativityWarning):
         ct2 = ClassicalTransport(
             T_e=self.T_e,
             n_e=self.n_e,
             T_i=self.T_i,
             n_i=self.n_i,
             ion=self.ion,
             model=model,
         )
         testTrue = np.allclose(ct2.ion_thermal_conductivity,
                                expected,
                                atol=1e-6 * u.W / (u.K * u.m))
         errStr = (f"Ion thermal conductivity in {model} model "
                   f"should be close to {expected} and not "
                   f"{ct2.ion_thermal_conductivity}.")
     assert testTrue, errStr
Beispiel #6
0
 def test_thermoelectric_conductivity_by_model(self, model, expected):
     with pytest.warns(RelativityWarning):
         ct2 = ClassicalTransport(
             T_e=self.T_e,
             n_e=self.n_e,
             T_i=self.T_i,
             n_i=self.n_i,
             ion=self.ion,
             model=model,
         )
         testTrue = np.isclose(ct2.thermoelectric_conductivity,
                               expected,
                               atol=1e-6 * u.s / u.s)
         errStr = (f"Thermoelectric conductivity in {model} model "
                   f"should be close {expected} and not "
                   f"{ct2.thermoelectric_conductivity}.")
     assert testTrue, errStr
Beispiel #7
0
 def test_coulomb_log_calc(self):
     """if no coulomb logs are input, they should be calculated"""
     with pytest.warns(RelativityWarning):
         ct2 = ClassicalTransport(T_e=self.T_e,
                                  n_e=self.n_e,
                                  T_i=self.T_i,
                                  n_i=self.n_i,
                                  ion=self.ion)
         cl_ii = Coulomb_logarithm(self.T_i, self.n_e, [self.ion, self.ion],
                                   self.V_ii)
         cl_ei = Coulomb_logarithm(self.T_e, self.n_e, ["e", self.ion],
                                   self.V_ei)
         testTrue = cl_ii == ct2.coulomb_log_ii
         errStr = (f"Ion-ion coulomb logarithm should be {cl_ii} "
                   f"and not {ct2.coulomb_log_ii}.")
     assert testTrue, errStr
     testTrue = cl_ei == ct2.coulomb_log_ei
     errStr = (f"Electron-ion coulomb logarithm should be {cl_ei} "
               f"and not {ct2.coulomb_log_ei}.")
     assert testTrue, errStr
Beispiel #8
0
 def test_hall_calc(self):
     """if no hall parameters are input, they should be calculated"""
     with pytest.warns(RelativityWarning):
         ct2 = ClassicalTransport(T_e=self.T_e,
                                  n_e=self.n_e,
                                  T_i=self.T_i,
                                  n_i=self.n_i,
                                  ion=self.ion)
         hall_i = Hall_parameter(ct2.n_i, ct2.T_i, ct2.B, ct2.ion, ct2.ion,
                                 ct2.coulomb_log_ii, ct2.V_ii)
         hall_e = Hall_parameter(ct2.n_e, ct2.T_e, ct2.B, ct2.ion,
                                 ct2.e_particle, ct2.coulomb_log_ei,
                                 ct2.V_ei)
         testTrue = hall_i == ct2.hall_i
         errStr = (f"Ion hall parameter should be {hall_i} "
                   f"and not {ct2.hall_i}.")
     assert testTrue, errStr
     testTrue = hall_e == ct2.hall_e
     errStr = (f"Electron hall parameter should be {hall_e} "
               f"and not {ct2.hall_e}.")
     assert testTrue, errStr
Beispiel #9
0
 def test_spitzer_vs_formulary(self):
     """Spitzer resistivity should agree with approx. in NRL formulary"""
     with pytest.warns(RelativityWarning):
         ct2 = ClassicalTransport(T_e=self.T_e,
                                  n_e=self.n_e,
                                  T_i=self.T_i,
                                  n_i=self.n_i,
                                  ion=self.ion,
                                  model='spitzer',
                                  field_orientation='perp')
         alpha_spitzer_perp_NRL = (
             1.03e-4 * ct2.Z * ct2.coulomb_log_ei *
             (ct2.T_e.to(u.eV, equivalencies=u.temperature_energy())).value
             **(-3 / 2) * u.Ohm * u.m)
         testTrue = np.isclose(ct2.resistivity.value,
                               alpha_spitzer_perp_NRL.value,
                               rtol=2e-2)
         errStr = (f"Resistivity should be close to "
                   f"{alpha_spitzer_perp_NRL.value} "
                   f"and not {ct2.resistivity.value}.")
     assert testTrue, errStr