From e1431ce1b4f1043508d487ff0a45493b40ac7e99 Mon Sep 17 00:00:00 2001 From: Thibault Barnouin Date: Fri, 22 Oct 2021 15:59:29 +0200 Subject: [PATCH] merge diff --- lib/integrator.py | 5 +++-- main.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/integrator.py b/lib/integrator.py index d148160..431d4cb 100755 --- a/lib/integrator.py +++ b/lib/integrator.py @@ -9,6 +9,8 @@ import numpy as np import time from lib.plots import DynamicUpdate +globals()["G"] = 1. #Gravitationnal constant + def dp_dt(m_array, q_array): """ 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]): q_j = np.delete(q_array, i, 0) 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. - print(dp_array) return dp_array def frogleap(duration, step, m_array, q_array, p_array, display=False): diff --git a/main.py b/main.py index 2de7042..9caa471 100755 --- a/main.py +++ b/main.py @@ -6,7 +6,7 @@ from lib.integrator import frogleap def main(): #initialisation - m = np.array([1e5, 1, 1]) + m = np.array([1e10, 1, 1]) x1 = np.array([0, 0, 0]) x2 = np.array([1, 0, 0])