request for comments and suggestions for implementing "self-adapting" input files

hi everybody,

we are about to implement some new functions into LAMMPS’ variable command that would allow to write input files that are:

  1. able to adapt automatically to different LAMMPS versions, i.e. where the syntax of individual commands change or when features are missing
  2. able to follow different strategies depending on which features are active, e.g. only use inner-middle-outer r-RESPA partitioning on the CPU, but not on the GPU.
  3. able to track whether particular fix/compute/region/group ids are defined
  4. able to query at run-time whether a particular style (fix/compute or pair/bond/…/kspace) is available in an individual executable.

point 1) has already been implemented, the variable command has now a “version” constant, that will output a numerical representation of the LAMMPS version string of the given executable. Here is a usage example from the manual. The following example, illustrates how this can work (since the version constant is new, it will - of course - fail with an error in old LAMMPS versions).

if $(version<20140513) then “communicate vel yes” else “comm_modify vel yes”

i am now looking for suggestions as to how the points 2)-4) are best integrated into the script language. is there anything that i am overlooking? is there something else, that should be integrated into this framework.

here is below is my current proposal for 2).

is_active(category,name,flag)
category = one of: package, comm_style, atom_style, units, newton, pair_style, bond_style, angle_style, dihedral_style, improper_style, kspace_style
name = the argument to the corresponding command that defines the category. in case of the ‘newton’ category either ‘pair’, ‘bond’, or ‘any’
flag = a keyword (or number?) to indicate whether an “exact” match is desired or, or the ‘name’ should be matched against the “lead”-ing part of the style, or any “substring” could be matched.

here is my proposal for 3)

is_available(category,name,flag)

same as before, but more categories including group, region, dump, fix, compute

and for 4)

is_defined(category,name)

category = one of: package, fix, group, compute, region, dump, variable
name = the ID/name of the object

here only exact matches would be allowed.

let me know what you think. i am happy to provide more explanations, if needed.

thanks,
axel.