Skip to content

Support for PLUMED output#94

Open
armaet wants to merge 3 commits intomolmod:mainfrom
armaet:plumed_print
Open

Support for PLUMED output#94
armaet wants to merge 3 commits intomolmod:mainfrom
armaet:plumed_print

Conversation

@armaet
Copy link
Contributor

@armaet armaet commented Feb 5, 2026

Support to handle PRINT functionality in PLUMED. A possible PLUMED input file might look like this:

UNITS LENGTH=A ENERGY=kj/mol
c: COORDINATION GROUPA=45 GROUPB=6,19,24 NN=6 MM=12 R_0=2.7
a1: ANGLE ATOMS=45,63,110
bb: RESTRAINT ARG=c,a1 KAPPA=1500,1000 AT=1.2,2.18
PRINT ARG=c,a1 STRIDE=1

If print_plumed=True in sample(), a walker-specific file will be created for the output as defined by the PRINT line. The raw output might look something like this (for 5 MD steps) and it will be copied into context_dir when the walker has completed:

#! FIELDS time c a1
 0.000000 2.230202 1.130952
 0.000000 2.230202 1.130952
 0.000000 2.230202 1.130952
 0.000000 2.230202 1.130952
 0.000000 2.230202 1.130952
 0.000000 2.230202 1.130952
 0.000000 2.230202 1.130952
 0.000000 2.230202 1.130952
 0.000000 2.230202 1.130952
 0.000000 2.230202 1.130952
 0.000000 2.230202 1.130952
 0.000000 2.227603 1.128984
 0.000000 2.223440 1.128063
 0.000000 2.217841 1.127830
 0.000000 2.210693 1.128594
 0.000000 2.202210 1.130197

Notice that, because of how PLUMED is called, the output does not keep track of time and it prints every timestep (regardless of STRIDE). Also notice that the first 11 entries are identical, this is because of the warmup steps and these steps can be ignored.
Each walker will then have an AppFuture for the PLUMED output represented as a dictionary and this becomes a property of the SimulationOutput-class:

outputs = sample(walkers, steps=5, print_plumed=True)
print(outputs[0].plumed_output.result())
      >  {'c': array([2.230202, 2.227603, 2.22344 , 2.217841, 2.210693, 2.20221 ]), 'a1': array([1.130952, 1.128984, 1.128063, 1.12783 , 1.128594, 1.130197])}

The dictionary can also be saved to an external file using the write_plumed_output()-function which will give a file that looks like this:

# c a1
2.230202 1.130952
2.227603 1.128984
2.22344 1.128063
2.217841 1.12783
2.210693 1.128594
2.20221 1.130197

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant