From 7e0eca5c8500b397583bf4fc494851e0b52e79d7 Mon Sep 17 00:00:00 2001 From: Alex_Hubert Date: Fri, 22 Oct 2021 16:51:28 +0200 Subject: [PATCH] method : com shifts --- lib/objects.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/objects.py b/lib/objects.py index cd0dfbd..05f1ab4 100755 --- a/lib/objects.py +++ b/lib/objects.py @@ -38,6 +38,20 @@ class System: coord = coord/self.Mass() return coord + def COMV(self): #return center of mass velocity in cartesian np_array + coord = np.zeros(3) + for body in self.bodylist: + coord = coord + body.p + coord = coord/self.Mass() + return coord + + def COMShift(self): #Shift coordinates of bodies in system to COM frame and set COM at rest + comcoord = self.COM + for body in self.bodylist: + body.q = body.q-self.COM() + body.p = body.p - self.COMV() + return 0 + def Lval(self,Lbodylist): #return angular momentum of bodies in bodylist comcoord = np.zeros(3) for body in Lbodylist: