How to apply different "forceConstant" in Colvars?

Hello everyone
I am using the colvars module in LAMMPS for umbrella sampling calculation, I want to use two forceConstant values in each targetNumStages, for example, in stage 1, the first 1ns forceConstant is 10, and the last 4ns forceConstant is 20. Each stage lasts for 5ns, and for stage 2, the same process applies.
I have reviewed the “Changing force constant” section in the manual, but according to my understanding, this command can only make the “forceConstant” reach the set “targetForceConstant” after all “targetNumStages” have ended, and cannot be changed within each stage and repeat this process in the next stage.
Is there any way to achieve my goal? Thanks.

Hi, that’s correct: at the moment you cannot both specify targetCenters and targetForceConstant, because there is no way implemented to compute the combined non-equilibrium work of both transformations.

However, using targetCenters in combination with targetNumStages is just one way of running umbrella sampling computations, where the ending snapshot of one stage becomes the initial snapshot for the next one.

As soon as you have suitable initial snapshots for each window, these can be simulated independently, and this can be useful to leverage a cluster. You would need to run more than one job, but can control each one fully. Each job can use targetForceConstant to gradually stiffen the restraint of that US window.

Just remember to include only configuration well after the force constant is equilibrated when unbiasing the trajectories with WHAM, M-BAR, or similar tools.

Giacomo

Thanks for your reply, but I don’t quite understand what you mean yet. Can the job using “targetForceConstant” be placed in the same colvars as the process used to achieve equilibration? Or do you need to run another colvars file? If so, how do you put the two in the same LAMMPS simulation?

I’m not 100% sure I understand either, but I’ll do my best (also for the forum).

The target* options are designed to achieve an entire transformation of either the centers or the FC in one go, optionally breaking it up in consecutive stages. Because the step counter is initialized before the first stage begins, the FC would increase only when going through all stages, not within each stage (as you also wrote in the first post).

In your case, you should not use targetCenters option. That is, instead of spanning all US windows in one simulation, each window should be an independent simulation with the center of the restraint defined statically. In that same restraint, you can use a targetForceConstant option to change the FC over time as you run that window. The same will also happen for all windows.

If you absolutely want to run all windows using one LAMMPS script, you could have a loop where you iterate between over multiple Colvars config files, each with a fixed restraint center and a FC that increases over time. Deleting and recreating the LAMMPS fix in between run commands should be sufficient.

To do that with the current version of LAMMPS, you still need to prepare individual Colvars config files, one for each window unfortunately. However, if you are able to try building a version of LAMMPS with the latest Colvars version embedded. That version includes an improved Colvars interface that allows you to inline the Colvars config and use LAMMPS variables in it, i.e. it lets you do this:

fix Colvars all colvars colvar_only.conf
variable window getenv SLURM_ARRAY_TASK_ID
variable x0 equal 2.0 + 0.25 * ${window}
fix_modify Colvars config """
harmonic {
  name us_${window}
  colvars xi
  centers ${x0}
  ...
}"""

The example above defines the window’s index based on an environment variable from the Slurm queue system, but you can also replace it with a different LAMMPS variable. This feature will be included in LAMMPS after the pending stable release is finalized. Hope that helps.

Giacomo

1 Like