# compute stress/atom of specific pair

Dear All,

I have two groups of atoms in my simulation(call them atom A and B).
There are LJ type interactions between atoms of A, and between A and B. And another type of interaction between atoms of B.
By using stress/atom, I can compute the stress on atom A by including the interaction between A-A and A-B.
My question is: is it possible to know what’s the contribution to the stress only from A-B interaction?

Thanks,
Wei

No simple way, b/c LAMMPS does not store the forces
from different interactions separately. It simply sums
them into one force array, which is what is used to
compute the virial.

However, you can save a series of snapshots from
the simulation, then read them back in one by one,
and compute the stress values for that one snapshot
using only the potential terms you define in the
new script (e.g. only turn on part of the potential).

Below is a small Pizza.py script I use to do that
kind of thing. It converts a dump file into
a series of data files which can be read in
a loop by a LAMMPS script.

This could be automated in just LAMMPS with
a rerun command, but that is in the works (not
yet released).

Steve

# Pizza.py script dump2data.py to process Matt's foam shock data
# read a dump file one shapshot at a time
# extract coords and velocities
# overwrite fields in original data file with the new values
# write out one data file per dump snapshot

if len(argv) != 3:
raise StandardError,"Syntax: pizza -f dump2data.py datafile dumpfile"

dt = data(argv[1])
dm = dump(argv[2],0)

while 1:
time = dm.next()
if time < 0: break
print "Timestep",time
dm.map(1,"id",3,"xu",4,"yu",5,"zu",6,"vx",7,"vy",8,"vz")
dm.sort("id")
id,xu,yu,zu,vx,vy,vz = dm.vecs(time,"id","xu","yu","zu","vx","vy","vz")
dt.replace("Atoms",5,xu)
dt.replace("Atoms",6,yu)
dt.replace("Atoms",7,zu)
lines = []
for i in xrange(len(id)):
line = "%d %g %g g\\n&quot; (id[i],vx[i],vy[i],vz[i])
lines.append(line)
dt.sections["Velocities"] = lines
newfile = "data.d&quot; time
dt.write(newfile)
print "Wrote data file",newfile
dm.tselect.none()
dm.delete()