# how to calculate rotational energy of particle

hello
i am simulating a particle column collapse, the particle system is consist of sphere and polyhedra, and i want calculate the energy loss caused by friction and the kinetic energy, so i need to know how to calculate the rotational energy, can you give me some advice, lookforward for your answer

## Question information

Language:
English Edit question
Status:
For:
Assignee:
No assignee Edit question
Last query:
2019-08-21
2019-08-21
 lip (mr.xie) said on 2019-08-20: #1

by the way, i know that function yade._utils.kineticEnergy() can be used to calculate the total kinetic neergy of all particles, but i want to calculate the kinetic energy of polyhedra and sphere separately, which will make the function yade._utils.kineticEnergy()
become useless to me, can you give me some advice?

 Jan Stránský (honzik) said on 2019-08-20: #2

> which will make the function yade._utils.kineticEnergy() become useless to me

I would not be that strict.
Even I dare to say that the implementation of kineticEnergy(), namely formulas for linear kinetic energy , rotational kinetic energy of spherical particle  and rotational kinetic energy of aspherical particle  could be actually very useful :-)

cheers
Jan

 lip (mr.xie) said on 2019-08-21: #3

dear Jan:
thanks for your answer. i noticed that the code below might solve my problem:
if(b->isAspherical()){
Matrix3r T(state->ori);
// the tensorial expression http://en.wikipedia.org/wiki/Moment_of_inertia#Moment_of_inertia_tensor
// inertia tensor rotation from http://www.kwon3d.com/theory/moi/triten.html
Matrix3r mI; mI<<state->inertia,0,0, 0,state->inertia,0, 0,0,state->inertia;
//E+=.5*state->angVel.transpose().dot((T.transpose()*mI*T)*state->angVel);
E+=.5*angVel.transpose().dot((T*mI*T.transpose())*angVel);
}

but i still have a problem, i think the code 'Matrix3r T(state->ori)' is used to conver quaternionr into a rotating matrix,if so, how can i achieve that by python? can you give me some advice?

 Jan Stránský (honzik) said on 2019-08-21: #4

b.state.ori.toRotationMatrix()

hint:
b = sphere((0,0,0),1)
help(b.state.ori)

cheers
Jan