14 #include "colvartypes.h" 15 #include "colvarproxy_io.h" 16 #include "colvarproxy_system.h" 17 #include "colvarproxy_tcl.h" 18 #include "colvarproxy_volmaps.h" 65 std::string
const &atom_name,
66 std::string
const &segment_id);
70 std::string
const &atom_name,
71 std::string
const &segment_id);
133 cvm::error(
"Error: reading the current velocity of an atom " 134 "is not yet implemented.\n",
135 COLVARS_NOT_IMPLEMENTED);
139 inline std::vector<int>
const *get_atom_ids()
const 147 inline std::vector<cvm::real>
const *get_atom_masses()
const 152 inline std::vector<cvm::real> *modify_atom_masses()
159 inline std::vector<cvm::real>
const *get_atom_charges()
164 inline std::vector<cvm::real> *modify_atom_charges()
167 updated_charges_ =
true;
171 inline std::vector<cvm::rvector>
const *get_atom_positions()
const 176 inline std::vector<cvm::rvector> *modify_atom_positions()
181 inline std::vector<cvm::rvector>
const *get_atom_total_forces()
const 186 inline std::vector<cvm::rvector> *modify_atom_total_forces()
191 inline std::vector<cvm::rvector>
const *get_atom_applied_forces()
const 196 inline std::vector<cvm::rvector> *modify_atom_applied_forces()
246 return updated_charges_;
352 cvm::error(
"Error: reading the current velocity of an atom group is not yet implemented.\n",
353 COLVARS_NOT_IMPLEMENTED);
357 inline std::vector<int>
const *get_atom_group_ids()
const 365 inline std::vector<cvm::real> *modify_atom_group_masses()
371 inline std::vector<cvm::real> *modify_atom_group_charges()
377 inline std::vector<cvm::rvector> *modify_atom_group_positions()
382 inline std::vector<cvm::rvector> *modify_atom_group_total_forces()
387 inline std::vector<cvm::rvector> *modify_atom_group_applied_forces()
547 virtual int run_colvar_callback(
548 std::string
const &name,
549 std::vector<const colvarvalue *>
const &cvcs,
552 virtual int run_colvar_gradient_callback(
553 std::string
const &name,
554 std::vector<const colvarvalue *>
const &cvcs,
586 inline std::string
const &engine_name()
const 615 std::string
const &pdb_field,
double pdb_field_value);
624 virtual int load_coords_pdb(
char const *filename, std::vector<cvm::atom_pos> &pos,
625 std::vector<int>
const &sorted_ids, std::string
const &pdb_field,
626 double pdb_field_value);
638 void add_config(std::string
const &cmd, std::string
const &conf);
652 virtual void log(std::string
const &message);
655 virtual void error(std::string
const &message);
bool modified_atom_list_
Whether the atom list has been modified internally.
Definition: colvarproxy.h:277
colvarproxy_smp()
Constructor.
Definition: colvarproxy.cpp:244
virtual int replica_enabled()
Indicate if multi-replica support is available and active.
Definition: colvarproxy_replicas.cpp:20
int version_int
Integer representing the version string (allows comparisons)
Definition: colvarproxy.h:718
virtual ~colvarproxy_atom_groups()
Destructor.
Definition: colvarproxy.cpp:159
Methods for scripting language interface (Tcl or Python)
Definition: colvarproxy.h:527
cvm::real get_atom_mass(int index) const
Definition: colvarproxy.h:89
cvm::real get_atom_charge(int index) const
Definition: colvarproxy.h:103
virtual int init_atom(int atom_number)
Definition: colvarproxy.cpp:65
virtual int smp_num_threads()
Number of threads sharing this address space.
Definition: colvarproxy.cpp:368
Container of grid-based objects.
Definition: colvarproxy_volmaps.h:8
size_t get_num_active_atom_groups() const
Return number of atom groups with positive reference count.
Definition: colvarproxy.cpp:219
bool simulation_running() const
Whether a simulation is running (warn against irrecovarable errors)
Definition: colvarproxy.h:667
virtual int check_atom_name_selections_available()
Check whether it is possible to select atoms by residue number name.
Definition: colvarproxy.cpp:77
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:420
std::string const & get_error_msgs()
Retrieve accumulated error messages.
Definition: colvarproxy.cpp:741
int max_atoms_applied_force_id() const
Get the atom ID with the largest applied force.
Definition: colvarproxy.h:220
virtual void replica_comm_barrier()
Synchronize replica with others.
Definition: colvarproxy_replicas.cpp:38
cvm::real atom_groups_max_applied_force_
Maximum norm among all applied group forces.
Definition: colvarproxy.h:432
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
colvarproxy_atom_groups()
Constructor.
Definition: colvarproxy.cpp:153
virtual int update_input()
Definition: colvarproxy.cpp:560
int post_run()
Called at the end of a simulation segment (i.e. "run" command)
Definition: colvarproxy.cpp:593
virtual void clear_atom_group(int index)
Used by the atom_group class destructor.
Definition: colvarproxy.cpp:206
bool b_simulation_running
Whether a simulation is running (warn against irrecovarable errors)
Definition: colvarproxy.h:707
virtual int scalable_group_coms()
Whether this proxy implementation has capability for scalable groups.
Definition: colvarproxy.cpp:191
virtual int smp_trylock()
Attempt to lock the proxy's shared data.
Definition: colvarproxy.cpp:387
virtual int request_deletion()
Request deallocation of the module (currently only implemented by VMD)
Definition: colvarproxy.cpp:492
bool io_available() override
Ensure that we're on the main thread (derived class will do actual check)
Definition: colvarproxy.cpp:471
cvm::rvector get_atom_group_com(int index) const
Read the current position of the center of mass given atom group.
Definition: colvarproxy.h:332
cvm::real get_atom_group_charge(int index) const
Get the charge of the given atom group.
Definition: colvarproxy.h:326
cvm::real get_atom_group_mass(int index) const
Get the mass of the given atom group.
Definition: colvarproxy.h:320
int end_of_step()
Carry out operations needed before next simulation step is run.
Definition: colvarproxy.cpp:572
virtual int check_atom_id(int atom_number)
Definition: colvarproxy.cpp:71
virtual void log(std::string const &message)
Print a message to the main log.
Definition: colvarproxy.cpp:712
std::vector< cvm::real > atoms_masses
Masses of the atoms (allow redefinition during a run, as done e.g. in LAMMPS)
Definition: colvarproxy.h:257
vector of real numbers with three components
Definition: colvartypes.h:727
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
Collective variables module (main class)
Definition: colvarmodule.h:59
bool updated_masses_
Whether the masses and charges have been updated from the host code.
Definition: colvarproxy.h:280
Definition: colvarproxy.h:563
cvm::rvector get_atom_position(int index) const
Definition: colvarproxy.h:110
virtual int check_smp_enabled()
Whether threaded parallelization is available (TODO: make this a cvm::deps feature) ...
Definition: colvarproxy.cpp:269
cvm::real atom_groups_rms_applied_force_
Root-mean-square of the applied group forces.
Definition: colvarproxy.h:429
std::vector< cvm::real > atom_groups_masses
Total masses of the atom groups.
Definition: colvarproxy.h:418
bool engine_ready_
Whether the engine allows to fully initialize Colvars immediately.
Definition: colvarproxy.h:701
void compute_max_atom_groups_applied_force()
Compute the maximum norm among all applied forces.
Definition: colvarproxy.cpp:236
void print_input_atomic_data()
Print a full list of all input atomic arrays for debug purposes.
Definition: colvarproxy.cpp:605
Collective variables main module.
virtual int smp_biases_loop()
Distribute calculation of biases across threads.
Definition: colvarproxy.cpp:306
double real
Defining an abstract real number allows to switch precision.
Definition: colvarmodule.h:89
bool b_smp_active
Definition: colvarproxy.h:458
Methods for using Tcl within Colvars.
Definition: colvarproxy_tcl.h:28
void increase_refcount(int index)
Definition: colvarproxy.h:96
bool b_delete_requested
Whether the entire module should be deallocated by the host engine.
Definition: colvarproxy.h:715
virtual ~colvarproxy_atoms()
Destructor.
Definition: colvarproxy.cpp:32
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:2025
virtual int parse_module_config()
(Re)initialize the module
Definition: colvarproxy.cpp:512
colvarproxy()
Constructor.
Definition: colvarproxy.cpp:446
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
bool have_scripts
Do we have a scripting interface?
Definition: colvarproxy.h:542
void apply_atom_force(int index, cvm::rvector const &new_force)
Definition: colvarproxy.h:125
Value of a collective variable: this is a metatype which can be set at runtime. By default it is set ...
Definition: colvarvalue.h:43
void reset_modified_atom_list()
Reset the modified atom list flag.
Definition: colvarproxy.h:232
Methods for multiple-replica communication.
Definition: colvarproxy.h:495
int get_atom_id(int index) const
Definition: colvarproxy.h:82
bool updated_masses() const
Record whether masses have been updated.
Definition: colvarproxy.h:238
std::vector< size_t > atoms_refcount
Keep track of how many times each atom is used by a separate colvar object.
Definition: colvarproxy.h:255
std::vector< int > atoms_ids
Array of 0-based integers used to uniquely associate atoms within the host program.
Definition: colvarproxy.h:253
std::vector< cvm::rvector > atom_groups_total_forces
Most recently updated total forces on the com of each group.
Definition: colvarproxy.h:424
void compute_rms_atom_groups_applied_force()
Compute the root-mean-square of the applied forces.
Definition: colvarproxy.cpp:229
size_t features_hash
Track which features have been acknowledged during the last run.
Definition: colvarproxy.h:721
virtual ~colvarproxy_script()
Destructor.
Definition: colvarproxy.cpp:414
int atoms_max_applied_force_id_
ID of the atom with the maximum norm among all applied forces.
Definition: colvarproxy.h:274
std::vector< cvm::real > atoms_charges
Charges of the atoms (allow redefinition during a run, as done e.g. in LAMMPS)
Definition: colvarproxy.h:259
cvm::rvector get_atom_velocity(int)
Read the current velocity of the given atom.
Definition: colvarproxy.h:131
virtual ~colvarproxy_smp()
Destructor.
Definition: colvarproxy.cpp:257
virtual int setup()
(Re)initialize required member data (called after the module)
Definition: colvarproxy.cpp:506
std::vector< cvm::rvector > atom_groups_new_colvar_forces
Forces applied from colvars, to be communicated to the MD integrator.
Definition: colvarproxy.h:426
void clear_error_msgs()
As the name says.
Definition: colvarproxy.cpp:735
int get_atom_group_id(int index) const
Get the numeric ID of the given atom group (for the MD program)
Definition: colvarproxy.h:314
~colvarproxy() override
Destructor.
Definition: colvarproxy.cpp:460
Methods for data input/output.
Definition: colvarproxy_io.h:20
virtual int replica_comm_recv(char *msg_data, int buf_len, int src_rep)
Receive data from other replica.
Definition: colvarproxy_replicas.cpp:41
std::string error_output
Collected error messages.
Definition: colvarproxy.h:704
Definition: colvarscript.h:29
cvm::rvector get_atom_group_velocity(int)
Read the current velocity of the given atom group.
Definition: colvarproxy.h:350
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:179
virtual ~colvarproxy_replicas()
Destructor.
Definition: colvarproxy_replicas.cpp:17
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
colvarscript * script
Definition: colvarproxy.h:539
cvm::rvector get_atom_total_force(int index) const
Definition: colvarproxy.h:117
virtual int reset()
Reset proxy state, e.g. requested atoms.
Definition: colvarproxy.cpp:478
std::vector< cvm::rvector > atoms_total_forces
Most recent total forces on each atom.
Definition: colvarproxy.h:263
int reset()
Clear atomic data.
Definition: colvarproxy.cpp:38
bool simulation_continuing() const
Definition: colvarproxy.h:675
int reset()
Clear atom group data.
Definition: colvarproxy.cpp:165
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
int residue_id
Residue identifier.
Definition: colvarmodule.h:184
Methods for accessing the simulation system (PBCs, integrator, etc)
Definition: colvarproxy_system.h:15
bool modified_atom_list() const
Whether the atom list has been modified internally.
Definition: colvarproxy.h:226
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
int add_atom_slot(int atom_id)
Definition: colvarproxy.cpp:51
colvarproxy_atoms()
Constructor.
Definition: colvarproxy.cpp:23
virtual int run_force_callback()
Run a user-defined colvar forces script.
Definition: colvarproxy.cpp:423
colvarproxy_script()
Constructor.
Definition: colvarproxy.cpp:407
cvm::real max_atom_groups_applied_force() const
Get the maximum norm among all applied forces.
Definition: colvarproxy.h:405
virtual int replica_comm_send(char *msg_data, int msg_len, int dest_rep)
Send data to other replica.
Definition: colvarproxy_replicas.cpp:49
size_t get_num_active_atoms() const
Return number of atoms with positive reference count.
Definition: colvarproxy.cpp:114
virtual int smp_thread_id()
Index of this thread.
Definition: colvarproxy.cpp:358
virtual int smp_unlock()
Release the lock.
Definition: colvarproxy.cpp:397
std::vector< cvm::rvector > atom_groups_coms
Current centers of mass of the atom groups.
Definition: colvarproxy.h:422
colvarproxy_replicas()
Constructor.
Definition: colvarproxy_replicas.cpp:14
cvm::real max_atoms_applied_force() const
Get the maximum norm among all applied forces.
Definition: colvarproxy.h:214
int version_number() const
Get the version number (higher = more recent)
Definition: colvarproxy.h:693
std::string engine_name_
Name of the simulation engine that the derived proxy object supports.
Definition: colvarproxy.h:726
void compute_rms_atoms_applied_force()
Compute the root-mean-square of the applied forces.
Definition: colvarproxy.cpp:124
int get_version_from_string(char const *version_string)
Convert a version string "YYYY-MM-DD" into an integer.
Definition: colvarproxy.cpp:747
std::vector< cvm::rvector > atoms_positions
Current three-dimensional positions of the atoms.
Definition: colvarproxy.h:261
bool engine_ready() const
Whether the engine allows to fully initialize Colvars immediately.
Definition: colvarproxy.h:632
std::vector< int > atom_groups_ids
Array of 0-based integers used to uniquely associate atom groups within the host program.
Definition: colvarproxy.h:414
colvarmodule * colvars
Pointer to the main object.
Definition: colvarproxy.h:578
void compute_max_atoms_applied_force()
Compute the maximum norm among all applied forces.
Definition: colvarproxy.cpp:131
virtual int replica_index()
Index of this replica.
Definition: colvarproxy_replicas.cpp:26
Container of atomic data for processing by Colvars.
Definition: colvarproxy.h:40
cvm::real rms_atoms_applied_force() const
Get the root-mean-square of the applied forces.
Definition: colvarproxy.h:208
void * config_queue_
Queue of config strings or files to be fed to the module.
Definition: colvarproxy.h:729
cvm::real atoms_max_applied_force_
Maximum norm among all applied forces.
Definition: colvarproxy.h:271
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_colvars_loop()
Distribute calculation of colvars (and their components) across threads.
Definition: colvarproxy.cpp:282
bool updated_charges() const
Record whether masses have been updated.
Definition: colvarproxy.h:244
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
cvm::real rms_atom_groups_applied_force() const
Get the root-mean-square of the applied forces.
Definition: colvarproxy.h:399
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 num_replicas()
Total number of replicas.
Definition: colvarproxy_replicas.cpp:32
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
void print_output_atomic_data()
Print a full list of all applied forces for debug purposes.
Definition: colvarproxy.cpp:687
Methods for SMP parallelization.
Definition: colvarproxy.h:446
cvm::rvector get_atom_group_total_force(int index) const
Read the current total force of the given atom group.
Definition: colvarproxy.h:338
omp_lock_t * omp_lock_state
Lock state for OpenMP.
Definition: colvarproxy.h:490
bool b_simulation_continuing
Definition: colvarproxy.h:712
Container of atom group data (allow collection of aggregated atomic data)
Definition: colvarproxy.h:291
cvm::real atoms_rms_applied_force_
Root-mean-square of the applied forces.
Definition: colvarproxy.h:268
bool delete_requested() const
Whether deallocation was requested.
Definition: colvarproxy.h:597
std::vector< size_t > atom_groups_refcount
Keep track of how many times each group is used by a separate cvc.
Definition: colvarproxy.h:416
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:344
std::vector< cvm::rvector > atoms_new_colvar_forces
Forces applied from colvars, to be communicated to the MD integrator.
Definition: colvarproxy.h:265
Group of atom objects, mostly used by a colvar::cvc object to gather all atomic data.
Definition: colvaratoms.h:157
virtual int update_output()
Update data based on the results of a Colvars call (e.g. send forces)
Definition: colvarproxy.cpp:566