modify leapfrog to take velocities instead of momenta, add new initial conditions
This commit is contained in:
15
main.py
15
main.py
@@ -12,7 +12,8 @@ globals()['au'] = 1.5e11 #Astronomical unit in m
|
||||
|
||||
def main():
|
||||
#initialisation
|
||||
m = np.array([1., 1., 0.1])*Ms # Masses in Solar mass
|
||||
m = np.array([1, 1, 0.1])*Ms # Masses in Solar mass
|
||||
mu = m[0]*m[1]/(m[0]+m[1])
|
||||
a = np.array([1., 1., 5.])*au # Semi-major axis in astronomical units
|
||||
psi = np.array([0., 0., 80.])*np.pi/180. # Inclination of the orbital plane in degrees
|
||||
|
||||
@@ -21,9 +22,9 @@ def main():
|
||||
x3 = np.array([np.cos(psi[2]), 0., np.sin(psi[2])])*a[2]
|
||||
q = np.array([x1, x2, x3])
|
||||
|
||||
v1 = np.array([0, -np.sqrt(G*Ms/np.sqrt(np.sum(x1**2))), 0])
|
||||
v2 = np.array([0, np.sqrt(G*Ms/np.sqrt(np.sum(x2**2))), 0])
|
||||
v3 = np.array([0, np.sqrt(G*Ms*(2./np.sqrt(np.sum(x3**2))-1./a[2])), 0])
|
||||
v1 = np.array([0., -np.sqrt(G*mu/np.sqrt(np.sum(x1**2))), 0])
|
||||
v2 = np.array([0., np.sqrt(G*mu/np.sqrt(np.sum(x2**2))), 0.])
|
||||
v3 = np.array([0., np.sqrt(G*(m[0]+m[1])*(2./np.sqrt(np.sum(x3**2))-1./a[2])), 0.])
|
||||
v = np.array([v1, v2, v3])
|
||||
|
||||
bodylist = []
|
||||
@@ -32,8 +33,9 @@ def main():
|
||||
dyn_syst = System(bodylist)
|
||||
dyn_syst.COMShift()
|
||||
|
||||
duration, step = 100, 0.01
|
||||
E, L = frogleap(duration, step, dyn_syst, recover_param=True, display=True)
|
||||
duration, step = 0.5*3e7, 1e1
|
||||
E, L = frogleap(duration, step, dyn_syst, recover_param=True)#, display=True)
|
||||
|
||||
fig1 = plt.figure(figsize=(30,15))
|
||||
ax1 = fig1.add_subplot(111)
|
||||
ax1.plot(np.arange(E.shape[0])/duration, E, label=r"$E_m$")
|
||||
@@ -45,6 +47,7 @@ def main():
|
||||
ax2.legend()
|
||||
fig2.savefig("plots/L2.png",bbox_inches="tight")
|
||||
plt.show(block=True)
|
||||
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user