Update Colvars library to version 2019-04-26
The following is list of relevant issues fixed and improvements: Fix forces and missing output of runtime histogram for histogramRestraint https://github.com/Colvars/colvars/pull/246 Use fix_modify to add configuration to Colvars: https://github.com/Colvars/colvars/pull/216 Fix componentCoeff and name not working with orientationAngle components: https://github.com/Colvars/colvars/issues/213 Fix 1-timestep offset with extendedLagrangian: https://github.com/Colvars/colvars/pull/210 Changes to improve compiler support: https://github.com/Colvars/colvars/pull/203 Fix ignored anisotropic cutoff3 for groupCoordNum: https://github.com/Colvars/colvars/pull/202 New dipoleMagnitude variable: https://github.com/Colvars/colvars/pull/198 Parser improvements: https://github.com/Colvars/colvars/pull/196
This commit is contained in:
@ -20,7 +20,8 @@ colvar::cvc::cvc()
|
||||
b_periodic(false),
|
||||
b_try_scalable(true)
|
||||
{
|
||||
init_cvc_requires();
|
||||
description = "uninitialized colvar component";
|
||||
init_dependencies();
|
||||
sup_coeff = 1.0;
|
||||
period = 0.0;
|
||||
wrap_center = 0.0;
|
||||
@ -33,7 +34,8 @@ colvar::cvc::cvc(std::string const &conf)
|
||||
b_periodic(false),
|
||||
b_try_scalable(true)
|
||||
{
|
||||
init_cvc_requires();
|
||||
description = "uninitialized colvar component";
|
||||
init_dependencies();
|
||||
sup_coeff = 1.0;
|
||||
period = 0.0;
|
||||
wrap_center = 0.0;
|
||||
@ -176,6 +178,100 @@ cvm::atom_group *colvar::cvc::parse_group(std::string const &conf,
|
||||
}
|
||||
|
||||
|
||||
int colvar::cvc::init_dependencies() {
|
||||
size_t i;
|
||||
// Initialize static array once and for all
|
||||
if (features().size() == 0) {
|
||||
for (i = 0; i < colvardeps::f_cvc_ntot; i++) {
|
||||
modify_features().push_back(new feature);
|
||||
}
|
||||
|
||||
init_feature(f_cvc_active, "active", f_type_dynamic);
|
||||
// The dependency below may become useful if we use dynamic atom groups
|
||||
// require_feature_children(f_cvc_active, f_ag_active);
|
||||
|
||||
init_feature(f_cvc_scalar, "scalar", f_type_static);
|
||||
|
||||
init_feature(f_cvc_gradient, "gradient", f_type_dynamic);
|
||||
|
||||
init_feature(f_cvc_explicit_gradient, "explicit gradient", f_type_static);
|
||||
require_feature_children(f_cvc_explicit_gradient, f_ag_explicit_gradient);
|
||||
|
||||
init_feature(f_cvc_inv_gradient, "inverse gradient", f_type_dynamic);
|
||||
require_feature_self(f_cvc_inv_gradient, f_cvc_gradient);
|
||||
|
||||
init_feature(f_cvc_debug_gradient, "debug gradient", f_type_user);
|
||||
require_feature_self(f_cvc_debug_gradient, f_cvc_gradient);
|
||||
require_feature_self(f_cvc_debug_gradient, f_cvc_explicit_gradient);
|
||||
|
||||
init_feature(f_cvc_Jacobian, "Jacobian derivative", f_type_dynamic);
|
||||
require_feature_self(f_cvc_Jacobian, f_cvc_inv_gradient);
|
||||
|
||||
init_feature(f_cvc_com_based, "depends on group centers of mass", f_type_static);
|
||||
|
||||
init_feature(f_cvc_pbc_minimum_image, "use minimum-image distances with PBCs", f_type_user);
|
||||
|
||||
// Compute total force on first site only to avoid unwanted
|
||||
// coupling to other colvars (see e.g. Ciccotti et al., 2005)
|
||||
init_feature(f_cvc_one_site_total_force, "compute total force from one group", f_type_user);
|
||||
require_feature_self(f_cvc_one_site_total_force, f_cvc_com_based);
|
||||
|
||||
init_feature(f_cvc_scalable, "scalable calculation", f_type_static);
|
||||
require_feature_self(f_cvc_scalable, f_cvc_scalable_com);
|
||||
|
||||
init_feature(f_cvc_scalable_com, "scalable calculation of centers of mass", f_type_static);
|
||||
require_feature_self(f_cvc_scalable_com, f_cvc_com_based);
|
||||
|
||||
|
||||
// TODO only enable this when f_ag_scalable can be turned on for a pre-initialized group
|
||||
// require_feature_children(f_cvc_scalable, f_ag_scalable);
|
||||
// require_feature_children(f_cvc_scalable_com, f_ag_scalable_com);
|
||||
|
||||
// check that everything is initialized
|
||||
for (i = 0; i < colvardeps::f_cvc_ntot; i++) {
|
||||
if (is_not_set(i)) {
|
||||
cvm::error("Uninitialized feature " + cvm::to_str(i) + " in " + description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize feature_states for each instance
|
||||
// default as available, not enabled
|
||||
// except dynamic features which default as unavailable
|
||||
feature_states.reserve(f_cvc_ntot);
|
||||
for (i = 0; i < colvardeps::f_cvc_ntot; i++) {
|
||||
bool avail = is_dynamic(i) ? false : true;
|
||||
feature_states.push_back(feature_state(avail, false));
|
||||
}
|
||||
|
||||
// Features that are implemented by all cvcs by default
|
||||
// Each cvc specifies what other features are available
|
||||
feature_states[f_cvc_active].available = true;
|
||||
feature_states[f_cvc_gradient].available = true;
|
||||
|
||||
// CVCs are enabled from the start - get disabled based on flags
|
||||
enable(f_cvc_active);
|
||||
// feature_states[f_cvc_active].enabled = true;
|
||||
|
||||
// Explicit gradients are implemented in mosts CVCs. Exceptions must be specified explicitly.
|
||||
// feature_states[f_cvc_explicit_gradient].enabled = true;
|
||||
enable(f_cvc_explicit_gradient);
|
||||
|
||||
// Use minimum-image distances by default
|
||||
// feature_states[f_cvc_pbc_minimum_image].enabled = true;
|
||||
enable(f_cvc_pbc_minimum_image);
|
||||
|
||||
// Features that are implemented by default if their requirements are
|
||||
feature_states[f_cvc_one_site_total_force].available = true;
|
||||
|
||||
// Features That are implemented only for certain simulation engine configurations
|
||||
feature_states[f_cvc_scalable_com].available = (cvm::proxy->scalable_group_coms() == COLVARS_OK);
|
||||
feature_states[f_cvc_scalable].available = feature_states[f_cvc_scalable_com].available;
|
||||
|
||||
return COLVARS_OK;
|
||||
}
|
||||
|
||||
|
||||
int colvar::cvc::setup()
|
||||
{
|
||||
description = "cvc " + name;
|
||||
@ -192,6 +288,7 @@ colvar::cvc::~cvc()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void colvar::cvc::read_data()
|
||||
{
|
||||
size_t ig;
|
||||
@ -214,6 +311,66 @@ void colvar::cvc::read_data()
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::vector<int> > colvar::cvc::get_atom_lists()
|
||||
{
|
||||
std::vector<std::vector<int> > lists;
|
||||
|
||||
std::vector<cvm::atom_group *>::iterator agi = atom_groups.begin();
|
||||
for ( ; agi != atom_groups.end(); ++agi) {
|
||||
(*agi)->create_sorted_ids();
|
||||
lists.push_back((*agi)->sorted_ids());
|
||||
if ((*agi)->is_enabled(f_ag_fitting_group) && (*agi)->is_enabled(f_ag_fit_gradients)) {
|
||||
cvm::atom_group &fg = *((*agi)->fitting_group);
|
||||
fg.create_sorted_ids();
|
||||
lists.push_back(fg.sorted_ids());
|
||||
}
|
||||
}
|
||||
return lists;
|
||||
}
|
||||
|
||||
|
||||
void colvar::cvc::collect_gradients(std::vector<int> const &atom_ids, std::vector<cvm::rvector> &atomic_gradients)
|
||||
{
|
||||
// Coefficient: d(a * x^n) = a * n * x^(n-1) * dx
|
||||
cvm::real coeff = sup_coeff * cvm::real(sup_np) *
|
||||
cvm::integer_power(value().real_value, sup_np-1);
|
||||
|
||||
for (size_t j = 0; j < atom_groups.size(); j++) {
|
||||
|
||||
cvm::atom_group &ag = *(atom_groups[j]);
|
||||
|
||||
// If necessary, apply inverse rotation to get atomic
|
||||
// gradient in the laboratory frame
|
||||
if (ag.b_rotate) {
|
||||
cvm::rotation const rot_inv = ag.rot.inverse();
|
||||
|
||||
for (size_t k = 0; k < ag.size(); k++) {
|
||||
size_t a = std::lower_bound(atom_ids.begin(), atom_ids.end(),
|
||||
ag[k].id) - atom_ids.begin();
|
||||
atomic_gradients[a] += coeff * rot_inv.rotate(ag[k].grad);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
for (size_t k = 0; k < ag.size(); k++) {
|
||||
size_t a = std::lower_bound(atom_ids.begin(), atom_ids.end(),
|
||||
ag[k].id) - atom_ids.begin();
|
||||
atomic_gradients[a] += coeff * ag[k].grad;
|
||||
}
|
||||
}
|
||||
if (ag.is_enabled(f_ag_fitting_group) && ag.is_enabled(f_ag_fit_gradients)) {
|
||||
cvm::atom_group const &fg = *(ag.fitting_group);
|
||||
for (size_t k = 0; k < fg.size(); k++) {
|
||||
size_t a = std::lower_bound(atom_ids.begin(), atom_ids.end(),
|
||||
fg[k].id) - atom_ids.begin();
|
||||
// fit gradients are in the unrotated (simulation) frame
|
||||
atomic_gradients[a] += coeff * fg.fit_gradients[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void colvar::cvc::calc_force_invgrads()
|
||||
{
|
||||
cvm::error("Error: calculation of inverse gradients is not implemented "
|
||||
@ -306,8 +463,8 @@ void colvar::cvc::debug_gradients()
|
||||
cvm::log("dx(interp) = "+cvm::to_str(dx_pred,
|
||||
21, 14)+"\n");
|
||||
cvm::log("|dx(actual) - dx(interp)|/|dx(actual)| = "+
|
||||
cvm::to_str(std::fabs(x_1 - x_0 - dx_pred) /
|
||||
std::fabs(x_1 - x_0), 12, 5)+"\n");
|
||||
cvm::to_str(cvm::fabs(x_1 - x_0 - dx_pred) /
|
||||
cvm::fabs(x_1 - x_0), 12, 5)+"\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -341,8 +498,8 @@ void colvar::cvc::debug_gradients()
|
||||
cvm::log("dx(interp) = "+cvm::to_str (dx_pred,
|
||||
21, 14)+"\n");
|
||||
cvm::log ("|dx(actual) - dx(interp)|/|dx(actual)| = "+
|
||||
cvm::to_str(std::fabs (x_1 - x_0 - dx_pred) /
|
||||
std::fabs (x_1 - x_0),
|
||||
cvm::to_str(cvm::fabs (x_1 - x_0 - dx_pred) /
|
||||
cvm::fabs (x_1 - x_0),
|
||||
12, 5)+
|
||||
".\n");
|
||||
}
|
||||
@ -378,7 +535,7 @@ colvarvalue colvar::cvc::dist2_rgrad(colvarvalue const &x1,
|
||||
}
|
||||
|
||||
|
||||
void colvar::cvc::wrap(colvarvalue &x) const
|
||||
void colvar::cvc::wrap(colvarvalue &x_unwrapped) const
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user