Collective Variables Module - Developer Documentation
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
colvarproxy_namd Class Reference

Communication between colvars and NAMD (implementation of colvarproxy) More...

#include <colvarproxy_namd.h>

Inheritance diagram for colvarproxy_namd:
Inheritance graph
[legend]
Collaboration diagram for colvarproxy_namd:
Collaboration graph
[legend]

Public Member Functions

void init_tcl_pointers () override
 Set Tcl pointers. More...
 
int setup () override
 (Re)initialize required member data (called after the module) More...
 
int reset () override
 Reset proxy state, e.g. requested atoms. More...
 
int update_target_temperature ()
 Get the target temperature from the NAMD thermostats supported so far.
 
void init_atoms_map ()
 Allocate an atoms map with the same size as the NAMD topology.
 
int update_atoms_map (AtomIDList::const_iterator begin, AtomIDList::const_iterator end)
 
void calculate ()
 
void log (std::string const &message) override
 Print a message to the main log. More...
 
void error (std::string const &message) override
 Print a message to the main log and/or let the host code know about it. More...
 
int set_unit_system (std::string const &units_in, bool check_only) override
 Request to set the units used internally by Colvars. More...
 
void add_energy (cvm::real energy) override
 Pass restraint energy value for current timestep to MD engine. More...
 
void request_total_force (bool yesno) override
 Tell the proxy whether total forces are needed (they may not always be available) More...
 
bool total_forces_enabled () const override
 Are total forces being used? More...
 
int run_force_callback () override
 Run a user-defined colvar forces script. More...
 
int run_colvar_callback (std::string const &name, std::vector< const colvarvalue * > const &cvcs, colvarvalue &value) override
 
int run_colvar_gradient_callback (std::string const &name, std::vector< const colvarvalue * > const &cvcs, std::vector< cvm::matrix2d< cvm::real > > &gradient) override
 
cvm::real rand_gaussian () override
 Pseudo-random number with Gaussian distribution. More...
 
cvm::real get_accelMD_factor () const override
 Get weight factor from accelMD. More...
 
bool accelMD_enabled () const override
 
int replica_enabled () override
 Indicate if multi-replica support is available and active. More...
 
int replica_index () override
 Index of this replica. More...
 
int num_replicas () override
 Total number of replicas. More...
 
void replica_comm_barrier () override
 Synchronize replica with others. More...
 
int replica_comm_recv (char *msg_data, int buf_len, int src_rep) override
 Receive data from other replica. More...
 
int replica_comm_send (char *msg_data, int msg_len, int dest_rep) override
 Send data to other replica. More...
 
int check_atom_name_selections_available () override
 Check whether it is possible to select atoms by residue number name. More...
 
int init_atom (int atom_number) override
 
int check_atom_id (int atom_number) override
 
int init_atom (cvm::residue_id const &residue, std::string const &atom_name, std::string const &segment_id) override
 
int check_atom_id (cvm::residue_id const &residue, std::string const &atom_name, std::string const &segment_id) override
 Check that this atom is valid, but do not initialize it yet. More...
 
void clear_atom (int index) override
 Used by the atom class destructor: rather than deleting the array slot (costly) set the corresponding atoms_refcount to zero. More...
 
void update_atom_properties (int index)
 
cvm::rvector position_distance (cvm::atom_pos const &pos1, cvm::atom_pos const &pos2) const
 Get the PBC-aware distance vector between two positions. More...
 
int load_atoms_pdb (char const *filename, cvm::atom_group &atoms, std::string const &pdb_field, double const pdb_field_value) override
 Read a selection of atom IDs from a PDB coordinate file. More...
 
int load_coords_pdb (char const *filename, std::vector< cvm::atom_pos > &pos, const std::vector< int > &indices, std::string const &pdb_field, double const pdb_field_value) override
 Load a set of coordinates from a PDB file. More...
 
int scalable_group_coms () override
 Whether this proxy implementation has capability for scalable groups. More...
 
int init_atom_group (std::vector< int > const &atoms_ids) override
 Prepare this group for collective variables calculation, selecting atoms by internal ids (0-based) More...
 
void clear_atom_group (int index) override
 Used by the atom_group class destructor. More...
 
int update_group_properties (int index)
 
int check_volmaps_available () override
 Test whether this implementation can use volumetric maps as CVs. More...
 
int init_volmap_by_id (int volmap_id) override
 
int init_volmap_by_name (const char *volmap_name) override
 
int check_volmap_by_id (int volmap_id) override
 
int check_volmap_by_name (char const *volmap_name) override
 
int get_volmap_id_from_name (char const *volmap_name) override
 Get the numeric ID of the given volumetric map (for the MD program) More...
 
void clear_volmap (int index) override
 Used by the CVC destructors. More...
 
int compute_volmap (int flags, int volmap_id, cvm::atom_iter atom_begin, cvm::atom_iter atom_end, cvm::real *value, cvm::real *atom_field) override
 
template<class T >
void getGridForceGridValue (int flags, T const *grid, cvm::atom_iter atom_begin, cvm::atom_iter atom_end, cvm::real *value, cvm::real *atom_field)
 Abstraction of the two types of NAMD volumetric maps.
 
template<class T , int flags>
void GridForceGridLoop (T const *g, cvm::atom_iter atom_begin, cvm::atom_iter atom_end, cvm::real *value, cvm::real *atom_field)
 Implementation of inner loop; allows for atom list computation and use.
 
std::ostream & output_stream (std::string const &output_name, std::string const description) override
 
int flush_output_stream (std::string const &output_name) override
 Flushes the given output file/channel. More...
 
int flush_output_streams () override
 Flushes all output files/channels. More...
 
int close_output_stream (std::string const &output_name) override
 Closes the given output file/channel. More...
 
int close_output_streams () override
 Close all open files/channels to prevent data loss. More...
 
int backup_file (char const *filename) override
 Rename the given file, before overwriting it. More...
 
- Public Member Functions inherited from colvarproxy
 colvarproxy ()
 Constructor.
 
 ~colvarproxy () override
 Destructor.
 
std::string const & engine_name () const
 
bool io_available () override
 Ensure that we're on the main thread (derived class will do actual check) More...
 
virtual int request_deletion ()
 Request deallocation of the module (currently only implemented by VMD) More...
 
bool delete_requested () const
 Whether deallocation was requested.
 
virtual int reset ()
 Reset proxy state, e.g. requested atoms. More...
 
virtual int parse_module_config ()
 (Re)initialize the module
 
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. More...
 
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. More...
 
virtual int setup ()
 (Re)initialize required member data (called after the module) More...
 
bool engine_ready () const
 Whether the engine allows to fully initialize Colvars immediately.
 
void add_config (std::string const &cmd, std::string const &conf)
 Enqueue new configuration text, to be parsed as soon as possible.
 
virtual int update_input ()
 
virtual int update_output ()
 Update data based on the results of a Colvars call (e.g. send forces)
 
int end_of_step ()
 Carry out operations needed before next simulation step is run.
 
virtual void log (std::string const &message)
 Print a message to the main log. More...
 
virtual void error (std::string const &message)
 Print a message to the main log and/or let the host code know about it. More...
 
void add_error_msg (std::string const &message)
 Record error message (used by VMD to collect them after a script call)
 
std::string const & get_error_msgs ()
 Retrieve accumulated error messages.
 
void clear_error_msgs ()
 As the name says.
 
bool simulation_running () const
 Whether a simulation is running (warn against irrecovarable errors)
 
bool simulation_continuing () const
 
int post_run ()
 Called at the end of a simulation segment (i.e. "run" command)
 
void print_input_atomic_data ()
 Print a full list of all input atomic arrays for debug purposes.
 
void print_output_atomic_data ()
 Print a full list of all applied forces for debug purposes.
 
int get_version_from_string (char const *version_string)
 Convert a version string "YYYY-MM-DD" into an integer.
 
int version_number () const
 Get the version number (higher = more recent)
 
- Public Member Functions inherited from colvarproxy_system
 colvarproxy_system ()
 Constructor.
 
virtual ~colvarproxy_system ()
 Destructor.
 
virtual int set_unit_system (std::string const &units, bool check_only)
 Request to set the units used internally by Colvars. More...
 
cvm::real angstrom_to_internal (cvm::real l) const
 Convert a length from Angstrom to internal.
 
cvm::real internal_to_angstrom (cvm::real l) const
 Convert a length from internal to Angstrom.
 
cvm::real boltzmann () const
 Boltzmann constant, with unit the same as energy / K.
 
cvm::real target_temperature () const
 Current target temperature of the simulation (K units)
 
virtual int set_target_temperature (cvm::real T)
 Set the current target temperature of the simulation (K units)
 
double dt () const
 Time step of the simulation (fs units)
 
virtual int set_integration_timestep (cvm::real dt)
 Set the current integration timestep of the simulation (fs units)
 
virtual cvm::real rand_gaussian (void)
 Pseudo-random number with Gaussian distribution. More...
 
virtual void add_energy (cvm::real energy)
 Pass restraint energy value for current timestep to MD engine. More...
 
virtual cvm::rvector position_distance (cvm::atom_pos const &pos1, cvm::atom_pos const &pos2) const
 Get the PBC-aware distance vector between two positions. More...
 
void update_pbc_lattice ()
 Recompute PBC reciprocal lattice (assumes XYZ periodicity)
 
void reset_pbc_lattice ()
 Set the lattice vectors to zero.
 
virtual void request_total_force (bool yesno)
 Tell the proxy whether total forces are needed (they may not always be available) More...
 
virtual bool total_forces_enabled () const
 Are total forces being used? More...
 
virtual bool total_forces_same_step () const
 Are total forces from the current step available? More...
 
virtual int get_molid (int &molid)
 
virtual int get_alch_lambda (cvm::real *lambda)
 Get value of alchemical lambda parameter from back-end (if available) More...
 
void set_alch_lambda (cvm::real lambda)
 Set value of alchemical lambda parameter to be sent to back-end at end of timestep.
 
virtual int send_alch_lambda ()
 Send cached value of alchemical lambda parameter to back-end (if available) More...
 
virtual int get_dE_dlambda (cvm::real *dE_dlambda)
 Get energy derivative with respect to lambda (if available) More...
 
virtual int apply_force_dE_dlambda (cvm::real *force)
 Apply a scalar force on dE_dlambda (back-end distributes it onto atoms)
 
virtual int get_d2E_dlambda2 (cvm::real *d2E_dlambda2)
 Get energy second derivative with respect to lambda (if available)
 
virtual cvm::real get_accelMD_factor () const
 Get weight factor from accelMD. More...
 
virtual bool accelMD_enabled () const
 
- Public Member Functions inherited from colvarproxy_atoms
 colvarproxy_atoms ()
 Constructor.
 
virtual ~colvarproxy_atoms ()
 Destructor.
 
virtual int init_atom (int atom_number)
 
virtual int check_atom_id (int atom_number)
 
virtual int check_atom_name_selections_available ()
 Check whether it is possible to select atoms by residue number name. More...
 
virtual int init_atom (cvm::residue_id const &residue, std::string const &atom_name, std::string const &segment_id)
 
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. More...
 
virtual void clear_atom (int index)
 Used by the atom class destructor: rather than deleting the array slot (costly) set the corresponding atoms_refcount to zero. More...
 
int reset ()
 Clear atomic data.
 
int get_atom_id (int index) const
 
cvm::real get_atom_mass (int index) const
 
void increase_refcount (int index)
 
cvm::real get_atom_charge (int index) const
 
cvm::rvector get_atom_position (int index) const
 
cvm::rvector get_atom_total_force (int index) const
 
void apply_atom_force (int index, cvm::rvector const &new_force)
 
cvm::rvector get_atom_velocity (int)
 Read the current velocity of the given atom.
 
std::vector< int > const * get_atom_ids () const
 
size_t get_num_active_atoms () const
 Return number of atoms with positive reference count.
 
std::vector< cvm::real > const * get_atom_masses () const
 
std::vector< cvm::real > * modify_atom_masses ()
 
std::vector< cvm::real > const * get_atom_charges ()
 
std::vector< cvm::real > * modify_atom_charges ()
 
std::vector< cvm::rvector > const * get_atom_positions () const
 
std::vector< cvm::rvector > * modify_atom_positions ()
 
std::vector< cvm::rvector > const * get_atom_total_forces () const
 
std::vector< cvm::rvector > * modify_atom_total_forces ()
 
std::vector< cvm::rvector > const * get_atom_applied_forces () const
 
std::vector< cvm::rvector > * modify_atom_applied_forces ()
 
void compute_rms_atoms_applied_force ()
 Compute the root-mean-square of the applied forces.
 
void compute_max_atoms_applied_force ()
 Compute the maximum norm among all applied forces.
 
cvm::real rms_atoms_applied_force () const
 Get the root-mean-square of the applied forces.
 
cvm::real max_atoms_applied_force () const
 Get the maximum norm among all applied forces.
 
int max_atoms_applied_force_id () const
 Get the atom ID with the largest applied force.
 
bool modified_atom_list () const
 Whether the atom list has been modified internally.
 
void reset_modified_atom_list ()
 Reset the modified atom list flag.
 
bool updated_masses () const
 Record whether masses have been updated.
 
bool updated_charges () const
 Record whether masses have been updated.
 
- Public Member Functions inherited from colvarproxy_atom_groups
 colvarproxy_atom_groups ()
 Constructor.
 
virtual ~colvarproxy_atom_groups ()
 Destructor.
 
int reset ()
 Clear atom group data.
 
virtual int scalable_group_coms ()
 Whether this proxy implementation has capability for scalable groups. More...
 
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) More...
 
virtual void clear_atom_group (int index)
 Used by the atom_group class destructor. More...
 
int get_atom_group_id (int index) const
 Get the numeric ID of the given atom group (for the MD program)
 
cvm::real get_atom_group_mass (int index) const
 Get the mass of the given atom group.
 
cvm::real get_atom_group_charge (int index) const
 Get the charge of the given atom group.
 
cvm::rvector get_atom_group_com (int index) const
 Read the current position of the center of mass given atom group.
 
cvm::rvector get_atom_group_total_force (int index) const
 Read the current total force of the given atom group.
 
void apply_atom_group_force (int index, cvm::rvector const &new_force)
 Request that this force is applied to the given atom group.
 
cvm::rvector get_atom_group_velocity (int)
 Read the current velocity of the given atom group.
 
std::vector< int > const * get_atom_group_ids () const
 
size_t get_num_active_atom_groups () const
 Return number of atom groups with positive reference count.
 
std::vector< cvm::real > * modify_atom_group_masses ()
 
std::vector< cvm::real > * modify_atom_group_charges ()
 
std::vector< cvm::rvector > * modify_atom_group_positions ()
 
std::vector< cvm::rvector > * modify_atom_group_total_forces ()
 
std::vector< cvm::rvector > * modify_atom_group_applied_forces ()
 
void compute_rms_atom_groups_applied_force ()
 Compute the root-mean-square of the applied forces.
 
void compute_max_atom_groups_applied_force ()
 Compute the maximum norm among all applied forces.
 
cvm::real rms_atom_groups_applied_force () const
 Get the root-mean-square of the applied forces.
 
cvm::real max_atom_groups_applied_force () const
 Get the maximum norm among all applied forces.
 
- Public Member Functions inherited from colvarproxy_volmaps
 colvarproxy_volmaps ()
 Contructor.
 
virtual ~colvarproxy_volmaps ()
 Destructor.
 
int reset ()
 Clear volumetric map data.
 
virtual int check_volmaps_available ()
 Test whether this implementation can use volumetric maps as CVs. More...
 
int add_volmap_slot (int volmap_id)
 Create a slot for a volumetric map not requested yet.
 
virtual int init_volmap_by_id (int volmap_id)
 
virtual int init_volmap_by_name (char const *volmap_name)
 
virtual int check_volmap_by_id (int volmap_id)
 
virtual int check_volmap_by_name (char const *volmap_name)
 
int init_volmap_by_name (std::string const &volmap_name)
 Request and prepare this volumetric map for use by Colvars.
 
int check_volmap_by_name (std::string const &volmap_name)
 Check that the given volmap name is valid (return COLVARS_OK if it is)
 
virtual void clear_volmap (int index)
 Used by the CVC destructors. More...
 
virtual int get_volmap_id_from_name (char const *volmap_name)
 Get the numeric ID of the given volumetric map (for the MD program) More...
 
int get_volmap_id (int index) const
 Get the numeric ID of the given volumetric map (for the MD program)
 
cvm::real get_volmap_value (int index) const
 Read the current value of the volumetric map.
 
void apply_volmap_force (int index, cvm::real const &new_force)
 Request that this force is applied to the given volumetric map.
 
virtual int compute_volmap (int flags, int volmap_id, cvm::atom_iter atom_begin, cvm::atom_iter atom_end, cvm::real *value, cvm::real *atom_field)
 
void compute_rms_volmaps_applied_force ()
 Compute the root-mean-square of the applied forces.
 
void compute_max_volmaps_applied_force ()
 Compute the maximum norm among all applied forces.
 
- Public Member Functions inherited from colvarproxy_smp
 colvarproxy_smp ()
 Constructor.
 
virtual ~colvarproxy_smp ()
 Destructor.
 
virtual int check_smp_enabled ()
 Whether threaded parallelization is available (TODO: make this a cvm::deps feature)
 
virtual int smp_colvars_loop ()
 Distribute calculation of colvars (and their components) across threads.
 
virtual int smp_biases_loop ()
 Distribute calculation of biases across threads.
 
virtual int smp_biases_script_loop ()
 Distribute calculation of biases across threads 2nd through last, with all scripted biased on 1st thread.
 
virtual int smp_thread_id ()
 Index of this thread.
 
virtual int smp_num_threads ()
 Number of threads sharing this address space.
 
virtual int smp_lock ()
 Lock the proxy's shared data for access by a thread, if threads are implemented; if not implemented, does nothing.
 
virtual int smp_trylock ()
 Attempt to lock the proxy's shared data.
 
virtual int smp_unlock ()
 Release the lock.
 
- Public Member Functions inherited from colvarproxy_replicas
 colvarproxy_replicas ()
 Constructor.
 
virtual ~colvarproxy_replicas ()
 Destructor.
 
virtual int replica_enabled ()
 Indicate if multi-replica support is available and active. More...
 
virtual int replica_index ()
 Index of this replica. More...
 
virtual int num_replicas ()
 Total number of replicas. More...
 
virtual void replica_comm_barrier ()
 Synchronize replica with others. More...
 
virtual int replica_comm_recv (char *msg_data, int buf_len, int src_rep)
 Receive data from other replica. More...
 
virtual int replica_comm_send (char *msg_data, int msg_len, int dest_rep)
 Send data to other replica. More...
 
- Public Member Functions inherited from colvarproxy_script
 colvarproxy_script ()
 Constructor.
 
virtual ~colvarproxy_script ()
 Destructor.
 
virtual int run_force_callback ()
 Run a user-defined colvar forces script. More...
 
virtual int run_colvar_callback (std::string const &name, std::vector< const colvarvalue * > const &cvcs, colvarvalue &value)
 
virtual int run_colvar_gradient_callback (std::string const &name, std::vector< const colvarvalue * > const &cvcs, std::vector< cvm::matrix2d< cvm::real > > &gradient)
 
- Public Member Functions inherited from colvarproxy_tcl
 colvarproxy_tcl ()
 Constructor.
 
virtual ~colvarproxy_tcl ()
 Destructor.
 
bool tcl_available ()
 Is Tcl available? (trigger initialization if needed)
 
char const * tcl_get_str (void *obj)
 Get a string representation of the Tcl object pointed to by obj.
 
int tcl_run_script (std::string const &script)
 
int tcl_run_file (std::string const &fileName)
 
int tcl_run_force_callback ()
 Tcl implementation of run_force_callback()
 
int tcl_run_colvar_callback (std::string const &name, std::vector< const colvarvalue * > const &cvcs, colvarvalue &value)
 Tcl implementation of run_colvar_callback()
 
int tcl_run_colvar_gradient_callback (std::string const &name, std::vector< const colvarvalue * > const &cvcs, std::vector< cvm::matrix2d< cvm::real > > &gradient)
 Tcl implementation of run_colvar_gradient_callback()
 
Tcl_Interp * get_tcl_interp ()
 Get a pointer to the Tcl interpreter.
 
void set_tcl_interp (Tcl_Interp *interp)
 Set the pointer to the Tcl interpreter.
 
virtual void init_tcl_pointers ()
 Set Tcl pointers. More...
 
- Public Member Functions inherited from colvarproxy_io
 colvarproxy_io ()
 Constructor.
 
virtual ~colvarproxy_io ()
 Destructor.
 
virtual bool io_available ()
 Ensure that we're on the main thread (derived class will do actual check) More...
 
virtual int get_frame (long int &)
 Save the current frame number in the argument given. More...
 
virtual int set_frame (long int)
 Set the current frame number (as well as colvarmodule::it) More...
 
virtual int backup_file (char const *filename)
 Rename the given file, before overwriting it. More...
 
int backup_file (std::string const &filename)
 Rename the given file, before overwriting it.
 
virtual int remove_file (char const *filename)
 Remove the given file (on Windows only, rename to filename.old)
 
int remove_file (std::string const &filename)
 Remove the given file (on Windows only, rename to filename.old)
 
virtual int rename_file (char const *filename, char const *newfilename)
 Rename the given file.
 
int rename_file (std::string const &filename, std::string const &newfilename)
 Rename the given file.
 
std::string const & input_prefix () const
 Prefix of the input state file to be read next.
 
virtual int set_input_prefix (std::string const &prefix)
 Initialize input_prefix (NOTE: it will be erased after state file is read)
 
std::string const & output_prefix () const
 Default prefix to be used for all output files (final configuration)
 
virtual int set_output_prefix (std::string const &prefix)
 Set default output prefix.
 
std::string const & restart_output_prefix () const
 Prefix of the restart (checkpoint) file to be written next.
 
virtual int set_restart_output_prefix (std::string const &prefix)
 Set default restart state file prefix.
 
int default_restart_frequency () const
 Default restart frequency (as set by the simulation engine)
 
virtual int set_default_restart_frequency (int freq)
 Communicate/set the restart frequency of the simulation engine.
 
std::istream & input_stream (std::string const &input_name, std::string const description="file/channel", bool error_on_fail=true)
 
std::istream & input_stream_from_string (std::string const &input_name, std::string const &content, std::string const description="string")
 
bool input_stream_exists (std::string const &input_name)
 Check if the file/channel is open (without opening it if not)
 
int close_input_stream (std::string const &input_name)
 Closes the given input stream.
 
int close_input_streams ()
 Closes all input streams.
 
int delete_input_stream (std::string const &input_name)
 Same as close_input_stream(), but also removes the corresponding entry from memory.
 
std::list< std::string > list_input_stream_names () const
 List all input streams that were opened at some point.
 
virtual std::ostream & output_stream (std::string const &output_name, std::string const description)
 
virtual bool output_stream_exists (std::string const &output_name)
 Check if the file/channel is open (without opening it if not)
 
virtual int flush_output_stream (std::string const &output_name)
 Flushes the given output file/channel. More...
 
virtual int flush_output_streams ()
 Flushes all output files/channels. More...
 
virtual int close_output_stream (std::string const &output_name)
 Closes the given output file/channel. More...
 
virtual int close_output_streams ()
 Close all open files/channels to prevent data loss. More...
 

Protected Member Functions

void update_accelMD_info ()
 
- Protected Member Functions inherited from colvarproxy_atoms
int add_atom_slot (int atom_id)
 
- Protected Member Functions inherited from colvarproxy_atom_groups
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.
 

Protected Attributes

std::vector< int > atoms_map
 Array of atom indices (relative to the colvarproxy arrays), usedfor faster copy of atomic data.
 
SimParameters * simparams
 Pointer to the NAMD simulation input object.
 
Random random
 NAMD-style PRNG object.
 
bool first_timestep
 
cvm::step_number previous_NAMD_step
 
SubmitReduction * reduction
 Used to submit restraint energy as MISC.
 
bool accelMDOn
 Accelerated MD reweighting factor.
 
cvm::real amd_weight_factor
 
- Protected Attributes inherited from colvarproxy
bool engine_ready_
 Whether the engine allows to fully initialize Colvars immediately.
 
std::string error_output
 Collected error messages.
 
bool b_simulation_running
 Whether a simulation is running (warn against irrecovarable errors)
 
bool b_simulation_continuing
 
bool b_delete_requested
 Whether the entire module should be deallocated by the host engine.
 
int version_int
 Integer representing the version string (allows comparisons)
 
size_t features_hash
 Track which features have been acknowledged during the last run.
 
std::string engine_name_ = "standalone"
 Name of the simulation engine that the derived proxy object supports.
 
void * config_queue_
 Queue of config strings or files to be fed to the module.
 
- Protected Attributes inherited from colvarproxy_system
cvm::real cached_alch_lambda
 Next value of lambda to be sent to back-end.
 
bool cached_alch_lambda_changed
 Whether lambda has been set and needs to be updated in backend.
 
cvm::real boltzmann_
 Boltzmann constant in internal Colvars units.
 
cvm::real target_temperature_
 Most up to date target temperature (K units); default to 0.0 if undefined.
 
double timestep_
 Current integration timestep (engine units); default to 1.0 if undefined.
 
cvm::real angstrom_value_
 Value of 1 Angstrom in the internal (front-end) Colvars unit for atomic coordinates. More...
 
cvm::real kcal_mol_value_
 Value of 1 kcal/mol in the internal Colvars unit for energy.
 
bool total_force_requested
 Whether the total forces have been requested.
 
Boundaries_type boundaries_type
 Type of boundary conditions.
 
cvm::rvector unit_cell_x
 Bravais lattice vectors.
 
cvm::rvector unit_cell_y
 
cvm::rvector unit_cell_z
 
cvm::rvector reciprocal_cell_x
 Reciprocal lattice vectors.
 
cvm::rvector reciprocal_cell_y
 
cvm::rvector reciprocal_cell_z
 
- Protected Attributes inherited from colvarproxy_atoms
std::vector< int > atoms_ids
 Array of 0-based integers used to uniquely associate atoms within the host program.
 
std::vector< size_t > atoms_refcount
 Keep track of how many times each atom is used by a separate colvar object.
 
std::vector< cvm::realatoms_masses
 Masses of the atoms (allow redefinition during a run, as done e.g. in LAMMPS)
 
std::vector< cvm::realatoms_charges
 Charges of the atoms (allow redefinition during a run, as done e.g. in LAMMPS)
 
std::vector< cvm::rvectoratoms_positions
 Current three-dimensional positions of the atoms.
 
std::vector< cvm::rvectoratoms_total_forces
 Most recent total forces on each atom.
 
std::vector< cvm::rvectoratoms_new_colvar_forces
 Forces applied from colvars, to be communicated to the MD integrator.
 
cvm::real atoms_rms_applied_force_
 Root-mean-square of the applied forces.
 
cvm::real atoms_max_applied_force_
 Maximum norm among all applied forces.
 
int atoms_max_applied_force_id_
 ID of the atom with the maximum norm among all applied forces.
 
bool modified_atom_list_
 Whether the atom list has been modified internally.
 
bool updated_masses_
 Whether the masses and charges have been updated from the host code.
 
bool updated_charges_
 
- Protected Attributes inherited from colvarproxy_atom_groups
std::vector< int > atom_groups_ids
 Array of 0-based integers used to uniquely associate atom groups within the host program.
 
std::vector< size_t > atom_groups_refcount
 Keep track of how many times each group is used by a separate cvc.
 
std::vector< cvm::realatom_groups_masses
 Total masses of the atom groups.
 
std::vector< cvm::realatom_groups_charges
 Total charges of the atom groups (allow redefinition during a run, as done e.g. in LAMMPS)
 
std::vector< cvm::rvectoratom_groups_coms
 Current centers of mass of the atom groups.
 
std::vector< cvm::rvectoratom_groups_total_forces
 Most recently updated total forces on the com of each group.
 
std::vector< cvm::rvectoratom_groups_new_colvar_forces
 Forces applied from colvars, to be communicated to the MD integrator.
 
cvm::real atom_groups_rms_applied_force_
 Root-mean-square of the applied group forces.
 
cvm::real atom_groups_max_applied_force_
 Maximum norm among all applied group forces.
 
- Protected Attributes inherited from colvarproxy_volmaps
std::vector< int > volmaps_ids
 Array of numeric IDs of volumetric maps.
 
std::vector< size_t > volmaps_refcount
 Keep track of how many times each vol map is used by a separate colvar object.
 
std::vector< cvm::realvolmaps_values
 Current values of the vol maps.
 
std::vector< cvm::realvolmaps_new_colvar_forces
 Forces applied from colvars, to be communicated to the MD integrator.
 
cvm::real volmaps_rms_applied_force_
 Root-mean-square of the the applied forces.
 
cvm::real volmaps_max_applied_force_
 Maximum norm among all applied forces.
 
- Protected Attributes inherited from colvarproxy_smp
omp_lock_t * omp_lock_state
 Lock state for OpenMP.
 
- Protected Attributes inherited from colvarproxy_tcl
Tcl_Interp * tcl_interp_
 Pointer to Tcl interpreter object.
 
- Protected Attributes inherited from colvarproxy_io
std::string input_prefix_str
 Prefix of the input state file to be read next.
 
std::string output_prefix_str
 Default prefix to be used for all output files (final configuration)
 
std::string restart_output_prefix_str
 Prefix of the restart (checkpoint) file to be written next.
 
int restart_frequency_engine
 How often the simulation engine will write its own restart.
 
std::map< std::string, std::istream * > input_streams_
 Container of input files/channels indexed by path name.
 
std::istream * input_stream_error_
 Object whose reference is returned when read errors occur.
 
std::map< std::string, std::ostream * > output_streams_
 Currently open output files/channels.
 
std::ostream * output_stream_error_
 Object whose reference is returned when write errors occur.
 

Friends

class cvm::atom
 

Additional Inherited Members

- Public Types inherited from colvarproxy_volmaps
enum  { volmap_flag_null = 0 , volmap_flag_gradients = 1 , volmap_flag_use_atom_field = (1<<8) }
 Flags controlling what computation is done on the map.
 
- Public Attributes inherited from colvarproxy
colvarmodulecolvars
 Pointer to the main object.
 
- Public Attributes inherited from colvarproxy_system
std::string units
 Name of the unit system used internally by Colvars (by default, that of the back-end). Supported depending on the back-end: real (A, kcal/mol), metal (A, eV), electron (Bohr, Hartree), gromacs (nm, kJ/mol) Note: calls to back-end PBC functions assume back-end length unit We use different unit from back-end in VMD bc using PBC functions from colvarproxy base class Colvars internal units are user specified, because the module exchanges info in unknown composite dimensions with user input, while it only exchanges quantities of known dimension with the back-end (length and forces)
 
cvm::real indirect_lambda_biasing_force
 Force to be applied onto alch. lambda, propagated from biasing forces on dE_dlambda.
 
- Public Attributes inherited from colvarproxy_smp
bool b_smp_active
 
- Public Attributes inherited from colvarproxy_script
colvarscriptscript
 
bool have_scripts
 Do we have a scripting interface?
 
- Protected Types inherited from colvarproxy_system
enum  Boundaries_type { boundaries_non_periodic , boundaries_pbc_ortho , boundaries_pbc_triclinic , boundaries_unsupported }
 Type of boundary conditions. More...
 

Detailed Description

Communication between colvars and NAMD (implementation of colvarproxy)

Member Function Documentation

◆ accelMD_enabled()

bool colvarproxy_namd::accelMD_enabled ( ) const
inlineoverridevirtual

Reimplemented from colvarproxy_system.

◆ add_energy()

void colvarproxy_namd::add_energy ( cvm::real  energy)
overridevirtual

Pass restraint energy value for current timestep to MD engine.

Reimplemented from colvarproxy_system.

◆ backup_file()

int colvarproxy_namd::backup_file ( char const *  filename)
overridevirtual

Rename the given file, before overwriting it.

Reimplemented from colvarproxy_io.

◆ check_atom_id() [1/2]

int colvarproxy_namd::check_atom_id ( cvm::residue_id const &  residue,
std::string const &  atom_name,
std::string const &  segment_id 
)
overridevirtual

Check that this atom is valid, but do not initialize it yet.

Reimplemented from colvarproxy_atoms.

◆ check_atom_id() [2/2]

int colvarproxy_namd::check_atom_id ( int  atom_number)
overridevirtual

Check that this atom number is valid, but do not initialize the corresponding atom yet

Reimplemented from colvarproxy_atoms.

◆ check_atom_name_selections_available()

int colvarproxy_namd::check_atom_name_selections_available ( )
overridevirtual

Check whether it is possible to select atoms by residue number name.

Reimplemented from colvarproxy_atoms.

◆ check_volmap_by_id()

int colvarproxy_namd::check_volmap_by_id ( int  volmap_id)
overridevirtual

Check that the given volmap ID is valid (return COLVARS_OK if it is)

Parameters
volmap_idNumeric ID used by the MD engine
Returns
Error code

Reimplemented from colvarproxy_volmaps.

◆ check_volmap_by_name()

int colvarproxy_namd::check_volmap_by_name ( char const *  volmap_name)
overridevirtual

Check that the given volmap name is valid (return COLVARS_OK if it is)

Parameters
volmap_nameName used by the MD engine
Returns
Error code

Reimplemented from colvarproxy_volmaps.

◆ check_volmaps_available()

int colvarproxy_namd::check_volmaps_available ( )
overridevirtual

Test whether this implementation can use volumetric maps as CVs.

Reimplemented from colvarproxy_volmaps.

◆ clear_atom()

void colvarproxy_namd::clear_atom ( int  index)
overridevirtual

Used by the atom class destructor: rather than deleting the array slot (costly) set the corresponding atoms_refcount to zero.

Reimplemented from colvarproxy_atoms.

◆ clear_atom_group()

void colvarproxy_namd::clear_atom_group ( int  index)
overridevirtual

Used by the atom_group class destructor.

Reimplemented from colvarproxy_atom_groups.

◆ clear_volmap()

void colvarproxy_namd::clear_volmap ( int  index)
overridevirtual

Used by the CVC destructors.

Reimplemented from colvarproxy_volmaps.

◆ close_output_stream()

int colvarproxy_namd::close_output_stream ( std::string const &  output_name)
overridevirtual

Closes the given output file/channel.

Reimplemented from colvarproxy_io.

◆ close_output_streams()

int colvarproxy_namd::close_output_streams ( )
overridevirtual

Close all open files/channels to prevent data loss.

Reimplemented from colvarproxy_io.

◆ compute_volmap()

int colvarproxy_namd::compute_volmap ( int  flags,
int  volmap_id,
cvm::atom_iter  atom_begin,
cvm::atom_iter  atom_end,
cvm::real value,
cvm::real atom_field 
)
overridevirtual

Re-weigh an atomic field (e.g. a colvar) by the value of a volumetric map

Parameters
flagsCombination of flags
volmap_idNumeric index of the map (no need to request it)
atom_beginIterator pointing to first atom
atom_endIterator pointing past the last atom
valuePointer to location of total to increment
atom_fieldArray of atomic field values (if NULL, ones are used)

Reimplemented from colvarproxy_volmaps.

◆ error()

void colvarproxy_namd::error ( std::string const &  message)
overridevirtual

Print a message to the main log and/or let the host code know about it.

Reimplemented from colvarproxy.

◆ flush_output_stream()

int colvarproxy_namd::flush_output_stream ( std::string const &  output_name)
overridevirtual

Flushes the given output file/channel.

Reimplemented from colvarproxy_io.

◆ flush_output_streams()

int colvarproxy_namd::flush_output_streams ( )
overridevirtual

Flushes all output files/channels.

Reimplemented from colvarproxy_io.

◆ get_accelMD_factor()

cvm::real colvarproxy_namd::get_accelMD_factor ( ) const
inlineoverridevirtual

Get weight factor from accelMD.

Reimplemented from colvarproxy_system.

◆ get_volmap_id_from_name()

int colvarproxy_namd::get_volmap_id_from_name ( char const *  volmap_name)
overridevirtual

Get the numeric ID of the given volumetric map (for the MD program)

Reimplemented from colvarproxy_volmaps.

◆ init_atom() [1/2]

int colvarproxy_namd::init_atom ( cvm::residue_id const &  residue,
std::string const &  atom_name,
std::string const &  segment_id 
)
overridevirtual

Select this atom for collective variables calculation, using name and residue number. Not all programs support this: leave this function as is in those cases.

Reimplemented from colvarproxy_atoms.

◆ init_atom() [2/2]

int colvarproxy_namd::init_atom ( int  atom_number)
overridevirtual

Prepare this atom for collective variables calculation, selecting it by numeric index (1-based)

Reimplemented from colvarproxy_atoms.

◆ init_atom_group()

int colvarproxy_namd::init_atom_group ( std::vector< int > const &  atoms_ids)
overridevirtual

Prepare this group for collective variables calculation, selecting atoms by internal ids (0-based)

Reimplemented from colvarproxy_atom_groups.

◆ init_tcl_pointers()

void colvarproxy_namd::init_tcl_pointers ( )
overridevirtual

Set Tcl pointers.

Reimplemented from colvarproxy_tcl.

◆ init_volmap_by_id()

int colvarproxy_namd::init_volmap_by_id ( int  volmap_id)
overridevirtual

Request and prepare this volumetric map for use by Colvars

Parameters
volmap_idNumeric ID used by the MD engine
Returns
Index of the map in the colvarproxy arrays

Reimplemented from colvarproxy_volmaps.

◆ init_volmap_by_name()

int colvarproxy_namd::init_volmap_by_name ( const char *  volmap_name)
overridevirtual

Request and prepare this volumetric map for use by Colvars

Parameters
volmap_nameName used by the MD engine
Returns
Index of the map in the colvarproxy arrays

Reimplemented from colvarproxy_volmaps.

◆ load_atoms_pdb()

int colvarproxy_namd::load_atoms_pdb ( char const *  filename,
cvm::atom_group atoms,
std::string const &  pdb_field,
double const  pdb_field_value 
)
overridevirtual

Read a selection of atom IDs from a PDB coordinate file.

Parameters
[in]filenamename of the file
[in,out]atomsarray into which atoms will be read from "filename"
[in]pdb_fieldif the file is a PDB and this string is non-empty, select atoms for which this field is non-zero
[in]pdb_field_valueif non-zero, select only atoms whose pdb_field equals this

Reimplemented from colvarproxy.

◆ load_coords_pdb()

int colvarproxy_namd::load_coords_pdb ( char const *  filename,
std::vector< cvm::atom_pos > &  pos,
const std::vector< int > &  sorted_ids,
std::string const &  pdb_field,
double const  pdb_field_value 
)
overridevirtual

Load a set of coordinates from a PDB file.

Parameters
[in]filenamename of the file
[in,out]posarray of coordinates to fill; if not empty, the number of its elements must match the number of entries in "filename"
[in]sorted_idsarray of sorted internal IDs, used to loop through the file only once
[in]pdb_fieldif non-empty, only atoms for which this field is non-zero will be processed
[in]pdb_field_valueif non-zero, process only atoms whose pdb_field equals this

Reimplemented from colvarproxy.

◆ log()

void colvarproxy_namd::log ( std::string const &  message)
overridevirtual

Print a message to the main log.

Reimplemented from colvarproxy.

◆ num_replicas()

int colvarproxy_namd::num_replicas ( )
overridevirtual

Total number of replicas.

Reimplemented from colvarproxy_replicas.

◆ output_stream()

std::ostream & colvarproxy_namd::output_stream ( std::string const &  output_name,
std::string const  description 
)
overridevirtual

Returns a reference to the named output file/channel (open it if needed)

Parameters
output_nameFile name or identifier
descriptionPurpose of the file

Reimplemented from colvarproxy_io.

◆ position_distance()

cvm::rvector colvarproxy_namd::position_distance ( cvm::atom_pos const &  pos1,
cvm::atom_pos const &  pos2 
) const
virtual

Get the PBC-aware distance vector between two positions.

Reimplemented from colvarproxy_system.

◆ rand_gaussian()

cvm::real colvarproxy_namd::rand_gaussian ( void  )
inlineoverridevirtual

Pseudo-random number with Gaussian distribution.

Reimplemented from colvarproxy_system.

◆ replica_comm_barrier()

void colvarproxy_namd::replica_comm_barrier ( )
overridevirtual

Synchronize replica with others.

Reimplemented from colvarproxy_replicas.

◆ replica_comm_recv()

int colvarproxy_namd::replica_comm_recv ( char *  msg_data,
int  buf_len,
int  src_rep 
)
overridevirtual

Receive data from other replica.

Reimplemented from colvarproxy_replicas.

◆ replica_comm_send()

int colvarproxy_namd::replica_comm_send ( char *  msg_data,
int  msg_len,
int  dest_rep 
)
overridevirtual

Send data to other replica.

Reimplemented from colvarproxy_replicas.

◆ replica_enabled()

int colvarproxy_namd::replica_enabled ( )
overridevirtual

Indicate if multi-replica support is available and active.

Reimplemented from colvarproxy_replicas.

◆ replica_index()

int colvarproxy_namd::replica_index ( )
overridevirtual

Index of this replica.

Reimplemented from colvarproxy_replicas.

◆ request_total_force()

void colvarproxy_namd::request_total_force ( bool  yesno)
overridevirtual

Tell the proxy whether total forces are needed (they may not always be available)

Reimplemented from colvarproxy_system.

◆ reset()

int colvarproxy_namd::reset ( )
overridevirtual

Reset proxy state, e.g. requested atoms.

Reimplemented from colvarproxy.

◆ run_colvar_callback()

int colvarproxy_namd::run_colvar_callback ( std::string const &  name,
std::vector< const colvarvalue * > const &  cvcs,
colvarvalue value 
)
overridevirtual

Reimplemented from colvarproxy_script.

◆ run_colvar_gradient_callback()

int colvarproxy_namd::run_colvar_gradient_callback ( std::string const &  name,
std::vector< const colvarvalue * > const &  cvcs,
std::vector< cvm::matrix2d< cvm::real > > &  gradient 
)
overridevirtual

Reimplemented from colvarproxy_script.

◆ run_force_callback()

int colvarproxy_namd::run_force_callback ( )
overridevirtual

Run a user-defined colvar forces script.

Reimplemented from colvarproxy_script.

◆ scalable_group_coms()

int colvarproxy_namd::scalable_group_coms ( )
inlineoverridevirtual

Whether this proxy implementation has capability for scalable groups.

Reimplemented from colvarproxy_atom_groups.

◆ set_unit_system()

int colvarproxy_namd::set_unit_system ( std::string const &  units,
bool  check_only 
)
overridevirtual

Request to set the units used internally by Colvars.

Reimplemented from colvarproxy_system.

◆ setup()

int colvarproxy_namd::setup ( )
overridevirtual

(Re)initialize required member data (called after the module)

Reimplemented from colvarproxy.

◆ total_forces_enabled()

bool colvarproxy_namd::total_forces_enabled ( ) const
inlineoverridevirtual

Are total forces being used?

Reimplemented from colvarproxy_system.


The documentation for this class was generated from the following file: