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

colvar::angle Class Reference

Colvar component: angle between the centers of mass of three groups (colvarvalue::type_scalar type, range [0:PI]). More...

#include <colvarcomp.h>

Inheritance diagram for colvar::angle:

colvar::cvc colvarparse List of all members.

Public Member Functions

 angle (std::string const &conf)
 Initialize by parsing the configuration.
 angle (cvm::atom const &a1, cvm::atom const &a2, cvm::atom const &a3)
 Initialize the three groups after three atoms.
 angle ()
virtual ~angle ()
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_group group1
 Atom group.
cvm::atom_group group2
 Atom group.
cvm::atom_group group3
 Atom group.
cvm::rvector r21
 Inter site vectors.
cvm::rvector r23
 Inter site vectors.
cvm::real r21l
 Inter site vector norms.
cvm::real r23l
 Inter site vector norms.

Detailed Description

Colvar component: angle between the centers of mass of three groups (colvarvalue::type_scalar type, range [0:PI]).

Definition at line 556 of file colvarcomp.h.


Constructor & Destructor Documentation

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

Initialize by parsing the configuration.

Definition at line 10 of file colvarcomp_angles.C.

References group1, group2, group3, colvar::cvc::parse_group(), and colvarvalue::type().

00011   : cvc (conf)
00012 {
00013   function_type = "angle";
00014   parse_group (conf, "group1", group1);
00015   parse_group (conf, "group2", group2);
00016   parse_group (conf, "group3", group3);
00017   x.type (colvarvalue::type_scalar);
00018 }

colvar::angle::angle cvm::atom const &  a1,
cvm::atom const &  a2,
cvm::atom const &  a3
 

Initialize the three groups after three atoms.

Definition at line 21 of file colvarcomp_angles.C.

References cvm, and colvarvalue::type().

00024   : group1 (std::vector<cvm::atom> (1, a1)),
00025     group2 (std::vector<cvm::atom> (1, a2)),
00026     group3 (std::vector<cvm::atom> (1, a3))
00027 {
00028   function_type = "angle";
00029   x.type (colvarvalue::type_scalar);
00030 }

colvar::angle::angle  ) 
 

Definition at line 33 of file colvarcomp_angles.C.

References colvarvalue::type().

00034 {
00035   function_type = "angle";
00036   x.type (colvarvalue::type_scalar);
00037 }

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

Definition at line 580 of file colvarcomp.h.

00580 {}


Member Function Documentation

void colvar::angle::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 91 of file colvarcomp_angles.C.

References colvarmodule::atom_group::apply_colvar_force(), group1, group2, group3, colvarmodule::atom_group::noforce, and colvarvalue::real_value.

00092 {
00093   if (!group1.noforce)
00094     group1.apply_colvar_force (force.real_value);
00095 
00096   if (!group2.noforce)
00097     group2.apply_colvar_force (force.real_value);
00098 
00099   if (!group3.noforce)
00100     group3.apply_colvar_force (force.real_value);
00101 }

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

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

Implements colvar::cvc.

Definition at line 61 of file colvarcomp_angles.C.

References group1, group2, group3, r21, r21l, r23, r23l, and colvarmodule::atom_group::total_mass.

00062 {
00063   cvm::real const cos_theta = (r21*r23)/(r21l*r23l);
00064   cvm::real const dxdcos = -1.0 / ::sqrt (1.0 - cos_theta*cos_theta);
00065     
00066   cvm::rvector const dthetadr21 = (180.0/PI) * dxdcos *
00067     ( (r23)/(r21l*r23l) +
00068       (r21l*cos_theta) * (-1.0/(r21l*r21l)) * r21/r21l );
00069 
00070   cvm::rvector const dthetadr23 = (180.0/PI) * dxdcos *
00071     ( (r21)/(r21l*r23l) +
00072       (r23l*cos_theta) * (-1.0/(r23l*r23l)) * r23/r23l );
00073 
00074   for (size_t i = 0; i < group1.size(); i++) {
00075     group1[i].grad = (group1[i].mass/group1.total_mass) *
00076       (dthetadr21);
00077   }
00078 
00079   for (size_t i = 0; i < group2.size(); i++) {
00080     group2[i].grad = (group2[i].mass/group2.total_mass) *
00081       (dthetadr21 + dthetadr23) * (-1.0);
00082   }
00083 
00084   for (size_t i = 0; i < group3.size(); i++) {
00085     group3[i].grad = (group3[i].mass/group3.total_mass) *
00086       (dthetadr23);
00087   }
00088 }

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

Calculate the variable.

Implements colvar::cvc.

Definition at line 40 of file colvarcomp_angles.C.

References colvarmodule::atom_pos, colvarmodule::atom_group::center_of_mass(), group1, group2, group3, colvarmodule::rvector::norm(), colvarmodule::position_distance(), r21, r21l, r23, r23l, colvarmodule::atom_group::read_positions(), and colvarvalue::real_value.

00041 {
00042   group1.read_positions();
00043   group2.read_positions();
00044   group3.read_positions();
00045 
00046   cvm::atom_pos const g1_pos = group1.center_of_mass();
00047   cvm::atom_pos const g2_pos = group2.center_of_mass();
00048   cvm::atom_pos const g3_pos = group3.center_of_mass();
00049 
00050   r21  = cvm::position_distance (g1_pos, g2_pos);
00051   r21l = r21.norm();
00052   r23  = cvm::position_distance (g3_pos, g2_pos);
00053   r23l = r23.norm();
00054 
00055   cvm::real     const cos_theta = (r21*r23)/(r21l*r23l);
00056 
00057   x.real_value = (180.0/PI) * ::acos (cos_theta);
00058 }

virtual cvm::real colvar::angle::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::angle::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::angle::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::angle::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_group colvar::angle::group1 [protected]
 

Atom group.

Definition at line 562 of file colvarcomp.h.

Referenced by angle(), apply_force(), calc_gradients(), and calc_value().

cvm::atom_group colvar::angle::group2 [protected]
 

Atom group.

Definition at line 564 of file colvarcomp.h.

Referenced by angle(), apply_force(), calc_gradients(), and calc_value().

cvm::atom_group colvar::angle::group3 [protected]
 

Atom group.

Definition at line 566 of file colvarcomp.h.

Referenced by angle(), apply_force(), calc_gradients(), and calc_value().

cvm::rvector colvar::angle::r21 [protected]
 

Inter site vectors.

Definition at line 569 of file colvarcomp.h.

Referenced by calc_gradients(), and calc_value().

cvm::real colvar::angle::r21l [protected]
 

Inter site vector norms.

Definition at line 571 of file colvarcomp.h.

Referenced by calc_gradients(), and calc_value().

cvm::rvector colvar::angle::r23 [protected]
 

Inter site vectors.

Definition at line 569 of file colvarcomp.h.

Referenced by calc_gradients(), and calc_value().

cvm::real colvar::angle::r23l [protected]
 

Inter site vector norms.

Definition at line 571 of file colvarcomp.h.

Referenced by calc_gradients(), and calc_value().


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