예제 #1
0
 def test_invalid_kappa(self):
     """
     Checks if function raises error when kappa <= 3/2 is passed as an
     argument.
     """
     with pytest.raises(ValueError):
         kappa_velocity_1D(
             v=self.v,
             T=self.T_e,
             kappa=self.kappaInvalid,
             particle=self.particle,
             units="units",
         )
예제 #2
0
 def test_std(self):
     """
     Tests standard deviation of function?
     """
     std = (kappa_velocity_1D(
         self.v_vect, T=self.T_e, kappa=self.kappa, particle=self.particle)
            * self.v_vect**2 * self.dv).sum()
     std = np.sqrt(std)
     T_distri = (std**2 / k_B * m_e).to(u.K)
     assert np.isclose(T_distri.value, self.T_e.value)
예제 #3
0
 def test_max_drift(self):
     """
     Checks maximum value of distribution function is in expected place,
     when there is drift applied.
     """
     max_index = kappa_velocity_1D(
         self.v_vect,
         T=self.T_e,
         kappa=self.kappa,
         particle=self.particle,
         v_drift=self.v_drift,
     ).argmax()
     assert np.isclose(self.v_vect[max_index].value, self.v_drift.value)
예제 #4
0
 def test_value_drift_units(self):
     """
     Testing vdrifts with values
     """
     testVal = 6.755498543630533e-07
     distFunc = kappa_velocity_1D(
         v=self.v,
         T=self.T_e,
         kappa=self.kappa,
         particle=self.particle,
         v_drift=self.v_drift3,
         units="units",
     )
     errStr = f"Distribution function should be {testVal} and not {distFunc}."
     assert np.isclose(distFunc.value, testVal, rtol=1e-5, atol=0.0), errStr
예제 #5
0
 def test_units_no_vTh(self):
     """
     Tests distribution function with units, but not passing vTh.
     """
     distFunc = kappa_velocity_1D(
         v=self.v,
         T=self.T_e,
         kappa=self.kappa,
         particle=self.particle,
         units="units",
     )
     errStr = (f"Distribution function should be {self.distFuncTrue} "
               f"and not {distFunc}.")
     assert np.isclose(distFunc.value,
                       self.distFuncTrue,
                       rtol=1e-5,
                       atol=0.0), errStr
예제 #6
0
 def test_unitless_no_vTh(self):
     """
     Tests distribution function without units, and not passing vTh.
     """
     # converting T to SI then stripping units
     T_e = self.T_e.to(u.K, equivalencies=u.temperature_energy())
     T_e = T_e.si.value
     distFunc = kappa_velocity_1D(
         v=self.v.si.value,
         T=T_e,
         kappa=self.kappa,
         particle=self.particle,
         units="unitless",
     )
     errStr = (f"Distribution function should be {self.distFuncTrue} "
               f"and not {distFunc}.")
     assert np.isclose(distFunc, self.distFuncTrue, rtol=1e-5,
                       atol=0.0), errStr
예제 #7
0
 def test_zero_drift_units(self):
     """
     Testing inputting drift equal to 0 with units. These should just
     get passed and not have extra units applied to them.
     """
     distFunc = kappa_velocity_1D(
         v=self.v,
         T=self.T_e,
         kappa=self.kappa,
         particle=self.particle,
         v_drift=self.v_drift2,
         units="units",
     )
     errStr = (f"Distribution function should be {self.distFuncTrue} "
               f"and not {distFunc}.")
     assert np.isclose(distFunc.value,
                       self.distFuncTrue,
                       rtol=1e-5,
                       atol=0.0), errStr