Esempio n. 1
0
 def test_as_dict(self):
     ham = EwaldSummation(self.s, compute_forces=True)
     d = ham.as_dict()
     self.assertTrue(d["compute_forces"])
     self.assertEqual(d["eta"], ham._eta)
     self.assertEqual(d["acc_factor"], ham._acc_factor)
     self.assertEqual(d["real_space_cut"], ham._rmax)
     self.assertEqual(d["recip_space_cut"], ham._gmax)
     self.assertEqual(ham.as_dict(), EwaldSummation.from_dict(d).as_dict())
Esempio n. 2
0
 def test_from_dict(self):
     ham = EwaldSummation(self.s, compute_forces=True)
     ham2 = EwaldSummation.from_dict(ham.as_dict())
     self.assertIsNone(ham._real)
     self.assertFalse(ham._initialized)
     self.assertIsNone(ham2._real)
     self.assertFalse(ham2._initialized)
     self.assertTrue(
         np.array_equal(ham.total_energy_matrix, ham2.total_energy_matrix))
     # check lazy eval
     self.assertAlmostEqual(ham.total_energy, -1123.00766, 1)
     self.assertIsNotNone(ham._real)
     self.assertTrue(ham._initialized)
     ham2 = EwaldSummation.from_dict(ham.as_dict())
     self.assertIsNotNone(ham2._real)
     self.assertTrue(ham2._initialized)
     self.assertTrue(
         np.array_equal(ham.total_energy_matrix, ham2.total_energy_matrix))