← Back to team overview

yade-users team mailing list archive

Re: [Question #689088]: Energy decomposition

 

Question #689088 on Yade changed:
https://answers.launchpad.net/yade/+question/689088

    Status: Open => Answered

Jan Stránský proposed the following answer:
Hello,

in Python, you have access to all relevant data, then it is easy to compute whatever you want, e.g. kinetic energy of individual bodies, sums them etc....:
###
# enegy of a single body
b1 = O.bodies[someID]
m1 = b1.state.mass
v1 = b1.state.vel.norm()
e1 = 0.5*m1*pow(v1,2)

# or using a function
def computeKineticEnergyOfOneBody(id):
   b = O.bodies[id]
   m = b.state.mass
   v = b.state.vel.norm()
   return 0.5*m*pow(v,2)
e1 = computeKineticEnergyOfOneBody(someID)

# sum of 2 bodies
e12 = computeKineticEnergyOfOneBody(id1) + computeKineticEnergyOfOneBody(id2)

# sum of several bodies
ids = [id1,id2,id3,id4]
e1234 = sum(computeKineticEnergyOfOneBody(i) for i in ids)
###

rotational energy can be taken into account, too
You can track the evolution over time or whatever, [1] is a good source of such stuff

cheers
Jan

[1] https://yade-dem.org/doc/user.html

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.