1
0

debugg hermite and force use of longdouble type

This commit is contained in:
Thibault Barnouin
2021-12-03 15:55:37 +01:00
parent 700b3b6c64
commit 34f9ed6ec7
26 changed files with 62 additions and 62 deletions

View File

@@ -13,23 +13,23 @@ from lib.units import *
def Update_a(dyn_syst): # update acceleration of bodies in system
for body in dyn_syst.bodylist:
body.a = np.zeros(3)
body.a = np.zeros(3,dtype=np.longdouble)
for otherbody in dyn_syst.bodylist:
if body != otherbody:
rij = np.linalg.norm(body.q - otherbody.q)
body.a = body.a - (body.q - otherbody.q) * G * otherbody.m / (rij ** 3)
body.a = body.a - (body.q - otherbody.q) * Ga * otherbody.m / (rij ** 3)
def Update_j(dyn_syst): # update jerk of bodies in system
for body in dyn_syst.bodylist:
body.j = np.zeros(3)
body.j = np.zeros(3,dtype=np.longdouble)
for otherbody in dyn_syst.bodylist:
if body != otherbody:
rij = np.linalg.norm(body.q - otherbody.q)
deltav = (body.v - otherbody.v)
deltar = (body.q - otherbody.q)
vr = deltav + 3. * deltar * np.inner(deltav, deltar) / (rij ** 2)
body.j = body.j - G * otherbody.m / (rij ** 3) * vr
body.j = body.j - Ga * otherbody.m / (rij ** 3) * vr
def Predict(dyn_syst, dt): # update predicted position and velocities of bodies in system
@@ -40,23 +40,23 @@ def Predict(dyn_syst, dt): # update predicted position and velocities of bodies
def Update_ap(dyn_syst): # update acceleration of bodies in system
for body in dyn_syst.bodylist:
body.ap = np.zeros(3)
body.ap = np.zeros(3,dtype=np.longdouble)
for otherbody in dyn_syst.bodylist:
if body != otherbody:
rij = np.linalg.norm(body.qp - otherbody.qp)
body.ap = body.ap - (body.qp - otherbody.qp) * G * otherbody.m / (rij ** 3)
body.ap = body.ap - (body.qp - otherbody.qp) * Ga * otherbody.m / (rij ** 3)
def Update_jp(dyn_syst): # update jerk of bodies in system
for body in dyn_syst.bodylist:
body.jp = np.zeros(3)
body.jp = np.zeros(3,dtype=np.longdouble)
for otherbody in dyn_syst.bodylist:
if body != otherbody:
rij = np.linalg.norm(body.qp - otherbody.qp)
deltav = (body.vp - otherbody.vp)
deltar = (body.qp - otherbody.qp)
vr = deltav + 3. * deltar * np.inner(deltav, deltar) / (rij ** 2)
body.jp = body.jp - G * otherbody.m / (rij ** 3) * vr
body.jp = body.jp - Ga * otherbody.m / (rij ** 3) * vr
def Correct(dyn_syst, dt): # correct position and velocities of bodies in system
@@ -69,7 +69,7 @@ def Correct(dyn_syst, dt): # correct position and velocities of bodies in syste
def HPC(dyn_syst, dt): # update position and velocities of bodies in system with hermite predictor corrector
COMShift(dyn_syst)
dyn_syst.COMShift()
Update_a(dyn_syst)
Update_j(dyn_syst)
Predict(dyn_syst, dt)
@@ -79,7 +79,7 @@ def HPC(dyn_syst, dt): # update position and velocities of bodies in system wit
dyn_syst.time = dyn_syst.time + dt
def hermite(dyn_syst, duration, dt, recover_param=False, display=False, savename=None):
def hermite(dyn_syst, bin_syst, duration, dt, recover_param=False, display=False, savename=None):
if display:
try:
system("mkdir tmp")
@@ -89,10 +89,10 @@ def hermite(dyn_syst, duration, dt, recover_param=False, display=False, savename
d.launch(dyn_syst.blackstyle)
N = np.ceil(duration / dt).astype(int)
E = np.zeros(N)
L = np.zeros((N, 3))
sma = np.zeros(N)
ecc = np.zeros(N)
E = np.zeros(N,dtype=np.longdouble)
L = np.zeros((N, 3),dtype=np.longdouble)
sma = np.zeros(N,dtype=np.longdouble)
ecc = np.zeros(N,dtype=np.longdouble)
for j in range(N):
HPC(dyn_syst, dt)
@@ -105,9 +105,9 @@ def hermite(dyn_syst, duration, dt, recover_param=False, display=False, savename
if display and j % 10 == 0:
# display progression
if len(dyn_syst.bodylist) == 1:
d.on_running(dyn_syst, step=j, label="step {0:d}/{1:d}".format(j, N))
d.on_running(dyn_syst, step=j, label="{0:.2f} yearq".format(j*dt))
else:
d.on_running(dyn_syst, step=j, label="step {0:d}/{1:d}".format(j, N))
d.on_running(dyn_syst, step=j, label="{0:.2f} years".format(j*dt))
if display:
d.close()
if not savename is None: