Colvars / colvars

Collective variables library for molecular simulation and analysis programs
http://colvars.github.io/
GNU Lesser General Public License v3.0
205 stars 59 forks source link

Feature request: reusable bias #712

Open HanatoK opened 2 weeks ago

HanatoK commented 2 weeks ago

It should be possible to use the bias energy, or other output components, of a colvarbias instance as the inputs of another colvarbias instance. For example, a histogram bias can reuse the bias energies from other biases to perform reweighting on-the-fly.

giacomofiorin commented 5 days ago

As commented in #709 we have already several cases where we are running all biases in sequence: https://github.com/Colvars/colvars/blob/a587282f1e0a8e97fbb440ebd7ca18a82f068fbd/src/colvarmodule.cpp#L1016-L1042

So if there is a dependency like the one you describe, we could just do the same (until we have the AST that you proposed elsewhere).

The only tricky detail would be ensuring that the biases are listed internally in the same order as they were defined in the user input. colvarmodule::parse_biases() reads all biases of the same type at once, and goes alphabetically over bias types. However, we could record the position of each bias in a new input string and use that position to sort all newly added biases?