1
0

Add get masses/positions/momenta methods and modify frogleap input/output

This commit is contained in:
Thibault Barnouin
2021-10-22 16:23:08 +02:00
parent e1431ce1b4
commit 3e40f412e6
3 changed files with 26 additions and 8 deletions

View File

@@ -24,6 +24,15 @@ class System:
def __init__(self, bodylist):
self.bodylist = bodylist
def get_masses(self): #return the masses of each object
return np.array([body.m for body in self.bodylit])
def get_positions(self): #return the positions of the bodies
return np.array([body.q for body in self.bodylist])
def get_momenta(self): #return the momenta of the bodies
return np.array([body.p for body in self.bodylist])
def Mass(self): #return total system mass
mass = 0
@@ -51,6 +60,7 @@ class System:
L = L + np.cross(comq[i],body.p)
i = i+1
return L
def Eval(self,Lbodylist): #return total energy of bodies in bodylist
G = 1. #Gravitational constant (here normalized)
T = 0