20#include "colvarvalue.h"
22#include "colvardeps.h"
99 virtual const std::vector<feature *> &
features()
const
103 virtual std::vector<feature *> &modify_features()
107 static void delete_features() {
169 return ( ( (dt > 0.0) ? (1.0/dt) : 1.0 ) *
252 int init(std::string
const &conf);
278 template <
typename def_
class_name>
383 int set_cvc_param(std::string
const ¶m_name,
void const *new_value);
454 std::istream &
read_traj(std::istream &is);
477 std::ostream &
write_state(std::ostream &os)
const;
526 std::vector<cvm::real>
acf;
616 class alpha_dihedrals;
659 std::vector<std::shared_ptr<colvar::cvc>>
cvcs;
677 std::vector<Lepton::CompiledExpression *> value_evaluators;
680 std::vector<Lepton::CompiledExpression *> gradient_evaluators;
683 std::vector<double *> value_eval_var_refs;
684 std::vector<double *> grad_eval_var_refs;
757 std::string(
"applying a force to the variable \""+
name+
"\""));
Definition: colvarcomp.h:1369
Definition: colvarcomp.h:1240
Definition: colvarcomp.h:1226
Definition: colvarcomp.h:1210
Colvar component: alpha helix content of a contiguous segment of 5 or more residues,...
Definition: colvarcomp.h:913
Colvar component: angle between the centers of mass of three groups (colvarvalue::type_scalar type,...
Definition: colvarcomp.h:635
Definition: colvarcomp.h:1472
Definition: colvarcomp.h:1442
Definition: colvarcomp.h:1488
Definition: colvarcomp.h:1457
Definition: colvarcomp.h:1179
Colvar component: coordination number between two groups (colvarvalue::type_scalar type,...
Definition: colvarcomp.h:748
custom expression of colvars
Definition: colvarcomp.h:1343
Colvar component (base class for collective variables)
Definition: colvarcomp.h:70
Colvar component: dihedPC Projection of the config onto a dihedral principal component See e....
Definition: colvarcomp.h:960
Colvar component: dihedral between the centers of mass of four groups (colvarvalue::type_scalar type,...
Definition: colvarcomp.h:711
Colvar component: angle between the dipole of a molecule and an axis formed by two groups of atoms(co...
Definition: colvarcomp.h:675
Colvar component: dipole magnitude of a molecule.
Definition: colvarcomp.h:532
Colvar component: distance unit vector (direction) between centers of mass of two groups (colvarvalue...
Definition: colvarcomp.h:372
Colvar component: average distance between two groups of atoms, weighted as the sixth power,...
Definition: colvarcomp.h:483
Colvar component: N1xN2 vector of pairwise distances (colvarvalue::type_vector type,...
Definition: colvarcomp.h:505
Definition: colvarcomp.h:349
Colvar component: projection of the distance vector on a plane (colvarvalue::type_scalar type,...
Definition: colvarcomp.h:427
Colvar component: projection of the distance vector along an axis(colvarvalue::type_scalar type,...
Definition: colvarcomp.h:395
Colvar component: distance between the centers of mass of two groups (colvarvalue::type_scalar type,...
Definition: colvarcomp.h:324
Colvar component: projection of 3N coordinates onto an eigenvector(colvarvalue::type_scalar type,...
Definition: colvarcomp.h:603
Definition: colvarcomp.h:1107
Definition: colvarcomp.h:1118
Definition: colvarcomp.h:1129
Colvar component: coordination number between two groups (colvarvalue::type_scalar type,...
Definition: colvarcomp.h:858
Colvar component: alternative path collective variable using geometry, variable s Allow any combinati...
Definition: colvarcomp.h:1408
Colvar component: alternative path collective variable using geometry, variable s For more informatio...
Definition: colvarcomp.h:1269
Colvar component: Radius of gyration of an atom group (colvarvalue::type_scalar type,...
Definition: colvarcomp.h:551
Definition: colvarcomp.h:1425
Colvar component: alternative path collective variable using geometry, variable z This should be merg...
Definition: colvarcomp.h:1291
Colvar component: hydrogen bond, defined as the product of a colvar::coordnum and 1/2*(1-cos((180-ang...
Definition: colvarcomp.h:886
Colvar component: moment of inertia of an atom group around a user-defined axis (colvarvalue::type_sc...
Definition: colvarcomp.h:585
Colvar component: moment of inertia of an atom group (colvarvalue::type_scalar type,...
Definition: colvarcomp.h:571
Current only linear combination of sub-CVCs is available.
Definition: colvarcomp.h:1311
Definition: colvarcomp.h:1540
Definition: colvarcomp.h:1509
Definition: colvarcomp.h:1035
Colvar component: cosine of the angle of rotation with respect to a set of reference coordinates (col...
Definition: colvarcomp.h:1060
Colvar component: orientation in space of an atom group, with respect to a set of reference coordinat...
Definition: colvarcomp.h:986
Colvar component: polar coordinate phi of a group (colvarvalue::type_scalar type, range [-180:180])
Definition: colvarcomp.h:447
Colvar component: polar coordinate theta of a group (colvarvalue::type_scalar type,...
Definition: colvarcomp.h:465
Colvar component: root mean square deviation (RMSD) of a group with respect to a set of reference coo...
Definition: colvarcomp.h:1144
Colvar component: self-coordination number within a group (colvarvalue::type_scalar type,...
Definition: colvarcomp.h:824
Colvar component: angle of rotation around a predefined axis (colvarvalue::type_scalar type,...
Definition: colvarcomp.h:1095
Colvar component: projection of the orientation vector onto a predefined axis (colvarvalue::type_scal...
Definition: colvarcomp.h:1075
A collective variable (main class); to be defined, it needs at least one object of a derived class of...
Definition: colvar.h:53
bool periodic_boundaries() const
Is the interval defined by the two boundaries periodic?
Definition: colvar.cpp:2202
void update_active_cvc_square_norm()
Update the sum of square coefficients for active cvcs.
Definition: colvar.cpp:2063
void communicate_forces()
Communicate forces (previously calculated in colvar::update()) to the external degrees of freedom.
Definition: colvar.cpp:1964
size_t num_cvcs() const
Number of CVC objects defined.
Definition: colvar.h:408
int end_of_step()
Carry out operations needed before next step is run.
Definition: colvar.cpp:1946
colvarvalue const * get_cvc_param_grad(std::string const ¶m_name)
Pointer to the derivative of the variable with respect to param_name.
Definition: colvar.cpp:2165
colvarvalue const & actual_value() const
Current actual value (not extended DOF)
Definition: colvar.h:730
colvarvalue const & run_ave() const
Current running average (if calculated as set by analysis flag)
Definition: colvar.h:736
colvarvalue const & velocity() const
Current velocity (previously set by calc() or by read_traj())
Definition: colvar.h:742
cvm::real active_cvc_square_norm
Sum of square coefficients for active cvcs.
Definition: colvar.h:391
colvarvalue x_restart
Value read from the most recent state file (if any)
Definition: colvar.h:494
size_t num_dimensions() const
Number of dimensions of the value of this colvar.
Definition: colvar.h:402
cvm::real runave_variance
Current value of the square deviation from the running average.
Definition: colvar.h:574
int calc_cvc_total_force(int first, size_t num_cvcs)
Same as colvar::calc_cvc_values but for total forces.
Definition: colvar.cpp:1584
colvarvalue f
Total applied force; fr (if extended_lagrangian is defined), fb (if biases are applied) and the walls...
Definition: colvar.h:216
std::list< std::list< colvarvalue > >::iterator x_history_p
Definition: colvar.h:510
std::vector< colvarbias * > biases
List of biases that depend on this colvar.
Definition: colvar.h:120
std::vector< const colvarvalue * > sorted_cvc_values
Definition: colvar.h:673
colvarvalue const & value() const
Current value (previously set by calc() or by read_traj())
Definition: colvar.h:724
int write_output_files()
Write output files (if defined, e.g. in analysis mode)
Definition: colvar.cpp:2640
std::ostream & write_state(std::ostream &os) const
Write the colvar's state to a formatted output stream.
Definition: colvar.cpp:2479
int parse_analysis(std::string const &conf)
Read the analysis tasks.
Definition: colvar.cpp:1016
int init_custom_function(std::string const &conf)
Parse parameters for custom function with Lepton.
Definition: colvar.cpp:484
cvm::real ext_gamma
Friction coefficient for Langevin extended dynamics.
Definition: colvar.h:190
std::string acf_outfile
Name of the file to write the ACF.
Definition: colvar.h:528
cvm::real ext_mass
Mass of the restraint center.
Definition: colvar.h:186
int init_components_type(const std::string &conf, const char *config_key)
Initialize any CVC objects matching the given key.
Definition: colvar.cpp:778
std::ostream & write_traj(std::ostream &os)
Output formatted values to the trajectory file.
Definition: colvar.cpp:2586
cvm::real dist2(colvarvalue const &x1, colvarvalue const &x2) const
Use the internal metrics (as from colvar::cvc objects) to calculate square distances and gradients.
Definition: colvar.cpp:2213
bool after_restart
True if a state file was just read.
Definition: colvar.h:497
std::string name
Name.
Definition: colvar.h:58
colvarvalue v_ext
Velocity of the restraint center.
Definition: colvar.h:182
virtual std::vector< std::vector< int > > get_atom_lists()
Get vector of vectors of atom IDs for all atom groups.
Definition: colvar.cpp:1252
size_t acf_nframes
Number of frames for each ACF point.
Definition: colvar.h:522
int set_state_params(std::string const &state_conf)
Read the values of colvar mutable data from a string (used by both versions of read_state())
Definition: colvar.cpp:2344
bool matching_state
Flag used to tell if the state string being read is for this colvar.
Definition: colvar.h:488
int calc()
Calculate the colvar's value and related quantities.
Definition: colvar.cpp:1339
cvm::real period
Period, if this variable is periodic.
Definition: colvar.h:226
cvm::real kinetic_energy
If extended Lagrangian active: colvar kinetic energy.
Definition: colvar.h:580
void calc_vel_acf(std::list< colvarvalue > &v_history, colvarvalue const &v)
Velocity ACF, scalar product between v(0) and v(t)
Definition: colvar.cpp:2799
colvarvalue lower_boundary
Location of the lower boundary.
Definition: colvar.h:236
int update_cvc_config(std::vector< std::string > const &confs)
Modify the configuration of CVCs (currently, only base class data)
Definition: colvar.cpp:2098
int init_output_flags(std::string const &conf)
Init output flags.
Definition: colvar.cpp:731
int collect_cvc_values()
Collect the values of the CVCs.
Definition: colvar.cpp:1459
std::istream & read_traj(std::istream &is)
Read the value from a collective variable trajectory file.
Definition: colvar.cpp:2429
int check_cvc_range(int first_cvc, size_t num_cvcs)
Ensure that the selected range of CVCs is consistent.
Definition: colvar.cpp:1417
colvarvalue fb
Bias force; reset_bias_force() should be called before the biases are updated.
Definition: colvar.h:208
size_t n_active_cvcs
Number of CVC objects with an active flag.
Definition: colvar.h:388
std::vector< cvm::real > acf
ACF values.
Definition: colvar.h:526
int cvc_param_exists(std::string const ¶m_name)
Whether this named parameter exists (in the first and only component)
Definition: colvar.cpp:2133
std::list< std::list< colvarvalue > >::iterator acf_x_history_p
Definition: colvar.h:504
colvarvalue dist2_rgrad(colvarvalue const &x1, colvarvalue const &x2) const
Use the internal metrics (as from colvar::cvc objects) to calculate square distances and gradients.
Definition: colvar.cpp:2251
size_t runave_length
Length of running average series.
Definition: colvar.h:566
acf_type_e
Type of autocorrelation function (ACF)
Definition: colvar.h:531
@ acf_coor
Coordinate ACF, scalar product between x(0) and x(t)
Definition: colvar.h:537
@ acf_notset
Unset type.
Definition: colvar.h:533
@ acf_vel
Velocity ACF, scalar product between v(0) and v(t)
Definition: colvar.h:535
@ acf_p2coor
Coordinate ACF, second order Legendre polynomial between x(0) and x(t) (does not work with scalar num...
Definition: colvar.h:540
colvarvalue fj
Jacobian force, when Jacobian_force is enabled.
Definition: colvar.h:198
colvarvalue const applied_force() const
Get the current applied force.
Definition: colvar.h:331
void calc_p2coor_acf(std::list< colvarvalue > &x_history, colvarvalue const &x)
Coordinate ACF, second order Legendre polynomial between x(0) and x(t) (does not work with scalar num...
Definition: colvar.cpp:2844
int init_grid_parameters(std::string const &conf)
Init defaults for grid options.
Definition: colvar.cpp:500
int collect_cvc_Jacobians()
Same as colvar::collect_cvc_values but for Jacobian derivatives/forces.
Definition: colvar.cpp:1666
void wrap(colvarvalue &x_unwrapped) const
Use the internal metrics (as from colvar::cvc objects) to wrap a value into a standard interval.
Definition: colvar.cpp:2271
void do_feature_side_effects(int id)
Definition: colvar.cpp:959
int calc_runave()
Calculate the running average and its standard deviation.
Definition: colvar.cpp:2924
cvm::step_number prev_timestep
Absolute timestep number when this colvar was last updated.
Definition: colvar.h:397
colvarvalue prev_x_ext
Previous value of the restraint center;.
Definition: colvar.h:180
int check_matching_state(std::string const &state_conf)
Check the name of the bias vs. the given string, set the matching_state flag accordingly.
Definition: colvar.cpp:2320
std::string scripted_function
Name of scripted function to be used.
Definition: colvar.h:669
void add_bias_force(colvarvalue const &force)
Add to the total force from biases.
Definition: colvar.h:754
virtual int init_dependencies()
Initialize dependency tree.
Definition: colvar.cpp:1089
std::ostream & write_traj_label(std::ostream &os)
Write a label to the trajectory file (comment line)
Definition: colvar.cpp:2535
int calc_colvar_properties()
Calculate the quantities associated to the colvar (but not to the CVCs)
Definition: colvar.cpp:1688
colvar()
Constructor.
Definition: colvar.cpp:32
int calc_cvc_Jacobians(int first, size_t num_cvcs)
Same as colvar::calc_cvc_values but for Jacobian derivatives/forces.
Definition: colvar.cpp:1645
int collect_cvc_total_forces()
Same as colvar::collect_cvc_values but for total forces.
Definition: colvar.cpp:1613
bool expand_boundaries
Expand the boundaries of multiples of width, to keep the value always within range.
Definition: colvar.h:233
void calc_coor_acf(std::list< colvarvalue > &x_history, colvarvalue const &x)
Coordinate ACF, scalar product between x(0) and x(t) (does not work with scalar numbers)
Definition: colvar.cpp:2824
static bool compare_cvc(const colvar::cvc *const i, const colvar::cvc *const j)
function for sorting cvcs by their names
Definition: colvar.cpp:55
static std::map< std::string, std::function< colvar::cvc *()> > global_cvc_map
A global mapping of cvc names to the cvc constructors.
Definition: colvar.h:691
std::list< std::list< colvarvalue > > x_history
Time series of values and velocities used in running averages.
Definition: colvar.h:507
colvarvalue v_reported
Cached reported velocity.
Definition: colvar.h:174
colvarvalue fr
Applied force on extended DOF, for output (unscaled if using MTS)
Definition: colvar.h:195
colvarvalue upper_boundary
Location of the upper boundary.
Definition: colvar.h:239
std::list< std::list< colvarvalue > > acf_x_history
Definition: colvar.h:501
std::string const get_state_params() const
Write the state information of this colvar in a block of text, suitable for later parsing.
Definition: colvar.cpp:2491
bool acf_normalize
Normalize the ACF to a maximum value of 1?
Definition: colvar.h:524
colvarvalue v_fdiff
Finite-difference velocity.
Definition: colvar.h:160
colvarvalue prev_v_ext
Previous velocity of the restraint center.
Definition: colvar.h:184
int init_extended_Lagrangian(std::string const &conf)
Init extended Lagrangian parameters.
Definition: colvar.cpp:648
static std::vector< feature * > cv_features
Implementation of the feature list for colvar.
Definition: colvar.h:96
cvm::real ext_sigma
Amplitude of Gaussian white noise for Langevin extended dynamics.
Definition: colvar.h:192
std::vector< cvm::rvector > atomic_gradients
Array of atomic gradients collected from all cvcs with appropriate components, rotations etc....
Definition: colvar.h:707
cvm::real width
Typical fluctuation amplitude for this collective variable (e.g. local width of a free energy basin)
Definition: colvar.h:93
colvarvalue runave
Current value of the running average.
Definition: colvar.h:572
void const * get_cvc_param_ptr(std::string const ¶m_name)
Get a pointer to the named parameter (from the first and only component)
Definition: colvar.cpp:2154
size_t acf_offset
After how many steps the ACF starts.
Definition: colvar.h:518
colvarvalue ft_reported
Cached reported total force.
Definition: colvar.h:201
std::vector< std::shared_ptr< colvar::cvc > > cvcs
Array of components objects.
Definition: colvar.h:659
static std::map< std::string, std::string > global_cvc_desc_map
A global mapping of cvc names to the corresponding descriptions.
Definition: colvar.h:694
acf_type_e acf_type
Type of autocorrelation function (ACF)
Definition: colvar.h:544
void build_atom_list(void)
Initialize the sorted list of atom IDs for atoms involved in all cvcs (called when enabling f_cv_coll...
Definition: colvar.cpp:976
std::istream & read_state(std::istream &is)
Read the colvar's state from a formatted input stream.
Definition: colvar.cpp:2290
cvm::real get_cvc_param(std::string const ¶m_name)
Get the value of the named parameter (from the first and only component)
Definition: colvar.cpp:2143
cvm::real wrap_center
Center of wrapping, if this variable is periodic.
Definition: colvar.h:229
void add_bias_force_actual_value(colvarvalue const &force)
Apply a force to the actual value (only meaningful with extended Lagrangian)
Definition: colvar.h:765
colvarvalue f_old
Applied force at the previous step (to be subtracted from total force if needed)
Definition: colvar.h:219
int update_cvc_flags()
Updates the flags in the CVC objects, and their number.
Definition: colvar.cpp:2074
cvm::real const & force_constant() const
Force constant of the spring.
Definition: colvar.h:718
cvm::real ext_force_k
Restraint force constant.
Definition: colvar.h:188
colvarvalue dist2_lgrad(colvarvalue const &x1, colvarvalue const &x2) const
Use the internal metrics (as from colvar::cvc objects) to calculate square distances and gradients.
Definition: colvar.cpp:2232
void define_component_types()
Populate the map of available CVC types.
Definition: colvar.cpp:838
~colvar()
Destructor.
Definition: colvar.cpp:1278
int calc_acf()
Calculate the auto-correlation function (ACF)
Definition: colvar.cpp:2704
void reset_bias_force()
Set the total biasing force to zero.
Definition: colvar.h:774
colvarvalue ft
Total force, as derived from the atomic trajectory; should equal the system force plus f.
Definition: colvar.h:223
std::string acf_colvar_name
Collective variable with which the correlation is calculated (default: itself)
Definition: colvar.h:514
colvarvalue const & total_force() const
Current total force (previously obtained from calc() or read_traj()). Note: this is calculated using ...
Definition: colvar.h:748
int init_components(std::string const &conf)
Parse the CVC configuration and allocate their data.
Definition: colvar.cpp:903
int collect_cvc_gradients()
Same as colvar::collect_cvc_values but for gradients.
Definition: colvar.cpp:1567
colvarvalue fb_actual
Bias force to the actual value (only useful with extended Lagrangian)
Definition: colvar.h:211
int collect_cvc_data()
Collect quantities from CVCs and update aggregated data for the colvar.
Definition: colvar.cpp:1388
size_t runave_stride
Timesteps to skip between two values in the running average series.
Definition: colvar.h:568
int calc_cvcs(int first=0, size_t num_cvcs=0)
Calculate a subset of the colvar components (CVCs) currently active (default: all active CVCs) Note: ...
Definition: colvar.cpp:1354
colvarvalue x_reported
Cached reported value (x may be manipulated)
Definition: colvar.h:157
colvarvalue x_old
Previous value (to calculate velocities during analysis)
Definition: colvar.h:491
int init(std::string const &conf)
Main init function.
Definition: colvar.cpp:61
cvm::real update_forces_energy()
Collect all forces on this colvar, integrate internal equations of motion of internal degrees of free...
Definition: colvar.cpp:1765
std::vector< int > const & get_volmap_ids()
Volmap numeric IDs, one for each CVC (-1 if not available)
Definition: colvar.cpp:1263
cvm::real potential_energy
If extended Lagrangian active: colvar harmonic potential.
Definition: colvar.h:582
colvarvalue x
Value of the colvar.
Definition: colvar.h:147
static const std::map< std::string, std::function< colvar::cvc *()> > & get_global_cvc_map()
A global mapping of cvc names to the cvc constructors.
Definition: colvar.h:648
size_t acf_stride
How many timesteps separate two ACF values.
Definition: colvar.h:520
size_t num_active_cvcs() const
number of CVC objects with an active flag (as set by update_cvc_flags)
Definition: colvar.h:415
void update_extended_Lagrangian()
Integrate equations of motion of extended Lagrangian coordinate if needed.
Definition: colvar.cpp:1811
int calc_cvc_values(int first, size_t num_cvcs)
Calculate the values of the given subset of CVCs.
Definition: colvar.cpp:1428
void add_component_type(char const *description, char const *config_key)
Declare an available CVC type and its description, register them in the global map.
Definition: colvar.cpp:767
std::vector< bool > cvc_flags
Flags to enable or disable cvcs at next colvar evaluation.
Definition: colvar.h:662
std::vector< int > volmap_ids_
Volmap numeric IDs, one for each CVC (-1 if not available)
Definition: colvar.h:697
size_t acf_length
Length of autocorrelation function (ACF)
Definition: colvar.h:516
std::string runave_outfile
Name of the file to write the running average.
Definition: colvar.h:570
int set_cvc_param(std::string const ¶m_name, void const *new_value)
Set the named parameter in the first and only component to the given value.
Definition: colvar.cpp:2176
int write_acf(std::ostream &os)
Save the ACF to a file.
Definition: colvar.cpp:2866
int calc_cvc_gradients(int first, size_t num_cvcs)
Same as colvar::calc_cvc_values but for gradients.
Definition: colvar.cpp:1532
virtual const std::vector< feature * > & features() const
Implementation of the feature list accessor for colvar.
Definition: colvar.h:99
colvarvalue x_ext
Restraint center.
Definition: colvar.h:178
int set_cvc_flags(std::vector< bool > const &flags)
Enables and disables individual CVCs based on the given array.
Definition: colvar.cpp:2050
int analyze()
Perform analysis tasks.
Definition: colvar.cpp:2670
std::vector< int > atom_ids
Sorted array of (zero-based) IDs for all atoms involved.
Definition: colvar.h:702
void setup()
Get ready for a run and re-initialize internal data if needed.
Definition: colvar.cpp:1238
Parent class for a member object of a bias, cv or cvc etc. containing features and their dependencies...
Definition: colvardeps.h:34
void check_enabled(int f, std::string const &reason) const
Check that a feature is enabled, raising COLVARS_BUG_ERROR if not.
Definition: colvardeps.h:434
@ f_cv_extended_Lagrangian
The variable has a harmonic restraint around a moving center with fictitious mass; bias forces will b...
Definition: colvardeps.h:291
@ f_cv_gradient
Gradients are calculated and temporarily stored, so that external forces can be applied.
Definition: colvardeps.h:268
double real
Defining an abstract real number allows to switch precision.
Definition: colvarmodule.h:95
static real dt()
Time step of MD integrator (fs)
static void log(std::string const &message, int min_log_level=10)
Definition: colvarmodule.cpp:1970
static bool debug()
Whether debug output should be enabled (compile-time option)
Definition: colvarmodule.h:330
static std::string to_str(char const *s)
Convert to string for output purposes.
Definition: colvarmodule.cpp:2393
long long step_number
Use a 64-bit integer to store the step number.
Definition: colvarmodule.h:92
Base class containing parsing functions; all objects which need to parse input inherit from this.
Definition: colvarparse.h:27
Value of a collective variable: this is a metatype which can be set at runtime. By default it is set ...
Definition: colvarvalue.h:43
Type type() const
Get the current type.
Definition: colvarvalue.h:154
void reset()
Set to the null value for the data type currently defined.
Definition: colvarvalue.cpp:178
size_t size() const
Number of dimensions of this variable.
Definition: colvarvalue.h:373
Definition: colvars_memstream.h:30
Collective variables main module.
Parsing functions for collective variables.