[lammps-users] invalid index in variable formula error when trying to print compute group/group energy

I am getting the “invalid index in variable formula” error when trying to output the energy from compute group/group using fix print. The energy has an index of zero. The forces will print out fine. I first set an equal variable equal to c_ID[0] and then try to print this variable. Is it correct that the index must be greater than 0 if it refers to an atom number, but can be zero if referring to an element in a vector? I found the line in variable.cpp, but I don’t know how to fix it if the index should be <= 0 if it refers to an atom number. Does anyone know a way around this problem, other than outputting the energy with the thermo command? I want to output it on a different frequency and/or separate file.

Here are the relevant lines from my script:
compute bwfrc base group/group wall
variable bwener equal c_bwfrc[0]
fix prfrcs all print 100 “${bwener}” file nucenergy.dat screen no

Thanks,
Brian

I think you want c_foo for the scalar energy (no index)
and c_foo[N] for the vector force, with N=1,2,3.

Steve