version 1.16 | version 1.17 |
---|
| |
} | } |
| |
| |
| simple_scalar_dist_functions(distance) |
| |
| |
| |
colvar::distance_vec::distance_vec(std::string const &conf) | colvar::distance_vec::distance_vec(std::string const &conf) |
: distance(conf) | : distance(conf) |
| |
} | } |
| |
| |
| cvm::real colvar::distance_vec::dist2(colvarvalue const &x1, |
| colvarvalue const &x2) const |
| { |
| return cvm::position_dist2(x1.rvector_value, x2.rvector_value); |
| } |
| |
| |
| colvarvalue colvar::distance_vec::dist2_lgrad(colvarvalue const &x1, |
| colvarvalue const &x2) const |
| { |
| return 2.0 * cvm::position_distance(x2.rvector_value, x1.rvector_value); |
| } |
| |
| |
| colvarvalue colvar::distance_vec::dist2_rgrad(colvarvalue const &x1, |
| colvarvalue const &x2) const |
| { |
| return 2.0 * cvm::position_distance(x2.rvector_value, x1.rvector_value); |
| } |
| |
| |
| |
colvar::distance_z::distance_z(std::string const &conf) | colvar::distance_z::distance_z(std::string const &conf) |
: cvc(conf) | : cvc(conf) |
| |
| |
} | } |
| |
| |
colvar::distance_z::distance_z() | colvar::distance_z::distance_z() |
{ | { |
function_type = "distance_z"; | function_type = "distance_z"; |
| |
x.type(colvarvalue::type_scalar); | x.type(colvarvalue::type_scalar); |
} | } |
| |
| |
void colvar::distance_z::calc_value() | void colvar::distance_z::calc_value() |
{ | { |
if (fixed_axis) { | if (fixed_axis) { |
| |
this->wrap(x); | this->wrap(x); |
} | } |
| |
| |
void colvar::distance_z::calc_gradients() | void colvar::distance_z::calc_gradients() |
{ | { |
main->set_weighted_gradient( axis ); | main->set_weighted_gradient( axis ); |
| |
} | } |
} | } |
| |
| |
void colvar::distance_z::calc_force_invgrads() | void colvar::distance_z::calc_force_invgrads() |
{ | { |
main->read_total_forces(); | main->read_total_forces(); |
| |
} | } |
} | } |
| |
| |
void colvar::distance_z::calc_Jacobian_derivative() | void colvar::distance_z::calc_Jacobian_derivative() |
{ | { |
jd.real_value = 0.0; | jd.real_value = 0.0; |
} | } |
| |
| |
void colvar::distance_z::apply_force(colvarvalue const &force) | void colvar::distance_z::apply_force(colvarvalue const &force) |
{ | { |
if (!ref1->noforce) | if (!ref1->noforce) |
| |
} | } |
| |
| |
| // Differences should always be wrapped around 0 (ignoring wrap_center) |
| cvm::real colvar::distance_z::dist2(colvarvalue const &x1, |
| colvarvalue const &x2) const |
| { |
| cvm::real diff = x1.real_value - x2.real_value; |
| if (b_periodic) { |
| cvm::real shift = std::floor(diff/period + 0.5); |
| diff -= shift * period; |
| } |
| return diff * diff; |
| } |
| |
| |
| colvarvalue colvar::distance_z::dist2_lgrad(colvarvalue const &x1, |
| colvarvalue const &x2) const |
| { |
| cvm::real diff = x1.real_value - x2.real_value; |
| if (b_periodic) { |
| cvm::real shift = std::floor(diff/period + 0.5); |
| diff -= shift * period; |
| } |
| return 2.0 * diff; |
| } |
| |
| |
| colvarvalue colvar::distance_z::dist2_rgrad(colvarvalue const &x1, |
| colvarvalue const &x2) const |
| { |
| cvm::real diff = x1.real_value - x2.real_value; |
| if (b_periodic) { |
| cvm::real shift = std::floor(diff/period + 0.5); |
| diff -= shift * period; |
| } |
| return (-2.0) * diff; |
| } |
| |
| |
| void colvar::distance_z::wrap(colvarvalue &x) const |
| { |
| if (!b_periodic) { |
| // don't wrap if the period has not been set |
| return; |
| } |
| |
| cvm::real shift = std::floor((x.real_value - wrap_center) / period + 0.5); |
| x.real_value -= shift * period; |
| return; |
| } |
| |
| |
| |
colvar::distance_xy::distance_xy(std::string const &conf) | colvar::distance_xy::distance_xy(std::string const &conf) |
: distance_z(conf) | : distance_z(conf) |
| |
x.type(colvarvalue::type_scalar); | x.type(colvarvalue::type_scalar); |
} | } |
| |
| |
colvar::distance_xy::distance_xy() | colvar::distance_xy::distance_xy() |
: distance_z() | : distance_z() |
{ | { |
| |
x.type(colvarvalue::type_scalar); | x.type(colvarvalue::type_scalar); |
} | } |
| |
| |
void colvar::distance_xy::calc_value() | void colvar::distance_xy::calc_value() |
{ | { |
if (b_no_PBC) { | if (b_no_PBC) { |
| |
x.real_value = dist_v_ortho.norm(); | x.real_value = dist_v_ortho.norm(); |
} | } |
| |
| |
void colvar::distance_xy::calc_gradients() | void colvar::distance_xy::calc_gradients() |
{ | { |
// Intermediate quantity (r_P3 / r_12 where P is the projection | // Intermediate quantity (r_P3 / r_12 where P is the projection |
| |
} | } |
} | } |
| |
| |
void colvar::distance_xy::calc_force_invgrads() | void colvar::distance_xy::calc_force_invgrads() |
{ | { |
main->read_total_forces(); | main->read_total_forces(); |
| |
} | } |
} | } |
| |
| |
void colvar::distance_xy::calc_Jacobian_derivative() | void colvar::distance_xy::calc_Jacobian_derivative() |
{ | { |
jd.real_value = x.real_value ? (1.0 / x.real_value) : 0.0; | jd.real_value = x.real_value ? (1.0 / x.real_value) : 0.0; |
} | } |
| |
| |
void colvar::distance_xy::apply_force(colvarvalue const &force) | void colvar::distance_xy::apply_force(colvarvalue const &force) |
{ | { |
if (!ref1->noforce) | if (!ref1->noforce) |
| |
} | } |
| |
| |
| simple_scalar_dist_functions(distance_xy) |
| |
| |
| |
colvar::distance_dir::distance_dir(std::string const &conf) | colvar::distance_dir::distance_dir(std::string const &conf) |
: distance(conf) | : distance(conf) |
| |
x.type(colvarvalue::type_scalar); | x.type(colvarvalue::type_scalar); |
} | } |
| |
| |
colvar::distance_inv::distance_inv() | colvar::distance_inv::distance_inv() |
{ | { |
function_type = "distance_inv"; | function_type = "distance_inv"; |
| |
x.type(colvarvalue::type_scalar); | x.type(colvarvalue::type_scalar); |
} | } |
| |
| |
void colvar::distance_inv::calc_value() | void colvar::distance_inv::calc_value() |
{ | { |
x.real_value = 0.0; | x.real_value = 0.0; |
| |
x.real_value = std::pow(x.real_value, -1.0/(cvm::real(exponent))); | x.real_value = std::pow(x.real_value, -1.0/(cvm::real(exponent))); |
} | } |
| |
| |
void colvar::distance_inv::calc_gradients() | void colvar::distance_inv::calc_gradients() |
{ | { |
cvm::real const dxdsum = (-1.0/(cvm::real(exponent))) * std::pow(x.real_value, exponent+1) / cvm::real(group1->size() * group2->size()); | cvm::real const dxdsum = (-1.0/(cvm::real(exponent))) * std::pow(x.real_value, exponent+1) / cvm::real(group1->size() * group2->size()); |
| |
} | } |
} | } |
| |
| |
void colvar::distance_inv::apply_force(colvarvalue const &force) | void colvar::distance_inv::apply_force(colvarvalue const &force) |
{ | { |
if (!group1->noforce) | if (!group1->noforce) |
| |
} | } |
| |
| |
| simple_scalar_dist_functions(distance_inv) |
| |
| |
| |
colvar::distance_pairs::distance_pairs(std::string const &conf) | colvar::distance_pairs::distance_pairs(std::string const &conf) |
: cvc(conf) | : cvc(conf) |
| |
} | } |
} | } |
| |
| |
void colvar::distance_pairs::calc_gradients() | void colvar::distance_pairs::calc_gradients() |
{ | { |
// will be calculated on the fly in apply_force() | // will be calculated on the fly in apply_force() |
} | } |
| |
| |
void colvar::distance_pairs::apply_force(colvarvalue const &force) | void colvar::distance_pairs::apply_force(colvarvalue const &force) |
{ | { |
if (b_no_PBC) { | if (b_no_PBC) { |
| |
} | } |
| |
| |
| |
colvar::gyration::gyration(std::string const &conf) | colvar::gyration::gyration(std::string const &conf) |
: cvc(conf) | : cvc(conf) |
{ | { |
| |
} | } |
| |
| |
| simple_scalar_dist_functions(gyration) |
| |
| |
| |
colvar::inertia::inertia(std::string const &conf) | colvar::inertia::inertia(std::string const &conf) |
: gyration(conf) | : gyration(conf) |
| |
} | } |
| |
| |
| simple_scalar_dist_functions(inertia_z) |
| |
| |
| |
colvar::inertia_z::inertia_z(std::string const &conf) | colvar::inertia_z::inertia_z(std::string const &conf) |
: inertia(conf) | : inertia(conf) |
{ | { |
| |
} | } |
| |
| |
| simple_scalar_dist_functions(inertia) |
| |
| |
| |
| |
colvar::rmsd::rmsd(std::string const &conf) | colvar::rmsd::rmsd(std::string const &conf) |
: cvc(conf) | : cvc(conf) |
| |
} | } |
| |
| |
| simple_scalar_dist_functions(rmsd) |
| |
| |
| |
colvar::eigenvector::eigenvector(std::string const &conf) | colvar::eigenvector::eigenvector(std::string const &conf) |
| |
} | } |
| |
| |
| simple_scalar_dist_functions(eigenvector) |
| |
| |
| |
colvar::cartesian::cartesian(std::string const &conf) | colvar::cartesian::cartesian(std::string const &conf) |
: cvc(conf) | : cvc(conf) |
{ | { |