Skip to content
Snippets Groups Projects
Commit 9d345601 authored by nguyed99's avatar nguyed99
Browse files

Update unit test, and web visualisation

parent ed827bec
No related branches found
No related tags found
No related merge requests found
Pipeline #59061 passed
......@@ -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())
......
......@@ -48,7 +48,7 @@
<table>
<tr>
<td>
<p class="observables" id="angular_mom">
<p class="observables" id="obs">
</td>
</tr>
</table>
......
......@@ -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):
......
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