[lammps-users] Question about print fix?

For curiosity’s sake, why do the print and fix print commands require you to define variables for things that are predefined elsewhere as thermo_styles, fixes, or computes?

For example, the following command works:

variable mystep equal step
fix test all print 100 “${mystep}” file test.out title “Test”

But this command dies:
fix test all print 100 “${step}” file test.out title “Test”

It might be useful to make a note of this in the documentation, because it is inconsistent with the thermo_styles documentation. Also, the documentation for print and fix print do not include the {} brackets, without them I get an error.

Thanks.

There is a big difference between variables and thermo keywords.
The only place thermo keywords can appear is in the thermo_style
command and in a variable definition. A variable can appear
anywhere in your input script, in any command. So if you
want to essentially use a thermo keyword as a variable, you
have to define a variable that is in fact that keyword. Like
you did below with mystep.

Also, as the variable doc page explains, any time you refer
to a variable (in any command) it can be x if it is a one\-letter var name, but must be {mystep} if it is multi-letter.

Finally if you refer to a variable as ${foo} it will be
evaluated immediately (the fix print delays it via the ""),
kind of like the shell.
Some commands take a variable as v_foo, like fix ave/time,
which is because the command itself will invoke the variable
at various times.

Steve