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

colvar::spin_angle Class Reference

Colvar component: angle of rotation around a predefined axis (colvarvalue::type_scalar type, range [-PI:PI]). More...

#include <colvarcomp.h>

Inheritance diagram for colvar::spin_angle:

colvar::orientation colvar::cvc colvarparse List of all members.

Public Member Functions

 spin_angle (std::string const &conf)
 spin_angle ()
virtual ~spin_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
 Redefined to handle the 2*PI periodicity.
virtual colvarvalue dist2_lgrad (colvarvalue const &x1, colvarvalue const &x2) const
 Redefined to handle the 2*PI periodicity.
virtual colvarvalue dist2_rgrad (colvarvalue const &x1, colvarvalue const &x2) const
 Redefined to handle the 2*PI periodicity.
virtual cvm::real compare (colvarvalue const &x1, colvarvalue const &x2) const
 Redefined to handle the 2*PI periodicity.
virtual void wrap (colvarvalue &x) const
 Redefined to handle the 2*PI periodicity.

Protected Attributes

cvm::rvector axis

Detailed Description

Colvar component: angle of rotation around a predefined axis (colvarvalue::type_scalar type, range [-PI:PI]).

Definition at line 1074 of file colvarcomp.h.


Constructor & Destructor Documentation

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

Definition at line 249 of file colvarcomp_rotations.C.

References axis, colvarmodule::log(), colvarmodule::rvector::norm(), colvarmodule::rvector::norm2(), and colvarvalue::type().

00250   : orientation (conf)
00251 {
00252   function_type = "spin_angle";
00253 
00254   get_keyval (conf, "axis", axis, cvm::rvector (0.0, 0.0, 1.0));
00255 
00256   if (axis.norm2() != 1.0) {
00257     axis /= axis.norm();
00258     cvm::log ("Normalizing rotation axis to "+cvm::to_str (axis)+".\n");
00259   }
00260 
00261   period = 360.0;
00262   b_periodic = true;
00263   x.type (colvarvalue::type_scalar);
00264 }

colvar::spin_angle::spin_angle  ) 
 

Definition at line 267 of file colvarcomp_rotations.C.

References colvarvalue::type().

00268   : orientation()
00269 {
00270   function_type = "spin_angle";
00271   period = 360.0;
00272   b_periodic = true;
00273   x.type (colvarvalue::type_scalar);
00274 }

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

Definition at line 1085 of file colvarcomp.h.

01085 {}


Member Function Documentation

void colvar::spin_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

Reimplemented from colvar::orientation.

Definition at line 304 of file colvarcomp_rotations.C.

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

00305 {
00306   cvm::real const &fw = force.real_value;
00307 
00308   if (!atoms.noforce) {
00309     atoms.apply_colvar_force (fw);
00310   }
00311 }

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

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

Reimplemented from colvar::orientation.

Definition at line 291 of file colvarcomp_rotations.C.

References axis, colvarmodule::rotation::dQ0_2, and colvarmodule::rotation::dspin_angle_dq().

00292 {
00293   cvm::quaternion const dxdq = rot.dspin_angle_dq (axis);
00294 
00295   for (size_t ia = 0; ia < atoms.size(); ia++) {
00296     atoms[ia].grad = cvm::rvector (0.0, 0.0, 0.0);
00297     for (size_t iq = 0; iq < 4; iq++) {
00298       atoms[ia].grad += (dxdq[iq] * (rot.dQ0_2[ia])[iq]);
00299     }
00300   }
00301 }

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

Calculate the variable.

Reimplemented from colvar::orientation.

Definition at line 277 of file colvarcomp_rotations.C.

References axis, colvarmodule::rotation::calc_optimal_rotation(), colvarmodule::atom_group::center_of_geometry(), colvarmodule::atom_group::positions_shifted(), colvarvalue::real_value, colvarmodule::rotation::spin_angle(), and wrap().

00278 {
00279   // atoms.reset_atoms_data();
00280   // atoms.read_positions();
00281 
00282   atoms_cog = atoms.center_of_geometry();
00283 
00284   rot.calc_optimal_rotation (ref_pos, atoms.positions_shifted (-1.0 * atoms_cog));
00285 
00286   x.real_value = rot.spin_angle (axis);
00287   this->wrap (x);
00288 }

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

Redefined to handle the 2*PI periodicity.

Reimplemented from colvar::orientation.

Definition at line 1214 of file colvarcomp.h.

References dist2_lgrad().

01216 {
01217   return dist2_lgrad (x1, x2);
01218 }

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

Redefined to handle the 2*PI periodicity.

Reimplemented from colvar::orientation.

Definition at line 1190 of file colvarcomp.h.

References colvarvalue::real_value.

01192 {
01193   cvm::real diff = x1.real_value - x2.real_value;
01194   diff = (diff < -180.0 ? diff + 360.0 : (diff > 180.0 ? diff - 360.0 : diff));
01195   return diff * diff;
01196 }

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

Redefined to handle the 2*PI periodicity.

Reimplemented from colvar::orientation.

Definition at line 1198 of file colvarcomp.h.

References colvarvalue::real_value.

Referenced by compare().

01200 {
01201   cvm::real diff = x1.real_value - x2.real_value;
01202   diff = (diff < -180.0 ? diff + 360.0 : (diff > 180.0 ? diff - 360.0 : diff));
01203   return 2.0 * diff;
01204 }

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

Redefined to handle the 2*PI periodicity.

Reimplemented from colvar::orientation.

Definition at line 1206 of file colvarcomp.h.

References colvarvalue::real_value.

01208 {
01209   cvm::real diff = x1.real_value - x2.real_value;
01210   diff = (diff < -180.0 ? diff + 360.0 : (diff > 180.0 ? diff - 360.0 : diff));
01211   return (-2.0) * diff;
01212 }

void colvar::spin_angle::wrap colvarvalue x  )  const [inline, virtual]
 

Redefined to handle the 2*PI periodicity.

Reimplemented from colvar::cvc.

Definition at line 1220 of file colvarcomp.h.

References colvarvalue::real_value.

Referenced by calc_value().

01221 {
01222   if ((x.real_value - wrap_center) >= 180.0) {
01223     x.real_value -= 360.0;
01224     return;
01225   } 
01226 
01227   if ((x.real_value - wrap_center) < -180.0) {
01228     x.real_value += 360.0;
01229     return;
01230   } 
01231 
01232   return;
01233 }


Member Data Documentation

cvm::rvector colvar::spin_angle::axis [protected]
 

Definition at line 1079 of file colvarcomp.h.

Referenced by calc_gradients(), calc_value(), and spin_angle().


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