# Combining potentials for calculation of heat flux

Dear LAMMPS users and Developers,

I am going to calculate heat flux vector (something like compute heat/flux) for a system that uses different potentials ( Tersoff + LJ + Coulomb + Buck + …). I write my code after calculations of forces in each potential and then save the calculated heat flux. For example, for two body term in Tersoff

f[i] += delxfpair;
f[i] += dely
fpair;
f[i] += delzfpair;
f[j] -= delx
fpair;
f[j] -= delyfpair;
f[j] -= delz
fpair;

if (evflag) ev_tally(i,j,nlocal,newton_pair,
evdwl,0.0,fpair,delx,dely,delz);

energyBit = evdwl;
atomE[i] += 0.5energyBit;
qdpi = 0.5
fpair*(delxv[i]+delyv[i]+delzv[i]);
q[i] += qdpi
delx;
q[i] += qdpidely;
q[i] += qdpi
delz;
atomE[j] += 0.5energyBit;
qdpj = -0.5
fpair*(delxv[j]+delyv[j]+delzv[j]);
q[j] -= qdpj
delx;
q[j] -= qdpjdely;
q[j] -= qdpj
delz;

for (i=0;i<nall;i++){
qflux += q[i]
qflux += q[i]
qflux += q[i]
}
MPI_Reduce(&qflux, &answer, 3, MPI_DOUBLE, MPI_SUM, 0, world);

if (me==0) {
}

I use the same method for LJ, Coulomb and other potentials. This method generates several heat flux files depending on the number of potentials I use in the simulation. I was wondering if I can add up the heat fluxes generated by each potential at each time step and save the sum in a single file.

The second question that I have is that if this is an efficient method to do this calculation or It would be better to combine all potential in single file and then calculate the heat flux.

Thanks

Hossein

If you’re modifying LAMMPS to do these calculations,
you can do whatever you want. You can try several
methods and see which you like best. So I’m not
sure what your question is.

Steve