Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

colvarmodule::atom Class Reference

Stores numeric id, mass and all mutable data for an atom, mostly used by a . More...

#include <colvaratoms.h>

List of all members.

Public Member Functions

 atom ()
 Default constructor, setting id to a non-valid value.
 atom (int const &atom_number)
 Initialize an atom for collective variable calculation and get its internal identifier.
 atom (cvm::residue_id const &residue, std::string const &atom_name, std::string const &segment_id)
 Initialize an atom for collective variable calculation and get its internal identifier.
 atom (atom const &a)
 Copy constructor.
 ~atom ()
 Destructor.
void reset_data ()
 Set non-constant data (everything except id and mass) to zero.
void read_position ()
 Get the current position.
void read_velocity ()
 Get the current velocity.
void read_system_force ()
 Get the system force.
void apply_force (cvm::rvector const &new_force)
 Apply a force to the atom.

Public Attributes

int id
 Internal identifier.
cvm::real mass
 Mass.
cvm::atom_pos pos
 Current position (copied from the program, can be manipulated).
cvm::rvector vel
 Current velocity (copied from the program, can be manipulated).
cvm::rvector system_force
 System force at the previous step (copied from the program, can be manipulated).
cvm::rvector grad
 Gradient of a scalar collective variable with respect to this atom.

Protected Attributes

size_t index
 Index in the list of atoms involved by the colvars (NOT in the global topology!).


Detailed Description

Stores numeric id, mass and all mutable data for an atom, mostly used by a .

This class may be used (although not necessarily) to keep atomic data (id, mass, position and collective variable derivatives) altogether. There may be multiple instances with identical numeric id, all acting independently: forces communicated through these instances will be summed together.

Read/write operations depend on the underlying code: hence, some member functions are defined in colvarproxy_xxx.h.

Definition at line 18 of file colvaratoms.h.


Constructor & Destructor Documentation

colvarmodule::atom::atom  )  [inline]
 

Default constructor, setting id to a non-valid value.

Definition at line 59 of file colvaratoms.h.

00059 {}

cvm::atom::atom int const &  atom_number  ) 
 

Initialize an atom for collective variable calculation and get its internal identifier.

Parameters:
atom_number Atom index in the system topology (starting from 1)

Definition at line 439 of file colvarproxy_namd.C.

References AtomID, Molecule::atommass(), colvarmodule::debug(), colvarmodule::fatal_error(), index, colvarmodule::log(), mass, Node::molecule, Molecule::numAtoms, Node::Object(), and reset_data().

00440 {
00441   // NAMD internal numbering starts from zero
00442   AtomID const aid (atom_number-1);
00443 
00444   if (cvm::debug())
00445     cvm::log ("Adding atom "+cvm::to_str (aid+1)+
00446               " for collective variables calculation.\n");
00447 
00448   if ( (aid < 0) || (aid >= Node::Object()->molecule->numAtoms) ) 
00449     cvm::fatal_error ("Error: invalid atom number specified, "+
00450                       cvm::to_str (atom_number)+"\n");
00451   this->index = ((colvarproxy_namd *) cvm::proxy)->init_namd_atom (aid);
00452   if (cvm::debug())
00453     cvm::log ("The index of this atom in the colvarproxy_namd arrays is "+
00454               cvm::to_str (this->index)+".\n");
00455   this->id = aid;
00456   this->mass = Node::Object()->molecule->atommass (aid);
00457   this->reset_data();
00458 }

cvm::atom::atom cvm::residue_id const &  residue,
std::string const &  atom_name,
std::string const &  segment_id
 

Initialize an atom for collective variable calculation and get its internal identifier.

Parameters:
residue Residue number
atom_name Name of the atom in the residue
segment_id For PSF topologies, the segment identifier; for other type of topologies, may not be required

Definition at line 464 of file colvarproxy_namd.C.

References AtomID, Molecule::atommass(), colvarmodule::debug(), colvarmodule::fatal_error(), Molecule::get_atom_from_name(), index, colvarmodule::log(), mass, Node::molecule, Node::Object(), and reset_data().

00467 {
00468   AtomID const aid =
00469     Node::Object()->molecule->get_atom_from_name (segment_id.c_str(),
00470                                                   residue,
00471                                                   atom_name.c_str());
00472 
00473   if (cvm::debug())
00474     cvm::log ("Adding atom \""+
00475               atom_name+"\" in residue "+
00476               cvm::to_str (residue)+
00477               " (index "+cvm::to_str (aid)+
00478               ") for collective variables calculation.\n");
00479 
00480   if (aid < 0) {
00481     // get_atom_from_name() has returned an error value
00482     cvm::fatal_error ("Error: could not find atom \""+
00483                       atom_name+"\" in residue "+
00484                       cvm::to_str (residue)+
00485                       ( (segment_id != "MAIN") ?
00486                         (", segment \""+segment_id+"\"") :
00487                         ("") )+
00488                       "\n");
00489   }
00490 
00491   this->index = ((colvarproxy_namd *) cvm::proxy)->init_namd_atom (aid);
00492   if (cvm::debug())
00493     cvm::log ("The index of this atom in the colvarproxy_namd arrays is "+
00494               cvm::to_str (this->index)+".\n");
00495   this->id = aid;
00496   this->mass = Node::Object()->molecule->atommass (aid);
00497   this->reset_data();
00498 }

cvm::atom::atom atom const &  a  ) 
 

Copy constructor.

Definition at line 502 of file colvarproxy_namd.C.

References colvarproxy_namd::colvars_atoms_ncopies.

00503   : index (a.index), id (a.id), mass (a.mass)
00504 {
00505   // init_namd_atom() has already been called by a's constructor, no
00506   // need to call it again
00507 
00508   // need to increment the counter anyway
00509   colvarproxy_namd *gm = (colvarproxy_namd *) cvm::proxy;
00510   gm->colvars_atoms_ncopies[this->index] += 1;
00511 }

cvm::atom::~atom  ) 
 

Destructor.

Definition at line 514 of file colvarproxy_namd.C.

References colvarproxy_namd::colvars_atoms_ncopies.

00515 {
00516   colvarproxy_namd *gm = (colvarproxy_namd *) cvm::proxy;
00517   if (gm->colvars_atoms_ncopies[this->index] > 0)
00518     gm->colvars_atoms_ncopies[this->index] -= 1;
00519 }


Member Function Documentation

void cvm::atom::apply_force cvm::rvector const &  new_force  ) 
 

Apply a force to the atom.

The force will be used later by the MD integrator, the collective variables module does not integrate equations of motion. Multiple calls to this function by either the same object or different objects with identical , will all add to the existing MD force.

Definition at line 543 of file colvarproxy_namd.C.

References ResizeArray< Elem >::add(), GlobalMaster::modifyAppliedForces(), GlobalMaster::modifyForcedAtoms(), colvarmodule::rvector::x, colvarmodule::rvector::y, and colvarmodule::rvector::z.

Referenced by colvar::h_bond::apply_force().

00544 {
00545   colvarproxy_namd *gm = (colvarproxy_namd *) cvm::proxy;
00546   gm->modifyForcedAtoms().add (this->id);
00547   gm->modifyAppliedForces().add (Vector (new_force.x, new_force.y, new_force.z));
00548 }

void cvm::atom::read_position  ) 
 

Get the current position.

Definition at line 522 of file colvarproxy_namd.C.

References pos, and colvarproxy_namd::positions.

Referenced by colvar::h_bond::calc_value(), and colvarmodule::atom_group::read_positions().

00523 {
00524   colvarproxy_namd const * const gm = (colvarproxy_namd *) cvm::proxy;
00525   this->pos = gm->positions[this->index];
00526 }

void cvm::atom::read_system_force  ) 
 

Get the system force.

Definition at line 536 of file colvarproxy_namd.C.

References colvarproxy_namd::applied_forces, system_force, and colvarproxy_namd::total_forces.

00537 {
00538   colvarproxy_namd const * const gm = (colvarproxy_namd *) cvm::proxy;
00539   this->system_force = gm->total_forces[this->index] - gm->applied_forces[this->index];
00540 }

void cvm::atom::read_velocity  ) 
 

Get the current velocity.

Definition at line 529 of file colvarproxy_namd.C.

References colvarmodule::fatal_error().

00530 {
00531   cvm::fatal_error ("Error: NAMD does not have yet a way to communicate "
00532                     "atom velocities to the colvars.\n");
00533 }

void colvarmodule::atom::reset_data  )  [inline]
 

Set non-constant data (everything except id and mass) to zero.

Definition at line 82 of file colvaratoms.h.

References colvarmodule::atom_pos.

Referenced by atom(), and colvar::h_bond::calc_value().

00082                            {
00083     pos = atom_pos (0.0);
00084     vel = grad = system_force = rvector (0.0);
00085   }


Member Data Documentation

cvm::rvector colvarmodule::atom::grad
 

Gradient of a scalar collective variable with respect to this atom.

This can only handle a scalar collective variable (i.e. when the member is used from the class), which is also the most frequent case. For more complex types of objects, atomic gradients should be defined within the specific implementation

Definition at line 56 of file colvaratoms.h.

Referenced by colvar::h_bond::apply_force(), colvar::coordnum::calc_gradients(), and colvar::coordnum::switching_function().

int colvarmodule::atom::id
 

Internal identifier.

Definition at line 29 of file colvaratoms.h.

size_t colvarmodule::atom::index [protected]
 

Index in the list of atoms involved by the colvars (NOT in the global topology!).

Definition at line 24 of file colvaratoms.h.

Referenced by atom().

cvm::real colvarmodule::atom::mass
 

Mass.

Definition at line 32 of file colvaratoms.h.

Referenced by colvarmodule::atom_group::add_atom(), and atom().

cvm::atom_pos colvarmodule::atom::pos
 

Current position (copied from the program, can be manipulated).

Definition at line 36 of file colvaratoms.h.

Referenced by colvar::coordnum::calc_gradients(), colvar::coordnum::calc_value(), read_position(), and colvar::coordnum::switching_function().

cvm::rvector colvarmodule::atom::system_force
 

System force at the previous step (copied from the program, can be manipulated).

Definition at line 44 of file colvaratoms.h.

Referenced by read_system_force().

cvm::rvector colvarmodule::atom::vel
 

Current velocity (copied from the program, can be manipulated).

Definition at line 40 of file colvaratoms.h.


The documentation for this class was generated from the following files:
Generated on Mon Nov 23 04:59:33 2009 for NAMD by  doxygen 1.3.9.1