Collective Variables Module - Developer Documentation
Loading...
Searching...
No Matches
colvarmodule.h
Go to the documentation of this file.
1// -*- c++ -*-
2
3// This file is part of the Collective Variables module (Colvars).
4// The original version of Colvars and its updates are located at:
5// https://github.com/Colvars/colvars
6// Please update all Colvars source files before making any changes.
7// If you wish to distribute your changes, please submit them to the
8// Colvars repository at GitHub.
9
10#ifndef COLVARMODULE_H
11#define COLVARMODULE_H
12
13#include <cstdint>
14
15#include "colvars_version.h"
16
17#ifndef COLVARS_DEBUG
18#define COLVARS_DEBUG false
19#endif
20
37
38#include <cmath>
39#include <iosfwd>
40#include <string>
41#include <vector>
42
43class colvarparse;
44class colvar;
45class colvarbias;
46class colvarproxy;
47class colvarvalue;
48
49
60
61public:
62
64 std::string version() const
65 {
66 return std::string(COLVARS_VERSION);
67 }
68
70 int version_number() const
71 {
72 return version_int;
73 }
74
77 {
78 return patch_version_int;
79 }
80
81private:
82
84 int version_int = 0;
85
88
89public:
90
92 typedef long long step_number;
93
95 typedef double real;
96
97
98 // Math functions
99
101 static inline real integer_power(real const &x, int const n)
102 {
103 // Original code: math_special.h in LAMMPS
104 double yy, ww;
105 if (x == 0.0) return 0.0;
106 int nn = (n > 0) ? n : -n;
107 ww = x;
108 for (yy = 1.0; nn != 0; nn >>= 1, ww *=ww) {
109 if (nn & 1) yy *= ww;
110 }
111 return (n > 0) ? yy : 1.0/yy;
112 }
113
115 static inline real pow(real const &x, real const &y)
116 {
117 return ::pow(static_cast<double>(x), static_cast<double>(y));
118 }
119
121 static inline real floor(real const &x)
122 {
123 return ::floor(static_cast<double>(x));
124 }
125
127 static inline real fabs(real const &x)
128 {
129 return ::fabs(static_cast<double>(x));
130 }
131
133 static inline real sqrt(real const &x)
134 {
135 return ::sqrt(static_cast<double>(x));
136 }
137
139 static inline real sin(real const &x)
140 {
141 return ::sin(static_cast<double>(x));
142 }
143
145 static inline real cos(real const &x)
146 {
147 return ::cos(static_cast<double>(x));
148 }
149
151 static inline real asin(real const &x)
152 {
153 return ::asin(static_cast<double>(x));
154 }
155
157 static inline real acos(real const &x)
158 {
159 return ::acos(static_cast<double>(x));
160 }
161
163 static inline real atan2(real const &x, real const &y)
164 {
165 return ::atan2(static_cast<double>(x), static_cast<double>(y));
166 }
167
169 static inline real exp(real const &x)
170 {
171 return ::exp(static_cast<double>(x));
172 }
173
177 static inline real logn(real const &x)
178 {
179 return ::log(static_cast<double>(x));
180 }
181
182 // Forward declarations
183 class rvector;
184 template <class T> class vector1d;
185 template <class T> class matrix2d;
186 class quaternion;
187 class rotation;
188
189 class usage;
190 class memory_stream;
191
193 typedef int residue_id;
194
198
200 class rmatrix;
201
202 // allow these classes to access protected data
203 class atom;
204 class atom_group;
205 typedef std::vector<atom>::iterator atom_iter;
206 typedef std::vector<atom>::const_iterator atom_const_iter;
207
210private:
211
212 static int errorCode;
213
214public:
215
216 static void set_error_bits(int code);
217
218 static bool get_error_bit(int code);
219
220 static inline int get_error()
221 {
222 return errorCode;
223 }
224
225 static void clear_error();
226
231
234 {
235 return it - it_restart;
236 }
237
241 {
242 return it;
243 }
244
245 bool binary_restart;
246
251
252private:
253
255 std::string cvm_output_prefix;
256
257public:
259 static inline std::string &output_prefix()
260 {
262 return cv->cvm_output_prefix;
263 }
264
265private:
266
268 std::vector<colvar *> colvars;
269
271 std::vector<colvar *> colvars_active;
272
275 std::vector<colvar *> colvars_smp;
277 std::vector<int> colvars_smp_items;
278
280 std::vector<atom_group *> named_atom_groups;
281public:
284
287
289 std::vector<colvar *> *variables();
290
291 /* TODO: implement named CVCs
293 static std::vector<cvc *> cvcs;
295 inline void register_cvc(cvc *p) {
296 cvcs.push_back(p);
297 }
298 */
299
301 std::vector<colvar *> *variables_active();
302
305 std::vector<colvar *> *variables_active_smp();
306
308 std::vector<int> *variables_active_smp_items();
309
311 std::vector<colvarbias *> biases;
312
315
316private:
317
320
322 std::vector<colvarbias *> biases_active_;
323
324public:
325
327 std::vector<colvarbias *> *biases_active();
328
330 static inline bool debug()
331 {
332 return COLVARS_DEBUG;
333 }
334
336 size_t size() const;
337
341
342private:
343
346
347public:
348
351
354
356 int reset();
357
360 int read_config_file(char const *config_file_name);
361
364 int read_config_string(std::string const &conf);
365
367 int parse_config(std::string &conf);
368
370 std::string const & get_config() const;
371
372 // Parse functions (setup internal data based on a string)
373
376 static std::istream & getline(std::istream &is, std::string &line);
377
379 int parse_global_params(std::string const &conf);
380
382 int parse_colvars(std::string const &conf);
383
385 int run_tcl_script(std::string const &filename);
386
388 int parse_biases(std::string const &conf);
389
393 int append_new_config(std::string const &conf);
394
396 void config_changed();
397
398private:
399
401 std::string config_string;
402
405 std::string extra_conf;
406
408 template <class bias_type>
409 int parse_biases_type(std::string const &conf, char const *keyword);
410
413 bool check_new_bias(std::string &conf, char const *key);
414
416 std::string source_Tcl_script;
417
418public:
419
421 size_t num_variables() const;
422
424 size_t num_variables_feature(int feature_id) const;
425
427 size_t num_biases() const;
428
430 size_t num_biases_feature(int feature_id) const;
431
433 size_t num_biases_type(std::string const &type) const;
434
437 std::vector<std::string> const time_dependent_biases() const;
438
439private:
441 int catch_input_errors(int result);
442
443public:
444
445 // "Setup" functions (change internal data based on related data
446 // from the proxy that may change during program execution)
447 // No additional parsing is done within these functions
448
452
454 int setup_input();
455
457 int setup_output();
458
459private:
460
461 template <typename IST> IST & read_state_template_(IST &is);
462
465
467 std::vector<unsigned char> input_state_buffer_;
468
469public:
470
472 std::istream & read_state(std::istream &is);
473
475 memory_stream & read_state(memory_stream &is);
476
478 int set_input_state_buffer(size_t n, unsigned char *buf);
479
481 int set_input_state_buffer(std::vector<unsigned char> &buf);
482
484 std::istream & read_objects_state(std::istream &is);
485
487 memory_stream & read_objects_state(memory_stream &is);
488
490 int print_total_forces_errning(bool warn_total_forces);
491
492private:
493 template <typename OST> OST &write_state_template_(OST &os);
494
495public:
496
498 std::ostream & write_state(std::ostream &os);
499
501 memory_stream & write_state(memory_stream &os);
502
504 int write_state_buffer(std::vector<unsigned char> &buffer);
505
507 static std::string state_file_prefix(char const *filename);
508
510 int open_traj_file(std::string const &file_name);
514 std::ostream & write_traj(std::ostream &os);
516 std::ostream & write_traj_label(std::ostream &os);
517
519 int write_traj_files();
521 int write_restart_file(std::string const &out_name);
523 int write_output_files();
525 static int backup_file(char const *filename);
526
528 int write_restart_string(std::string &output);
529
531 static colvarbias * bias_by_name(std::string const &name);
532
534 static colvar * colvar_by_name(std::string const &name);
535
537 static atom_group * atom_group_by_name(std::string const &name);
538
541 int change_configuration(std::string const &bias_name, std::string const &conf);
542
544 std::string read_colvar(std::string const &name);
545
548 real energy_difference(std::string const &bias_name, std::string const &conf);
549
551 int calc();
552
554 int calc_colvars();
555
557 int calc_biases();
558
561
563 int analyze();
564
566 int end_of_step();
567
570 int read_traj(char const *traj_filename,
571 long traj_read_begin,
572 long traj_read_end);
573
575 static std::string to_str(char const *s);
576
578 static std::string to_str(std::string const &s);
579
581 static std::string to_str(bool x);
582
584 static std::string to_str(int const &x,
585 size_t width = 0, size_t prec = 0);
586
588 static std::string to_str(size_t const &x,
589 size_t width = 0, size_t prec = 0);
590
592 static std::string to_str(long int const &x,
593 size_t width = 0, size_t prec = 0);
594
596 static std::string to_str(step_number const &x,
597 size_t width = 0, size_t prec = 0);
598
600 static std::string to_str(real const &x,
601 size_t width = 0, size_t prec = 0);
602
604 static std::string to_str(rvector const &x,
605 size_t width = 0, size_t prec = 0);
606
608 static std::string to_str(quaternion const &x,
609 size_t width = 0, size_t prec = 0);
610
612 static std::string to_str(colvarvalue const &x,
613 size_t width = 0, size_t prec = 0);
614
616 static std::string to_str(vector1d<real> const &x,
617 size_t width = 0, size_t prec = 0);
618
620 static std::string to_str(matrix2d<real> const &x,
621 size_t width = 0, size_t prec = 0);
622
623
625 static std::string to_str(std::vector<int> const &x,
626 size_t width = 0, size_t prec = 0);
627
629 static std::string to_str(std::vector<size_t> const &x,
630 size_t width = 0, size_t prec = 0);
631
633 static std::string to_str(std::vector<long int> const &x,
634 size_t width = 0, size_t prec = 0);
635
637 static std::string to_str(std::vector<real> const &x,
638 size_t width = 0, size_t prec = 0);
639
641 static std::string to_str(std::vector<rvector> const &x,
642 size_t width = 0, size_t prec = 0);
643
645 static std::string to_str(std::vector<quaternion> const &x,
646 size_t width = 0, size_t prec = 0);
647
649 static std::string to_str(std::vector<colvarvalue> const &x,
650 size_t width = 0, size_t prec = 0);
651
653 static std::string to_str(std::vector<std::string> const &x,
654 size_t width = 0, size_t prec = 0);
655
656
658 static std::string wrap_string(std::string const &s,
659 size_t nchars);
660
662 static size_t const it_width;
664 static size_t const cv_prec;
666 static size_t const cv_width;
668 static size_t const en_prec;
670 static size_t const en_width;
672 static const char * const line_marker;
673
674
675 // proxy functions
676
678 static real dt();
679
681 static void request_total_force();
682
684 int cite_feature(std::string const &feature);
685
687 std::string feature_report(int flag = 0);
688
692 static void log(std::string const &message, int min_log_level = 10);
693
695 static int error(std::string const &message, int code = -1);
696
697private:
698
700 static int log_level_;
701
702public:
703
705 static inline int log_level()
706 {
707 return log_level_;
708 }
709
711 static inline int log_init_messages()
712 {
713 return 1;
714 }
715
717 static inline int log_user_params()
718 {
719 return 2;
720 }
721
723 static inline int log_default_params()
724 {
725 return 3;
726 }
727
729 static inline int log_output_files()
730 {
731 return 4;
732 }
733
735 static inline int log_input_files()
736 {
737 return 5;
738 }
739
743 atom_pos const &pos2);
744
746 std::vector<std::string> index_file_names;
747
749 std::vector<std::string> index_group_names;
750
752 std::vector<std::vector<int> *> index_groups;
753
755 int read_index_file(char const *filename);
756
758 int reset_index_groups();
759
768 static int load_coords(char const *filename,
769 std::vector<rvector> *pos,
770 atom_group *atoms,
771 std::string const &pdb_field,
772 double pdb_field_value = 0.0);
773
775 int load_coords_xyz(char const *filename,
776 std::vector<rvector> *pos,
777 atom_group *atoms,
778 bool keep_open = false);
779
781 static size_t cv_traj_freq;
782
784 static size_t restart_out_freq;
786 std::string restart_out_name;
787
790
791protected:
792
795
797 std::string cv_traj_name;
798
801
804
807
809 size_t depth_s;
810
812 std::vector<size_t> depth_v;
813
816
819
820public:
821
823 inline std::string restart_version() const
824 {
825 return restart_version_str;
826 }
827
829 inline int restart_version_number() const
830 {
831 return restart_version_int;
832 }
833
835 static size_t & depth();
836
838 static void increase_depth();
839
841 static void decrease_depth();
842
843 static inline bool scripted_forces()
844 {
845 return use_scripted_forces;
846 }
847
850
853
856
861
863 static colvarmodule *main();
864
865};
866
867
870
871
872std::ostream & operator << (std::ostream &os, cvm::rvector const &v);
873std::istream & operator >> (std::istream &is, cvm::rvector &v);
874
875
876namespace {
877 constexpr int32_t COLVARS_OK = 0;
878 constexpr int32_t COLVARS_ERROR = 1;
879 constexpr int32_t COLVARS_NOT_IMPLEMENTED = (1<<1);
880 constexpr int32_t COLVARS_INPUT_ERROR = (1<<2); // out of bounds or inconsistent input
881 constexpr int32_t COLVARS_BUG_ERROR = (1<<3); // Inconsistent state indicating bug
882 constexpr int32_t COLVARS_FILE_ERROR = (1<<4);
883 constexpr int32_t COLVARS_MEMORY_ERROR = (1<<5);
884 constexpr int32_t COLVARS_NO_SUCH_FRAME = (1<<6); // Cannot load the requested frame
885}
886
887
888#endif
A collective variable (main class); to be defined, it needs at least one object of a derived class of...
Definition: colvar.h:53
Collective variable bias, base class.
Definition: colvarbias.h:23
Group of atom objects, mostly used by a colvar::cvc object to gather all atomic data.
Definition: colvaratoms.h:159
Stores numeric id, mass and all mutable data for an atom, mostly used by a colvar::cvc.
Definition: colvaratoms.h:31
Arbitrary size array (two dimensions) suitable for linear algebra operations (i.e....
Definition: colvartypes.h:376
1-dimensional vector of real numbers with four components and a quaternion algebra
Definition: colvartypes.h:958
2-dimensional array of real numbers with three components along each dimension (works with colvarmodu...
Definition: colvartypes.h:895
vector of real numbers with three components
Definition: colvartypes.h:727
Track usage of Colvars features.
Definition: colvarmodule.cpp:33
Arbitrary size array (one dimensions) suitable for linear algebra operations (i.e....
Definition: colvartypes.h:37
Collective variables module (main class)
Definition: colvarmodule.h:59
int cite_feature(std::string const &feature)
Track usage of the given Colvars feature.
Definition: colvarmodule.cpp:2506
static const char *const line_marker
Line separator in the log output.
Definition: colvarmodule.h:672
rvector atom_pos
Atom position (different type name from rvector, to make possible future PBC-transparent implementati...
Definition: colvarmodule.h:197
int write_traj_files()
Write all trajectory files.
Definition: colvarmodule.cpp:1167
int load_coords_xyz(char const *filename, std::vector< rvector > *pos, atom_group *atoms, bool keep_open=false)
Load coordinates into an atom group from an XYZ file (assumes Angstroms)
std::ostream & write_state(std::ostream &os)
Write the state of the module to a formatted (text) file.
Definition: colvarmodule.cpp:1875
static std::string state_file_prefix(char const *filename)
Strips .colvars.state from filename and checks that it is not empty.
Definition: colvarmodule.cpp:1505
static real pow(real const &x, real const &y)
Reimplemented to work around MS compiler issues.
Definition: colvarmodule.h:115
size_t num_biases_feature(int feature_id) const
Return how many biases have this feature enabled.
Definition: colvarmodule.cpp:643
static real asin(real const &x)
Reimplemented to work around MS compiler issues.
Definition: colvarmodule.h:151
static step_number it
Current step number.
Definition: colvarmodule.h:228
bool cv_traj_write_labels
Write labels at the next iteration.
Definition: colvarmodule.h:800
static std::string to_str(std::vector< quaternion > const &x, size_t width=0, size_t prec=0)
Convert to string for output purposes.
std::vector< std::string > const time_dependent_biases() const
Definition: colvarmodule.cpp:671
std::string cv_traj_name
Name of the trajectory file.
Definition: colvarmodule.h:797
static real logn(real const &x)
Definition: colvarmodule.h:177
std::vector< atom_group * > named_atom_groups
Array of named atom groups.
Definition: colvarmodule.h:280
std::ostream & write_traj(std::ostream &os)
Write in the trajectory file.
Definition: colvarmodule.cpp:1925
void register_named_atom_group(atom_group *ag)
Register a named atom group into named_atom_groups.
Definition: colvarmodule.cpp:741
double real
Defining an abstract real number allows to switch precision.
Definition: colvarmodule.h:95
static size_t const en_prec
Number of digits to represent the collective variables energy.
Definition: colvarmodule.h:668
int read_config_string(std::string const &conf)
Parse a config string assuming it is a complete configuration (i.e. calling all parse functions)
Definition: colvarmodule.cpp:251
static std::string to_str(std::vector< rvector > const &x, size_t width=0, size_t prec=0)
Convert to string for output purposes.
static real floor(real const &x)
Reimplemented to work around MS compiler issues.
Definition: colvarmodule.h:121
static std::string wrap_string(std::string const &s, size_t nchars)
Reduce the number of characters in a string.
size_t size() const
How many objects (variables and biases) are configured yet?
Definition: colvarmodule.cpp:209
int xyz_reader_use_count
Track how many times the XYZ reader has been used.
Definition: colvarmodule.h:815
std::vector< std::string > index_group_names
Names of groups from one or more Gromacs .ndx files.
Definition: colvarmodule.h:749
usage * usage_
Track usage of Colvars features.
Definition: colvarmodule.h:818
int update_colvar_forces()
Integrate bias and restraint forces, send colvar forces to atoms.
Definition: colvarmodule.cpp:1047
std::string restart_version() const
Version of the most recent state file read.
Definition: colvarmodule.h:823
int set_input_state_buffer(size_t n, unsigned char *buf)
Set an internal state buffer, to be read later as an unformatted stream when ready.
Definition: colvarmodule.cpp:1609
int parse_config(std::string &conf)
Parse a "clean" config string (no comments)
Definition: colvarmodule.cpp:290
int write_restart_file(std::string const &out_name)
Write a state file useful to resume the simulation.
Definition: colvarmodule.cpp:1126
static void request_total_force()
Request calculation of total force from MD engine.
void set_initial_step(step_number it)
Set the initial step number (it is 0 otherwise); may be overridden when reading a state.
Definition: colvarmodule.cpp:215
static real exp(real const &x)
Reimplemented to work around MS compiler issues.
Definition: colvarmodule.h:169
memory_stream & read_state(memory_stream &is)
Read all objects' state fron an unformatted (binary) stream.
std::vector< int > * variables_active_smp_items()
Indexes of the items to calculate for each colvar.
Definition: colvarmodule.cpp:197
int residue_id
Residue identifier.
Definition: colvarmodule.h:193
std::vector< colvarbias * > biases_active_
Array of active collective variable biases.
Definition: colvarmodule.h:322
static int log_output_files()
Level at which output-file operations are logged.
Definition: colvarmodule.h:729
int end_of_step()
Carry out operations needed before next step is run.
Definition: colvarmodule.cpp:1240
size_t num_biases() const
Return how many biases are defined.
Definition: colvarmodule.cpp:637
int setup_output()
(Re)initialize the output trajectory and state file (does not write it yet)
Definition: colvarmodule.cpp:1460
bool check_new_bias(std::string &conf, char const *key)
Definition: colvarmodule.cpp:498
std::string feature_report(int flag=0)
Report usage of the Colvars features.
Definition: colvarmodule.cpp:2511
std::vector< int > colvars_smp_items
Indexes of the items to calculate for each colvar.
Definition: colvarmodule.h:277
static int load_coords(char const *filename, std::vector< rvector > *pos, atom_group *atoms, std::string const &pdb_field, double pdb_field_value=0.0)
Load coordinates for a group of atoms from a file (PDB or XYZ); if "pos" is already allocated,...
static int backup_file(char const *filename)
Backup a file before writing it.
Definition: colvarmodule.cpp:1733
int calc()
Main worker function.
Definition: colvarmodule.cpp:810
static real cos(real const &x)
Reimplemented to work around MS compiler issues.
Definition: colvarmodule.h:145
int patch_version_number() const
Get the patch version number (non-zero in patch releases of other packages)
Definition: colvarmodule.h:76
std::string extra_conf
Definition: colvarmodule.h:405
static real dt()
Time step of MD integrator (fs)
static step_number it_restart
Starting step number for this run.
Definition: colvarmodule.h:230
static real integer_power(real const &x, int const n)
Override the STL pow() with a product for n integer.
Definition: colvarmodule.h:101
std::string config_string
Configuration string read so far by the module (includes comments)
Definition: colvarmodule.h:401
std::string default_input_state_file_
Default input state file; if given, it is read unless the MD engine provides it.
Definition: colvarmodule.h:464
int read_config_file(char const *config_file_name)
Definition: colvarmodule.cpp:222
std::vector< std::vector< int > * > index_groups
Groups from one or more Gromacs .ndx files.
Definition: colvarmodule.h:752
int restart_version_number() const
Integer version of the most recent state file read.
Definition: colvarmodule.h:829
void * num_biases_types_used_
Pointer to a map counting how many biases of each type were used.
Definition: colvarmodule.h:319
int catch_input_errors(int result)
Useful wrapper to interrupt parsing if any error occurs.
Definition: colvarmodule.cpp:687
std::vector< std::string > index_file_names
Names of .ndx files that have been loaded.
Definition: colvarmodule.h:746
static int log_level_
Level of logging requested by the user.
Definition: colvarmodule.h:700
std::vector< colvar * > * variables_active()
Collective variables with the active flag on.
Definition: colvarmodule.cpp:185
std::vector< colvarbias * > * biases_active()
Array of active collective variable biases.
Definition: colvarmodule.cpp:203
int patch_version_int
Patch version number (non-zero in patch releases of other packages)
Definition: colvarmodule.h:87
static atom_group * atom_group_by_name(std::string const &name)
Look up a named atom group by name; returns NULL if not found.
Definition: colvarmodule.cpp:727
int append_new_config(std::string const &conf)
Add new configuration during parsing (e.g. to implement back-compatibility); cannot be nested,...
Definition: colvarmodule.cpp:352
std::istream & read_objects_state(std::istream &is)
Read the states of individual objects; allows for changes.
Definition: colvarmodule.cpp:1624
real total_bias_energy
Energy of built-in and scripted biases, summed per time-step.
Definition: colvarmodule.h:314
static rvector position_distance(atom_pos const &pos1, atom_pos const &pos2)
Get the distance between two atomic positions with pbcs handled correctly.
size_t num_biases_type(std::string const &type) const
Return how many biases of this type are defined.
Definition: colvarmodule.cpp:657
static size_t const it_width
Number of characters to represent a time step.
Definition: colvarmodule.h:662
static bool use_scripted_forces
Use scripted colvars forces?
Definition: colvarmodule.h:849
std::istream & read_state(std::istream &is)
Read all objects' state fron a formatted (text) stream.
Definition: colvarmodule.cpp:1583
static void log(std::string const &message, int min_log_level=10)
Definition: colvarmodule.cpp:1950
std::vector< unsigned char > input_state_buffer_
Internal state buffer, to be read as an unformatted stream.
Definition: colvarmodule.h:467
colvarparse * parse
Configuration file parser object.
Definition: colvarmodule.h:794
static size_t cv_traj_freq
Frequency for collective variables trajectory output.
Definition: colvarmodule.h:781
static size_t & depth()
Get the current object depth in the hierarchy.
Definition: colvarmodule.cpp:1980
static bool scripting_after_biases
Wait for all biases before calculating scripted forces?
Definition: colvarmodule.h:852
std::string const & get_config() const
Get the configuration string read so far (includes comments)
Definition: colvarmodule.cpp:346
static size_t restart_out_freq
Frequency for saving output restarts.
Definition: colvarmodule.h:784
int parse_colvars(std::string const &conf)
Parse and initialize collective variables.
Definition: colvarmodule.cpp:449
static int error(std::string const &message, int code=-1)
Print a message to the main log and set global error code.
Definition: colvarmodule.cpp:2027
static int errorCode
Definition: colvarmodule.h:212
std::vector< colvar * > colvars
Array of collective variables.
Definition: colvarmodule.h:268
static real atan2(real const &x, real const &y)
Reimplemented to work around MS compiler issues.
Definition: colvarmodule.h:163
std::vector< colvar * > * variables_active_smp()
Definition: colvarmodule.cpp:191
static void increase_depth()
Increase the depth (number of indentations in the output)
Definition: colvarmodule.cpp:1966
static real rand_gaussian()
Pseudo-random number with Gaussian distribution.
colvarmodule()
Cannot initialize the main object without a proxy.
int write_output_files()
Write all other output files.
Definition: colvarmodule.cpp:1739
static size_t const cv_prec
Number of digits to represent a collective variables value(s)
Definition: colvarmodule.h:664
static colvarmodule * main()
Access the one instance of the Colvars module.
Definition: colvarmodule.cpp:173
int parse_biases_type(std::string const &conf, char const *keyword)
Parse and initialize collective variable biases of a specific type.
Definition: colvarmodule.cpp:512
static real sqrt(real const &x)
Reimplemented to work around MS compiler issues.
Definition: colvarmodule.h:133
std::string version() const
Get the version string (YYYY-MM-DD format)
Definition: colvarmodule.h:64
static int log_level()
Level of logging requested by the user.
Definition: colvarmodule.h:705
int version_int
Integer representing the version string (allows comparisons)
Definition: colvarmodule.h:84
std::ostream & write_traj_label(std::ostream &os)
Write explanatory labels in the trajectory file.
Definition: colvarmodule.cpp:1900
static real acos(real const &x)
Reimplemented to work around MS compiler issues.
Definition: colvarmodule.h:157
int reset()
Actual function called by the destructor.
Definition: colvarmodule.cpp:1315
int calc_biases()
Calculate biases.
Definition: colvarmodule.cpp:974
std::vector< colvar * > colvars_smp
Definition: colvarmodule.h:275
std::vector< colvar * > colvars_active
Array of collective variables.
Definition: colvarmodule.h:271
int analyze()
Perform analysis.
Definition: colvarmodule.cpp:1212
std::string read_colvar(std::string const &name)
Read a colvar value.
Definition: colvarmodule.cpp:777
size_t num_variables() const
Return how many variables are defined.
Definition: colvarmodule.cpp:617
std::string restart_out_name
Output restart file name.
Definition: colvarmodule.h:786
int version_number() const
Get the version number (higher = more recent)
Definition: colvarmodule.h:70
int read_traj(char const *traj_filename, long traj_read_begin, long traj_read_end)
Read a collective variable trajectory (post-processing only, not called at runtime)
Definition: colvarmodule.cpp:1759
static size_t const cv_width
Number of characters to represent a collective variables value(s)
Definition: colvarmodule.h:666
size_t depth_s
Counter for the current depth in the object hierarchy (useg e.g. in output)
Definition: colvarmodule.h:809
static bool debug()
Whether debug output should be enabled (compile-time option)
Definition: colvarmodule.h:330
int change_configuration(std::string const &bias_name, std::string const &conf)
Definition: colvarmodule.cpp:759
std::vector< colvarbias * > biases
Array of collective variable biases.
Definition: colvarmodule.h:311
std::string restart_version_str
Version of the most recent state file read.
Definition: colvarmodule.h:803
int restart_version_int
Integer version of the most recent state file read.
Definition: colvarmodule.h:806
int calc_scripted_forces()
Calculate the energy and forces of scripted biases.
Definition: colvarmodule.cpp:1108
std::string source_Tcl_script
Initialization Tcl script, user-provided.
Definition: colvarmodule.h:416
int write_restart_string(std::string &output)
Write the state into a string.
Definition: colvarmodule.cpp:1155
static std::istream & getline(std::istream &is, std::string &line)
Definition: colvarmodule.cpp:270
static int log_input_files()
Level at which input-file operations (configuration, state) are logged.
Definition: colvarmodule.h:735
int calc_colvars()
Calculate collective variables.
Definition: colvarmodule.cpp:878
static real fabs(real const &x)
Reimplemented to work around MS compiler issues.
Definition: colvarmodule.h:127
std::vector< colvar * > * variables()
Array of collective variables.
Definition: colvarmodule.cpp:179
static void decrease_depth()
Decrease the depth (number of indentations in the output)
Definition: colvarmodule.cpp:1972
int update_engine_parameters()
Definition: colvarmodule.cpp:1267
real energy_difference(std::string const &bias_name, std::string const &conf)
Definition: colvarmodule.cpp:793
static int log_default_params()
Level at which a keyword's default value is logged.
Definition: colvarmodule.h:723
memory_stream & write_state(memory_stream &os)
Write the state of the module to an unformatted (binary) file.
int reset_index_groups()
Clear the index groups loaded so far.
Definition: colvarmodule.cpp:2135
static int log_user_params()
Level at which a keyword's user-provided value is logged.
Definition: colvarmodule.h:717
int print_total_forces_errning(bool warn_total_forces)
If needed (old restart file), print the warning that cannot be ignored.
Definition: colvarmodule.cpp:1709
memory_stream & read_objects_state(memory_stream &is)
Read the states of individual objects; allows for changes.
static step_number step_relative()
Return the current step number from the beginning of this run.
Definition: colvarmodule.h:233
int read_index_file(char const *filename)
Read a Gromacs .ndx file.
size_t num_variables_feature(int feature_id) const
Return how many variables have this feature enabled.
Definition: colvarmodule.cpp:623
static real sin(real const &x)
Reimplemented to work around MS compiler issues.
Definition: colvarmodule.h:139
~colvarmodule()
Destructor.
Definition: colvarmodule.cpp:1286
static std::string & output_prefix()
Accessor for the above.
Definition: colvarmodule.h:259
void config_changed()
Signals to the module object that the configuration has changed.
Definition: colvarmodule.cpp:359
static colvarproxy * proxy
Pointer to the proxy object, used to retrieve atomic data from the hosting program; it is static in o...
Definition: colvarmodule.h:860
static std::string to_str(char const *s)
Convert to string for output purposes.
Definition: colvarmodule.cpp:2373
static step_number step_absolute()
Definition: colvarmodule.h:240
static colvar * colvar_by_name(std::string const &name)
Look up a colvar by name; returns NULL if not found.
Definition: colvarmodule.cpp:713
void unregister_named_atom_group(atom_group *ag)
Remove a named atom group from named_atom_groups.
Definition: colvarmodule.cpp:746
static int log_init_messages()
Level at which initialization messages are logged.
Definition: colvarmodule.h:711
static colvarbias * bias_by_name(std::string const &name)
Look up a bias by name; returns NULL if not found.
Definition: colvarmodule.cpp:699
int open_traj_file(std::string const &file_name)
Open a trajectory file if requested (and leave it open)
std::string cvm_output_prefix
Prefix for all output files for this run.
Definition: colvarmodule.h:255
int setup_input()
(Re)initialize and (re)read the input state file calling read_restart()
Definition: colvarmodule.cpp:1350
int parse_biases(std::string const &conf)
Parse and initialize collective variable biases.
Definition: colvarmodule.cpp:556
int write_state_buffer(std::vector< unsigned char > &buffer)
Write the state of the module to an array of bytes (wrapped as a memory_stream object)
Definition: colvarmodule.cpp:1890
long long step_number
Use a 64-bit integer to store the step number.
Definition: colvarmodule.h:92
int parse_global_params(std::string const &conf)
Parse the few module's global parameters.
Definition: colvarmodule.cpp:365
static real debug_gradients_step_size
Finite difference step size (if there is no dynamics, or if gradients need to be tested independently...
Definition: colvarmodule.h:250
int run_tcl_script(std::string const &filename)
Run provided Tcl script.
Definition: colvarmodule.cpp:437
int close_traj_file()
Close it (note: currently unused)
std::vector< size_t > depth_v
Thread-specific depth.
Definition: colvarmodule.h:812
static size_t const en_width
Number of characters to represent the collective variables energy.
Definition: colvarmodule.h:670
static std::string to_str(std::vector< real > const &x, size_t width=0, size_t prec=0)
Convert to string for output purposes.
Base class containing parsing functions; all objects which need to parse input inherit from this.
Definition: colvarparse.h:27
Definition: colvarproxy.h:573
Value of a collective variable: this is a metatype which can be set at runtime. By default it is set ...
Definition: colvarvalue.h:43
colvarmodule cvm
Shorthand for the frequently used type prefix.
Definition: colvarmodule.h:869