Fellow LAMMPS users,

Is there a way by which I can output the virial from LAMMPS simulation for

each timestep? I am interested in knowing the quantity: SUM(fij.rij) for i<j for

each timestep, where fij is the vector force acting on i due to j and rij is the

distance vector from j to i and '.' represents the dot product between two vectors.

Since I could not find a direct way to output virial, I thought of

calculating it from the pressure output in log file. For the case of a system of

particles interacting via LJ pair potential, I looked in the pair_lj_cut.cpp, in

the functions PairLJCut::compute(it eflag, int vflag) and

PairLJCut::compute_outer(it eflag, int vflag) the following code is used to

calculate virial: