How to print string literal as a thermo column?

i want to print "step " at the beginning of every thermo line so i can grep '^step ’ later my lammps.log from tee to filter only my thermo lines.

variable        step_string string "step "
thermo_style    custom v_step_string step spcpu temp etotal &

gives

ERROR: Thermo custom variable step_string is not an equal-style variable

and

variable        step_string equal "step "
thermo_style    custom v_step_string step spcpu temp etotal &

gives

100 ...
200 ...

also i might get cute later and add some |'s to group related columns for readability

Thermo variables must evaluate to numbers.

You have multiple options:

  • use fix print instead of thermo output to have all kinds of custom characters in your output
  • use thermo_modify format 1 "step %d" to insert desired characters as part of the column-wise output format
  • use thermo_modify line yaml to have a structured output format

See 10.3.9. Output structured data from LAMMPS — LAMMPS documentation for some examples

I personally prefer having output in either YAML or JSON format, as that can be most easily processed using existing data processing tools and the minimum amount of custom parsing and processing.

1 Like
awk '/Step/,/Loop/ {if(/Step|Loop/) next; print}' log.lammps

This prints lines between lines with patterns “Step” (which starts off a thermo block if step is the first variable) and “Loop” (as in “Loop time: …”), non-inclusive of the lines containing those words (modified from https://stackoverflow.com/a/38977614 posted by karakfa, retrieved 2026-03-28, License - CC BY-SA 3.0).

fix print has the very important advantage of retaining the header line which is very useful for figuring out what numbers you’ve actually printed.