update to colvars version of 27-04-2016

This commit is contained in:
Axel Kohlmeyer
2016-04-27 13:17:41 -04:00
parent c5f83fc7dd
commit 7005d59d25
10 changed files with 103 additions and 131 deletions

View File

@ -39,14 +39,17 @@ colvar::cvc::cvc(std::string const &conf)
get_keyval(conf, "period", period, 0.0);
get_keyval(conf, "wrapAround", wrap_center, 0.0);
get_keyval(conf, "debugGradients", b_debug_gradient, false, parse_silent);
// All cvcs implement this
provide(f_cvc_debug_gradient);
{
bool b_debug_gradient;
get_keyval(conf, "debugGradients", b_debug_gradient, false, parse_silent);
if (b_debug_gradient) enable(f_cvc_debug_gradient);
}
// Attempt scalable calculations when in parallel? (By default yes, if available)
get_keyval(conf, "scalable", b_try_scalable, true);
// All cvcs implement this
provide(f_cvc_debug_gradient);
if (cvm::debug())
cvm::log("Done initializing cvc base object.\n");
}
@ -107,7 +110,6 @@ int colvar::cvc::setup()
if (b_try_scalable && is_available(f_cvc_scalable)) {
enable(f_cvc_scalable);
}
if (b_debug_gradient) enable(f_cvc_debug_gradient);
return COLVARS_OK;
}
@ -176,30 +178,21 @@ void colvar::cvc::debug_gradients(cvm::atom_group *group)
// cvm::log("gradients = "+cvm::to_str (gradients)+"\n");
cvm::atom_group *group_for_fit = group->ref_pos_group ? group->ref_pos_group : group;
cvm::atom_pos fit_gradient_sum, gradient_sum;
// print the values of the fit gradients
if (group->b_rotate || group->b_center) {
if (group->b_fit_gradients) {
size_t j;
// fit_gradients are in the original frame: we should print them in the rotated frame
if (group->b_rotate) {
for (j = 0; j < group_for_fit->fit_gradients.size(); j++) {
group_for_fit->fit_gradients[j] = rot_0.rotate(group_for_fit->fit_gradients[j]);
}
}
// fit_gradients are in the simulation frame: we should print them in the rotated frame
cvm::log("Fit gradients:\n");
for (j = 0; j < group_for_fit->fit_gradients.size(); j++) {
cvm::log((group->ref_pos_group ? std::string("refPosGroup") : group->key) +
"[" + cvm::to_str(j) + "] = " + cvm::to_str(group_for_fit->fit_gradients[j]));
}
if (group->b_rotate) {
for (j = 0; j < group_for_fit->fit_gradients.size(); j++) {
group_for_fit->fit_gradients[j] = rot_inv.rotate(group_for_fit->fit_gradients[j]);
}
"[" + cvm::to_str(j) + "] = " +
(group->b_rotate ?
cvm::to_str(rot_0.rotate(group_for_fit->fit_gradients[j])) :
cvm::to_str(group_for_fit->fit_gradients[j])));
}
}
}
@ -208,9 +201,10 @@ void colvar::cvc::debug_gradients(cvm::atom_group *group)
for (size_t ia = 0; ia < group->size(); ia++) {
// tests are best conducted in the unrotated (simulation) frame
cvm::rvector const atom_grad = group->b_rotate ?
rot_inv.rotate((*group)[ia].grad) :
(*group)[ia].grad;
cvm::rvector const atom_grad = (group->b_rotate ?
rot_inv.rotate((*group)[ia].grad) :
(*group)[ia].grad);
gradient_sum += atom_grad;
for (size_t id = 0; id < 3; id++) {
// (re)read original positions
@ -242,26 +236,26 @@ void colvar::cvc::debug_gradients(cvm::atom_group *group)
for (size_t ia = 0; ia < ref_group->size(); ia++) {
// tests are best conducted in the unrotated (simulation) frame
// fit gradients are in the unrotated (simulation) frame
cvm::rvector const atom_grad = ref_group->fit_gradients[ia];
fit_gradient_sum += atom_grad;
for (size_t id = 0; id < 3; id++) {
// (re)read original positions
group->read_positions();
ref_group->read_positions();
// change one coordinate
(*ref_group)[ia].pos[id] += cvm::debug_gradients_step_size;
group->calc_required_properties();
calc_value();
cvm::real const x_1 = x.real_value;
cvm::log("refPosGroup atom "+cvm::to_str(ia)+", component "+cvm::to_str (id)+":\n");
cvm::log("dx(actual) = "+cvm::to_str (x_1 - x_0,
21, 14)+"\n");
cvm::real const dx_pred = cvm::debug_gradients_step_size * atom_grad[id];
cvm::log("dx(interp) = "+cvm::to_str (dx_pred,
21, 14)+"\n");
cvm::log ("|dx(actual) - dx(interp)|/|dx(actual)| = "+
@ -273,6 +267,10 @@ void colvar::cvc::debug_gradients(cvm::atom_group *group)
}
}
cvm::log("Gradient sum: " + cvm::to_str(gradient_sum) +
" Fit gradient sum: " + cvm::to_str(fit_gradient_sum) +
" Total " + cvm::to_str(gradient_sum + fit_gradient_sum));
return;
}