Error with fix ave/time

Dear all,

I do not know why I get this error when i want to get the outputs from fix ave/time:

LAMMPS (3 Aug 2023 - Development - patch_2Aug2023-759-g23ae4a34b3)
  using 1 OpenMP thread(s) per MPI task

package omp 1 neigh yes
using multi-threaded neighbor list subroutines
suffix omp

processors * * * grid numa map cart

read_restart File.restart
Reading restart file ...
  restart file = 3 Aug 2023, LAMMPS = 3 Aug 2023
  restoring atom style atomic from restart
  orthogonal box = (0.54814066 0.63231952 0.90414045) to (91.587504 105.75552 6.9281757)
  4 by 4 by 1 MPI processor grid
  4 by 4 by 1 core grid within node
  pair style mlip stores no restart info
  2700 atoms
  read_restart CPU = 0.020 seconds

variable Lx   equal lx
variable Ly   equal ly
variable Lz   equal lz

fix 1 all nvt temp 600 600 0.1
fix 2 all dt/reset 1 NULL NULL 0.1 units box
fix 3 all momentum 1000 linear 1 1 1
fix 4 all balance 5000 1.0 shift xyz 10 1.0 weight time 0.8
fix 6 all ave/time 1 100 100 v_Lx v_Ly v_Lz ave running start 350 file test.avg

run 500

print $(f_6[1])

print $(f_6[1])
ERROR: Invalid syntax in variable formula (../variable.cpp:2374)
Last command: print $(f_6[1])

Here is the output file values for fix 6 ave/time

# Time-averaged data for fix 6
# TimeStep v_Lx v_Ly v_Lz
400 91.3532 105.462 5.7804
500 91.5196 105.655 5.82973

Thanks for your help in advance!

Does anyone have any idea why I get this error? I cannot find where I’m making a mistake.

The error does not concern fix ave/time. If it did, you wouldn’t see the output.

The error concerns :

and does not matter so much as this print command is located after the run. On a side note, calling the fix ave/time this way does not make much sense. (edit : forget about the last sentence)

It does matter to me as I need the averaged values after the run for some reasons. I used print here to show that something is wrong with reading values from f_6[]. I have been using this way of getting outputs from f_ave[*], and this is not a weird way of calling of fix ave/time as you think, like the example provided below by Aidan:

lammps/examples/ELASTIC_T/DEFORMATION/Silicon/in.elastic at develop · lammps/lammps · GitHub

include init.mod

Compute initial state

variable thermostat equal 1
include potential.mod
run ${nequil}

if “${adiabatic} == 1” &
then “variable thermostat equal 0” &
else “variable thermostat equal 1”

print ${thermostat}

include potential.mod
run ${nrun}

variable pxx0 equal f_avp[1]
variable pyy0 equal f_avp[2]
variable pzz0 equal f_avp[3]
variable pxy0 equal f_avp[4]
variable pxz0 equal f_avp[5]
variable pyz0 equal f_avp[6]

Oh yes, you are right indeed.

1 Like

I tried something similar using the LAMMPS (2 Aug 2023) version, and it works just fine. My input is:

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 1 simulation_box
create_atoms 1 random 1500 341341 simulation_box
mass 1 1
pair_coeff 1 1 1.0 1.0

minimize 1.0e-4 1.0e-6 1000 10000

variable Lx equal lx
variable Ly equal ly
variable Lz equal lz
fix myat all ave/time 1 100 100 v_Lx v_Ly v_Lz ave running start 350 file test.avg

fix mynve all nve
fix mylgv all langevin 1.0 1.0 0.1 1530917
timestep 0.005
run 1000

print $(f_myat[1])


Dangerous builds = 0
Total wall time: 0:00:00

So, may be you are using an older LAMMPS version?

Thanks, Simon, for checking this out!

I ran your script, and I got the same error!

I’m not sure what LAMMPS version you are using, but mine is LAMMPS (3 Aug 2023 - Development - patch_2Aug2023-759-g23ae4a34b3).

Please see the attached log file for more details.

log.lammps (4.6 KB)

I am using the Stable Release of 2 Aug 2023, not the Development version. Apart from that difference, I have no clue.

Thanks a lot Simon for you time!

Now you said that I get the feeling this error could be the new patch’s bug, and LAMMPS developers might have a clue about what exactly goes wrong here.

Not an official dev but I’ll take a look. Thanks @simongravelle for putting together a minimal example and @RezaNamakian for testing it.

1 Like
1 Like