diff --git a/jobs/tests/test_integrator.py b/jobs/tests/test_integrator.py index ad4b9e12bf4cd1aba4b7e2c2ff3ef790f36124c4..7aefb9fb6cdad93e7ef5e1f4f3e5b2c85c4facf9 100644 --- a/jobs/tests/test_integrator.py +++ b/jobs/tests/test_integrator.py @@ -82,9 +82,12 @@ class IntegratorTest(unittest.TestCase): 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:]) + ## checking total linear momentum conservation + P = p[:, :2] + p[:, 2:] + self.assertTrue(np.greater(1e-10 + np.zeros(P[0].shape), P - P[0]).all()) + ## checking total angular momentum conservation + 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()) diff --git a/public/index.html b/public/index.html index c3b7bc21533059b89bb3209d9eb897d743d2f8f7..1dd66bdea9b7b014f930753d25aad1ad76d9c54b 100644 --- a/public/index.html +++ b/public/index.html @@ -48,7 +48,7 @@ <table> <tr> <td> - <p class="observables" id="angular_mom"> + <p class="observables" id="obs"> </td> </tr> </table> diff --git a/public/threebody.py b/public/threebody.py index 272dc272154585e83e98d26ab89b19874f5bd506..c2056c1888a725cb23032142e8c9bd6878ef4eb6 100644 --- a/public/threebody.py +++ b/public/threebody.py @@ -98,11 +98,13 @@ def replot_canvas(): L2 = float(np.cross(x[2, :], p[2, :])) L_tot = L0 + L1 + L2 + P_tot = p[0, :] + p[1, :] + p[2, :] + COM = np.sum(globals['m']) * (globals['m'][0] * x[0, :] + globals['m'][1] * x[1, :] + globals['m'][2] * x[2, :]) - angular_mom = document.getElementById("angular_mom") - s = f"L0 = {L0:.6f}Ẑ<br>L1 = {L1:.6f}Ẑ<br>L2 = {L2:.6f}Ẑ<br>L_tot = {L_tot:.6f}Ẑ<br><br>E = {E():.6f}<br> COM = {COM[0]:.6f}X̂, {COM[1]:.6f}Ŷ" - angular_mom.innerHTML = s + obs = document.getElementById("angular_mom") + s = f"L0 = {L0:.6f}Ẑ<br>L1 = {L1:.6f}Ẑ<br>L2 = {L2:.6f}Ẑ<br>L_tot = {L_tot:.6f}Ẑ<br><br>E = {E():.6f}<br> COM = {COM[0]:.6f}X̂, {COM[1]:.6f}Ŷ<br> P_tot = {P_tot[0]:.6f}X̂, {P_tot[1]:.6f}Ŷ" + obs.innerHTML = s def push_queue(func, str):