1
0

merge diff

This commit is contained in:
Thibault Barnouin
2021-10-22 15:59:29 +02:00
parent 01629896e9
commit e1431ce1b4
2 changed files with 4 additions and 3 deletions

View File

@@ -9,6 +9,8 @@ import numpy as np
import time import time
from lib.plots import DynamicUpdate from lib.plots import DynamicUpdate
globals()["G"] = 1. #Gravitationnal constant
def dp_dt(m_array, q_array): def dp_dt(m_array, q_array):
""" """
Time derivative of the momentum, given by the position derivative of the Hamiltonian. Time derivative of the momentum, given by the position derivative of the Hamiltonian.
@@ -18,9 +20,8 @@ def dp_dt(m_array, q_array):
for i in range(q_array.shape[0]): for i in range(q_array.shape[0]):
q_j = np.delete(q_array, i, 0) q_j = np.delete(q_array, i, 0)
m_j = np.delete(m_array, i).reshape((q_j.shape[0],1)) m_j = np.delete(m_array, i).reshape((q_j.shape[0],1))
dp_array[i] = -m_array[i]*np.sum(m_j/np.sum(np.sqrt(np.sum((q_j-q_array[i])**2, axis=0)))**3*(q_j-q_array[i]), axis=0) dp_array[i] = -G*m_array[i]*np.sum(m_j/np.sum(np.sqrt(np.sum((q_j-q_array[i])**2, axis=0)))**3*(q_j-q_array[i]), axis=0)
dp_array[np.isnan(dp_array)] = 0. dp_array[np.isnan(dp_array)] = 0.
print(dp_array)
return dp_array return dp_array
def frogleap(duration, step, m_array, q_array, p_array, display=False): def frogleap(duration, step, m_array, q_array, p_array, display=False):

View File

@@ -6,7 +6,7 @@ from lib.integrator import frogleap
def main(): def main():
#initialisation #initialisation
m = np.array([1e5, 1, 1]) m = np.array([1e10, 1, 1])
x1 = np.array([0, 0, 0]) x1 = np.array([0, 0, 0])
x2 = np.array([1, 0, 0]) x2 = np.array([1, 0, 0])