Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | 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 calc_force_invgrads ()
 Calculate the total force from the system using the inverse atomic gradients.
virtual void calc_Jacobian_derivative ()
 Calculate the divergence of the inverse atomic gradients.
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.
cvm::rvector dxdr1
 Derivatives wrt group centers of mass.
cvm::rvector dxdr3
 Derivatives wrt group centers of mass.
bool b_1site_force

Detailed Description

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

Definition at line 626 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 b_1site_force, group1, group2, group3, colvarmodule::log(), colvar::cvc::parse_group(), and colvarvalue::type().

00011   : cvc (conf)
00012 {
00013   function_type = "angle";
00014   b_inverse_gradients = true;
00015   b_Jacobian_derivative = true;
00016   parse_group (conf, "group1", group1);
00017   parse_group (conf, "group2", group2);
00018   parse_group (conf, "group3", group3);
00019   atom_groups.push_back (&group1);
00020   atom_groups.push_back (&group2);
00021   atom_groups.push_back (&group3);
00022   if (get_keyval (conf, "oneSiteSystemForce", b_1site_force, false)) {
00023     cvm::log ("Computing system force on group 1 only");
00024   }
00025   x.type (colvarvalue::type_scalar);
00026 }

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 29 of file colvarcomp_angles.C.

References b_1site_force, cvm, group1, group2, group3, and colvarvalue::type().

00032   : group1 (std::vector<cvm::atom> (1, a1)),
00033     group2 (std::vector<cvm::atom> (1, a2)),
00034     group3 (std::vector<cvm::atom> (1, a3))
00035 {
00036   function_type = "angle";
00037   b_inverse_gradients = true;
00038   b_Jacobian_derivative = true;
00039   b_1site_force = false;
00040   atom_groups.push_back (&group1);
00041   atom_groups.push_back (&group2);
00042   atom_groups.push_back (&group3);
00043 
00044   x.type (colvarvalue::type_scalar);
00045 }

colvar::angle::angle  ) 
 

Definition at line 48 of file colvarcomp_angles.C.

References colvarvalue::type().

00049 {
00050   function_type = "angle";
00051   x.type (colvarvalue::type_scalar);
00052 }

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

Definition at line 656 of file colvarcomp.h.

00656 {}


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 134 of file colvarcomp_angles.C.

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

00135 {
00136   if (!group1.noforce)
00137     group1.apply_colvar_force (force.real_value);
00138 
00139   if (!group2.noforce)
00140     group2.apply_colvar_force (force.real_value);
00141 
00142   if (!group3.noforce)
00143     group3.apply_colvar_force (force.real_value);
00144 }

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

Calculate the total force from the system using the inverse atomic gradients.

Reimplemented from colvar::cvc.

Definition at line 103 of file colvarcomp_angles.C.

References dxdr1, dxdr3, group1, group3, colvarmodule::rvector::norm2(), colvarmodule::atom_group::read_system_forces(), colvarvalue::real_value, and colvarmodule::atom_group::system_force().

00104 {
00105   // This uses a force measurement on groups 1 and 3 only
00106   // to keep in line with the implicit variable change used to
00107   // evaluate the Jacobian term (essentially polar coordinates
00108   // centered on group2, which means group2 is kept fixed
00109   // when propagating changes in the angle)
00110 
00111   if (b_1site_force) {
00112     group1.read_system_forces();
00113     cvm::real norm_fact = 1.0 / dxdr1.norm2();
00114     ft.real_value = norm_fact * dxdr1 * group1.system_force();
00115   } else {
00116     group1.read_system_forces();
00117     group3.read_system_forces();
00118     cvm::real norm_fact = 1.0 / (dxdr1.norm2() + dxdr3.norm2());
00119     ft.real_value = norm_fact * ( dxdr1 * group1.system_force()
00120                                 + dxdr3 * group3.system_force());
00121   }
00122   return;
00123 }

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 76 of file colvarcomp_angles.C.

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

00077 {
00078   cvm::real const cos_theta = (r21*r23)/(r21l*r23l);
00079   cvm::real const dxdcos = -1.0 / std::sqrt (1.0 - cos_theta*cos_theta);
00080     
00081   dxdr1 = (180.0/PI) * dxdcos *
00082     (1.0/r21l) * ( r23/r23l + (-1.0) * cos_theta * r21/r21l );
00083 
00084   dxdr3 = (180.0/PI) * dxdcos *
00085     (1.0/r23l) * ( r21/r21l + (-1.0) * cos_theta * r23/r23l );
00086 
00087   for (size_t i = 0; i < group1.size(); i++) {
00088     group1[i].grad = (group1[i].mass/group1.total_mass) *
00089       (dxdr1);
00090   }
00091 
00092   for (size_t i = 0; i < group2.size(); i++) {
00093     group2[i].grad = (group2[i].mass/group2.total_mass) *
00094       (dxdr1 + dxdr3) * (-1.0);
00095   }
00096 
00097   for (size_t i = 0; i < group3.size(); i++) {
00098     group3[i].grad = (group3[i].mass/group3.total_mass) *
00099       (dxdr3);
00100   }
00101 }

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

Calculate the divergence of the inverse atomic gradients.

Reimplemented from colvar::cvc.

Definition at line 125 of file colvarcomp_angles.C.

References PI, and colvarvalue::real_value.

00126 {
00127   // det(J) = (2 pi) r^2 * sin(theta)
00128   // hence Jd = cot(theta)
00129   const cvm::real theta = x.real_value * PI / 180.0;
00130   jd = PI / 180.0 * (theta != 0.0 ? std::cos(theta) / std::sin(theta) : 0.0);
00131 }

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

Calculate the variable.

Implements colvar::cvc.

Definition at line 55 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.

00056 {
00057   group1.read_positions();
00058   group2.read_positions();
00059   group3.read_positions();
00060 
00061   cvm::atom_pos const g1_pos = group1.center_of_mass();
00062   cvm::atom_pos const g2_pos = group2.center_of_mass();
00063   cvm::atom_pos const g3_pos = group3.center_of_mass();
00064 
00065   r21  = cvm::position_distance (g2_pos, g1_pos);
00066   r21l = r21.norm();
00067   r23  = cvm::position_distance (g2_pos, g3_pos);
00068   r23l = r23.norm();
00069 
00070   cvm::real     const cos_theta = (r21*r23)/(r21l*r23l);
00071 
00072   x.real_value = (180.0/PI) * std::acos (cos_theta);
00073 }

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

bool colvar::angle::b_1site_force [protected]
 

Compute system force on first site only to avoid unwanted coupling to other colvars (see e.g. Ciccotti et al., 2005) (or to allow dummy atoms)

Definition at line 648 of file colvarcomp.h.

Referenced by angle().

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

Derivatives wrt group centers of mass.

Definition at line 643 of file colvarcomp.h.

Referenced by calc_force_invgrads(), and calc_gradients().

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

Derivatives wrt group centers of mass.

Definition at line 643 of file colvarcomp.h.

Referenced by calc_force_invgrads(), and calc_gradients().

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

Atom group.

Definition at line 632 of file colvarcomp.h.

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

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

Atom group.

Definition at line 634 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 636 of file colvarcomp.h.

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

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

Inter site vectors.

Definition at line 639 of file colvarcomp.h.

Referenced by calc_gradients(), and calc_value().

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

Inter site vector norms.

Definition at line 641 of file colvarcomp.h.

Referenced by calc_gradients(), and calc_value().

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

Inter site vectors.

Definition at line 639 of file colvarcomp.h.

Referenced by calc_gradients(), and calc_value().

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

Inter site vector norms.

Definition at line 641 of file colvarcomp.h.

Referenced by calc_gradients(), and calc_value().


The documentation for this class was generated from the following files:
Generated on Sat May 18 04:07:21 2013 for NAMD by  doxygen 1.3.9.1