ERROR: Per-atom virial was not tallied on needed timestep

Dear All,

In my LAMMPS simulation I need to do first some runs in order to thermalize my system

then I define a couple of fixes and computes and then I perform production runs.

But before the first production run I got the following error message
“ERROR: Per-atom virial was not tallied on needed timestep”.

I have the previous post in the LAMMPS-Forum.

There have been similar error reports in the year 2010. The suggestion was to use a newer version of LAMMPS.

My version of LAMMPS is pretty new (from 2 April 2014).

Does any know how to eliminate this error?

LAMMPS input and output files are just below.

Thank you in advance!
Anton

The LAMMPS output with the error message:

LAMMPS (2 Apr 2014)
Reading data file …
orthogonal box = (0 0 0) to (24.56 24.56 100)
1 by 2 by 8 MPI processor grid
reading atoms …
1000 atoms
Setting up run …
Memory usage per processor = 0.0581818 Mbytes
Step PotEng KinEng TotEng Temp
0 -336.74382 30.345758 -306.39806 235
1 -336.76119 30.363127 -306.39807 235.1345
Loop time of 0.00210918 on 16 procs for 1 steps with 1000 atoms

Pair time () = 0.000692233 (32.82) Neigh time () = 0 (0)
Comm time () = 0.000678539 (32.1707) Outpt time () = 0.00072059 (34.1644)
Other time (%) = 1.78218e-05 (0.844961)

Nlocal: 62.5 ave 156 max 0 min
Histogram: 8 0 0 0 0 1 3 0 0 4
Nghost: 856.812 ave 1901 max 0 min
Histogram: 4 0 4 0 0 4 0 0 0 4
Neighs: 6380 ave 18319 max 0 min
Histogram: 8 0 0 2 0 2 0 0 0 4

Total # of neighbors = 102080
Ave neighs/atom = 102.08
Neighbor list builds = 0
Dangerous builds = 0
Setting up run …
Memory usage per processor = 0.0670166 Mbytes
Step PotEng KinEng TotEng Temp
0 -336.76119 30.363127 -306.39807 235.1345
Loop time of 6.13928e-06 on 16 procs for 0 steps with 1000 atoms

Pair time () = 0 (0) Neigh time () = 0 (0)
Comm time () = 0 (0) Outpt time () = 0 (0)
Other time (%) = 6.13928e-06 (100)

Nlocal: 62.5 ave 156 max 0 min
Histogram: 8 0 0 0 0 1 3 0 0 4
Nghost: 856.812 ave 1901 max 0 min
Histogram: 4 0 4 0 0 4 0 0 0 4
Neighs: 6380 ave 18322 max 0 min
Histogram: 8 0 0 2 0 2 0 0 0 4

Total # of neighbors = 102080
Ave neighs/atom = 102.08
Neighbor list builds = 0
Dangerous builds = 0
Setting up run …
Memory usage per processor = 0.0670166 Mbytes
Step PotEng KinEng TotEng Temp
0 -336.76119 30.363127 -306.39807 235.1345
ERROR: Per-atom virial was not tallied on needed timestep (…/compute_stress_atom.cpp:137)

My input script:

units metal
dimension 3

atom_style atomic
boundary p p p
neighbor 2.0 bin

read_data data.my
pair_style mypairstyle 4.0 # cutoff

pair_coeff * * 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0

fix 1 all nve
velocity all create 235.0 4928459 rot yes dist gaussian
fix 2 all temp/rescale 100 235.0 235.0 10.0 1.0

timestep 0.001
thermo_style custom step pe ke etotal temp

Thermalization

thermo 1
run 1

compute peratom all stress/atom NULL virial
variable ptotatom atom -(c_peratom[1]+c_peratom[2]+c_peratom[3])/(3*vol)
fix 3 all ave/spatial 1 1 1 z 0 2 v_ptotatom units box norm sample file press_prof
fix 4 all ave/spatial 1 1 1 z 0 2 density/number units box norm sample file dens_prof

compute tz all temp/profile 0 0 1 z 50 out bin
fix 5 all ave/time 1 1 1 c_tz mode vector file temp_prof

Run Simulation

reset_timestep 0
run 1

Problem solved.
Instead of “reset_timestep 0” one has to use “reset_timestep 1”.

Unfortunately the problem remains unsolved.

I have done the following changes to the “fix … ave/…” and made the number of production runs larger and this time I got the same error just right after the first production run.

Changes to the input file:

Thermalization

thermo 10
run 1

compute peratom all stress/atom NULL virial
variable ptotatom atom -(c_peratom[1]+c_peratom[2]+c_peratom[3])/(3*vol)
fix 3 all ave/spatial 10 10 100 z 0 2 v_ptotatom units box norm sample file press_prof
fix 4 all ave/spatial 10 10 100 z 0 2 density/number units box norm sample file dens_prof

compute tz all temp/profile 0 0 1 z 50 out bin
fix 5 all ave/time 10 10 100 c_tz mode vector file temp_prof

Run Simulation

reset_timestep 1
run 100

The problem is that LAMMPS tries to predict on

what timestep it needs to evaulate the compute.
More specifically, when it needs to tally the virial
inside the pair style for the compute to use.

By resetting the timestep, you are confusing
that calculation. I suggest you reset the timestep

(if you must) before you invoke the fixes that use
the compute, like fix ave/spatial. More generally,

you should not be using reset_timestep after
defining a fix ave/spatial or ave/time command

b/c they also expect timesteps to proceed
in a pre-determined fashion. If you dial back
the timestep, you will not be doing the averaging
you think you are doing.

Steve