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

colvar::distance_xy Class Reference

Colvar component: projection of the distance vector on a plane (colvarvalue::type_scalar type, range [0:*)). More...

#include <colvarcomp.h>

Inheritance diagram for colvar::distance_xy:

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

Public Member Functions

 distance_xy (std::string const &conf)
 distance_xy ()
virtual ~distance_xy ()
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::rvector dist_v_ortho
 Components of the distance vector orthogonal to the axis.
cvm::rvector v12
 Vector distances.
cvm::rvector v13
 Vector distances.

Detailed Description

Colvar component: projection of the distance vector on a plane (colvarvalue::type_scalar type, range [0:*)).

Definition at line 428 of file colvarcomp.h.


Constructor & Destructor Documentation

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

Definition at line 240 of file colvarcomp_distances.C.

References colvarvalue::type().

00241   : distance_z (conf)
00242 {
00243   function_type = "distance_xy";
00244   b_inverse_gradients = true;
00245   b_Jacobian_derivative = true;
00246   x.type (colvarvalue::type_scalar);
00247 }

colvar::distance_xy::distance_xy  ) 
 

Definition at line 249 of file colvarcomp_distances.C.

References colvarvalue::type().

00250   : distance_z()
00251 {
00252   function_type = "distance_xy";
00253   b_inverse_gradients = true;
00254   b_Jacobian_derivative = true;
00255   x.type (colvarvalue::type_scalar);
00256 }

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

Definition at line 439 of file colvarcomp.h.

00439 {}


Member Function Documentation

void colvar::distance_xy::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::distance_z.

Definition at line 321 of file colvarcomp_distances.C.

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

00322 {
00323   if (!ref1.noforce)
00324     ref1.apply_colvar_force (force.real_value);
00325 
00326   if (ref2.size() && !ref2.noforce)
00327     ref2.apply_colvar_force (force.real_value);
00328 
00329   if (!main.noforce)
00330     main.apply_colvar_force (force.real_value);
00331 }

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

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

Reimplemented from colvar::distance_z.

Definition at line 304 of file colvarcomp_distances.C.

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

00305 {
00306   main.read_system_forces();
00307 
00308   if (fixed_axis && !b_1site_force) {
00309     ref1.read_system_forces();
00310     ft.real_value = 0.5 / x.real_value * ((main.system_force() - ref1.system_force()) * dist_v_ortho);
00311   } else {
00312     ft.real_value = 1.0 / x.real_value * main.system_force() * dist_v_ortho;
00313   }
00314 }

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

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

Reimplemented from colvar::distance_z.

Definition at line 281 of file colvarcomp_distances.C.

References colvarmodule::atom_group::center_of_mass(), dist_v_ortho, colvarmodule::position_distance(), colvarvalue::real_value, colvarmodule::atom_group::set_weighted_gradient(), and v13.

00282 {
00283   // Intermediate quantity (r_P3 / r_12 where P is the projection
00284   // of 3 (main) on the plane orthogonal to 12, containing 1 (ref1))
00285   cvm::real A;
00286   cvm::real x_inv;
00287 
00288   if (x.real_value == 0.0) return;
00289   x_inv = 1.0 / x.real_value;
00290 
00291   if (fixed_axis) {
00292     ref1.set_weighted_gradient (-1.0 * x_inv * dist_v_ortho);
00293     main.set_weighted_gradient (       x_inv * dist_v_ortho);
00294   } else {
00295     v13 = cvm::position_distance (ref1.center_of_mass(), main.center_of_mass());
00296     A = (dist_v * axis) / axis_norm;
00297 
00298     ref1.set_weighted_gradient ( (A - 1.0) * x_inv * dist_v_ortho);
00299     ref2.set_weighted_gradient ( -A        * x_inv * dist_v_ortho);
00300     main.set_weighted_gradient (      1.0  * x_inv * dist_v_ortho);
00301   }
00302 }

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

Calculate the divergence of the inverse atomic gradients.

Reimplemented from colvar::distance_z.

Definition at line 316 of file colvarcomp_distances.C.

References colvarvalue::real_value.

00317 {
00318   jd.real_value = x.real_value ? (1.0 / x.real_value) : 0.0;
00319 }

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

Calculate the variable.

Reimplemented from colvar::distance_z.

Definition at line 258 of file colvarcomp_distances.C.

References colvarmodule::atom_group::center_of_mass(), dist_v_ortho, colvarmodule::rvector::norm(), colvarmodule::position_distance(), colvarmodule::atom_group::read_positions(), colvarvalue::real_value, colvarmodule::atom_group::reset_atoms_data(), colvarmodule::rvector::unit(), and v12.

00259 {
00260   ref1.reset_atoms_data();
00261   main.reset_atoms_data();
00262 
00263   ref1.read_positions();
00264   main.read_positions();
00265 
00266   dist_v = cvm::position_distance (ref1.center_of_mass(),
00267                                    main.center_of_mass());
00268   if (!fixed_axis) {
00269     ref2.reset_atoms_data();
00270     ref2.read_positions();
00271 
00272     v12 = cvm::position_distance (ref1.center_of_mass(), ref2.center_of_mass());
00273     axis_norm = v12.norm();
00274     axis = v12.unit();
00275   }
00276 
00277   dist_v_ortho = dist_v - (dist_v * axis) * axis;
00278   x.real_value = dist_v_ortho.norm();
00279 }

virtual cvm::real colvar::distance_xy::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::distance_z.

virtual cvm::real colvar::distance_xy::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::distance_z.

virtual colvarvalue colvar::distance_xy::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::distance_z.

virtual colvarvalue colvar::distance_xy::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::distance_z.


Member Data Documentation

cvm::rvector colvar::distance_xy::dist_v_ortho [protected]
 

Components of the distance vector orthogonal to the axis.

Definition at line 433 of file colvarcomp.h.

Referenced by calc_gradients(), and calc_value().

cvm::rvector colvar::distance_xy::v12 [protected]
 

Vector distances.

Definition at line 435 of file colvarcomp.h.

Referenced by calc_value().

cvm::rvector colvar::distance_xy::v13 [protected]
 

Vector distances.

Definition at line 435 of file colvarcomp.h.

Referenced by calc_gradients().


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