#include <colvarcomp.h>
Inheritance diagram for colvar::distance_z:

Public Member Functions | |
| distance_z (std::string const &conf) | |
| distance_z () | |
| virtual | ~distance_z () |
| 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 | main |
| Main atom group. | |
| cvm::atom_group | ref1 |
| Reference atom group. | |
| cvm::atom_group | ref2 |
| Optional, second ref atom group. | |
| bool | b_1site_force |
| cvm::rvector | axis |
| Vector on which the distance vector is projected. | |
| cvm::real | axis_norm |
| Norm of the axis. | |
| cvm::rvector | dist_v |
| Vector distance, cached to be recycled. | |
| bool | fixed_axis |
| Flag: using a fixed axis vector? | |
Definition at line 385 of file colvarcomp.h.
|
|
Definition at line 131 of file colvarcomp_distances.C. References axis, b_1site_force, colvarmodule::fatal_error(), fixed_axis, colvarparse::key_lookup(), colvarmodule::log(), colvarmodule::rvector::norm2(), colvar::cvc::parse_group(), ref1, ref2, colvarvalue::type(), and colvarmodule::rvector::unit(). 00132 : cvc (conf) 00133 { 00134 function_type = "distance_z"; 00135 b_inverse_gradients = true; 00136 b_Jacobian_derivative = true; 00137 x.type (colvarvalue::type_scalar); 00138 00139 parse_group (conf, "main", main); 00140 parse_group (conf, "ref", ref1); 00141 // this group is optional 00142 parse_group (conf, "ref2", ref2, true); 00143 00144 if (ref2.size()) { 00145 cvm::log ("Using axis joining the centers of mass of groups \"ref\" and \"ref2\""); 00146 fixed_axis = false; 00147 if (key_lookup (conf, "axis")) 00148 cvm::log ("Warning: explicit axis definition will be ignored!"); 00149 } else { 00150 if (get_keyval (conf, "axis", axis, cvm::rvector (0.0, 0.0, 1.0))) { 00151 if (axis.norm2() == 0.0) 00152 cvm::fatal_error ("Axis vector is zero!"); 00153 axis = axis.unit(); 00154 } 00155 fixed_axis = true; 00156 } 00157 00158 if (get_keyval (conf, "oneSiteSystemForce", b_1site_force, false)) { 00159 cvm::log ("Computing system force on group \"main\" only"); 00160 } 00161 }
|
|
|
Definition at line 163 of file colvarcomp_distances.C. References colvarvalue::type(). 00164 {
00165 function_type = "distance_z";
00166 b_inverse_gradients = true;
00167 b_Jacobian_derivative = true;
00168 x.type (colvarvalue::type_scalar);
00169 }
|
|
|
Definition at line 409 of file colvarcomp.h. 00409 {}
|
|
|
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
Implements colvar::cvc. Reimplemented in colvar::distance_xy. Definition at line 226 of file colvarcomp_distances.C. References colvarmodule::atom_group::apply_colvar_force(), colvarmodule::atom_group::noforce, colvarvalue::real_value, ref1, and ref2. 00227 {
00228 if (!ref1.noforce)
00229 ref1.apply_colvar_force (force.real_value);
00230
00231 if (ref2.size() && !ref2.noforce)
00232 ref2.apply_colvar_force (force.real_value);
00233
00234 if (!main.noforce)
00235 main.apply_colvar_force (force.real_value);
00236 }
|
|
|
Calculate the total force from the system using the inverse atomic gradients.
Reimplemented from colvar::cvc. Reimplemented in colvar::distance_xy. Definition at line 209 of file colvarcomp_distances.C. References fixed_axis, colvarmodule::atom_group::read_system_forces(), colvarvalue::real_value, ref1, and colvarmodule::atom_group::system_force(). 00210 {
00211 main.read_system_forces();
00212
00213 if (fixed_axis && !b_1site_force) {
00214 ref1.read_system_forces();
00215 ft.real_value = 0.5 * ((main.system_force() - ref1.system_force()) * axis);
00216 } else {
00217 ft.real_value = main.system_force() * axis;
00218 }
00219 }
|
|
|
Calculate the atomic gradients, to be reused later in order to apply forces.
Implements colvar::cvc. Reimplemented in colvar::distance_xy. Definition at line 195 of file colvarcomp_distances.C. References axis, axis_norm, colvarmodule::atom_group::center_of_mass(), colvarvalue::real_value, ref1, ref2, and colvarmodule::atom_group::set_weighted_gradient(). 00196 {
00197 if (fixed_axis) {
00198 ref1.set_weighted_gradient (-1.0 * axis);
00199 main.set_weighted_gradient ( axis);
00200 } else {
00201 ref1.set_weighted_gradient ( 1.0 / axis_norm * (
00202 cvm::position_distance (ref2.center_of_mass(), main.center_of_mass()) - x.real_value * axis ));
00203 ref2.set_weighted_gradient ( 1.0 / axis_norm * (
00204 cvm::position_distance (main.center_of_mass(), ref1.center_of_mass()) + x.real_value * axis ));
00205 main.set_weighted_gradient ( axis );
00206 }
00207 }
|
|
|
Calculate the divergence of the inverse atomic gradients.
Reimplemented from colvar::cvc. Reimplemented in colvar::distance_xy. Definition at line 221 of file colvarcomp_distances.C. References colvarvalue::real_value. 00222 {
00223 jd.real_value = 0.0;
00224 }
|
|
|
||||||||||||
|
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. Reimplemented in colvar::distance_xy. |
|
||||||||||||
|
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. Reimplemented in colvar::distance_xy. |
|
||||||||||||
|
Gradient (with respect to x1) of the square distance (can be redefined to transparently implement constraints, symmetries and periodicities).
Reimplemented from colvar::cvc. Reimplemented in colvar::distance_xy. |
|
||||||||||||
|
Gradient (with respect to x2) of the square distance (can be redefined to transparently implement constraints, symmetries and periodicities).
Reimplemented from colvar::cvc. Reimplemented in colvar::distance_xy. |
|
|
Vector on which the distance vector is projected.
Definition at line 399 of file colvarcomp.h. Referenced by calc_gradients(), calc_value(), and distance_z(). |
|
|
Norm of the axis.
Definition at line 401 of file colvarcomp.h. Referenced by calc_gradients(), and calc_value(). |
|
|
Compute system force on one site only to avoid unwanted coupling to other colvars (see e.g. Ciccotti et al., 2005) Definition at line 397 of file colvarcomp.h. Referenced by distance_z(). |
|
|
Vector distance, cached to be recycled.
Definition at line 403 of file colvarcomp.h. Referenced by calc_value(). |
|
|
Flag: using a fixed axis vector?
Definition at line 405 of file colvarcomp.h. Referenced by calc_force_invgrads(), and distance_z(). |
|
|
Main atom group.
Definition at line 390 of file colvarcomp.h. |
|
|
Reference atom group.
Definition at line 392 of file colvarcomp.h. Referenced by apply_force(), calc_force_invgrads(), calc_gradients(), calc_value(), and distance_z(). |
|
|
Optional, second ref atom group.
Definition at line 394 of file colvarcomp.h. Referenced by apply_force(), calc_gradients(), calc_value(), and distance_z(). |
1.3.9.1