Collective Variables Module - Developer Documentation
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 reset ()
 Reset proxy state, e.g. requested atoms.
 
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)
 
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 ()
 Target temperature of the simulation (K units)
 
cvm::real rand_gaussian ()
 Pseudo-random number with Gaussian distribution.
 
cvm::real dt ()
 Time step of the simulation (fs)
 
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.
 
int replica_comm_send ()
 
int replica_comm_async_send ()
 
size_t restart_frequency ()
 Restarts will be written each time this number of steps has passed.
 
int init_atom (int atom_number)
 
int check_atom_id (int atom_number)
 
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)
 
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 ()
 Whether this proxy implementation has capability for scalable groups.
 
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, std::ios_base::openmode mode)
 Returns a reference to the given output channel; if this is not open already, then open it.
 
int flush_output_stream (std::ostream *os)
 Flushes the given output channel.
 
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.
 
char * script_obj_to_str (unsigned char *obj)
 Convert a script object (Tcl or Python call argument) to a C string.
 
- 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)
 
bool simulation_running () const
 Whether a simulation is running (warn against irrecovarable errors)
 
- Public Member Functions inherited from colvarproxy_system
 colvarproxy_system ()
 Constructor.
 
virtual ~colvarproxy_system ()
 Destructor.
 
virtual bool total_forces_same_step () const
 Are total forces from the current step available?
 
- Public Member Functions inherited from colvarproxy_atoms
 colvarproxy_atoms ()
 Constructor.
 
virtual ~colvarproxy_atoms ()
 Destructor.
 
int reset ()
 Clear atomic data.
 
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.
 
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 ()
 
- Public Member Functions inherited from colvarproxy_atom_groups
 colvarproxy_atom_groups ()
 Contructor.
 
virtual ~colvarproxy_atom_groups ()
 Destructor.
 
int reset ()
 Clear atom group data.
 
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 index)
 Read the current velocity of the given atom group.
 
- Public Member Functions inherited from colvarproxy_smp
 colvarproxy_smp ()
 Constructor.
 
virtual ~colvarproxy_smp ()
 Destructor.
 
virtual int 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.
 
- Public Member Functions inherited from colvarproxy_script
 colvarproxy_script ()
 Constructor.
 
virtual ~colvarproxy_script ()
 Destructor.
 
- Public Member Functions inherited from colvarproxy_io
 colvarproxy_io ()
 Constructor.
 
virtual ~colvarproxy_io ()
 Destructor.
 
virtual int get_frame (long int &)
 Save the current frame number in the argument given.
 
virtual int set_frame (long int)
 Set the current frame number (as well as colvarmodule::it)
 
int backup_file (std::string const &filename)
 Rename the given file, before overwriting it.
 
std::string & input_prefix ()
 Prefix of the input state file.
 
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)
 

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.
 
- Protected Attributes inherited from colvarproxy
bool b_simulation_running
 Whether a simulation is running (warn against irrecovarable errors)
 
- 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_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.
 
- 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_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.
 
- Protected Attributes inherited from colvarproxy_smp
void * omp_lock_state
 Lock state for OpenMP.
 
- Protected Attributes inherited from colvarproxy_io
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
 
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.
 

Friends

class cvm::atom
 

Additional Inherited Members

- Public Attributes inherited from colvarproxy
colvarmodulecolvars
 Pointer to the main object.
 
- Public Attributes inherited from colvarproxy_smp
bool b_smp_active
 
- Public Attributes inherited from colvarproxy_script
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_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.
 

Detailed Description

Communication between colvars and NAMD (implementation of colvarproxy)

Member Function Documentation

◆ check_atom_id()

int colvarproxy_namd::check_atom_id ( int  atom_number)
virtual

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

Implements colvarproxy_atoms.

◆ init_atom() [1/2]

int colvarproxy_namd::init_atom ( int  atom_number)
virtual

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

Implements colvarproxy_atoms.

◆ init_atom() [2/2]

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

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.

◆ load_atoms()

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_atoms.


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