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

Public Member Functions | |
| orientation (std::string const &conf) | |
| orientation () | |
| virtual | ~orientation () |
| 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::atom_group | atoms |
| Atom group. | |
| cvm::atom_pos | atoms_cog |
| Center of geometry of the group. | |
| std::vector< cvm::atom_pos > | ref_pos |
| Reference coordinates. | |
| cvm::rotation | rot |
| Rotation object. | |
| cvm::quaternion | ref_quat |
| This is used to remove jumps in the sign of the quaternion, which may be annoying in the colvars trajectory. | |
Definition at line 832 of file colvarcomp.h.
|
|
Definition at line 11 of file colvarcomp_rotations.C. References atoms, colvarmodule::rotation::b_debug_gradients, colvarmodule::fatal_error(), colvarmodule::load_coords(), colvarmodule::log(), colvarmodule::atom_group::noforce, colvar::cvc::parse_group(), colvarmodule::real, ref_pos, ref_quat, colvarmodule::rotation::request_group2_gradients(), rot, and colvarvalue::type(). 00012 : cvc (conf) 00013 { 00014 function_type = "orientation"; 00015 parse_group (conf, "atoms", atoms); 00016 x.type (colvarvalue::type_quaternion); 00017 00018 ref_pos.reserve (atoms.size()); 00019 00020 if (get_keyval (conf, "refPositions", ref_pos, ref_pos)) { 00021 cvm::log ("Using reference positions from input file.\n"); 00022 if (ref_pos.size() != atoms.size()) { 00023 cvm::fatal_error ("Error: reference positions do not " 00024 "match the number of atom indexes.\n"); 00025 } 00026 } 00027 00028 { 00029 std::string file_name; 00030 if (get_keyval (conf, "refPositionsFile", file_name)) { 00031 00032 std::string file_col; 00033 get_keyval (conf, "refPositionsCol", file_col, std::string ("O")); 00034 00035 double file_col_value; 00036 bool found = get_keyval (conf, "refPositionsColValue", file_col_value, 0.0); 00037 if (found && !file_col_value) 00038 cvm::fatal_error ("Error: refPositionsColValue, " 00039 "if provided, must be non-zero.\n"); 00040 00041 ref_pos.resize (atoms.size()); 00042 cvm::load_coords (file_name.c_str(), ref_pos, file_col, file_col_value); 00043 } 00044 } 00045 00046 if (!ref_pos.size()) { 00047 cvm::fatal_error ("Error: must define a set of " 00048 "reference coordinates.\n"); 00049 } 00050 00051 00052 cvm::log ("Centering the reference coordinates: it is " 00053 "assumed that each atom is the closest " 00054 "periodic image to the center of geometry.\n"); 00055 cvm::rvector cog (0.0, 0.0, 0.0); 00056 for (size_t i = 0; i < ref_pos.size(); i++) { 00057 cog += ref_pos[i]; 00058 } 00059 cog /= cvm::real (ref_pos.size()); 00060 for (size_t i = 0; i < ref_pos.size(); i++) { 00061 ref_pos[i] -= cog; 00062 } 00063 00064 get_keyval (conf, "closestToQuaternion", ref_quat, cvm::quaternion (1.0, 0.0, 0.0, 0.0)); 00065 00066 // initialize rot member data 00067 if (!atoms.noforce) { 00068 rot.request_group2_gradients (atoms.size()); 00069 } 00070 00071 rot.b_debug_gradients = this->b_debug_gradients; 00072 }
|
|
|
Definition at line 75 of file colvarcomp_rotations.C. References colvarvalue::type(). 00076 : cvc () 00077 { 00078 function_type = "orientation"; 00079 x.type (colvarvalue::type_quaternion); 00080 }
|
|
|
Definition at line 856 of file colvarcomp.h. 00856 {}
|
|
|
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::orientation_angle, colvar::rmsd, and colvar::logmsd. Definition at line 109 of file colvarcomp_rotations.C. References colvarmodule::atom_group::apply_force(), atoms, colvarmodule::rotation::dQ0_2, colvarmodule::atom_group::noforce, colvarvalue::quaternion_value, and rot. 00110 {
00111 cvm::quaternion const &FQ = force.quaternion_value;
00112
00113 if (!atoms.noforce) {
00114 for (size_t ia = 0; ia < atoms.size(); ia++) {
00115 for (size_t i = 0; i < 4; i++) {
00116 atoms[ia].apply_force (FQ[i] * rot.dQ0_2[ia][i]);
00117 }
00118 }
00119 }
00120 }
|
|
|
Calculate the atomic gradients, to be reused later in order to apply forces.
Implements colvar::cvc. Reimplemented in colvar::orientation_angle, colvar::rmsd, and colvar::logmsd. Definition at line 100 of file colvarcomp_rotations.C. 00101 {
00102 // gradients have already been calculated and stored within the
00103 // member object "rot"; we're not using the "grad" member of each
00104 // atom object, because it only can represent the gradient of a
00105 // scalar colvar
00106 }
|
|
|
Calculate the variable.
Implements colvar::cvc. Reimplemented in colvar::orientation_angle, colvar::rmsd, and colvar::logmsd. Definition at line 83 of file colvarcomp_rotations.C. References atoms, atoms_cog, colvarmodule::rotation::calc_optimal_rotation(), colvarmodule::atom_group::center_of_geometry(), colvarmodule::atom_group::positions_shifted(), colvarmodule::rotation::q, colvarvalue::quaternion_value, colvarmodule::atom_group::read_positions(), ref_pos, ref_quat, colvarmodule::atom_group::reset_atoms_data(), and rot. 00084 {
00085 atoms.reset_atoms_data();
00086 atoms.read_positions();
00087
00088 atoms_cog = atoms.center_of_geometry();
00089
00090 rot.calc_optimal_rotation (ref_pos, atoms.positions_shifted (-1.0 * atoms_cog));
00091
00092 if ((rot.q).inner (ref_quat) >= 0.0) {
00093 x.quaternion_value = rot.q;
00094 } else {
00095 x.quaternion_value = -1.0 * rot.q;
00096 }
00097 }
|
|
||||||||||||
|
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::orientation_angle, colvar::rmsd, and colvar::logmsd. Definition at line 1098 of file colvarcomp.h. References colvarmodule::fatal_error(). 01100 {
01101 cvm::fatal_error ("Error: cannot compare() two quaternions.\n");
01102 return 0.0;
01103 }
|
|
||||||||||||
|
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::orientation_angle, colvar::rmsd, and colvar::logmsd. |
|
||||||||||||
|
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::orientation_angle, colvar::rmsd, and colvar::logmsd. Definition at line 1086 of file colvarcomp.h. References colvarmodule::quaternion::dist2_grad(), and colvarvalue::quaternion_value. 01088 {
01089 return x1.quaternion_value.dist2_grad (x2);
01090 }
|
|
||||||||||||
|
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::orientation_angle, colvar::rmsd, and colvar::logmsd. Definition at line 1092 of file colvarcomp.h. References colvarmodule::quaternion::dist2_grad(), and colvarvalue::quaternion_value. 01094 {
01095 return x2.quaternion_value.dist2_grad (x1);
01096 }
|
|
|
Atom group.
Definition at line 838 of file colvarcomp.h. Referenced by apply_force(), calc_value(), and orientation(). |
|
|
Center of geometry of the group.
Definition at line 840 of file colvarcomp.h. Referenced by calc_value(). |
|
|
Reference coordinates.
Definition at line 843 of file colvarcomp.h. Referenced by calc_value(), and orientation(). |
|
|
This is used to remove jumps in the sign of the quaternion, which may be annoying in the colvars trajectory.
Definition at line 850 of file colvarcomp.h. Referenced by calc_value(), and orientation(). |
|
|
Rotation object.
Definition at line 846 of file colvarcomp.h. Referenced by apply_force(), calc_value(), and orientation(). |
1.3.9.1