# rdf

Hi
I have calculated rdf (radial distribution function) from lammps using an input file.After the simulation i got a output file where wrapped positions(x y z) are dumped and using this file as an input I am now trying to do same thing in fortran code.I expected that both plots should correspond one to one.But the peak value of G® from fortran code is less than that of from lammps.Then i have added periodic boundary condition to code & the plots are exactly same both from lammps and codes.
I have the wrapped up positions of the particles in ,so it should not be out of the box(slightly out of)which can be managed by
if(rxij.lt.-rblt) rxij = rxij + rblt
if(rxij.ge. rblt) rxij = rxij - rblt
if(ryij.lt.-rblt) ryij = ryij + rblt
if(ryij.ge. rblt) ryij = ryij - rblt
if(rzij.lt.-rblt) rzij = rzij + rblt
if(rzij.ge. rblt) rzij = rzij - rblt
But it did not work.

Then i used these
c image distance
rxjk = rxjk - ANINT ( rxjk / rblt ) * rblt
ryjk = ryjk - ANINT ( ryjk / rblt ) * rblt
rzjk = rzjk - ANINT ( rzjk / rblt ) * rblt
& it works fine.

Now my question is if positions are slightly out of the box then why the first one did not work?

Hi
I have calculated rdf (radial distribution function) from lammps using an input file.After the simulation i got a output file where wrapped positions(x y z) are dumped and using this file as an input I am now trying to do same thing in fortran code.I expected that both plots should correspond one to one.But the peak value of G(r) from fortran code is less than that of from lammps.Then i have added periodic boundary condition to code & the plots are exactly same both from lammps and codes.
I have the wrapped up positions of the particles in ,so it should not be out of the box(slightly out of)which can be managed by
if(rxij.lt.-rblt) rxij = rxij + rblt
if(rxij.ge. rblt) rxij = rxij - rblt
if(ryij.lt.-rblt) ryij = ryij + rblt
if(ryij.ge. rblt) ryij = ryij - rblt
if(rzij.lt.-rblt) rzij = rzij + rblt
if(rzij.ge. rblt) rzij = rzij - rblt
But it did not work.

Then i used these
c image distance
rxjk = rxjk - ANINT ( rxjk / rblt ) * rblt
ryjk = ryjk - ANINT ( ryjk / rblt ) * rblt
rzjk = rzjk - ANINT ( rzjk / rblt ) * rblt
& it works fine.

Now my question is if positions are slightly out of the box then why the first one did not work?

Because it is wrong. It is not doing the same thing as the second code fragment.

Those if statements have to check for +/- half the box length.

Axel

The first one is PBC and second is the minimum image conditions. I think you are confusing with both of them. If you think over it a bit I think you will get the answer.

regards