[lammps-users] Computing the total work done on a granule every timestep and outputting it

Dear all,

I am doing a simulation where I prescribe a velocity onto a big granule and push it into an array of smaller granules. The big granule is what drives the system and to check my energy distribution, I would have to compute the input energy which is

Integral( Force on big granule * velocity of big granule *dt)

or for a more MD friendly framework, it would be summing over all the timesteps the product (Force on big granule*displacement).

The thing is I would have to perform this every timestep. My goal is to calculate this quantity and keep track of energies over time. I would appreciate it if you could tell me how to proceed with this and if it does require me to alter the source code, could you point me to some resources (don’t hve much experience with c++).


you should be able to do what you are after by using an atom style variable and fix ave/atom. by multiplying with the number of frames you are averaging over, you should be able to recover the sum from the average.
if you need a sum over groups of atoms, you can use compute reduce.