Skip to content
Snippets Groups Projects
Commit 1d0860e0 authored by nguyed99's avatar nguyed99
Browse files

correct unit test yoohoo!

parent 90c303e8
No related branches found
No related tags found
No related merge requests found
Pipeline #58928 passed
......@@ -67,7 +67,7 @@ class IntegratorTest(unittest.TestCase):
"""
system = GravitationalSystem(r0=x0[:4],
v0=x0[:4],
v0=x0[4:],
m=np.array([M_E, M_E, M_L, M_L]),
t=np.linspace(0, T, int(T // dt)),
force=force,
......@@ -79,13 +79,13 @@ class IntegratorTest(unittest.TestCase):
H = np.linalg.norm(p[:,:2], axis=1)**2 / (2 * M_E) + np.linalg.norm(p[:,2:], axis=1)**2 / (2 * M_L) + \
-G * M_S * M_E / np.linalg.norm(q[:,:2], axis=1) - G * M_S * M_L / np.linalg.norm(q[:,2:], axis=1) + \
-G * M_E * M_L / np.linalg.norm(q[:,2:] - q[:,:2], axis=1)
self.assertTrue(np.greater(1e-2 + np.zeros(H.shape[0]),
H - H[0]).all()) #TODO: why is it so badly conserved..., DEBUG another day...
self.assertTrue(np.greater(1e-10 + np.zeros(H.shape[0]), H - H[0]).all())
## checking total momentum conservation
L = np.cross(q[:, :2], p[:, :2]) + np.cross(q[:, 2:], p[:,
2:]) # TODO: strange behaviour..., DEBUG another day...
self.assertTrue(np.array_equal(np.zeros(L.shape[0]), L))
L = np.cross(q[:, :2], p[:, :2]) + np.cross(q[:, 2:], p[:, 2:])
self.assertTrue(np.greater(1e-10 + np.zeros(L.shape[0]), L - L[0]).all())
if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment