16#include "colvartypes.h"
17#include "colvarproxy_io.h"
18#include "colvarproxy_replicas.h"
19#include "colvarproxy_system.h"
20#include "colvarproxy_tcl.h"
21#include "colvarproxy_volmaps.h"
68 std::string
const &atom_name,
69 std::string
const &segment_id);
73 std::string
const &atom_name,
74 std::string
const &segment_id);
136 cvm::error(
"Error: reading the current velocity of an atom "
137 "is not yet implemented.\n",
138 COLVARS_NOT_IMPLEMENTED);
142 inline std::vector<int>
const *get_atom_ids()
const
150 inline std::vector<cvm::real>
const *get_atom_masses()
const
155 inline std::vector<cvm::real> *modify_atom_masses()
162 inline std::vector<cvm::real>
const *get_atom_charges()
167 inline std::vector<cvm::real> *modify_atom_charges()
170 updated_charges_ =
true;
174 inline std::vector<cvm::rvector>
const *get_atom_positions()
const
179 inline std::vector<cvm::rvector> *modify_atom_positions()
184 inline std::vector<cvm::rvector>
const *get_atom_total_forces()
const
189 inline std::vector<cvm::rvector> *modify_atom_total_forces()
194 inline std::vector<cvm::rvector>
const *get_atom_applied_forces()
const
199 inline std::vector<cvm::rvector> *modify_atom_applied_forces()
249 return updated_charges_;
355 cvm::error(
"Error: reading the current velocity of an atom group is not yet implemented.\n",
356 COLVARS_NOT_IMPLEMENTED);
360 inline std::vector<int>
const *get_atom_group_ids()
const
368 inline std::vector<cvm::real> *modify_atom_group_masses()
374 inline std::vector<cvm::real> *modify_atom_group_charges()
380 inline std::vector<cvm::rvector> *modify_atom_group_positions()
385 inline std::vector<cvm::rvector> *modify_atom_group_total_forces()
390 inline std::vector<cvm::rvector> *modify_atom_group_applied_forces()
453 enum class smp_mode_t {cvcs, inner_loop, none};
468 virtual int smp_loop(
int n_items, std::function<
int (
int)>
const &worker);
523 virtual int run_colvar_callback(
524 std::string
const &name,
525 std::vector<const colvarvalue *>
const &cvcs,
528 virtual int run_colvar_gradient_callback(
529 std::string
const &name,
530 std::vector<const colvarvalue *>
const &cvcs,
562 inline std::string
const &engine_name()
const
591 std::string
const &pdb_field,
double pdb_field_value);
600 virtual int load_coords_pdb(
char const *filename, std::vector<cvm::atom_pos> &pos,
601 std::vector<int>
const &sorted_ids, std::string
const &pdb_field,
602 double pdb_field_value);
614 void add_config(std::string
const &cmd, std::string
const &conf);
628 virtual void log(std::string
const &message);
631 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:372
vector of real numbers with three components
Definition: colvartypes.h:723
Collective variables module (main class)
Definition: colvarmodule.h:64
double real
Defining an abstract real number allows to switch precision.
Definition: colvarmodule.h:100
int residue_id
Residue identifier.
Definition: colvarmodule.h:225
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:2070
Container of atom group data (allow collection of aggregated atomic data)
Definition: colvarproxy.h:294
cvm::rvector get_atom_group_total_force(int index) const
Read the current total force of the given atom group.
Definition: colvarproxy.h:341
int get_atom_group_id(int index) const
Get the numeric ID of the given atom group (for the MD program)
Definition: colvarproxy.h:317
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:329
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:423
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:429
std::vector< size_t > atom_groups_refcount
Keep track of how many times each group is used by a separate cvc.
Definition: colvarproxy.h:419
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:353
cvm::real atom_groups_max_applied_force_
Maximum norm among all applied group forces.
Definition: colvarproxy.h:435
cvm::real rms_atom_groups_applied_force() const
Get the root-mean-square of the applied forces.
Definition: colvarproxy.h:402
cvm::real get_atom_group_mass(int index) const
Get the mass of the given atom group.
Definition: colvarproxy.h:323
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:408
std::vector< cvm::real > atom_groups_masses
Total masses of the atom groups.
Definition: colvarproxy.h:421
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:335
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:347
cvm::real atom_groups_rms_applied_force_
Root-mean-square of the applied group forces.
Definition: colvarproxy.h:432
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:427
std::vector< int > atom_groups_ids
Array of 0-based integers used to uniquely associate atom groups within the host program.
Definition: colvarproxy.h:417
std::vector< cvm::rvector > atom_groups_coms
Current centers of mass of the atom groups.
Definition: colvarproxy.h:425
Container of atomic data for processing by Colvars.
Definition: colvarproxy.h:43
cvm::real get_atom_mass(int index) const
Definition: colvarproxy.h:92
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:241
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:271
colvarproxy_atoms()
Constructor.
Definition: colvarproxy.cpp:23
void apply_atom_force(int index, cvm::rvector const &new_force)
Definition: colvarproxy.h:128
cvm::rvector get_atom_velocity(int)
Read the current velocity of the given atom.
Definition: colvarproxy.h:134
cvm::real get_atom_charge(int index) const
Definition: colvarproxy.h:106
virtual ~colvarproxy_atoms()
Destructor.
Definition: colvarproxy.cpp:32
void increase_refcount(int index)
Definition: colvarproxy.h:99
cvm::real rms_atoms_applied_force() const
Get the root-mean-square of the applied forces.
Definition: colvarproxy.h:211
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:280
cvm::rvector get_atom_position(int index) const
Definition: colvarproxy.h:113
bool modified_atom_list() const
Whether the atom list has been modified internally.
Definition: colvarproxy.h:229
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:277
void reset_modified_atom_list()
Reset the modified atom list flag.
Definition: colvarproxy.h:235
std::vector< cvm::rvector > atoms_total_forces
Most recent total forces on each atom.
Definition: colvarproxy.h:266
cvm::rvector get_atom_total_force(int index) const
Definition: colvarproxy.h:120
int max_atoms_applied_force_id() const
Get the atom ID with the largest applied force.
Definition: colvarproxy.h:223
bool updated_masses_
Whether the masses and charges have been updated from the host code.
Definition: colvarproxy.h:283
std::vector< cvm::real > atoms_charges
Charges of the atoms (allow redefinition during a run, as done e.g. in LAMMPS)
Definition: colvarproxy.h:262
cvm::real atoms_max_applied_force_
Maximum norm among all applied forces.
Definition: colvarproxy.h:274
std::vector< size_t > atoms_refcount
Keep track of how many times each atom is used by a separate colvar object.
Definition: colvarproxy.h:258
bool updated_charges() const
Record whether masses have been updated.
Definition: colvarproxy.h:247
cvm::real max_atoms_applied_force() const
Get the maximum norm among all applied forces.
Definition: colvarproxy.h:217
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:264
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:260
int get_atom_id(int index) const
Definition: colvarproxy.h:85
std::vector< cvm::rvector > atoms_new_colvar_forces
Forces applied from colvars, to be communicated to the MD integrator.
Definition: colvarproxy.h:268
std::vector< int > atoms_ids
Array of 0-based integers used to uniquely associate atoms within the host program.
Definition: colvarproxy.h:256
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:503
bool have_scripts
Do we have a scripting interface?
Definition: colvarproxy.h:518
virtual ~colvarproxy_script()
Destructor.
Definition: colvarproxy.cpp:418
colvarproxy_script()
Constructor.
Definition: colvarproxy.cpp:411
virtual int run_force_callback()
Run a user-defined colvar forces script.
Definition: colvarproxy.cpp:427
colvarscript * script
Definition: colvarproxy.h:515
Methods for SMP parallelization.
Definition: colvarproxy.h:449
virtual smp_mode_t get_smp_mode() const
Get the current SMP mode.
Definition: colvarproxy.cpp:268
smp_mode_t smp_mode
Definition: colvarproxy.h:498
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:333
virtual int smp_thread_id()
Index of this thread.
Definition: colvarproxy.cpp:362
virtual int smp_trylock()
Attempt to lock the proxy's shared data.
Definition: colvarproxy.cpp:391
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:382
virtual int set_smp_mode(smp_mode_t mode)
Set the current SMP mode.
Definition: colvarproxy.cpp:276
virtual int smp_num_threads()
Number of threads sharing this address space.
Definition: colvarproxy.cpp:372
omp_lock_t * omp_lock_state
Lock state for OpenMP.
Definition: colvarproxy.h:494
virtual int smp_unlock()
Release the lock.
Definition: colvarproxy.cpp:401
virtual int smp_biases_loop()
Distribute calculation of biases across threads.
Definition: colvarproxy.cpp:310
virtual int smp_loop(int n_items, std::function< int(int)> const &worker)
Distribute computation over threads using OpenMP, unless overridden in the backend (e....
Definition: colvarproxy.cpp:291
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:549
virtual int update_input()
Definition: colvarproxy.cpp:564
colvarproxy()
Constructor.
Definition: colvarproxy.cpp:450
std::string error_output
Collected error messages.
Definition: colvarproxy.h:680
virtual int update_output()
Update data based on the results of a Colvars call (e.g. send forces)
Definition: colvarproxy.cpp:570
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:504
virtual int request_deletion()
Request deallocation of the module (currently only implemented by VMD)
Definition: colvarproxy.cpp:496
colvarmodule * colvars
Pointer to the main object.
Definition: colvarproxy.h:554
bool simulation_continuing() const
Definition: colvarproxy.h:651
void clear_error_msgs()
As the name says.
Definition: colvarproxy.cpp:739
void add_error_msg(std::string const &message)
Record error message (used by VMD to collect them after a script call)
Definition: colvarproxy.cpp:729
int version_int
Integer representing the version string (allows comparisons)
Definition: colvarproxy.h:694
std::string const & get_error_msgs()
Retrieve accumulated error messages.
Definition: colvarproxy.cpp:745
int end_of_step()
Carry out operations needed before next simulation step is run.
Definition: colvarproxy.cpp:576
virtual void log(std::string const &message)
Print a message to the main log.
Definition: colvarproxy.cpp:716
bool b_delete_requested
Whether the entire module should be deallocated by the host engine.
Definition: colvarproxy.h:691
std::string engine_name_
Name of the simulation engine that the derived proxy object supports.
Definition: colvarproxy.h:702
void print_input_atomic_data()
Print a full list of all input atomic arrays for debug purposes.
Definition: colvarproxy.cpp:609
virtual int parse_module_config()
(Re)initialize the module
Definition: colvarproxy.cpp:516
bool engine_ready() const
Whether the engine allows to fully initialize Colvars immediately.
Definition: colvarproxy.h:608
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:551
int get_version_from_string(char const *version_string)
Convert a version string "YYYY-MM-DD" into an integer.
Definition: colvarproxy.cpp:751
bool simulation_running() const
Whether a simulation is running (warn against irrecovarable errors)
Definition: colvarproxy.h:643
virtual int reset()
Reset proxy state, e.g. requested atoms.
Definition: colvarproxy.cpp:482
void * config_queue_
Queue of config strings or files to be fed to the module.
Definition: colvarproxy.h:705
int post_run()
Called at the end of a simulation segment (i.e. "run" command)
Definition: colvarproxy.cpp:597
bool b_simulation_continuing
Definition: colvarproxy.h:688
bool engine_ready_
Whether the engine allows to fully initialize Colvars immediately.
Definition: colvarproxy.h:677
bool delete_requested() const
Whether deallocation was requested.
Definition: colvarproxy.h:573
size_t features_hash
Track which features have been acknowledged during the last run.
Definition: colvarproxy.h:697
void print_output_atomic_data()
Print a full list of all applied forces for debug purposes.
Definition: colvarproxy.cpp:691
int version_number() const
Get the version number (higher = more recent)
Definition: colvarproxy.h:669
bool io_available() override
Ensure that we're on the main thread (derived class will do actual check)
Definition: colvarproxy.cpp:475
virtual int setup()
(Re)initialize required member data (called after the module)
Definition: colvarproxy.cpp:510
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:539
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:722
bool b_simulation_running
Whether a simulation is running (warn against irrecovarable errors)
Definition: colvarproxy.h:683
~colvarproxy() override
Destructor.
Definition: colvarproxy.cpp:464
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.