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

Public Member Functions | |
| logmsd (std::string const &conf) | |
| Constructor. | |
| virtual | ~logmsd () |
| 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::real | ref_pos_sum2 |
| Sum of the squares of ref_coords. | |
| cvm::real | MSD |
Definition at line 934 of file colvarcomp.h.
|
|
Constructor.
Definition at line 657 of file colvarcomp_distances.C. References colvarvalue::norm2(), ref_pos_sum2, and colvarvalue::type(). 00658 : orientation (conf) 00659 { 00660 b_inverse_gradients = true; 00661 b_Jacobian_derivative = true; 00662 function_type = "logmsd"; 00663 x.type (colvarvalue::type_scalar); 00664 00665 ref_pos_sum2 = 0.0; 00666 for (size_t i = 0; i < ref_pos.size(); i++) { 00667 ref_pos_sum2 += ref_pos[i].norm2(); 00668 } 00669 }
|
|
|
Definition at line 947 of file colvarcomp.h. 00947 {}
|
|
|
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::orientation. Definition at line 707 of file colvarcomp_distances.C. References colvarmodule::atom_group::apply_colvar_force(), colvarmodule::atom_group::noforce, and colvarvalue::real_value. 00708 {
00709 if (!atoms.noforce)
00710 atoms.apply_colvar_force (force.real_value);
00711 }
|
|
|
Calculate the total force from the system using the inverse atomic gradients.
Reimplemented from colvar::cvc. Definition at line 714 of file colvarcomp_distances.C. References MSD, colvarmodule::atom_group::read_system_forces(), colvarvalue::real_value, and colvarmodule::atom_group::system_force(). 00715 {
00716 atoms.read_system_forces();
00717 ft.real_value = 0.0;
00718
00719 // Note: gradient square norm is 4.0 / (N_atoms * E)
00720
00721 for (size_t ia = 0; ia < atoms.size(); ia++) {
00722 ft.real_value += atoms[ia].grad * atoms[ia].system_force;
00723 }
00724 ft.real_value *= atoms.size() * MSD / 4.0;
00725 }
|
|
|
Calculate the atomic gradients, to be reused later in order to apply forces.
Reimplemented from colvar::orientation. Definition at line 697 of file colvarcomp_distances.C. References colvarmodule::rotation::dL0_2, MSD, and colvarmodule::real. 00698 {
00699 cvm::real fact = (MSD > 0.0) ? 2.0/(cvm::real (atoms.size()) * MSD) : 0.0;
00700
00701 for (size_t ia = 0; ia < atoms.size(); ia++) {
00702 atoms[ia].grad = fact * (atoms[ia].pos - atoms_cog - rot.dL0_2[ia]);
00703 }
00704 }
|
|
|
Calculate the divergence of the inverse atomic gradients.
Reimplemented from colvar::cvc. Definition at line 728 of file colvarcomp_distances.C. References colvarmodule::atom_pos, colvarmodule::rotation::dQ0_2, j, colvarmodule::rotation::q, and colvarvalue::real_value. 00729 {
00730 // divergence of the back-rotated target coordinates
00731 cvm::real divergence = 0.0;
00732
00733 // gradient of the rotation matrix
00734 cvm::matrix2d <cvm::rvector, 3, 3> grad_rot_mat;
00735
00736 // gradients of products of 2 quaternion components
00737 cvm::rvector g11, g22, g33, g01, g02, g03, g12, g13, g23;
00738
00739 for (size_t ia = 0; ia < atoms.size(); ia++) {
00740
00741 // Gradient of optimal quaternion wrt current Cartesian position
00742 cvm::vector1d< cvm::rvector, 4 > &dq = rot.dQ0_2[ia];
00743
00744 g11 = 2.0 * (rot.q)[1]*dq[1];
00745 g22 = 2.0 * (rot.q)[2]*dq[2];
00746 g33 = 2.0 * (rot.q)[3]*dq[3];
00747 g01 = (rot.q)[0]*dq[1] + (rot.q)[1]*dq[0];
00748 g02 = (rot.q)[0]*dq[2] + (rot.q)[2]*dq[0];
00749 g03 = (rot.q)[0]*dq[3] + (rot.q)[3]*dq[0];
00750 g12 = (rot.q)[1]*dq[2] + (rot.q)[2]*dq[1];
00751 g13 = (rot.q)[1]*dq[3] + (rot.q)[3]*dq[1];
00752 g23 = (rot.q)[2]*dq[3] + (rot.q)[3]*dq[2];
00753
00754 // Gradient of the rotation matrix wrt current Cartesian position
00755 // Note: we are only going to use "diagonal" terms: grad_rot_mat[i][j][i]
00756 grad_rot_mat[0][0] = -2.0 * (g22 + g33);
00757 grad_rot_mat[1][0] = 2.0 * (g12 + g03);
00758 grad_rot_mat[2][0] = 2.0 * (g13 - g02);
00759 grad_rot_mat[0][1] = 2.0 * (g12 - g03);
00760 grad_rot_mat[1][1] = -2.0 * (g11 + g33);
00761 grad_rot_mat[2][1] = 2.0 * (g01 + g23);
00762 grad_rot_mat[0][2] = 2.0 * (g02 + g13);
00763 grad_rot_mat[1][2] = 2.0 * (g23 - g01);
00764 grad_rot_mat[2][2] = -2.0 * (g11 + g22);
00765
00766 cvm::atom_pos &y = ref_pos[ia];
00767
00768 for (size_t i = 0; i < 3; i++) {
00769 for (size_t j = 0; j < 3; j++) {
00770 divergence += grad_rot_mat[i][j][i] * y[j];
00771 }
00772 }
00773 }
00774
00775 jd.real_value = (3.0 * atoms.size() - 3.0 - divergence) / 2.0;
00776 }
|
|
|
||||||||||||
|
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::orientation. |
|
||||||||||||
|
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::orientation. |
|
||||||||||||
|
Gradient (with respect to x1) of the square distance (can be redefined to transparently implement constraints, symmetries and periodicities).
Reimplemented from colvar::orientation. |
|
||||||||||||
|
Gradient (with respect to x2) of the square distance (can be redefined to transparently implement constraints, symmetries and periodicities).
Reimplemented from colvar::orientation. |
|
|
Definition at line 941 of file colvarcomp.h. Referenced by calc_force_invgrads(), calc_gradients(), and calc_value(). |
|
|
Sum of the squares of ref_coords.
Definition at line 940 of file colvarcomp.h. Referenced by calc_value(), and logmsd(). |
1.3.9.1