The condition under which compute is invoked?

Hi all,

Although I didn’t encounter any errors, when I saw the description of variable accuracy in the manual, I was a little confused: under what circumstances can compute be invoiced?

“Likewise, in between runs, a variable containing a compute cannot be evaluated unless the compute was invoked on the last timestep of the preceding run, e.g. by thermodynamic output.”

for my in.file

run 10000

compute id group/group

variable equal c_ id[2]

fix ave/time v_ c_

run 10000

I haven’t encountered any errors, but how can this new compute be invoked by the run in front of it?

A compute is invoked when its data is “consumed”. That would be some time during a run when you reference it in a thermo_style or fix ave/* or fix print or dump command. Or it would be consumed immediately if you reference it in a print or if command.

In general, the output of a compute must be considered “volatile”, so if you want to refer to it after a run, it may be better to “cache” its value with a properly set up fix ave/time command or similar, in case you want to use its value for some computations in between runs.

Thank you very much for your guidance. However, as you said, it means that run cannot invoke the compute command. However, the manual about variable accuracy says:

run 0
variable t equal temp
print “Initial temperature = $t”
run 1000

'The 0-timestep run initializes and invokes various computes, including the one for temperature, so that the value it stores is current and can be accessed by the variable “t” after the run has completed. ’

My understanding is that run will invoke the compute(in-built) contained in the thermo_style, but it will not invoke other compute commands, except referenced in fix ave/print/dump/thermo_style. Am I right?

Sorry, I don’t understand what you are arguing and what your concern is.

But you are a scientist, right? So, you have everything at your hand to apply the “scientific method”. You have an unsolved problem, you have a hypothesis, you have technical documentation, so all that is needed are a couple of well crafted experiments (i.e. minimal input files that check just this one property) and verify beyond doubt whether your hypothesis can be proven right or wrong.

If in the process you observe that the behavior of LAMMPS differs from its documentation, please report back here and provide the input decks so we can take a closer look.

If I remember correctly (about how LAMMPS works, not about how the documentation was written), run 0 triggers a thermo output and the default thermo_style includes a temp compute, and yes, this might not generalise to all uses of compute.