Why do the time-averaged quantities in the thermo print differ from those in the output file?

Hello, I am running a LAMMPS simulation where I use the fix ave/time command to calculate time-averaged quantities. I notice that the values of these time-averaged quantities printed in the thermo output differ from those written in the output file specified by fix ave/time. What could be causing this discrepancy, and how can I ensure that the time-averaged quantities are consistent between the thermo print and the output file? My LAMMPS version is LAMMPS (2 Aug 2023 - Update 2)/Linux. A simple example LAMMPS input is as follows.

units lj
dimension 3
atom_style atomic
pair_style lj/cut 2.5
boundary p p p

region simulation_box block -20 20 -20 20 -20 20
create_box 2 simulation_box
create_atoms 1 random 1500 341341 simulation_box
create_atoms 2 random 100 127569 simulation_box

mass 1 1
mass 2 1
pair_coeff 1 1 1.0 1.0
pair_coeff 2 2 0.5 3.0

compute         temper  all temp
compute         press   all pressure temper
compute         poten   all pe
compute         kinen   all ke
variable        toten   equal c_kinen+c_poten
variable        Vol           equal vol
timestep 0.005

thermo 100
thermo_style custom step temp pe ke etotal press

min_style       cg
minimize        1.0e-25 1.0e-25 20000 20000

reset_timestep  0

thermo 10
fix 1 all ave/time 1 10 10 c_temper c_press c_poten c_kinen v_toten file ave.dat
thermo_style custom step   c_temper c_press c_poten c_kinen v_toten 
fix 2 all nvt temp 300 300 100

run 100
unfix 2
unfix 1

They are not time-averaged quantities, and the thermo output simply returns their instantaneous values every 10 steps.

The fix ave/time, however, applies an averaging to the quantities.

If you really want the same outputs between the thermo and the ave/time, you can use β€˜10 1 10’ instead of β€˜1 10 10’ in the ave/time command. Alternatively, you can use the fix ave/time command to average those quantities first, and then print the averaged quantiles generated by the fix ave/time using the thermo command. See also fix ave/time command β€” LAMMPS documentation

Simon

1 Like

Hi Simon,
Thank you for your quick response.

According to the documented example of fix ave/time Nevery Nrepeat Nfreq, if Nevery=2, Nrepeat=6, Nfreq=100, then values on time steps 90, 92, 94, 96, 98, and 100 will be used to compute the final average on time step 100 (Nrepeat=6 values, taken in backward from and including Nfreq=100 with a step of Nevery=2). Similarly for time steps 190, 192, 194, 196, 198, and 200 on time step 200, etc.

If I understood it correctly, then if Nevery=1, Nrepeat=10, Nfreq=10, then the values on times steps 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 will be used to compute the final average on time step 10 (Nrepeat=10 values, taken in backward from and including Nfreq=10 with a step of Nevery=1 to compute average), Similarly 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 will be used to compute the final average on time step 20, etc.

Whereas, fix ave/time 10 1 10, with Nrepeat=1 values, taken in backward from and including Nfreq=10 with a step of Nevery=10) will simply give the instantaneous value of quantities at step 10, 20, so on.

Indeed I am doing that in the script,

and I notice that the values in thermo print and ave.dat file are different.

No, you are not doing that currently. To print out the values generated by the fix ave/time, you would need to refer to the outputs of the fix ave/time, which can be done using f_myname[1] where β€˜myname’ is the name of the fix ave/time.

1 Like

@Z.Rashid
Please observe what happens when you replace

with

thermo_style custom step f_1[*]
1 Like

Thank you Axel,

The f_ID[*] now gives the time-averaged values, and they are really the same as in ave.dat output file. Thank you so much!

Hi Simon, thank you, yes you are right, I have to use f_ID to print the time-averaged values in thermo print. Thanks