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

colvar::gyration Class Reference

Colvar component: Radius of gyration of an atom group (colvarvalue::type_scalar type, range [0:*)). More...

#include <colvarcomp.h>

Inheritance diagram for colvar::gyration:

colvar::cvc colvarparse List of all members.

Public Member Functions

 gyration (std::string const &conf)
 Constructor.
 gyration ()
virtual ~gyration ()
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 atoms
 Atoms involved.

Detailed Description

Colvar component: Radius of gyration of an atom group (colvarvalue::type_scalar type, range [0:*)).

Definition at line 486 of file colvarcomp.h.


Constructor & Destructor Documentation

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

Constructor.

Definition at line 464 of file colvarcomp_distances.C.

References atoms, colvar::cvc::parse_group(), and colvarvalue::type().

00465   : cvc (conf)
00466 {
00467   function_type = "gyration";
00468   b_inverse_gradients = true;
00469   b_Jacobian_derivative = true;
00470   parse_group (conf, "atoms", atoms);
00471   x.type (colvarvalue::type_scalar);
00472 }

colvar::gyration::gyration  ) 
 

Definition at line 475 of file colvarcomp_distances.C.

References colvarvalue::type().

00476 {
00477   function_type = "gyration";
00478   b_inverse_gradients = true;
00479   b_Jacobian_derivative = true;
00480   x.type (colvarvalue::type_scalar);
00481 }

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

Definition at line 496 of file colvarcomp.h.

00496 {}


Member Function Documentation

void colvar::gyration::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 526 of file colvarcomp_distances.C.

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

00527 {
00528   if (!atoms.noforce)
00529     atoms.apply_colvar_force (force.real_value);
00530 }

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

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

Reimplemented from colvar::cvc.

Definition at line 507 of file colvarcomp_distances.C.

References atoms, colvarmodule::atom_group::read_system_forces(), and colvarvalue::real_value.

00508 {
00509   atoms.read_system_forces();
00510 
00511   cvm::real const dxdr = 1.0/x.real_value;
00512   ft.real_value = 0.0;
00513 
00514   for (cvm::atom_iter ai = atoms.begin(); ai != atoms.end(); ai++) {
00515     ft.real_value += dxdr * ai->pos * ai->system_force;
00516   }
00517 }

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

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

Implements colvar::cvc.

Definition at line 498 of file colvarcomp_distances.C.

References atoms, colvarmodule::real, and colvarvalue::real_value.

00499 {
00500   cvm::real const drdx = 1.0/(cvm::real (atoms.size()) * x.real_value);
00501   for (cvm::atom_iter ai = atoms.begin(); ai != atoms.end(); ai++) {
00502     ai->grad = drdx * ai->pos;
00503   }
00504 }

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

Calculate the divergence of the inverse atomic gradients.

Reimplemented from colvar::cvc.

Definition at line 520 of file colvarcomp_distances.C.

References atoms, colvarmodule::real, and colvarvalue::real_value.

00521 {
00522   jd = x.real_value ? (3.0 * cvm::real (atoms.size()) - 4.0) / x.real_value : 0.0;
00523 }

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

Calculate the variable.

Implements colvar::cvc.

Definition at line 484 of file colvarcomp_distances.C.

References colvarmodule::atom_group::apply_translation(), atoms, colvarmodule::atom_group::center_of_geometry(), colvarvalue::norm2(), colvarmodule::atom_group::read_positions(), colvarvalue::real_value, colvarmodule::atom_group::reset_atoms_data(), and colvarmodule::atom_group::total_mass.

00485 {
00486   atoms.reset_atoms_data();
00487   atoms.read_positions();
00488   atoms.apply_translation ((-1.0) * atoms.center_of_geometry());
00489 
00490   x.real_value = 0.0;
00491   for (cvm::atom_iter ai = atoms.begin(); ai != atoms.end(); ai++) {
00492     x.real_value += (ai->mass/atoms.total_mass) * (ai->pos).norm2();
00493   }
00494   x.real_value = ::sqrt (x.real_value);
00495 }

virtual cvm::real colvar::gyration::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::gyration::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::gyration::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::gyration::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::gyration::atoms [protected]
 

Atoms involved.

Definition at line 491 of file colvarcomp.h.

Referenced by apply_force(), calc_force_invgrads(), calc_gradients(), calc_Jacobian_derivative(), calc_value(), and gyration().


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