14#include "colvartypes.h"
15#include "colvarproxy_io.h"
16#include "colvarproxy_replicas.h"
17#include "colvarproxy_system.h"
18#include "colvarproxy_tcl.h"
19#include "colvarproxy_volmaps.h"
66 std::string
const &atom_name,
67 std::string
const &segment_id);
71 std::string
const &atom_name,
72 std::string
const &segment_id);
134 cvm::error(
"Error: reading the current velocity of an atom "
135 "is not yet implemented.\n",
136 COLVARS_NOT_IMPLEMENTED);
140 inline std::vector<int>
const *get_atom_ids()
const
148 inline std::vector<cvm::real>
const *get_atom_masses()
const
153 inline std::vector<cvm::real> *modify_atom_masses()
160 inline std::vector<cvm::real>
const *get_atom_charges()
165 inline std::vector<cvm::real> *modify_atom_charges()
168 updated_charges_ =
true;
172 inline std::vector<cvm::rvector>
const *get_atom_positions()
const
177 inline std::vector<cvm::rvector> *modify_atom_positions()
182 inline std::vector<cvm::rvector>
const *get_atom_total_forces()
const
187 inline std::vector<cvm::rvector> *modify_atom_total_forces()
192 inline std::vector<cvm::rvector>
const *get_atom_applied_forces()
const
197 inline std::vector<cvm::rvector> *modify_atom_applied_forces()
247 return updated_charges_;
353 cvm::error(
"Error: reading the current velocity of an atom group is not yet implemented.\n",
354 COLVARS_NOT_IMPLEMENTED);
358 inline std::vector<int>
const *get_atom_group_ids()
const
366 inline std::vector<cvm::real> *modify_atom_group_masses()
372 inline std::vector<cvm::real> *modify_atom_group_charges()
378 inline std::vector<cvm::rvector> *modify_atom_group_positions()
383 inline std::vector<cvm::rvector> *modify_atom_group_total_forces()
388 inline std::vector<cvm::rvector> *modify_atom_group_applied_forces()
516 virtual int run_colvar_callback(
517 std::string
const &name,
518 std::vector<const colvarvalue *>
const &cvcs,
521 virtual int run_colvar_gradient_callback(
522 std::string
const &name,
523 std::vector<const colvarvalue *>
const &cvcs,
555 inline std::string
const &engine_name()
const
584 std::string
const &pdb_field,
double pdb_field_value);
593 virtual int load_coords_pdb(
char const *filename, std::vector<cvm::atom_pos> &pos,
594 std::vector<int>
const &sorted_ids, std::string
const &pdb_field,
595 double pdb_field_value);
607 void add_config(std::string
const &cmd, std::string
const &conf);
621 virtual void log(std::string
const &message);
624 virtual void error(std::string
const &message);
Group of atom objects, mostly used by a colvar::cvc object to gather all atomic data.
Definition: colvaratoms.h:159
Arbitrary size array (two dimensions) suitable for linear algebra operations (i.e....
Definition: colvartypes.h:376
vector of real numbers with three components
Definition: colvartypes.h:727
Collective variables module (main class)
Definition: colvarmodule.h:59
double real
Defining an abstract real number allows to switch precision.
Definition: colvarmodule.h:95
int residue_id
Residue identifier.
Definition: colvarmodule.h:193
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:2047
Container of atom group data (allow collection of aggregated atomic data)
Definition: colvarproxy.h:292
cvm::rvector get_atom_group_total_force(int index) const
Read the current total force of the given atom group.
Definition: colvarproxy.h:339
int get_atom_group_id(int index) const
Get the numeric ID of the given atom group (for the MD program)
Definition: colvarproxy.h:315
virtual void clear_atom_group(int index)
Used by the atom_group class destructor.
Definition: colvarproxy.cpp:206
colvarproxy_atom_groups()
Constructor.
Definition: colvarproxy.cpp:153
cvm::real get_atom_group_charge(int index) const
Get the charge of the given atom group.
Definition: colvarproxy.h:327
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:421
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.cpp:178
virtual int scalable_group_coms()
Whether this proxy implementation has capability for scalable groups.
Definition: colvarproxy.cpp:191
std::vector< cvm::rvector > atom_groups_new_colvar_forces
Forces applied from colvars, to be communicated to the MD integrator.
Definition: colvarproxy.h:427
std::vector< size_t > atom_groups_refcount
Keep track of how many times each group is used by a separate cvc.
Definition: colvarproxy.h:417
void compute_max_atom_groups_applied_force()
Compute the maximum norm among all applied forces.
Definition: colvarproxy.cpp:236
cvm::rvector get_atom_group_velocity(int)
Read the current velocity of the given atom group.
Definition: colvarproxy.h:351
cvm::real atom_groups_max_applied_force_
Maximum norm among all applied group forces.
Definition: colvarproxy.h:433
cvm::real rms_atom_groups_applied_force() const
Get the root-mean-square of the applied forces.
Definition: colvarproxy.h:400
cvm::real get_atom_group_mass(int index) const
Get the mass of the given atom group.
Definition: colvarproxy.h:321
int reset()
Clear atom group data.
Definition: colvarproxy.cpp:165
void compute_rms_atom_groups_applied_force()
Compute the root-mean-square of the applied forces.
Definition: colvarproxy.cpp:229
cvm::real max_atom_groups_applied_force() const
Get the maximum norm among all applied forces.
Definition: colvarproxy.h:406
std::vector< cvm::real > atom_groups_masses
Total masses of the atom groups.
Definition: colvarproxy.h:419
virtual ~colvarproxy_atom_groups()
Destructor.
Definition: colvarproxy.cpp:159
size_t get_num_active_atom_groups() const
Return number of atom groups with positive reference count.
Definition: colvarproxy.cpp:219
cvm::rvector get_atom_group_com(int index) const
Read the current position of the center of mass given atom group.
Definition: colvarproxy.h:333
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:345
cvm::real atom_groups_rms_applied_force_
Root-mean-square of the applied group forces.
Definition: colvarproxy.h:430
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.cpp:197
std::vector< cvm::rvector > atom_groups_total_forces
Most recently updated total forces on the com of each group.
Definition: colvarproxy.h:425
std::vector< int > atom_groups_ids
Array of 0-based integers used to uniquely associate atom groups within the host program.
Definition: colvarproxy.h:415
std::vector< cvm::rvector > atom_groups_coms
Current centers of mass of the atom groups.
Definition: colvarproxy.h:423
Container of atomic data for processing by Colvars.
Definition: colvarproxy.h:41
cvm::real get_atom_mass(int index) const
Definition: colvarproxy.h:90
int reset()
Clear atomic data.
Definition: colvarproxy.cpp:38
int add_atom_slot(int atom_id)
Definition: colvarproxy.cpp:51
bool updated_masses() const
Record whether masses have been updated.
Definition: colvarproxy.h:239
virtual int init_atom(int atom_number)
Definition: colvarproxy.cpp:65
size_t get_num_active_atoms() const
Return number of atoms with positive reference count.
Definition: colvarproxy.cpp:114
cvm::real atoms_rms_applied_force_
Root-mean-square of the applied forces.
Definition: colvarproxy.h:269
colvarproxy_atoms()
Constructor.
Definition: colvarproxy.cpp:23
void apply_atom_force(int index, cvm::rvector const &new_force)
Definition: colvarproxy.h:126
cvm::rvector get_atom_velocity(int)
Read the current velocity of the given atom.
Definition: colvarproxy.h:132
cvm::real get_atom_charge(int index) const
Definition: colvarproxy.h:104
virtual ~colvarproxy_atoms()
Destructor.
Definition: colvarproxy.cpp:32
void increase_refcount(int index)
Definition: colvarproxy.h:97
cvm::real rms_atoms_applied_force() const
Get the root-mean-square of the applied forces.
Definition: colvarproxy.h:209
virtual int check_atom_name_selections_available()
Check whether it is possible to select atoms by residue number name.
Definition: colvarproxy.cpp:77
bool modified_atom_list_
Whether the atom list has been modified internally.
Definition: colvarproxy.h:278
cvm::rvector get_atom_position(int index) const
Definition: colvarproxy.h:111
bool modified_atom_list() const
Whether the atom list has been modified internally.
Definition: colvarproxy.h:227
void compute_max_atoms_applied_force()
Compute the maximum norm among all applied forces.
Definition: colvarproxy.cpp:131
virtual void clear_atom(int index)
Used by the atom class destructor: rather than deleting the array slot (costly) set the corresponding...
Definition: colvarproxy.cpp:102
int atoms_max_applied_force_id_
ID of the atom with the maximum norm among all applied forces.
Definition: colvarproxy.h:275
void reset_modified_atom_list()
Reset the modified atom list flag.
Definition: colvarproxy.h:233
std::vector< cvm::rvector > atoms_total_forces
Most recent total forces on each atom.
Definition: colvarproxy.h:264
cvm::rvector get_atom_total_force(int index) const
Definition: colvarproxy.h:118
int max_atoms_applied_force_id() const
Get the atom ID with the largest applied force.
Definition: colvarproxy.h:221
bool updated_masses_
Whether the masses and charges have been updated from the host code.
Definition: colvarproxy.h:281
std::vector< cvm::real > atoms_charges
Charges of the atoms (allow redefinition during a run, as done e.g. in LAMMPS)
Definition: colvarproxy.h:260
cvm::real atoms_max_applied_force_
Maximum norm among all applied forces.
Definition: colvarproxy.h:272
std::vector< size_t > atoms_refcount
Keep track of how many times each atom is used by a separate colvar object.
Definition: colvarproxy.h:256
bool updated_charges() const
Record whether masses have been updated.
Definition: colvarproxy.h:245
cvm::real max_atoms_applied_force() const
Get the maximum norm among all applied forces.
Definition: colvarproxy.h:215
void compute_rms_atoms_applied_force()
Compute the root-mean-square of the applied forces.
Definition: colvarproxy.cpp:124
std::vector< cvm::rvector > atoms_positions
Current three-dimensional positions of the atoms.
Definition: colvarproxy.h:262
virtual int check_atom_id(int atom_number)
Definition: colvarproxy.cpp: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:258
int get_atom_id(int index) const
Definition: colvarproxy.h:83
std::vector< cvm::rvector > atoms_new_colvar_forces
Forces applied from colvars, to be communicated to the MD integrator.
Definition: colvarproxy.h:266
std::vector< int > atoms_ids
Array of 0-based integers used to uniquely associate atoms within the host program.
Definition: colvarproxy.h:254
Methods for data input/output.
Definition: colvarproxy_io.h:20
Methods for multiple-replica communication.
Definition: colvarproxy_replicas.h:23
Methods for scripting language interface (Tcl or Python)
Definition: colvarproxy.h:496
bool have_scripts
Do we have a scripting interface?
Definition: colvarproxy.h:511
virtual ~colvarproxy_script()
Destructor.
Definition: colvarproxy.cpp:414
colvarproxy_script()
Constructor.
Definition: colvarproxy.cpp:407
virtual int run_force_callback()
Run a user-defined colvar forces script.
Definition: colvarproxy.cpp:423
colvarscript * script
Definition: colvarproxy.h:508
Methods for SMP parallelization.
Definition: colvarproxy.h:447
virtual int smp_colvars_loop()
Distribute calculation of colvars (and their components) across threads.
Definition: colvarproxy.cpp:282
virtual int smp_biases_script_loop()
Distribute calculation of biases across threads 2nd through last, with all scripted biased on 1st thr...
Definition: colvarproxy.cpp:329
virtual int smp_thread_id()
Index of this thread.
Definition: colvarproxy.cpp:358
virtual int smp_trylock()
Attempt to lock the proxy's shared data.
Definition: colvarproxy.cpp:387
virtual int smp_lock()
Lock the proxy's shared data for access by a thread, if threads are implemented; if not implemented,...
Definition: colvarproxy.cpp:378
virtual int smp_num_threads()
Number of threads sharing this address space.
Definition: colvarproxy.cpp:368
omp_lock_t * omp_lock_state
Lock state for OpenMP.
Definition: colvarproxy.h:491
virtual int check_smp_enabled()
Whether threaded parallelization is available (TODO: make this a cvm::deps feature)
Definition: colvarproxy.cpp:269
bool b_smp_active
Definition: colvarproxy.h:459
virtual int smp_unlock()
Release the lock.
Definition: colvarproxy.cpp:397
virtual int smp_biases_loop()
Distribute calculation of biases across threads.
Definition: colvarproxy.cpp:306
virtual ~colvarproxy_smp()
Destructor.
Definition: colvarproxy.cpp:257
colvarproxy_smp()
Constructor.
Definition: colvarproxy.cpp:244
Methods for accessing the simulation system (PBCs, integrator, etc)
Definition: colvarproxy_system.h:15
Methods for using Tcl within Colvars.
Definition: colvarproxy_tcl.h:28
Container of grid-based objects.
Definition: colvarproxy_volmaps.h:8
Definition: colvarproxy.h:542
virtual int update_input()
Definition: colvarproxy.cpp:560
colvarproxy()
Constructor.
Definition: colvarproxy.cpp:446
std::string error_output
Collected error messages.
Definition: colvarproxy.h:673
virtual int update_output()
Update data based on the results of a Colvars call (e.g. send forces)
Definition: colvarproxy.cpp:566
void add_config(std::string const &cmd, std::string const &conf)
Enqueue new configuration text, to be parsed as soon as possible.
Definition: colvarproxy.cpp:500
virtual int request_deletion()
Request deallocation of the module (currently only implemented by VMD)
Definition: colvarproxy.cpp:492
colvarmodule * colvars
Pointer to the main object.
Definition: colvarproxy.h:547
bool simulation_continuing() const
Definition: colvarproxy.h:644
void clear_error_msgs()
As the name says.
Definition: colvarproxy.cpp:735
void add_error_msg(std::string const &message)
Record error message (used by VMD to collect them after a script call)
Definition: colvarproxy.cpp:725
int version_int
Integer representing the version string (allows comparisons)
Definition: colvarproxy.h:687
std::string const & get_error_msgs()
Retrieve accumulated error messages.
Definition: colvarproxy.cpp:741
int end_of_step()
Carry out operations needed before next simulation step is run.
Definition: colvarproxy.cpp:572
virtual void log(std::string const &message)
Print a message to the main log.
Definition: colvarproxy.cpp:712
bool b_delete_requested
Whether the entire module should be deallocated by the host engine.
Definition: colvarproxy.h:684
std::string engine_name_
Name of the simulation engine that the derived proxy object supports.
Definition: colvarproxy.h:695
void print_input_atomic_data()
Print a full list of all input atomic arrays for debug purposes.
Definition: colvarproxy.cpp:605
virtual int parse_module_config()
(Re)initialize the module
Definition: colvarproxy.cpp:512
bool engine_ready() const
Whether the engine allows to fully initialize Colvars immediately.
Definition: colvarproxy.h:601
virtual int load_coords_pdb(char const *filename, std::vector< cvm::atom_pos > &pos, std::vector< int > const &sorted_ids, std::string const &pdb_field, double pdb_field_value)
Load a set of coordinates from a PDB file.
Definition: colvarproxy.cpp:547
int get_version_from_string(char const *version_string)
Convert a version string "YYYY-MM-DD" into an integer.
Definition: colvarproxy.cpp:747
bool simulation_running() const
Whether a simulation is running (warn against irrecovarable errors)
Definition: colvarproxy.h:636
virtual int reset()
Reset proxy state, e.g. requested atoms.
Definition: colvarproxy.cpp:478
void * config_queue_
Queue of config strings or files to be fed to the module.
Definition: colvarproxy.h:698
int post_run()
Called at the end of a simulation segment (i.e. "run" command)
Definition: colvarproxy.cpp:593
bool b_simulation_continuing
Definition: colvarproxy.h:681
bool engine_ready_
Whether the engine allows to fully initialize Colvars immediately.
Definition: colvarproxy.h:670
bool delete_requested() const
Whether deallocation was requested.
Definition: colvarproxy.h:566
size_t features_hash
Track which features have been acknowledged during the last run.
Definition: colvarproxy.h:690
void print_output_atomic_data()
Print a full list of all applied forces for debug purposes.
Definition: colvarproxy.cpp:687
int version_number() const
Get the version number (higher = more recent)
Definition: colvarproxy.h:662
bool io_available() override
Ensure that we're on the main thread (derived class will do actual check)
Definition: colvarproxy.cpp:471
virtual int setup()
(Re)initialize required member data (called after the module)
Definition: colvarproxy.cpp:506
virtual int load_atoms_pdb(char const *filename, cvm::atom_group &atoms, std::string const &pdb_field, double pdb_field_value)
Read a selection of atom IDs from a PDB coordinate file.
Definition: colvarproxy.cpp:535
virtual void error(std::string const &message)
Print a message to the main log and/or let the host code know about it.
Definition: colvarproxy.cpp:718
bool b_simulation_running
Whether a simulation is running (warn against irrecovarable errors)
Definition: colvarproxy.h:676
~colvarproxy() override
Destructor.
Definition: colvarproxy.cpp:460
Definition: colvarscript.h:29
Value of a collective variable: this is a metatype which can be set at runtime. By default it is set ...
Definition: colvarvalue.h:43
Collective variables main module.