method : com shifts
This commit is contained in:
@@ -61,27 +61,19 @@ class System:
|
|||||||
body.p = body.p - self.COMV()
|
body.p = body.p - self.COMV()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def Lval(self,Lbodylist): #return angular momentum of bodies in bodylist
|
def Lval(self): #return angular momentum of bodies in system
|
||||||
comcoord = np.zeros(3)
|
|
||||||
for body in Lbodylist:
|
|
||||||
comcoord = comcoord + body.m*body.q
|
|
||||||
comcoord = comcoord/self.Mass()
|
|
||||||
comq = np.zeros((len(Lbodylist),3))
|
|
||||||
i = 0
|
|
||||||
L = np.zeros(3)
|
L = np.zeros(3)
|
||||||
for body in Lbodylist:
|
for body in self.bodylist:
|
||||||
comq[i] = body.q-comcoord
|
L = L + np.cross(body.q,body.p)
|
||||||
L = L + np.cross(comq[i],body.p)
|
|
||||||
i = i+1
|
|
||||||
return L
|
return L
|
||||||
|
|
||||||
def Eval(self,Lbodylist): #return total energy of bodies in bodylist
|
def Eval(self): #return total energy of bodies in system
|
||||||
G = 1. #Gravitational constant (here normalized)
|
G = 1. #Gravitational constant (here normalized)
|
||||||
T = 0
|
T = 0
|
||||||
W = 0
|
W = 0
|
||||||
for body in Lbodylist:
|
for body in self.bodylist:
|
||||||
T = T + 1./2.*body.m*np.linalg.norm(body.v)**2
|
T = T + 1./2.*body.m*np.linalg.norm(body.v)**2
|
||||||
for otherbody in Lbodylist:
|
for otherbody in self.bodylist:
|
||||||
if body != otherbody:
|
if body != otherbody:
|
||||||
rij = np.linalg.norm(body.q-otherbody.q)
|
rij = np.linalg.norm(body.q-otherbody.q)
|
||||||
W = W - G*body.m*otherbody.m/rij
|
W = W - G*body.m*otherbody.m/rij
|
||||||
|
|||||||
Reference in New Issue
Block a user