Collective Variables Module - Developer Documentation
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
colvarproxy.h
1 // -*- c++ -*-
2 
3 #ifndef COLVARPROXY_H
4 #define COLVARPROXY_H
5 
6 #include <fstream>
7 #include <list>
8 
9 #include "colvarmodule.h"
10 #include "colvarvalue.h"
11 
12 // forward declarations
13 class colvarscript;
14 
19 
20 class colvarproxy {
21 
22 public:
23 
26 
29  {
30  colvars = NULL;
31  b_simulation_running = true;
32  b_smp_active = true;
33  script = NULL;
34  }
35 
37  virtual ~colvarproxy()
38  {}
39 
41  virtual int setup()
42  {
43  return COLVARS_OK;
44  }
45 
49  virtual int update_input()
50  {
51  return COLVARS_OK;
52  }
53 
55  virtual int update_output()
56  {
57  return COLVARS_OK;
58  }
59 
60  // **************** SIMULATION PARAMETERS ****************
61 
64  virtual cvm::real unit_angstrom() = 0;
65 
67  virtual cvm::real boltzmann() = 0;
68 
70  virtual cvm::real temperature() = 0;
71 
73  virtual cvm::real dt() = 0;
74 
76  virtual cvm::real rand_gaussian(void) = 0;
77 
79  // Returns error code
80  virtual int get_frame(long int&) { return COLVARS_NOT_IMPLEMENTED; }
81 
83  // Returns error code
84  virtual int set_frame(long int) { return COLVARS_NOT_IMPLEMENTED; }
85 
88  std::string input_prefix_str, output_prefix_str, restart_output_prefix_str;
89 
90  inline std::string & input_prefix()
91  {
92  return input_prefix_str;
93  }
94 
96  inline std::string restart_output_prefix()
97  {
98  return restart_output_prefix_str;
99  }
100 
103  inline std::string output_prefix()
104  {
105  return output_prefix_str;
106  }
107 
109  virtual size_t restart_frequency()
110  {
111  return 0;
112  }
113 
114 protected:
115 
118 
119 public:
120 
122  virtual bool simulation_running() const
123  {
124  return b_simulation_running;
125  }
126 
127 protected:
128 
131  std::list<std::ostream *> output_files;
133  std::list<std::string> output_stream_names;
134 
135 public:
136 
137  // ***************** SHARED-MEMORY PARALLELIZATION *****************
138 
140  virtual int smp_enabled()
141  {
142  return COLVARS_NOT_IMPLEMENTED;
143  }
144 
147 
149  virtual int smp_colvars_loop()
150  {
151  return COLVARS_NOT_IMPLEMENTED;
152  }
153 
155  virtual int smp_biases_loop()
156  {
157  return COLVARS_NOT_IMPLEMENTED;
158  }
159 
162  {
163  return COLVARS_NOT_IMPLEMENTED;
164  }
165 
167  virtual int smp_thread_id()
168  {
169  return COLVARS_NOT_IMPLEMENTED;
170  }
171 
173  virtual int smp_num_threads()
174  {
175  return COLVARS_NOT_IMPLEMENTED;
176  }
177 
179  virtual int smp_lock()
180  {
181  return COLVARS_OK;
182  }
183 
185  virtual int smp_trylock()
186  {
187  return COLVARS_OK;
188  }
189 
191  virtual int smp_unlock()
192  {
193  return COLVARS_OK;
194  }
195 
196  // **************** MULTIPLE REPLICAS COMMUNICATION ****************
197 
198  // Replica exchange commands:
199 
201  virtual bool replica_enabled() { return false; }
202 
204  virtual int replica_index() { return 0; }
205 
207  virtual int replica_num() { return 1; }
208 
210  virtual void replica_comm_barrier() {}
211 
213  virtual int replica_comm_recv(char* msg_data, int buf_len, int src_rep) {
214  return COLVARS_NOT_IMPLEMENTED;
215  }
216 
218  virtual int replica_comm_send(char* msg_data, int msg_len, int dest_rep) {
219  return COLVARS_NOT_IMPLEMENTED;
220  }
221 
222 
223  // **************** SCRIPTING INTERFACE ****************
224 
228 
231 
234 
236  virtual int run_force_callback() { return COLVARS_NOT_IMPLEMENTED; }
237 
238  virtual int run_colvar_callback(std::string const &name,
239  std::vector<const colvarvalue *> const &cvcs,
240  colvarvalue &value)
241  { return COLVARS_NOT_IMPLEMENTED; }
242 
243  virtual int run_colvar_gradient_callback(std::string const &name,
244  std::vector<const colvarvalue *> const &cvcs,
245  std::vector<cvm::matrix2d<cvm::real> > &gradient)
246  { return COLVARS_NOT_IMPLEMENTED; }
247 
248 
249  // **************** INPUT/OUTPUT ****************
250 
252  virtual void log(std::string const &message) = 0;
253 
255  virtual void error(std::string const &message) = 0;
256 
258  virtual void fatal_error(std::string const &message) = 0;
259 
261  virtual void exit(std::string const &message)
262  {
263  cvm::error("Error: exiting without error is not implemented, returning error code.\n",
264  COLVARS_NOT_IMPLEMENTED);
265  }
266 
267  // TODO the following definitions may be moved to a .cpp file
268 
271  virtual std::ostream * output_stream(std::string const &output_name)
272  {
273  std::list<std::ostream *>::iterator osi = output_files.begin();
274  std::list<std::string>::iterator osni = output_stream_names.begin();
275  for ( ; osi != output_files.end(); osi++, osni++) {
276  if (*osni == output_name) {
277  return *osi;
278  }
279  }
280  output_stream_names.push_back(output_name);
281  std::ofstream * os = new std::ofstream(output_name.c_str());
282  if (!os->is_open()) {
283  cvm::error("Error: cannot write to file \""+output_name+"\".\n",
284  FILE_ERROR);
285  }
286  output_files.push_back(os);
287  return os;
288  }
289 
291  virtual int close_output_stream(std::string const &output_name)
292  {
293  std::list<std::ostream *>::iterator osi = output_files.begin();
294  std::list<std::string>::iterator osni = output_stream_names.begin();
295  for ( ; osi != output_files.end(); osi++, osni++) {
296  if (*osni == output_name) {
297  ((std::ofstream *) (*osi))->close();
298  output_files.erase(osi);
299  output_stream_names.erase(osni);
300  return COLVARS_OK;
301  }
302  }
303  cvm::error("Error: trying to close an output file or stream that wasn't open.\n",
304  BUG_ERROR);
305  return COLVARS_ERROR;
306  }
307 
309  virtual int backup_file(char const *filename)
310  {
311  return COLVARS_NOT_IMPLEMENTED;
312  }
313 
314 
315 
316  // **************** ACCESS SYSTEM DATA ****************
317 
319  virtual void add_energy(cvm::real energy) = 0;
320 
322  virtual void request_total_force(bool yesno)
323  {
324  if (yesno == true)
325  cvm::error("Error: total forces are currently not implemented.\n",
326  COLVARS_NOT_IMPLEMENTED);
327  }
328 
330  virtual bool total_forces_enabled() const
331  {
332  return false;
333  }
334 
336  virtual cvm::rvector position_distance(cvm::atom_pos const &pos1,
337  cvm::atom_pos const &pos2) = 0;
338 
342  cvm::atom_pos const &pos2)
343  {
344  return (position_distance(pos1, pos2)).norm2();
345  }
346 
351  cvm::atom_pos const &ref_pos)
352  {
353  pos = position_distance(ref_pos, pos) + ref_pos;
354  }
355 
360  void select_closest_images(std::vector<cvm::atom_pos> &pos,
361  cvm::atom_pos const &ref_pos)
362  {
363  for (std::vector<cvm::atom_pos>::iterator pi = pos.begin();
364  pi != pos.end(); ++pi) {
365  select_closest_image(*pi, ref_pos);
366  }
367  }
368 
369 
370  // **************** ACCESS ATOMIC DATA ****************
371 protected:
372 
375  std::vector<int> atoms_ids;
377  std::vector<size_t> atoms_ncopies;
379  std::vector<cvm::real> atoms_masses;
381  std::vector<cvm::real> atoms_charges;
383  std::vector<cvm::rvector> atoms_positions;
385  std::vector<cvm::rvector> atoms_total_forces;
387  std::vector<cvm::rvector> atoms_new_colvar_forces;
388 
390  inline int add_atom_slot(int atom_id)
391  {
392  atoms_ids.push_back(atom_id);
393  atoms_ncopies.push_back(1);
394  atoms_masses.push_back(1.0);
395  atoms_charges.push_back(0.0);
396  atoms_positions.push_back(cvm::rvector(0.0, 0.0, 0.0));
397  atoms_total_forces.push_back(cvm::rvector(0.0, 0.0, 0.0));
398  atoms_new_colvar_forces.push_back(cvm::rvector(0.0, 0.0, 0.0));
399  return (atoms_ids.size() - 1);
400  }
401 
402 public:
403 
405  virtual int init_atom(int atom_number) = 0;
406 
408  virtual int check_atom_id(int atom_number) = 0;
409 
412  virtual int init_atom(cvm::residue_id const &residue,
413  std::string const &atom_name,
414  std::string const &segment_id)
415  {
416  cvm::error("Error: initializing an atom by name and residue number is currently not supported.\n",
417  COLVARS_NOT_IMPLEMENTED);
418  return COLVARS_NOT_IMPLEMENTED;
419  }
420 
422  virtual int check_atom_id(cvm::residue_id const &residue,
423  std::string const &atom_name,
424  std::string const &segment_id)
425  {
426  cvm::error("Error: initializing an atom by name and residue number is currently not supported.\n",
427  COLVARS_NOT_IMPLEMENTED);
428  return COLVARS_NOT_IMPLEMENTED;
429  }
430 
433  virtual void clear_atom(int index)
434  {
435  if (((size_t) index) >= atoms_ids.size()) {
436  cvm::error("Error: trying to disable an atom that was not previously requested.\n",
437  INPUT_ERROR);
438  }
439  if (atoms_ncopies[index] > 0) {
440  atoms_ncopies[index] -= 1;
441  }
442  }
443 
445  inline int get_atom_id(int index) const
446  {
447  return atoms_ids[index];
448  }
449 
451  inline cvm::real get_atom_mass(int index) const
452  {
453  return atoms_masses[index];
454  }
455 
457  inline cvm::real get_atom_charge(int index) const
458  {
459  return atoms_charges[index];
460  }
461 
463  inline cvm::rvector get_atom_position(int index) const
464  {
465  return atoms_positions[index];
466  }
467 
469  inline cvm::rvector get_atom_total_force(int index) const
470  {
471  return atoms_total_forces[index];
472  }
473 
475  inline void apply_atom_force(int index, cvm::rvector const &new_force)
476  {
477  atoms_new_colvar_forces[index] += new_force;
478  }
479 
481  virtual cvm::rvector get_atom_velocity(int index)
482  {
483  cvm::error("Error: reading the current velocity of an atom is not yet implemented.\n",
484  COLVARS_NOT_IMPLEMENTED);
485  return cvm::rvector(0.0);
486  }
487 
488  // useful functions for data management outside this class
489  inline std::vector<int> *modify_atom_ids() { return &atoms_ids; }
490  inline std::vector<cvm::real> *modify_atom_masses() { return &atoms_masses; }
491  inline std::vector<cvm::real> *modify_atom_charges() { return &atoms_charges; }
492  inline std::vector<cvm::rvector> *modify_atom_positions() { return &atoms_positions; }
493  inline std::vector<cvm::rvector> *modify_atom_total_forces() { return &atoms_total_forces; }
494  inline std::vector<cvm::rvector> *modify_atom_new_colvar_forces() { return &atoms_new_colvar_forces; }
495 
501  virtual int load_atoms(char const *filename,
502  cvm::atom_group &atoms,
503  std::string const &pdb_field,
504  double const pdb_field_value = 0.0)
505  {
506  cvm::error("Error: loading atom identifiers from a file is currently not implemented.\n",
507  COLVARS_NOT_IMPLEMENTED);
508  return COLVARS_NOT_IMPLEMENTED;
509  }
510 
514  virtual int load_coords(char const *filename,
515  std::vector<cvm::atom_pos> &pos,
516  const std::vector<int> &indices,
517  std::string const &pdb_field,
518  double const pdb_field_value = 0.0)
519  {
520  cvm::error("Error: loading atomic coordinates from a file is currently not implemented.\n");
521  return COLVARS_NOT_IMPLEMENTED;
522  }
523 
524  // **************** ACCESS GROUP DATA ****************
525 
526 protected:
527 
530  std::vector<int> atom_groups_ids;
532  std::vector<size_t> atom_groups_ncopies;
534  std::vector<cvm::real> atom_groups_masses;
536  std::vector<cvm::real> atom_groups_charges;
538  std::vector<cvm::rvector> atom_groups_coms;
540  std::vector<cvm::rvector> atom_groups_total_forces;
542  std::vector<cvm::rvector> atom_groups_new_colvar_forces;
543 
545 
546 public:
547 
549  virtual int scalable_group_coms()
550  {
551  return COLVARS_NOT_IMPLEMENTED;
552  }
553 
555  // TODO Add a handle to cvc objects
556  inline int add_atom_group_slot(int atom_group_id)
557  {
558  atom_groups_ids.push_back(atom_group_id);
559  atom_groups_ncopies.push_back(1);
560  atom_groups_masses.push_back(1.0);
561  atom_groups_charges.push_back(0.0);
562  atom_groups_coms.push_back(cvm::rvector(0.0, 0.0, 0.0));
563  atom_groups_total_forces.push_back(cvm::rvector(0.0, 0.0, 0.0));
564  atom_groups_new_colvar_forces.push_back(cvm::rvector(0.0, 0.0, 0.0));
565  return (atom_groups_ids.size() - 1);
566  }
567 
569  virtual int init_atom_group(std::vector<int> const &atoms_ids) // TODO Add a handle to cvc objects
570  {
571  cvm::error("Error: initializing a group outside of the colvars module is currently not supported.\n",
572  COLVARS_NOT_IMPLEMENTED);
573  return COLVARS_NOT_IMPLEMENTED;
574  }
575 
577  virtual void clear_atom_group(int index)
578  {
579  if (cvm::debug()) {
580  log("Trying to remove/disable atom group number "+cvm::to_str(index)+"\n");
581  }
582 
583  if (((size_t) index) >= atom_groups_ids.size()) {
584  cvm::error("Error: trying to disable an atom group that was not previously requested.\n",
585  INPUT_ERROR);
586  }
587 
588  if (atom_groups_ncopies[index] > 0) {
589  atom_groups_ncopies[index] -= 1;
590  }
591  }
592 
594  inline cvm::real get_atom_group_id(int index) const
595  {
596  return atom_groups_ids[index];
597  }
598 
600  inline cvm::real get_atom_group_mass(int index) const
601  {
602  return atom_groups_masses[index];
603  }
604 
606  inline cvm::real get_atom_group_charge(int index) const
607  {
608  return atom_groups_charges[index];
609  }
610 
612  inline cvm::rvector get_atom_group_com(int index) const
613  {
614  return atom_groups_coms[index];
615  }
616 
618  inline cvm::rvector get_atom_group_total_force(int index) const
619  {
620  return atom_groups_total_forces[index];
621  }
622 
624  inline void apply_atom_group_force(int index, cvm::rvector const &new_force)
625  {
626  atom_groups_new_colvar_forces[index] += new_force;
627  }
628 
631  {
632  cvm::error("Error: reading the current velocity of an atom group is not yet implemented.\n",
633  COLVARS_NOT_IMPLEMENTED);
634  return cvm::rvector(0.0);
635  }
636 
637 };
638 
639 
640 #endif
virtual int init_atom(cvm::residue_id const &residue, std::string const &atom_name, std::string const &segment_id)
Definition: colvarproxy.h:412
void select_closest_images(std::vector< cvm::atom_pos > &pos, cvm::atom_pos const &ref_pos)
Perform select_closest_image() on a set of atomic positions.
Definition: colvarproxy.h:360
std::string restart_output_prefix()
Prefix to be used for output restart files.
Definition: colvarproxy.h:96
virtual int smp_enabled()
Whether threaded parallelization is available (TODO: make this a cvm::deps feature) ...
Definition: colvarproxy.h:140
std::string output_prefix()
Prefix to be used for output files (final system configuration)
Definition: colvarproxy.h:103
cvm::rvector get_atom_group_total_force(int index) const
Read the current total force of the given atom group.
Definition: colvarproxy.h:618
virtual bool total_forces_enabled() const
Are total forces being used?
Definition: colvarproxy.h:330
virtual int backup_file(char const *filename)
Rename the given file, before overwriting it.
Definition: colvarproxy.h:309
cvm::real get_atom_group_id(int index) const
Get the numeric ID of the given atom group (for the MD program)
Definition: colvarproxy.h:594
virtual cvm::real dt()=0
Time step of the simulation (fs)
virtual int replica_comm_send(char *msg_data, int msg_len, int dest_rep)
Send data to other replica.
Definition: colvarproxy.h:218
std::vector< size_t > atom_groups_ncopies
Keep track of how many times each group is used by a separate cvc.
Definition: colvarproxy.h:532
virtual cvm::real boltzmann()=0
Boltzmann constant.
virtual int check_atom_id(int atom_number)=0
Check that this atom number is valid, but do not initialize the corresponding atom yet...
virtual void log(std::string const &message)=0
Print a message to the main log.
virtual cvm::real position_dist2(cvm::atom_pos const &pos1, cvm::atom_pos const &pos2)
Get the PBC-aware square distance between two positions; may need to be reimplemented independently f...
Definition: colvarproxy.h:341
cvm::rvector get_atom_group_com(int index) const
Read the current position of the center of mass given atom group.
Definition: colvarproxy.h:612
virtual int update_output()
Update data based from the results of a module update (e.g. send forces)
Definition: colvarproxy.h:55
virtual int run_force_callback()
Run a user-defined colvar forces script.
Definition: colvarproxy.h:236
virtual void fatal_error(std::string const &message)=0
Print a message to the main log and exit with error code.
std::vector< cvm::real > atom_groups_charges
Total charges of the atom groups (allow redefinition during a run, as done e.g. in LAMMPS) ...
Definition: colvarproxy.h:536
cvm::real get_atom_group_charge(int index) const
Get the charge of the given atom group.
Definition: colvarproxy.h:606
std::string input_prefix_str
Prefix to be used for input files (restarts, not configuration)
Definition: colvarproxy.h:88
bool b_simulation_running
Whether a simulation is running (and try to prevent irrecovarable errors)
Definition: colvarproxy.h:117
virtual int setup()
(Re)initialize required member data after construction
Definition: colvarproxy.h:41
vector of real numbers with three components
Definition: colvartypes.h:709
virtual int init_atom_group(std::vector< int > const &atoms_ids)
Prepare this group for collective variables calculation, selecting atoms by internal ids (0-based) ...
Definition: colvarproxy.h:569
Collective variables module (main class)
Definition: colvarmodule.h:71
std::vector< cvm::real > atoms_masses
Masses of the atoms (allow redefinition during a run, as done e.g. in LAMMPS)
Definition: colvarproxy.h:379
virtual cvm::real temperature()=0
Temperature of the simulation (K)
Interface between the collective variables module and the simulation or analysis program (NAMD...
Definition: colvarproxy.h:20
virtual int scalable_group_coms()
TODO Add here containers of handles to cvc objects that are computed in parallel. ...
Definition: colvarproxy.h:549
std::vector< cvm::rvector > atom_groups_coms
Current centers of mass of the atom groups.
Definition: colvarproxy.h:538
virtual void add_energy(cvm::real energy)=0
Pass restraint energy value for current timestep to MD engine.
virtual int load_atoms(char const *filename, cvm::atom_group &atoms, std::string const &pdb_field, double const pdb_field_value=0.0)
Read atom identifiers from a file.
Definition: colvarproxy.h:501
virtual void select_closest_image(cvm::atom_pos &pos, cvm::atom_pos const &ref_pos)
Get the closest periodic image to a reference position.
Definition: colvarproxy.h:350
std::list< std::string > output_stream_names
Identifiers for output_stream objects: by default, these are the names of the files.
Definition: colvarproxy.h:133
Collective variables main module.
double real
Defining an abstract real number allows to switch precision.
Definition: colvarmodule.h:85
int add_atom_slot(int atom_id)
Used by all init_atom() functions: create a slot for an atom not requested yet.
Definition: colvarproxy.h:390
colvarscript * script
Definition: colvarproxy.h:227
std::vector< cvm::real > atoms_charges
Charges of the atoms (allow redefinition during a run, as done e.g. in LAMMPS)
Definition: colvarproxy.h:381
colvarproxy()
Constructor.
Definition: colvarproxy.h:28
std::vector< cvm::rvector > atoms_positions
Current three-dimensional positions of the atoms.
Definition: colvarproxy.h:383
virtual cvm::rvector position_distance(cvm::atom_pos const &pos1, cvm::atom_pos const &pos2)=0
Get the PBC-aware distance vector between two positions.
Value of a collective variable: this is a metatype which can be set at runtime. By default it is set ...
Definition: colvarvalue.h:34
bool b_smp_active
Whether threaded parallelization should be used (TODO: make this a cvm::deps feature) ...
Definition: colvarproxy.h:146
virtual void request_total_force(bool yesno)
Tell the proxy whether total forces are needed (may not always be available)
Definition: colvarproxy.h:322
virtual int check_atom_id(cvm::residue_id const &residue, std::string const &atom_name, std::string const &segment_id)
Check that this atom is valid, but do not initialize it yet.
Definition: colvarproxy.h:422
virtual cvm::rvector get_atom_group_velocity(int index)
Read the current velocity of the given atom group.
Definition: colvarproxy.h:630
std::vector< cvm::real > atom_groups_masses
Total masses of the atom groups.
Definition: colvarproxy.h:534
virtual void clear_atom(int index)
Used by the atom class destructor: rather than deleting the array slot (costly) set the corresponding...
Definition: colvarproxy.h:433
cvm::rvector get_atom_position(int index) const
Read the current position of the given atom.
Definition: colvarproxy.h:463
virtual cvm::real unit_angstrom()=0
Value of the unit for atomic coordinates with respect to angstroms (used by some variables for hard-c...
virtual int init_atom(int atom_number)=0
Prepare this atom for collective variables calculation, selecting it by numeric index (1-based) ...
std::list< std::ostream * > output_files
Currently opened output files: by default, these are ofstream objects. Allows redefinition to impleme...
Definition: colvarproxy.h:131
virtual std::ostream * output_stream(std::string const &output_name)
Returns a reference to the given output channel; if this is not open already, then open it...
Definition: colvarproxy.h:271
virtual int smp_num_threads()
Number of threads sharing this address space.
Definition: colvarproxy.h:173
Definition: colvarscript.h:16
virtual int replica_comm_recv(char *msg_data, int buf_len, int src_rep)
Receive data from other replica.
Definition: colvarproxy.h:213
Arbitrary size array (two dimensions) suitable for linear algebra operations (i.e. for floating point numbers it can be used with library functions)
Definition: colvarmodule.h:91
std::vector< int > atom_groups_ids
Array of 0-based integers used to uniquely associate atom groups within the host program.
Definition: colvarproxy.h:530
std::vector< int > atoms_ids
Array of 0-based integers used to uniquely associate atoms within the host program.
Definition: colvarproxy.h:375
virtual int load_coords(char const *filename, std::vector< cvm::atom_pos > &pos, const std::vector< int > &indices, std::string const &pdb_field, double const pdb_field_value=0.0)
Load the coordinates for a group of atoms from a file (usually a PDB); if "pos" is already allocated...
Definition: colvarproxy.h:514
int residue_id
Residue identifier.
Definition: colvarmodule.h:87
virtual size_t restart_frequency()
Restarts will be written each time this number of steps has passed.
Definition: colvarproxy.h:109
cvm::real get_atom_group_mass(int index) const
Get the mass of the given atom group.
Definition: colvarproxy.h:600
virtual int set_frame(long int)
Set the current frame number (as well as colvarmodule::it)
Definition: colvarproxy.h:84
static void error(std::string const &message, int code=COLVARS_ERROR)
Print a message to the main log and set global error code.
Definition: colvarmodule.cpp:1536
virtual int get_frame(long int &)
Get the current frame number.
Definition: colvarproxy.h:80
virtual int update_input()
Update data required by the colvars module (e.g. cache atom positions)
Definition: colvarproxy.h:49
virtual int smp_colvars_loop()
Distribute calculation of colvars (and their components) across threads.
Definition: colvarproxy.h:149
static std::string to_str(T const &x, size_t const &width=0, size_t const &prec=0)
Quick conversion of an object to a string.
Definition: colvarmodule.h:615
virtual int smp_trylock()
Attempt to lock the proxy's shared data.
Definition: colvarproxy.h:185
virtual int replica_num()
Total number of replica.
Definition: colvarproxy.h:207
int add_atom_group_slot(int atom_group_id)
Used by all init_atom_group() functions: create a slot for an atom group not requested yet...
Definition: colvarproxy.h:556
virtual bool replica_enabled()
Indicate if multi-replica support is available and active.
Definition: colvarproxy.h:201
virtual int replica_index()
Index of this replica.
Definition: colvarproxy.h:204
virtual cvm::rvector get_atom_velocity(int index)
Read the current velocity of the given atom.
Definition: colvarproxy.h:481
int get_atom_id(int index) const
Get the numeric ID of the given atom (for the program)
Definition: colvarproxy.h:445
virtual int smp_lock()
Lock the proxy's shared data for access by a thread, if threads are implemented; if not implemented...
Definition: colvarproxy.h:179
virtual int close_output_stream(std::string const &output_name)
Closes the given output channel.
Definition: colvarproxy.h:291
std::vector< cvm::rvector > atoms_total_forces
Most recent total forces on each atom.
Definition: colvarproxy.h:385
virtual void exit(std::string const &message)
Print a message to the main log and exit normally.
Definition: colvarproxy.h:261
virtual void error(std::string const &message)=0
Print a message to the main log and let the rest of the program handle the error. ...
void apply_atom_force(int index, cvm::rvector const &new_force)
Request that this force is applied to the given atom.
Definition: colvarproxy.h:475
virtual void replica_comm_barrier()
Synchronize replica.
Definition: colvarproxy.h:210
void apply_atom_group_force(int index, cvm::rvector const &new_force)
Request that this force is applied to the given atom group.
Definition: colvarproxy.h:624
std::vector< cvm::rvector > atoms_new_colvar_forces
Forces applied from colvars, to be communicated to the MD integrator.
Definition: colvarproxy.h:387
virtual void clear_atom_group(int index)
Used by the atom_group class destructor.
Definition: colvarproxy.h:577
std::vector< cvm::rvector > atom_groups_total_forces
Most recently updated total forces on the com of each group.
Definition: colvarproxy.h:540
bool force_script_defined
is a user force script defined?
Definition: colvarproxy.h:230
colvarmodule * colvars
Pointer to the main object.
Definition: colvarproxy.h:25
virtual int smp_unlock()
Release the lock.
Definition: colvarproxy.h:191
std::vector< cvm::rvector > atom_groups_new_colvar_forces
Forces applied from colvars, to be communicated to the MD integrator.
Definition: colvarproxy.h:542
virtual int smp_thread_id()
Index of this thread.
Definition: colvarproxy.h:167
virtual int smp_biases_loop()
Distribute calculation of biases across threads.
Definition: colvarproxy.h:155
virtual cvm::real rand_gaussian(void)=0
Pseudo-random number with Gaussian distribution.
cvm::real get_atom_charge(int index) const
Get the charge of the given atom.
Definition: colvarproxy.h:457
virtual int smp_biases_script_loop()
Distribute calculation of biases across threads 2nd through last, with all scripted biased on 1st thr...
Definition: colvarproxy.h:161
virtual bool simulation_running() const
Whether a simulation is running (and try to prevent irrecovarable errors)
Definition: colvarproxy.h:122
std::vector< size_t > atoms_ncopies
Keep track of how many times each atom is used by a separate colvar object.
Definition: colvarproxy.h:377
cvm::real get_atom_mass(int index) const
Get the mass of the given atom.
Definition: colvarproxy.h:451
virtual ~colvarproxy()
Destructor.
Definition: colvarproxy.h:37
cvm::rvector get_atom_total_force(int index) const
Read the current total force of the given atom.
Definition: colvarproxy.h:469
bool have_scripts
Do we have a scripting interface?
Definition: colvarproxy.h:233
static bool debug()
Whether debug output should be enabled (compile-time option)
Definition: colvarmodule.h:225
Group of atom objects, mostly used by a cvc object to gather all atomic data.
Definition: colvaratoms.h:141