Collective Variables Module - Developer Documentation
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public 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

int setup ()
 (Re)initialize required member data after construction
 
int update_atoms_map (AtomIDList::const_iterator begin, AtomIDList::const_iterator end)
 
void calculate ()
 
void log (std::string const &message)
 Print a message to the main log.
 
void error (std::string const &message)
 Print a message to the main log and let the rest of the program handle the error.
 
void fatal_error (std::string const &message)
 Print a message to the main log and exit with error code.
 
void exit (std::string const &message)
 Print a message to the main log and exit normally.
 
void add_energy (cvm::real energy)
 Pass restraint energy value for current timestep to MD engine.
 
void request_total_force (bool yesno)
 Tell the proxy whether total forces are needed (may not always be available)
 
bool total_forces_enabled () const
 Are total forces being used?
 
int run_force_callback ()
 Run a user-defined colvar forces script.
 
int run_colvar_callback (std::string const &name, std::vector< const colvarvalue * > const &cvcs, colvarvalue &value)
 
int run_colvar_gradient_callback (std::string const &name, std::vector< const colvarvalue * > const &cvcs, std::vector< cvm::matrix2d< cvm::real > > &gradient)
 
cvm::real unit_angstrom ()
 Value of the unit for atomic coordinates with respect to angstroms (used by some variables for hard-coded default values)
 
cvm::real boltzmann ()
 Boltzmann constant.
 
cvm::real temperature ()
 Temperature of the simulation (K)
 
cvm::real rand_gaussian ()
 Pseudo-random number with Gaussian distribution.
 
cvm::real dt ()
 Time step of the simulation (fs)
 
int smp_enabled ()
 Whether threaded parallelization is available (TODO: make this a cvm::deps feature)
 
int smp_thread_id ()
 Index of this thread.
 
int smp_num_threads ()
 Number of threads sharing this address space.
 
int smp_lock ()
 Lock the proxy's shared data for access by a thread, if threads are implemented; if not implemented, does nothing.
 
int smp_trylock ()
 Attempt to lock the proxy's shared data.
 
int smp_unlock ()
 Release the lock.
 
bool replica_enabled ()
 Indicate if multi-replica support is available and active.
 
int replica_index ()
 Index of this replica.
 
int replica_num ()
 Total number of replica.
 
void replica_comm_barrier ()
 Synchronize replica.
 
int replica_comm_recv (char *msg_data, int buf_len, int src_rep)
 Receive data from other replica.
 
int replica_comm_send (char *msg_data, int msg_len, int dest_rep)
 Send data to other replica.
 
size_t restart_frequency ()
 Restarts will be written each time this number of steps has passed.
 
int init_atom (int atom_number)
 Prepare this atom for collective variables calculation, selecting it by numeric index (1-based)
 
int check_atom_id (int atom_number)
 Check that this atom number is valid, but do not initialize the corresponding atom yet.
 
int init_atom (cvm::residue_id const &residue, std::string const &atom_name, std::string const &segment_id)
 
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.
 
void clear_atom (int index)
 Used by the atom class destructor: rather than deleting the array slot (costly) set the corresponding atoms_ncopies to zero.
 
void update_atom_properties (int index)
 
cvm::rvector position_distance (cvm::atom_pos const &pos1, cvm::atom_pos const &pos2)
 Get the PBC-aware distance vector between two positions.
 
cvm::real position_dist2 (cvm::atom_pos const &pos1, cvm::atom_pos const &pos2)
 Get the PBC-aware square distance between two positions; may need to be reimplemented independently from position_distance() for optimization purposes.
 
void select_closest_image (cvm::atom_pos &pos, cvm::atom_pos const &ref_pos)
 Get the closest periodic image to a reference position. More...
 
int load_atoms (char const *filename, cvm::atom_group &atoms, std::string const &pdb_field, double const pdb_field_value=0.0)
 Read atom identifiers from a file. More...
 
int load_coords (char const *filename, std::vector< cvm::atom_pos > &pos, const std::vector< int > &indices, std::string const &pdb_field, double const pdb_field_value=0.0)
 Load the coordinates for a group of atoms from a file (usually a PDB); if "pos" is already allocated, the number of its elements must match the number of atoms in "filename".
 
int scalable_group_coms ()
 TODO Add here containers of handles to cvc objects that are computed in parallel. More...
 
int init_atom_group (std::vector< int > const &atoms_ids)
 Prepare this group for collective variables calculation, selecting atoms by internal ids (0-based)
 
void clear_atom_group (int index)
 Used by the atom_group class destructor.
 
int update_group_properties (int index)
 
std::ostream * output_stream (std::string const &output_name)
 Returns a reference to the given output channel; if this is not open already, then open it.
 
int close_output_stream (std::string const &output_name)
 Closes the given output channel.
 
int backup_file (char const *filename)
 Rename the given file, before overwriting it.
 
- Public Member Functions inherited from colvarproxy
 colvarproxy ()
 Constructor.
 
virtual ~colvarproxy ()
 Destructor.
 
virtual int update_input ()
 Update data required by the colvars module (e.g. cache atom positions) More...
 
virtual int update_output ()
 Update data based from the results of a module update (e.g. send forces)
 
virtual int get_frame (long int &)
 Get the current frame number.
 
virtual int set_frame (long int)
 Set the current frame number (as well as colvarmodule::it)
 
std::string & input_prefix ()
 
std::string restart_output_prefix ()
 Prefix to be used for output restart files.
 
std::string output_prefix ()
 Prefix to be used for output files (final system configuration)
 
virtual bool simulation_running () const
 Whether a simulation is running (and try to prevent irrecovarable errors)
 
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.
 
void select_closest_images (std::vector< cvm::atom_pos > &pos, cvm::atom_pos const &ref_pos)
 Perform select_closest_image() on a set of atomic positions. More...
 
int get_atom_id (int index) const
 Get the numeric ID of the given atom (for the program)
 
cvm::real get_atom_mass (int index) const
 Get the mass of the given atom.
 
cvm::real get_atom_charge (int index) const
 Get the charge of the given atom.
 
cvm::rvector get_atom_position (int index) const
 Read the current position of the given atom.
 
cvm::rvector get_atom_total_force (int index) const
 Read the current total force of the given atom.
 
void apply_atom_force (int index, cvm::rvector const &new_force)
 Request that this force is applied to the given atom.
 
virtual cvm::rvector get_atom_velocity (int index)
 Read the current velocity of the given atom.
 
std::vector< int > * modify_atom_ids ()
 
std::vector< cvm::real > * modify_atom_masses ()
 
std::vector< cvm::real > * modify_atom_charges ()
 
std::vector< cvm::rvector > * modify_atom_positions ()
 
std::vector< cvm::rvector > * modify_atom_total_forces ()
 
std::vector< cvm::rvector > * modify_atom_new_colvar_forces ()
 
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.
 
cvm::real 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.
 
virtual cvm::rvector get_atom_group_velocity (int index)
 Read the current velocity of the given atom group.
 

Protected Attributes

std::vector< int > atoms_map
 Array of atom indices (relative to the colvarproxy arrays), usedfor faster copy of atomic data.
 
SimParameters const * simparams
 Pointer to the NAMD simulation input object.
 
BigReal thermostat_temperature
 Self-explained.
 
Random random
 NAMD-style PRNG object.
 
size_t restart_frequency_s
 How often NAMD is instructed to write state files.
 
bool first_timestep
 
size_t previous_NAMD_step
 
bool total_force_requested
 
SubmitReduction * reduction
 Used to submit restraint energy as MISC.
 
CmiNodeLock smp_lock_state
 
- Protected Attributes inherited from colvarproxy
bool b_simulation_running
 Whether a simulation is running (and try to prevent irrecovarable errors)
 
std::list< std::ostream * > output_files
 Currently opened output files: by default, these are ofstream objects. Allows redefinition to implement different output mechanisms.
 
std::list< std::string > output_stream_names
 Identifiers for output_stream objects: by default, these are the names of the files.
 
std::vector< int > atoms_ids
 Array of 0-based integers used to uniquely associate atoms within the host program.
 
std::vector< size_t > atoms_ncopies
 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.
 
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_ncopies
 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.
 

Friends

class cvm::atom
 
void calc_cv_scripted_forces (int paramNum, void *param)
 

Additional Inherited Members

- Public Attributes inherited from colvarproxy
colvarmodulecolvars
 Pointer to the main object.
 
std::string input_prefix_str
 Prefix to be used for input files (restarts, not configuration)
 
std::string output_prefix_str
 
std::string restart_output_prefix_str
 
bool b_smp_active
 Whether threaded parallelization should be used (TODO: make this a cvm::deps feature)
 
colvarscriptscript
 
bool force_script_defined
 is a user force script defined?
 
bool have_scripts
 Do we have a scripting interface?
 
- Protected Member Functions inherited from colvarproxy
int add_atom_slot (int atom_id)
 Used by all init_atom() functions: create a slot for an atom not requested yet.
 

Detailed Description

Communication between colvars and NAMD (implementation of colvarproxy)

Member Function Documentation

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

For AMBER topologies, the segment id is automatically set to "MAIN" (the segment id assigned by NAMD's AMBER topology parser), and is therefore optional when an AMBER topology is used

Reimplemented from colvarproxy.

int colvarproxy_namd::load_atoms ( char const *  filename,
cvm::atom_group atoms,
std::string const &  pdb_field,
double const  pdb_field_value = 0.0 
)
virtual

Read atom identifiers from a file.

Parameters
filenamename of the file (usually a PDB)
atomsarray to which atoms read from "filename" will be appended
pdb_field(optiona) if "filename" is a PDB file, use this field to determine which are the atoms to be set

Reimplemented from colvarproxy.

int colvarproxy_namd::scalable_group_coms ( )
inlinevirtual

TODO Add here containers of handles to cvc objects that are computed in parallel.

Whether this proxy implementation has capability for scalable groups

Reimplemented from colvarproxy.

void colvarproxy_namd::select_closest_image ( cvm::atom_pos pos,
cvm::atom_pos const &  ref_pos 
)
inlinevirtual

Get the closest periodic image to a reference position.

Parameters
posThe position to look for the closest periodic image
ref_posThe reference position

Reimplemented from colvarproxy.


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