I am using the 29th August 2025 version of LAMMPS to use the fix ave/time command in combination with rerun.
The minimal script below uses rerun to read the trajectory file dump.lammpstrj and compute the average density of a fixed simulation box containing water molecules modeled with the SPC/E force field, using fix ave/time. The results are written to dens.dat. Although the box size remains constant and the density itself is not physically meaningful in this context, I chose this variable as a simple and transparent test case to demonstrate the issue I encountered, namely, that fix ave/time does not appear to work as expected when used with rerun.
The average densities are not written to the file. However, the same density values are printed correctly through the thermo output, which suggests that the variable itself is being computed as expected.
I am likely making a mistake somewhere, but I cannot figure out why dens.dat remains empty.
log log.spce_rerun
# specification of units, spatial dimensions, boundary conditions and atom-style
units real
dimension 3
boundary p p p
atom_style full
read_restart restart.*
# calculate number of molecules for a given density and box size
variable halfLx equal 25.26/2 # Ang.
variable halfLy equal 25.26/2 # Ang.
variable halfLz equal 25.26
# parameters for the spce model
variable epsOO equal 0.1553
variable sigOO equal 3.166
# long-range and short-range cutoffs, respectively
variable cutC equal ${halfLx}
variable cutLJ equal 10
mass 1 15.9994
mass 2 1.008
# group atoms to molecules
group O type 1
group H type 2
group water type 1 2
# define the pair style with long-range Coulomb interaction
# and short-range LJ interaction
pair_style lj/cut/coul/cut ${cutLJ} ${cutC}
pair_coeff 1 1 ${epsOO} ${sigOO}
pair_coeff 1 2 0 0
pair_coeff 2 2 0 0
bond_style harmonic
bond_coeff 1 1000 1.0
angle_style harmonic
angle_coeff 1 1000 109.47
neighbor 3.0 bin
neigh_modify one 10000
fix fshake all shake 1e-5 20 0 b 1 a 1
variable dens equal density
fix calcDens all ave/time 10 4 40 v_dens file dens.dat format "%15.8f"
thermo_style custom step v_dens
thermo_modify flush yes
thermo 10
rerun dump.lammpstrj first 10 every 10 last 40 dump x y z vx vy vz box yes
dump.lammpstrj (1.1 MB)
restart.40 (499.0 KB)