Update Colvars to version 2017-07-15 and support automated builds for it

This commit is contained in:
Giacomo Fiorin
2017-07-19 14:10:43 -04:00
parent cc9b3864bf
commit ee6cac826e
52 changed files with 3473 additions and 2413 deletions

View File

@ -23,10 +23,14 @@
/// 3. Static features are static properties of the object, determined
/// programatically at initialization time.
///
/// In all classes, feature 0 is active. When an object is inactivated
/// all its children dependencies are dereferenced (free_children_deps)
/// While the object is inactive, no dependency solving is done on children
/// it is done when the object is activated back (restore_children_deps)
class colvardeps {
public:
colvardeps() {}
colvardeps();
virtual ~colvardeps();
// Subclasses should initialize the following members:
@ -34,9 +38,10 @@ public:
std::string description; // reference to object name (cv, cvc etc.)
/// This contains the current state of each feature for each object
// since the feature class only contains static properties
struct feature_state {
feature_state(bool a, bool e)
: available(a), enabled(e) {}
: available(a), enabled(e), ref_count(0) {}
/// Feature may be enabled, subject to possible dependencies
bool available;
@ -44,9 +49,28 @@ public:
/// TODO consider implications for dependency solving: anyone who disables
/// it should trigger a refresh of parent objects
bool enabled; // see if this should be private depending on implementation
// bool enabledOnce; // this should trigger an update when object is evaluated
/// Number of features requiring this one as a dependency
/// When it falls to zero:
/// - a dynamic feature is disabled automatically
/// - other features may be disabled statically
int ref_count;
/// List of features that were enabled by this one
/// as part of an alternate requirement (for ref counting purposes)
/// This is necessary because we don't know which feature in the list
/// we enabled, otherwise
std::vector<int> alternate_refs;
};
protected:
/// Time step multiplier (for coarse-timestep biases & colvars)
/// Biases and colvars will only be calculated at those times
/// (f_cvb_awake and f_cv_awake); a
/// Biases use this to apply "impulse" biasing forces at the outer timestep
/// Unused by lower-level objects (cvcs and atom groups)
int time_step_factor;
private:
/// List of the states of all features
@ -61,10 +85,13 @@ private:
};
public:
/// \brief returns time_step_factor
inline int get_time_step_factor() const {return time_step_factor;}
/// Pair a numerical feature ID with a description and type
void init_feature(int feature_id, const char *description, feature_type type = f_type_not_set);
/// Describes a feature and its dependecies
/// Describes a feature and its dependencies
/// used in a static array within each subclass
class feature {
@ -120,30 +147,16 @@ public:
private:
// pointers to objects this object depends on
// list should be maintained by any code that modifies the object
// this could be secured by making lists of colvars / cvcs / atom groups private and modified through accessor functions
/// pointers to objects this object depends on
/// list should be maintained by any code that modifies the object
/// this could be secured by making lists of colvars / cvcs / atom groups private and modified through accessor functions
std::vector<colvardeps *> children;
// pointers to objects that depend on this object
// the size of this array is in effect a reference counter
/// pointers to objects that depend on this object
/// the size of this array is in effect a reference counter
std::vector<colvardeps *> parents;
public:
// disabling a feature f:
// if parents depend on f, tell them to refresh / check that they are ok?
// if children provide features to satisfy f ONLY, disable that
// When the state of this object has changed, recursively tell parents
// to enforce their dependencies
// void refresh_parents() {
//
// }
// std::vector<colvardeps *> parents; // Needed to trigger a refresh if capabilities of this object change
// End of members to be initialized by subclasses
// Checks whether given feature is enabled
// Defaults to querying f_*_active
inline bool is_enabled(int f = f_cv_active) const {
@ -161,9 +174,7 @@ public:
/// dependencies will be checked by enable()
void provide(int feature_id, bool truefalse = true);
/// Set the feature's enabled flag, without dependency check or resolution
/// To be used for static properties only
/// Checking for availability is up to the caller
/// Enable or disable, depending on flag value
void set_enabled(int feature_id, bool truefalse = true);
protected:
@ -178,31 +189,57 @@ protected:
public:
int enable(int f, bool dry_run = false, bool toplevel = true); // enable a feature and recursively solve its dependencies
// dry_run is set to true to recursively test if a feature is available, without enabling it
// int disable(int f);
/// enable a feature and recursively solve its dependencies
/// for proper reference counting, one should not add
/// spurious calls to enable()
/// dry_run is set to true to recursively test if a feature is available, without enabling it
int enable(int f, bool dry_run = false, bool toplevel = true);
/// Disable a feature, decrease the reference count of its dependencies
/// and recursively disable them as applicable
int disable(int f);
/// This function is called whenever feature states are changed outside
/// of the object's control, that is, by parents
/// Eventually it may also be used when properties of children change
virtual int refresh_deps() { return COLVARS_OK; }
/// disable all enabled features to free their dependencies
/// to be done when deleting the object
/// Cannot be in the base class destructor because it needs the derived class features()
void free_children_deps();
/// re-enable children features (to be used when object becomes active)
void restore_children_deps();
/// Decrement the reference count of a feature
/// disabling it if it's dynamic and count reaches zero
int decr_ref_count(int f);
/// Implements possible actions to be carried out
/// when a given feature is enabled
/// Base function does nothing, can be overloaded
virtual void do_feature_side_effects(int id) {}
// NOTE that all feature enums should start with f_*_active
enum features_biases {
/// \brief Bias is active
f_cvb_active,
f_cvb_apply_force, // will apply forces
f_cvb_get_total_force, // requires total forces
f_cvb_history_dependent, // depends on simulation history
f_cvb_scalar_variables, // requires scalar colvars
f_cvb_calc_pmf, // whether this bias will compute a PMF
/// \brief Bias is awake (active on its own accord) this timestep
f_cvb_awake,
/// \brief will apply forces
f_cvb_apply_force,
/// \brief requires total forces
f_cvb_get_total_force,
/// \brief depends on simulation history
f_cvb_history_dependent,
/// \brief requires scalar colvars
f_cvb_scalar_variables,
/// \brief whether this bias will compute a PMF
f_cvb_calc_pmf,
f_cvb_ntot
};
enum features_colvar {
/// \brief Calculate colvar
f_cv_active,
/// \brief Colvar is awake (active on its own accord) this timestep
f_cv_awake,
/// \brief Gradients are calculated and temporarily stored, so
/// that external forces can be applied
f_cv_gradient,
@ -254,12 +291,16 @@ public:
f_cv_corrfunc,
/// \brief Value and gradient computed by user script
f_cv_scripted,
/// \brief Value and gradient computed by user function through Lepton
f_cv_custom_function,
/// \brief Colvar is periodic
f_cv_periodic,
/// \brief is scalar
f_cv_scalar,
f_cv_linear,
f_cv_homogeneous,
/// \brief multiple timestep through time_step_factor
f_cv_multiple_ts,
/// \brief Number of colvar features
f_cv_ntot
};
@ -268,10 +309,13 @@ public:
f_cvc_active,
f_cvc_scalar,
f_cvc_gradient,
/// \brief CVC doesn't calculate and store explicit atom gradients
f_cvc_implicit_gradient,
f_cvc_inv_gradient,
/// \brief If enabled, calc_gradients() will call debug_gradients() for every group needed
f_cvc_debug_gradient,
f_cvc_Jacobian,
f_cvc_pbc_minimum_image,
f_cvc_one_site_total_force,
f_cvc_com_based,
f_cvc_scalable,
@ -287,9 +331,9 @@ public:
/// Perform a standard minimum msd fit for given atoms
/// ie. not using refpositionsgroup
// f_ag_min_msd_fit,
f_ag_fit_gradient_group,// TODO check that these are sometimes needed separately
// maybe for minimum RMSD?
f_ag_fit_gradient_ref,
/// \brief Does not have explicit atom gradients from parent CVC
f_ag_implicit_gradient,
f_ag_fit_gradients,
f_ag_atom_forces,
f_ag_scalable,
f_ag_scalable_com,