Esempio n. 1
0
 def check_velocity_distribution(self, vel, minmax, n_bins, error_tol, kT):
     """check the recorded particle distributions in vel againsta histogram with n_bins bins. Drop velocities outside minmax. Check individual histogram bins up to an accuracy of error_tol agaisnt the analytical result for kT."""
     for i in range(3):
         hist = np.histogram(vel[:, i],
                             range=(-minmax, minmax),
                             bins=n_bins,
                             normed=False)
         data = hist[0] / float(vel.shape[0])
         bins = hist[1]
         for j in range(n_bins):
             found = data[j]
             expected = single_component_maxwell(bins[j], bins[j + 1], kT)
             self.assertLessEqual(abs(found - expected), error_tol)
Esempio n. 2
0
 def test_velocity_distribution(self):
     self.prepare()
     self.system.integrator.run(20)
     N = len(self.system.part)
     loops = 250
     v_stored = np.zeros((N * loops, 3))
     for i in range(loops):
         self.system.integrator.run(6)
         v_stored[i * N:(i + 1) * N, :] = self.system.part[:].v
     minmax = 5
     n_bins = 7
     error_tol = 0.01
     for i in range(3):
         hist = np.histogram(v_stored[:, i], range=(-minmax, minmax),
                             bins=n_bins, normed=False)
         data = hist[0] / float(v_stored.shape[0])
         bins = hist[1]
         for j in range(n_bins):
             found = data[j]
             expected = single_component_maxwell(bins[j], bins[j + 1], KT)
             self.assertLessEqual(abs(found - expected), error_tol)
 def test_00_verify_single_component_maxwell(self):
     """Verifies the normalization of the analytical expression."""
     self.assertLessEqual(abs(single_component_maxwell(-10, 10, 4.) - 1.),
                          1E-4)
Esempio n. 4
0
 def test_00_verify_single_component_maxwell(self):
     """Verifies the normalization of the analytical expression."""
     self.assertAlmostEqual(single_component_maxwell(-10, 10, 4.),
                            1.,
                            delta=1E-4)