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

colvar::h_bond Class Reference

Colvar component: hydrogen bond, defined as the product of a colvar::coordnum and 1/2*(1-cos((180-ang)/ang_tol)) (colvarvalue::type_scalar type, range [0:1]). More...

#include <colvarcomp.h>

Inheritance diagram for colvar::h_bond:

colvar::cvc colvarparse List of all members.

Public Member Functions

 h_bond (std::string const &conf)
 h_bond (cvm::atom const &acceptor, cvm::atom const &donor, cvm::real r0, int en, int ed)
 Constructor for atoms already allocated.
 h_bond ()
virtual ~h_bond ()
virtual void calc_value ()
 Calculate the variable.
virtual void calc_gradients ()
 Calculate the atomic gradients, to be reused later in order to apply forces.
virtual void apply_force (colvarvalue const &force)
 Apply the collective variable force, by communicating the atomic forces to the simulation program (Note: the member is not altered by this function).
virtual cvm::real dist2 (colvarvalue const &x1, colvarvalue const &x2) const
 Square distance between x1 and x2 (can be redefined to transparently implement constraints, symmetries and periodicities).
virtual colvarvalue dist2_lgrad (colvarvalue const &x1, colvarvalue const &x2) const
 Gradient (with respect to x1) of the square distance (can be redefined to transparently implement constraints, symmetries and periodicities).
virtual colvarvalue dist2_rgrad (colvarvalue const &x1, colvarvalue const &x2) const
 Gradient (with respect to x2) of the square distance (can be redefined to transparently implement constraints, symmetries and periodicities).
virtual cvm::real compare (colvarvalue const &x1, colvarvalue const &x2) const
 Return a positive number if x2>x1, zero if x2==x1, negative otherwise (can be redefined to transparently implement constraints, symmetries and periodicities) Note: it only works with scalar variables, otherwise raises an error.

Protected Attributes

cvm::atom acceptor
 Atoms involved in the component.
cvm::atom donor
 Atoms involved in the component.
cvm::real r0
 "Cutoff" distance between acceptor and donor
int en
 Integer exponent of the function numerator.
int ed
 Integer exponent of the function denominator.

Detailed Description

Colvar component: hydrogen bond, defined as the product of a colvar::coordnum and 1/2*(1-cos((180-ang)/ang_tol)) (colvarvalue::type_scalar type, range [0:1]).

Definition at line 707 of file colvarcomp.h.


Constructor & Destructor Documentation

colvar::h_bond::h_bond std::string const &  conf  ) 
 

Definition at line 218 of file colvarcomp_coordnums.C.

References acceptor, colvarmodule::atom, donor, ed, en, colvarmodule::fatal_error(), r0, and colvarvalue::type().

00219   : cvc (conf)
00220 {
00221   function_type = "h_bond";
00222   x.type (colvarvalue::type_scalar);
00223 
00224   int a_num, d_num;
00225   get_keyval (conf, "acceptor", a_num, -1);
00226   get_keyval (conf, "donor",    d_num, -1);
00227 
00228   if ( (a_num == -1) || (d_num == -1) ) {
00229     cvm::fatal_error ("Error: either acceptor or donor undefined.\n");
00230   }
00231 
00232   acceptor = cvm::atom (a_num);
00233   donor    = cvm::atom (d_num);
00234 
00235   get_keyval (conf, "cutoff",   r0, (3.3 * cvm::unit_angstrom()));
00236   get_keyval (conf, "expNumer", en, 6);
00237   get_keyval (conf, "expDenom", ed, 8);
00238 
00239   if ( (en%2) || (ed%2) ) {
00240     cvm::fatal_error ("Error: odd exponents provided, can only use even ones.\n");
00241   }
00242 }

colvar::h_bond::h_bond cvm::atom const &  acceptor,
cvm::atom const &  donor,
cvm::real  r0,
int  en,
int  ed
 

Constructor for atoms already allocated.

Definition at line 245 of file colvarcomp_coordnums.C.

References colvarvalue::type().

00248   : acceptor (acceptor_i),
00249     donor (donor_i),
00250     r0 (r0_i), en (en_i), ed (ed_i)
00251 {
00252   function_type = "h_bond";
00253   x.type (colvarvalue::type_scalar);
00254 }

colvar::h_bond::h_bond  ) 
 

Definition at line 257 of file colvarcomp_coordnums.C.

References colvarvalue::type().

00258   : cvc ()
00259 {
00260   function_type = "h_bond";
00261   x.type (colvarvalue::type_scalar);
00262 }

virtual colvar::h_bond::~h_bond  )  [inline, virtual]
 

Definition at line 726 of file colvarcomp.h.

00726 {}


Member Function Documentation

void colvar::h_bond::apply_force colvarvalue const &  force  )  [virtual]
 

Apply the collective variable force, by communicating the atomic forces to the simulation program (Note: the member is not altered by this function).

Note: multiple calls to this function within the same simulation step will add the forces altogether

Parameters:
cvforce The collective variable force, usually coming from the biases and eventually manipulated by the parent object

Implements colvar::cvc.

Definition at line 286 of file colvarcomp_coordnums.C.

References acceptor, colvarmodule::atom::apply_force(), donor, colvarmodule::atom::grad, and colvarvalue::real_value.

00287 {
00288   acceptor.apply_force (force.real_value * acceptor.grad);
00289   donor.apply_force    (force.real_value * donor.grad);
00290 }

void colvar::h_bond::calc_gradients  )  [virtual]
 

Calculate the atomic gradients, to be reused later in order to apply forces.

Implements colvar::cvc.

Definition at line 280 of file colvarcomp_coordnums.C.

00281 {
00282   colvar::coordnum::switching_function<true> (r0, en, ed, acceptor, donor);
00283 }

void colvar::h_bond::calc_value  )  [virtual]
 

Calculate the variable.

Implements colvar::cvc.

Definition at line 266 of file colvarcomp_coordnums.C.

References acceptor, donor, colvarmodule::atom::read_position(), colvarvalue::real_value, and colvarmodule::atom::reset_data().

00267 {
00268   // this is necessary, because switching_function() will sum the new
00269   // gradient to the current one
00270   acceptor.reset_data();
00271   donor.reset_data();
00272 
00273   acceptor.read_position();
00274   donor.read_position();
00275 
00276   x.real_value = colvar::coordnum::switching_function<false> (r0, en, ed, acceptor, donor);
00277 }

virtual cvm::real colvar::h_bond::compare colvarvalue const &  x1,
colvarvalue const &  x2
const [virtual]
 

Return a positive number if x2>x1, zero if x2==x1, negative otherwise (can be redefined to transparently implement constraints, symmetries and periodicities) Note: it only works with scalar variables, otherwise raises an error.

Reimplemented from colvar::cvc.

virtual cvm::real colvar::h_bond::dist2 colvarvalue const &  x1,
colvarvalue const &  x2
const [virtual]
 

Square distance between x1 and x2 (can be redefined to transparently implement constraints, symmetries and periodicities).

colvar::cvc::dist2() and the related functions are declared as "const" functions, but not "static", because additional parameters defining the metrics (e.g. the periodicity) may be specific to each colvar::cvc object.

If symmetries or periodicities are present, the colvar::cvc::dist2() should be redefined to return the "closest distance" value and colvar::cvc::dist2_lgrad(), colvar::cvc::dist2_rgrad() to return its gradients.

If constraints are present (and not already implemented by any of the types), the colvar::cvc::dist2_lgrad() and colvar::cvc::dist2_rgrad() functions should be redefined to provide a gradient which is compatible with the constraint, i.e. already deprived of its component normal to the constraint hypersurface.

Finally, another useful application, if you are performing very many operations with these functions, could be to override the member functions and access directly its member data. For instance: to define dist2(x1,x2) as (x2.real_value-x1.real_value)*(x2.real_value-x1.real_value) in case of a scalar type.

Reimplemented from colvar::cvc.

virtual colvarvalue colvar::h_bond::dist2_lgrad colvarvalue const &  x1,
colvarvalue const &  x2
const [virtual]
 

Gradient (with respect to x1) of the square distance (can be redefined to transparently implement constraints, symmetries and periodicities).

Reimplemented from colvar::cvc.

virtual colvarvalue colvar::h_bond::dist2_rgrad colvarvalue const &  x1,
colvarvalue const &  x2
const [virtual]
 

Gradient (with respect to x2) of the square distance (can be redefined to transparently implement constraints, symmetries and periodicities).

Reimplemented from colvar::cvc.


Member Data Documentation

cvm::atom colvar::h_bond::acceptor [protected]
 

Atoms involved in the component.

Definition at line 712 of file colvarcomp.h.

Referenced by apply_force(), calc_value(), and h_bond().

cvm::atom colvar::h_bond::donor [protected]
 

Atoms involved in the component.

Definition at line 712 of file colvarcomp.h.

Referenced by apply_force(), calc_value(), and h_bond().

int colvar::h_bond::ed [protected]
 

Integer exponent of the function denominator.

Definition at line 718 of file colvarcomp.h.

Referenced by h_bond().

int colvar::h_bond::en [protected]
 

Integer exponent of the function numerator.

Definition at line 716 of file colvarcomp.h.

Referenced by h_bond().

cvm::real colvar::h_bond::r0 [protected]
 

"Cutoff" distance between acceptor and donor

Definition at line 714 of file colvarcomp.h.

Referenced by h_bond().


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