#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. | |
| virtual void | wrap (colvarvalue &x) const |
| Redefined to make use of the user-provided period. | |
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_no_PBC |
| Use absolute positions, ignoring PBCs when present. | |
| 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 398 of file colvarcomp.h.
|
|
Definition at line 132 of file colvarcomp_distances.C. References axis, b_1site_force, b_no_PBC, 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(). 00133 : cvc (conf) 00134 { 00135 function_type = "distance_z"; 00136 b_inverse_gradients = true; 00137 b_Jacobian_derivative = true; 00138 x.type (colvarvalue::type_scalar); 00139 00140 // TODO detect PBC from MD engine (in simple cases) 00141 // and then update period in real time 00142 if (period != 0.0) 00143 b_periodic = true; 00144 00145 if ((wrap_center != 0.0) && (period == 0.0)) { 00146 cvm::fatal_error ("Error: wrapAround was defined in a distanceZ component," 00147 " but its period has not been set.\n"); 00148 } 00149 00150 parse_group (conf, "main", main); 00151 parse_group (conf, "ref", ref1); 00152 atom_groups.push_back (&main); 00153 atom_groups.push_back (&ref1); 00154 // this group is optional 00155 parse_group (conf, "ref2", ref2, true); 00156 00157 if (ref2.size()) { 00158 atom_groups.push_back (&ref2); 00159 cvm::log ("Using axis joining the centers of mass of groups \"ref\" and \"ref2\""); 00160 fixed_axis = false; 00161 if (key_lookup (conf, "axis")) 00162 cvm::log ("Warning: explicit axis definition will be ignored!"); 00163 } else { 00164 if (get_keyval (conf, "axis", axis, cvm::rvector (0.0, 0.0, 1.0))) { 00165 if (axis.norm2() == 0.0) 00166 cvm::fatal_error ("Axis vector is zero!"); 00167 if (axis.norm2() != 1.0) { 00168 axis = axis.unit(); 00169 cvm::log ("The normalized axis is: "+cvm::to_str (axis)+".\n"); 00170 } 00171 } 00172 fixed_axis = true; 00173 } 00174 00175 if (get_keyval (conf, "forceNoPBC", b_no_PBC, false)) { 00176 cvm::log ("Computing distance using absolute positions (not minimal-image)"); 00177 } 00178 if (get_keyval (conf, "oneSiteSystemForce", b_1site_force, false)) { 00179 cvm::log ("Computing system force on group \"main\" only"); 00180 } 00181 }
|
|
|
Definition at line 183 of file colvarcomp_distances.C. References colvarvalue::type(). 00184 {
00185 function_type = "distance_z";
00186 b_inverse_gradients = true;
00187 b_Jacobian_derivative = true;
00188 x.type (colvarvalue::type_scalar);
00189 }
|
|
|
Definition at line 424 of file colvarcomp.h. 00424 {}
|
|
|
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 256 of file colvarcomp_distances.C. References colvarmodule::atom_group::apply_colvar_force(), colvarmodule::atom_group::noforce, colvarvalue::real_value, ref1, and ref2. 00257 {
00258 if (!ref1.noforce)
00259 ref1.apply_colvar_force (force.real_value);
00260
00261 if (ref2.size() && !ref2.noforce)
00262 ref2.apply_colvar_force (force.real_value);
00263
00264 if (!main.noforce)
00265 main.apply_colvar_force (force.real_value);
00266 }
|
|
|
Calculate the total force from the system using the inverse atomic gradients.
Reimplemented from colvar::cvc. Reimplemented in colvar::distance_xy. Definition at line 239 of file colvarcomp_distances.C. References fixed_axis, colvarmodule::atom_group::read_system_forces(), colvarvalue::real_value, ref1, and colvarmodule::atom_group::system_force(). 00240 {
00241 main.read_system_forces();
00242
00243 if (fixed_axis && !b_1site_force) {
00244 ref1.read_system_forces();
00245 ft.real_value = 0.5 * ((main.system_force() - ref1.system_force()) * axis);
00246 } else {
00247 ft.real_value = main.system_force() * axis;
00248 }
00249 }
|
|
|
Calculate the atomic gradients, to be reused later in order to apply forces.
Implements colvar::cvc. Reimplemented in colvar::distance_xy. Definition at line 218 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(). 00219 {
00220 main.set_weighted_gradient ( axis );
00221
00222 if (fixed_axis) {
00223 ref1.set_weighted_gradient (-1.0 * axis);
00224 } else {
00225 if (b_no_PBC) {
00226 ref1.set_weighted_gradient ( 1.0 / axis_norm * (main.center_of_mass() - ref2.center_of_mass() -
00227 x.real_value * axis ));
00228 ref2.set_weighted_gradient ( 1.0 / axis_norm * (ref1.center_of_mass() - main.center_of_mass() +
00229 x.real_value * axis ));
00230 } else {
00231 ref1.set_weighted_gradient ( 1.0 / axis_norm * (
00232 cvm::position_distance (ref2.center_of_mass(), main.center_of_mass()) - x.real_value * axis ));
00233 ref2.set_weighted_gradient ( 1.0 / axis_norm * (
00234 cvm::position_distance (main.center_of_mass(), ref1.center_of_mass()) + x.real_value * axis ));
00235 }
00236 }
00237 }
|
|
|
Calculate the divergence of the inverse atomic gradients.
Reimplemented from colvar::cvc. Reimplemented in colvar::distance_xy. Definition at line 251 of file colvarcomp_distances.C. References colvarvalue::real_value. 00252 {
00253 jd.real_value = 0.0;
00254 }
|
|
|
||||||||||||
|
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. Definition at line 1323 of file colvarcomp.h. References dist2_lgrad(). 01325 {
01326 return dist2_lgrad (x1, x2);
01327 }
|
|
||||||||||||
|
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. Definition at line 1301 of file colvarcomp.h. References colvarvalue::real_value. Referenced by compare(). 01303 {
01304 cvm::real diff = x1.real_value - x2.real_value;
01305 if (period != 0.0) {
01306 cvm::real shift = std::floor (diff/period + 0.5);
01307 diff -= shift * period;
01308 }
01309 return 2.0 * diff;
01310 }
|
|
||||||||||||
|
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. Definition at line 1312 of file colvarcomp.h. References colvarvalue::real_value. 01314 {
01315 cvm::real diff = x1.real_value - x2.real_value;
01316 if (period != 0.0) {
01317 cvm::real shift = std::floor (diff/period + 0.5);
01318 diff -= shift * period;
01319 }
01320 return (-2.0) * diff;
01321 }
|
|
|
Redefined to make use of the user-provided period.
Reimplemented from colvar::cvc. Definition at line 1329 of file colvarcomp.h. References colvarvalue::real_value. Referenced by calc_value(). 01330 {
01331 if (! this->b_periodic) {
01332 // don't wrap if the period has not been set
01333 return;
01334 }
01335
01336 cvm::real shift = std::floor ((x.real_value - wrap_center) / period + 0.5);
01337 x.real_value -= shift * period;
01338 return;
01339 }
|
|
|
Vector on which the distance vector is projected.
Definition at line 414 of file colvarcomp.h. Referenced by calc_gradients(), calc_value(), and distance_z(). |
|
|
Norm of the axis.
Definition at line 416 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 412 of file colvarcomp.h. Referenced by distance_z(). |
|
|
Use absolute positions, ignoring PBCs when present.
Definition at line 409 of file colvarcomp.h. Referenced by distance_z(). |
|
|
Vector distance, cached to be recycled.
Definition at line 418 of file colvarcomp.h. Referenced by calc_value(). |
|
|
Flag: using a fixed axis vector?
Definition at line 420 of file colvarcomp.h. Referenced by calc_force_invgrads(), and distance_z(). |
|
|
Main atom group.
Definition at line 403 of file colvarcomp.h. |
|
|
Reference atom group.
Definition at line 405 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 407 of file colvarcomp.h. Referenced by apply_force(), calc_gradients(), calc_value(), and distance_z(). |
1.3.9.1