Skip to content

Commit

Permalink
Interoperate with alchLambdaFreq in NAMD
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jhenin committed Feb 25, 2025
1 parent 1ee3ec1 commit 99a197c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions namd/src/colvarproxy_namd.C
Original file line number Diff line number Diff line change
Expand Up @@ -1669,14 +1669,21 @@ int colvarproxy_namd::request_alch_energy_freq(int const freq) {

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


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

Expand Down

0 comments on commit 99a197c

Please sign in to comment.