nph and lengevin fix replication issues

Hi,

I’m using both a nph and langevin fix on a lennard-jones system and i’m having reproducibility issues.
If I do one long run (say 1000) I get different final atom positions to if I do two separate shorter runs (2x 500).
If I remove one of the fixes I get the same atom positions whether I do single or multiple runs.

I’ve put the script i’m using below
(i’ve tried single nve, nph, langevin and npt fixes which all work fine, just the combination of nph and langevin is giving me the issue)

Is there a way to make these two cases consistent?

Thanks,

Craig

Single.lmp:

log log.single
units lj
atom_style atomic
lattice fcc 1.0 spacing 1 1 1
region box block 0 5 0 5 0 5 units lattice
create_box 1 box
create_atoms 1 box
mass 1 1.0
pair_style lj/cut 2.5
pair_modify tail yes
pair_coeff 1 1 1.0 1.0
thermo 100

dump 1 all xyz 1 inital_single.xyz
dump_modify 1 element Ar
run 0
undump 1

velocity all create 2.4 41787 dist gaussian mom yes

#fix 1 all nve
fix 2 all nph iso 0.02 0.02 1
fix 3 all langevin 2.4 2.4 0.1 1
#fix 4 all npt temp 2.4 2.4 0.1 aniso 5.0 5.0 0.5 mtk yes tchain 5 pchain 5 dilate all

run 1000
#run 500
#run 500

dump 1 all xyz 1 final_single.xyz
dump_modify 1 element Ar
run 0
undump 1

Multiple.lmp:

log log.multiple
units lj
atom_style atomic
lattice fcc 1.0 spacing 1 1 1
region box block 0 5 0 5 0 5 units lattice
create_box 1 box
create_atoms 1 box
mass 1 1.0
pair_style lj/cut 2.5
pair_modify tail yes
pair_coeff 1 1 1.0 1.0
thermo 100

dump 1 all xyz 1 inital_multiple.xyz
dump_modify 1 element Ar
run 0
undump 1

velocity all create 2.4 41787 dist gaussian mom yes

#fix 1 all nve
fix 2 all nph iso 0.02 0.02 1
fix 3 all langevin 2.4 2.4 0.1 1
#fix 4 all npt temp 2.4 2.4 0.1 aniso 5.0 5.0 0.5 mtk yes tchain 5 pchain 5 dilate all

#run 1000
run 500
run 500

dump 1 all xyz 1 final_multiple.xyz
dump_modify 1 element Ar
run 0
undump 1

Hi,

I’m using both a nph and langevin fix on a lennard-jones system and i’m
having reproducibility issues.
If I do one long run (say 1000) I get different final atom positions to if
I do two separate shorter runs (2x 500).
If I remove one of the fixes I get the same atom positions whether I do
single or multiple runs.

I’ve put the script i’m using below
(i’ve tried single nve, nph, langevin and npt fixes which all work fine,
just the combination of nph and langevin is giving me the issue)

Is there a way to make these two cases consistent?

​you cannot. also, the situation is not exactly as you describe. it just
doesn't show with this short trajectories:

- fix langevin does not store the state of the utilized pseudo random
number generators, so it cannot be restarted *exactly*. however, how much
this will be visible depends on the length of your trajectory or trajectory
parts.
- when using fix nph (or actually any fixes chan​ging the system volume
*and* rescaling atom positions), any divergences of trajectories due to
rounding or random changes, e.g. from using fix langevin will be enhanced:
a) the cell size change depends on the stress tensor, which is much more
sensitive to small changes than atomic forces. b) the rescaling of
positions is done by converting to fractional coordinates and back using
the old and new dimensions, respectively.
- when fix npt, there is going to be some divergence, too, but fix npt
stores its internal state, from which it is restarted, so the difference
due to restarting is less. however, it will still show some divergence
(there are other factors like ordering/sorting of atoms and handling of
inexact floating point numbers due to underflow that can cause it, number
of MPI tasks or OpenMP threads), only that it can take more steps until
they surface.
- if you want exactly reproducible runs, you will have to write an MD code,
that using fixed point math; if you want reversible, too, you cannot use a
thermostat.

in summary, you will always have divergence of trajectories eventually
(especially with fully optimized executables), the combination of fix nph
and fix langevin is however causing this to become more quickly visible.
that doesn't mean, that any of those trajectories are wrong. they just
sample phase space slightly (and then increasingly) differently.

axel.