Rerun and vacf

Dear LAMMPS users,

I’m trying to create a LAMMPS script to post-procesate a trajectory using “rerun” command. I started from something simple and compute MSD for a trajectory in 2D. That was easy, but I have tried to compute velocity autocorrelation function (vacf) with the same scheme and always find vacf[*]=0

I have been reading “rerun” command page in the manual and I wonder if fix vacf is one these special cases when they write: “Every time a snapshot is read, the timestep for the simulation is reset, as if the reset_timestep command were used. This command has some restrictions as to what fixes can be defined…”.

Finally, to double check MSD, I have tried to compute directly the diffusion coefficient using the example in “compute vacf” page, but I get and error that I don’t know how to solve: ERROR on proc 0: Failed to allocate -8 bytes for array vector:vector (…/memory.cpp:63)

So, the main question: Isn’t it possible to compute vacf using “rerun” command? How exactly?

You can find the codes that I have used below in case you need it

Thank you very much
José

#######################################################################
########################## LJ + NVT#####################################
dimension 2
units lj
atom_style atomic
lattice sq 0.5
region box block 0 100 0 100 -0.5 0.5
create_box 1 box
create_atoms 1 box
mass 1 1.0

pair_style lj/cut 2.5
pair_coeff 1 1 1.0 1.0
pair_modify shift yes
neighbor 0.3 bin
neigh_modify every 20 delay 0 check no

write_data Initial.lammpsdat

timestep 0.001

fix 1 all nvt temp 0.6 0.6 5.0
fix 2 all enforce2d

velocity all create 0.6 4928459 rot yes dist gaussian

dump id all custom 1000 traj.dat id type x y z vx vy vz
dump_modify id sort id

thermo 1000
run 1000000
##########################LJ+NVT#####################################
#######################################################################

#######################################################################
##########################MSD and VACF###############################
dimension 2
units lj
atom_style atomic
boundary p p p

pair_style lj/cut 2.5
read_data Initial.lammpsdat
neighbor 0.3 bin
neigh_modify every 1 delay 0 check no
pair_coeff 1 1 1.0 1.0
thermo 1
timestep 0.001

compute cvv all vacf
compute mss all msd

fix 1 all ave/time 1 1 1 c_cvv[] c_mss[] file test.dat

rerun traj.dat dump x y vx vy box yes label id id format native

##########################MSD and VACF###############################
#######################################################################

#######################################################################
#############################DIFFUSION###############################

dimension 2
units lj
atom_style atomic
boundary p p p

pair_style lj/cut 3.0
read_data Initial.lammpsdat
neighbor 0.3 bin
neigh_modify every 1 delay 0 check no
pair_coeff 1 1 1.0 1.0
thermo 1
timestep 0.001

compute 2 all vacf
fix 5 all vector 1 c_2[4]
variable diff equal dt*trap(f_5)
thermo_style custom step v_diff

rerun traj.dat dump x y vx vy box yes label id id format native
#############################DIFFUSION###############################
#######################################################################

Using rerun to compute VACF is not a good idea. To get an accurate representation of the ACF you need to store data very frequently because the changes of the velocity are significant over short time periods and if you don’t “see” them, the following integration will be off by a lot. This is different from using the MSD where you are only interested in long time behavior.

The error you see is most certainly a side effect from the “rerun” command not performing the same setup procedure as with a “run”. With a more recent development version of LAMMPS, you will get additional problems since the timestep resetting has become more restrictive and while that prohibits some bad uses of the reset_timestep command, it also didn’t anticipate that the rerun command is using it “under the hood”.

Oh, I see…

I presume that use fix ave/correlation it is the same story, right? For example, to compute the viscosity, I would need to save very frequently and it is better expend time computing it on the fly, isn’t it?

Thank you very much for your time!

Yes

1 Like