Change in variable behavior between 2024-2026

I have modular input scripts where I have multiple “include” statements I can use to add different calculations (fix bond reactions, energies, stress, etc) to a LAMMPS script that update output commands by updating/appending string variables.

I’m experiencing a change in variable behavior after updating LAMMPS from a 2024 version of LAMMPS to the current version:

  • LAMMPS (27 Jun 2024 - Development - patch_27Jun2024-956-g6e791034f9-modified)
  • LAMMPS (4 Jul 2026 - Development - patch_4Jul2026-178-gc4fe7a5bcf)

In the previous version the commands below worked without error:

variable string_thermo string "temp press"
variable string_thermo string "${string_thermo} lx ly lz"
fix global all ave/time 1000 1 1000 ${string_thermo} file thermo.1.txt

While the current version produces the error:

ERROR on proc 0: Substitution for illegal variable string_thermo

For more information see 
 (src/input.cpp:675)

I can get around this by creating and deleting a temporary variable, which works but is a bit clunky.

variable string_thermo string "temp press"
variable string_thermo_temp string "${string_thermo}"
variable string_thermo delete
variable string_thermo string "${string_thermo_temp} lx ly lz"
variable string_thermo_temp delete

I’m wondering if anybody has any suggestions for a cleaner way to accomplish this?

@benjamindjensen It looks like you have become a victim of some recent refactoring and removal of duplicated code in the LAMMPS Variable class. Let me have a look at the source code to see if the original (and valid) use case can be restored.

Thank you!

@benjamindjensen This seems to be working again with the changes in this commit: Collected small changes and fixes by akohlmey · Pull Request #5096 · lammps/lammps · GitHub
Should be included in the next LAMMPS release.

@akohlmey That fixed it for me too. Thank you so much!

1 Like

Great! Thanks for letting us know.