Skip to content

Commit 525ad8e

Browse files
committed
Interoperate with alchLambdaFreq in NAMD
alchLambdaFreq is a yet undocumented NAMD feature that makes the alchemical lambda evolve according to a linear ramp over time. This change set ensures compatibility of that feature with Colvars: - prevents conflicts between the ramp and lambda-dynamics from Colvars - fetches the up-to-date value of lambda when using linear ramps.
1 parent da6f0dc commit 525ad8e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

namd/src/colvarproxy_namd.C

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,14 +1669,21 @@ int colvarproxy_namd::request_alch_energy_freq(int const freq) {
16691669

16701670
/// Get value of alchemical lambda parameter from back-end
16711671
int colvarproxy_namd::get_alch_lambda(cvm::real* lambda) {
1672-
*lambda = simparams->alchLambda;
1672+
*lambda = simparams->getCurrentLambda(step);
16731673
return COLVARS_OK;
16741674
}
16751675

16761676

16771677
/// Set value of alchemical lambda parameter in back-end
16781678
int colvarproxy_namd::send_alch_lambda(void) {
1679-
simparams->alchLambda = cached_alch_lambda;
1679+
if (simparams->alchLambdaFreq > 0) {
1680+
cvm::error("Cannot set lambda from Colvars because alchLambdaFreq is enabled. "
1681+
"Either remove biasing forces and extended Lagrangian dynamics on the alchemical coordinate, "
1682+
"or disable alchLambdaFreq.\n");
1683+
return COLVARS_INPUT_ERROR;
1684+
} else {
1685+
simparams->alchLambda = cached_alch_lambda;
1686+
}
16801687
return COLVARS_OK;
16811688
}
16821689

0 commit comments

Comments
 (0)