| 1 | 
< | 
 /* | 
| 1 | 
> | 
/* | 
| 2 | 
  | 
 * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. | 
| 3 | 
  | 
 * | 
| 4 | 
  | 
 * The University of Notre Dame grants you ("Licensee") a | 
| 43 | 
  | 
 | 
| 44 | 
  | 
namespace oopse { | 
| 45 | 
  | 
 | 
| 46 | 
< | 
GhostTorsion::GhostTorsion(Atom *atom1, Atom *atom2,  DirectionalAtom* ghostAtom, | 
| 47 | 
< | 
                 TorsionType *tt) : Torsion(atom1, atom2, ghostAtom, ghostAtom, tt) {} | 
| 46 | 
> | 
  GhostTorsion::GhostTorsion(Atom *atom1, Atom *atom2,  DirectionalAtom* ghostAtom, | 
| 47 | 
> | 
                             TorsionType *tt) : Torsion(atom1, atom2, ghostAtom, ghostAtom, tt) {} | 
| 48 | 
  | 
 | 
| 49 | 
< | 
void GhostTorsion::calcForce() { | 
| 50 | 
< | 
    DirectionalAtom* ghostAtom = static_cast<DirectionalAtom*>(atom2_);     | 
| 49 | 
> | 
  void GhostTorsion::calcForce(double& angle) { | 
| 50 | 
> | 
    DirectionalAtom* ghostAtom = static_cast<DirectionalAtom*>(atom3_);     | 
| 51 | 
  | 
 | 
| 52 | 
  | 
    Vector3d pos1 = atom1_->getPos(); | 
| 53 | 
  | 
    Vector3d pos2 = atom2_->getPos(); | 
| 71 | 
  | 
     | 
| 72 | 
  | 
    //  Calculate the sin and cos | 
| 73 | 
  | 
    double cos_phi = dot(A, B) ; | 
| 74 | 
– | 
    double sin_phi = dot(C, B); | 
| 74 | 
  | 
 | 
| 75 | 
< | 
    double dVdPhi; | 
| 76 | 
< | 
    torsionType_->calcForce(cos_phi, sin_phi, potential_, dVdPhi); | 
| 75 | 
> | 
    double dVdcosPhi; | 
| 76 | 
> | 
    torsionType_->calcForce(cos_phi, potential_, dVdcosPhi); | 
| 77 | 
  | 
 | 
| 78 | 
  | 
    Vector3d dcosdA = (cos_phi * A - B) /rA; | 
| 79 | 
  | 
    Vector3d dcosdB = (cos_phi * B - A) /rB; | 
| 80 | 
  | 
 | 
| 82 | 
– | 
    double dVdcosPhi = -dVdPhi / sin_phi; | 
| 83 | 
– | 
 | 
| 81 | 
  | 
    Vector3d f1 = dVdcosPhi * cross(r32, dcosdA); | 
| 82 | 
  | 
    Vector3d f2 = dVdcosPhi * ( cross(r43, dcosdB) - cross(r21, dcosdA)); | 
| 83 | 
  | 
    Vector3d f3 = dVdcosPhi * cross(dcosdB, r32); | 
| 89 | 
  | 
 | 
| 90 | 
  | 
    f3.negate(); | 
| 91 | 
  | 
    ghostAtom->addTrq(cross(r43, f3));     | 
| 95 | 
– | 
} | 
| 92 | 
  | 
 | 
| 93 | 
+ | 
    angle = acos(cos_phi) /M_PI * 180.0; | 
| 94 | 
+ | 
  } | 
| 95 | 
+ | 
 | 
| 96 | 
  | 
} | 
| 97 | 
  | 
 |