Ejemplo n.º 1
0
void colvar::distance_z::calc_gradients()
{
  main.set_weighted_gradient( axis );

  if (fixed_axis) {
    ref1.set_weighted_gradient(-1.0 * axis);
  } else {
    if (b_no_PBC) {
      ref1.set_weighted_gradient( 1.0 / axis_norm * (main.center_of_mass() - ref2.center_of_mass() -
                                   x.real_value * axis ));
      ref2.set_weighted_gradient( 1.0 / axis_norm * (ref1.center_of_mass() - main.center_of_mass() +
                                   x.real_value * axis ));
    } else {
      ref1.set_weighted_gradient( 1.0 / axis_norm * (
        cvm::position_distance(ref2.center_of_mass(), main.center_of_mass()) - x.real_value * axis ));
      ref2.set_weighted_gradient( 1.0 / axis_norm * (
        cvm::position_distance(main.center_of_mass(), ref1.center_of_mass()) + x.real_value * axis ));
    }
  }

  if (b_debug_gradients) {
    cvm::log("Debugging gradients for group main:\n");
    debug_gradients(main);
    cvm::log("Debugging gradients for group ref1:\n");
    debug_gradients(ref1);
    cvm::log("Debugging gradients for group ref2:\n");
    debug_gradients(ref2);
  }
}
Ejemplo n.º 2
0
void colvar::distance_pairs::calc_gradients()
{
  // will be calculated on the fly in apply_force()
  if (b_debug_gradients) {
    cvm::log("Debugging gradients:\n");
    debug_gradients(group1);
  }
}
Ejemplo n.º 3
0
void colvar::inertia_z::calc_gradients()
{
  for (cvm::atom_iter ai = atoms.begin(); ai != atoms.end(); ai++) {
    ai->grad = 2.0 * (ai->pos * axis) * axis;
  }

  if (b_debug_gradients) {
    cvm::log ("Debugging gradients:\n");
    debug_gradients (atoms);
  }
}
Ejemplo n.º 4
0
void colvar::eigenvector::calc_gradients()
{
  for (size_t ia = 0; ia < atoms.size(); ia++) {
    atoms[ia].grad = eigenvec[ia];
  }

  if (b_debug_gradients) {
    cvm::log ("Debugging gradients:\n");
    debug_gradients (atoms);
  }
}
Ejemplo n.º 5
0
void colvar::orientation_proj::calc_gradients()
{
  cvm::real const dxdq0 = 2.0 * 2.0 * (rot.q).q0;
  for (size_t ia = 0; ia < atoms.size(); ia++) {
    atoms[ia].grad = (dxdq0 * (rot.dQ0_2[ia])[0]);
  }
  if (b_debug_gradients) {
    cvm::log("Debugging orientationProj component gradients:\n");
    debug_gradients(atoms);
  }
}
Ejemplo n.º 6
0
void colvar::gyration::calc_gradients()
{
  cvm::real const drdx = 1.0/(cvm::real (atoms.size()) * x.real_value);
  for (cvm::atom_iter ai = atoms.begin(); ai != atoms.end(); ai++) {
    ai->grad = drdx * ai->pos;
  }

  if (b_debug_gradients) {
    cvm::log ("Debugging gradients:\n");
    debug_gradients (atoms);
  }
}
Ejemplo n.º 7
0
void colvar::angle::calc_gradients()
{
  cvm::real const cos_theta = (r21*r23)/(r21l*r23l);
  cvm::real const dxdcos = -1.0 / std::sqrt(1.0 - cos_theta*cos_theta);

  dxdr1 = (180.0/PI) * dxdcos *
    (1.0/r21l) * ( r23/r23l + (-1.0) * cos_theta * r21/r21l );

  dxdr3 = (180.0/PI) * dxdcos *
    (1.0/r23l) * ( r21/r21l + (-1.0) * cos_theta * r23/r23l );

  group1->set_weighted_gradient(dxdr1);
  group2->set_weighted_gradient((dxdr1 + dxdr3) * (-1.0));
  group3->set_weighted_gradient(dxdr3);

  if (is_enabled(f_cvc_debug_gradient)) {
    debug_gradients(group1);
    debug_gradients(group2);
    debug_gradients(group3);
  }
}
Ejemplo n.º 8
0
void colvar::rmsd::calc_gradients()
{
  cvm::real const drmsddx2 = (x.real_value > 0.0) ?
    0.5 / (x.real_value * cvm::real (atoms.size())) :
    0.0;

  for (size_t ia = 0; ia < atoms.size(); ia++) {
    atoms[ia].grad = (drmsddx2 * 2.0 * (atoms[ia].pos - ref_pos[ia]));
  }

  if (b_debug_gradients) {
    cvm::log ("Debugging gradients:\n");
    debug_gradients (atoms);
  }
}
Ejemplo n.º 9
0
void colvar::orientation_angle::calc_gradients()
{
  cvm::real const dxdq0 =
    ( ((rot.q).q0 * (rot.q).q0 < 1.0) ?
      ((180.0 / PI) * (-2.0) / std::sqrt(1.0 - ((rot.q).q0 * (rot.q).q0))) :
      0.0 );

  for (size_t ia = 0; ia < atoms.size(); ia++) {
    atoms[ia].grad = (dxdq0 * (rot.dQ0_2[ia])[0]);
  }
  if (b_debug_gradients) {
    cvm::log("Debugging orientationAngle component gradients:\n");
    debug_gradients(atoms);
  }
}
Ejemplo n.º 10
0
void colvar::tilt::calc_gradients()
{
  cvm::quaternion const dxdq = rot.dcos_theta_dq(axis);

  for (size_t ia = 0; ia < atoms.size(); ia++) {
    atoms[ia].grad = cvm::rvector(0.0, 0.0, 0.0);
    for (size_t iq = 0; iq < 4; iq++) {
      atoms[ia].grad += (dxdq[iq] * (rot.dQ0_2[ia])[iq]);
    }
  }

  if (b_debug_gradients) {
    cvm::log("Debugging tilt component gradients:\n");
    debug_gradients(atoms);
  }
}