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

Public Member Functions | |
| min_distance (std::string const &conf) | |
| min_distance () | |
| virtual | ~min_distance () |
| 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 |
| 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::real | smoothing |
| Components of the distance vector orthogonal to the axis. | |
Definition at line 458 of file colvarcomp.h.
|
|
Definition at line 335 of file colvarcomp_distances.C. References smoothing, and colvarvalue::type(). 00336 : distance (conf) 00337 { 00338 function_type = "min_distance"; 00339 x.type (colvarvalue::type_scalar); 00340 00341 get_keyval (conf, "smoothing", smoothing, (1.0 * cvm::unit_angstrom())); 00342 }
|
|
|
Definition at line 344 of file colvarcomp_distances.C. References colvarvalue::type(). 00345 : distance() 00346 { 00347 function_type = "min_distance"; 00348 x.type (colvarvalue::type_scalar); 00349 }
|
|
|
Definition at line 467 of file colvarcomp.h. 00467 {}
|
|
|
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
Reimplemented from colvar::distance. Definition at line 401 of file colvarcomp_distances.C. References colvarmodule::atom_group::apply_colvar_force(), colvarmodule::atom_group::noforce, and colvarvalue::real_value. 00402 {
00403 if (!group1.noforce)
00404 group1.apply_colvar_force (force.real_value);
00405
00406 if (!group2.noforce)
00407 group2.apply_colvar_force (force.real_value);
00408 }
|
|
|
Calculate the atomic gradients, to be reused later in order to apply forces.
Reimplemented from colvar::distance. Definition at line 377 of file colvarcomp_distances.C. References colvarmodule::rvector::norm(), colvarmodule::position_distance(), colvarvalue::real_value, and smoothing. 00378 {
00379 if (x.real_value > 0.0) {
00380 cvm::real const sum = ::exp (smoothing/x.real_value);
00381 cvm::real const dxdsum = -1.0 *
00382 (x.real_value/smoothing) * (x.real_value/smoothing) *
00383 (1.0 / sum);
00384
00385 for (cvm::atom_iter ai1 = group1.begin(); ai1 != group1.end(); ai1++) {
00386 for (cvm::atom_iter ai2 = group2.begin(); ai2 != group2.end(); ai2++) {
00387 cvm::rvector const dv = cvm::position_distance (ai1->pos, ai2->pos);
00388 cvm::real const d = dv.norm();
00389 if (d > 0.0) {
00390 cvm::rvector const dvu = dv / dv.norm();
00391 ai1->grad += dxdsum * ::exp (smoothing / d) *
00392 smoothing * (-1.0/(d*d)) * (-1.0) * dvu;
00393 ai2->grad += dxdsum * ::exp (smoothing / d) *
00394 smoothing * (-1.0/(d*d)) * dvu;
00395 }
00396 }
00397 }
00398 }
00399 }
|
|
|
Calculate the variable.
Reimplemented from colvar::distance. Definition at line 351 of file colvarcomp_distances.C. References colvarmodule::rvector::norm(), colvarmodule::position_distance(), colvarmodule::atom_group::read_positions(), colvarvalue::real_value, colvarmodule::atom_group::reset_atoms_data(), and smoothing. 00352 {
00353 group1.reset_atoms_data();
00354 group2.reset_atoms_data();
00355
00356 group1.read_positions();
00357 group2.read_positions();
00358
00359 x.real_value = 0.0;
00360
00361 bool zero_dist = false;
00362
00363 for (cvm::atom_iter ai1 = group1.begin(); ai1 != group1.end(); ai1++) {
00364 for (cvm::atom_iter ai2 = group2.begin(); ai2 != group2.end(); ai2++) {
00365 cvm::rvector const dv = cvm::position_distance (ai1->pos, ai2->pos);
00366 cvm::real const d = dv.norm();
00367 if (d > 0.0)
00368 x.real_value += ::exp (smoothing / d);
00369 else
00370 zero_dist = true;
00371 }
00372 }
00373
00374 x.real_value = zero_dist ? 0.0 : smoothing/(::log (x.real_value));
00375 }
|
|
||||||||||||
|
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. |
|
||||||||||||
|
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. |
|
||||||||||||
|
Gradient (with respect to x1) of the square distance (can be redefined to transparently implement constraints, symmetries and periodicities).
Reimplemented from colvar::distance. |
|
||||||||||||
|
Gradient (with respect to x2) of the square distance (can be redefined to transparently implement constraints, symmetries and periodicities).
Reimplemented from colvar::distance. |
|
|
Components of the distance vector orthogonal to the axis.
Definition at line 463 of file colvarcomp.h. Referenced by calc_gradients(), calc_value(), and min_distance(). |
1.3.9.1