示例#1
0
 def test_zmean(self):
     """
     Test collisional frequency function when given arbitrary z_mean.
     """
     with pytest.warns(exceptions.PhysicsWarning, match="strong coupling effects"):
         methodVal = collision_frequency(self.T,
                                         self.n,
                                         self.particles,
                                         z_mean=self.z_mean,
                                         V=np.nan * u.m / u.s,
                                         method="classical")
     testTrue = np.isclose(self.True_zmean,
                           methodVal.si.value,
                           rtol=1e-1,
                           atol=0.0)
     errStr = (f"Collision frequency should be {self.True_zmean} and "
               f"not {methodVal}.")
     assert testTrue, errStr
示例#2
0
 def test_protons(self):
     """
     Testing collision frequency between protons (ions).
     """
     with pytest.warns(exceptions.PhysicsWarning, match="strong coupling effects"):
         methodVal = collision_frequency(self.T,
                                         self.n,
                                         self.protons,
                                         z_mean=np.nan * u.dimensionless_unscaled,
                                         V=np.nan * u.m / u.s,
                                         method="classical")
     testTrue = np.isclose(self.True_protons,
                           methodVal.si.value,
                           rtol=1e-1,
                           atol=0.0)
     errStr = (f"Collision frequency should be {self.True_protons} and "
               f"not {methodVal}.")
     assert testTrue, errStr
示例#3
0
 def test_fail1(self):
     """
     Tests if test_known1() would fail if we slightly adjusted the
     value comparison by some quantity close to numerical error.
     """
     fail1 = self.True1 * (1 + 1e-15)
     with pytest.warns(exceptions.PhysicsWarning,
                       match="strong coupling effects"):
         methodVal = collision_frequency(self.T,
                                         self.n,
                                         self.particles,
                                         z_mean=np.nan *
                                         u.dimensionless_unscaled,
                                         V=np.nan * u.m / u.s,
                                         method="classical")
     testTrue = not np.isclose(
         methodVal.si.value, fail1, rtol=1e-16, atol=0.0)
     errStr = (f"Collision frequency value test gives {methodVal} and "
               f"should not be equal to {fail1}.")
     assert testTrue, errStr
示例#4
0
 def test_symmetry(self):
     result = collision_frequency(self.T, self.n, self.particles)
     resultRev = collision_frequency(self.T, self.n, self.particles[::-1])
     assert result == resultRev