Unable to assign scalar value of compute to a variable

Dear All,

I am trying to assign the value of the radius of gyration compute to a variable, but I get this error:
Compute used in variable between runs is not current.

I have followed the instructions mentioned in the LAMMPS documentation and some responses from Steve on the archives.
(Referring to Variable Accuracy paragraph in Variable References section: )

  1. Even after giving a 0-timestep run to initialize the compute, I am still getting errors. Please see the following lines:

    compute g1 all gyration
    run 0
    variable Rg equal c_g1
    print “Initial R of gyration is = ${Rg}”
    run 100000

Put your c_g1 into your thermo output (thermo_style) before running the
"run 0". That will force the calculation of the compute.
The variable should then be current in-between run.

Julien

Thanks for your reply, Julien. Your solution worked. I take it that putting the compute in the thermo output counts as ‘evaluating’ the compute. Are there no other ways of doing this? Say, for instance, by using a print command?

A word of advice to those who may be referring to this thread in the future: Since the compute is now being calculated by the thermo_style command, resetting the timestep at any point of the code will lead to the same error again. The variable will not be ‘current’ in between runs.

Thanks,
Praneeth

Thanks for your reply, Julien. Your solution worked. I take it that
putting the compute in the thermo output counts as 'evaluating' the
compute. Are there no other ways of doing this? Say, for instance, by using
a print command?

​any command that references a compute *and* knows when the computed data
is needed next​ will work. that includes all kinds of fixes. there are
plenty of discussions on this subject in the mailing list archive. the
reason for this is that it has to be known at the beginning of a time step
whether data from a compute is needed, since some computed depend on data
that needs to be collected during the time step and that collection is not
done for efficiency reasons by default. thus the print command does not
qualify, as it is instantaneous.

axel.