ADiheRestraint Class Reference

#include <FreeEnergyRestrain.h>

Inheritance diagram for ADiheRestraint:

ARestraint ABoundDiheRestraint AFixedDiheRestraint AForcingDiheRestraint List of all members.

Public Member Functions

 ADiheRestraint ()
void PrintInfo ()
virtual Bool_t TwoTargets ()=0
virtual double GetDiheTarget1 ()=0
virtual double GetDiheTarget2 ()=0

Protected Member Functions

double GetE (double RefDihe, double Const)
AVector GetGrad (int WhichGroup, double RefDihe, double Const)
AVector gradU (AVector &P1P2P3, AVector &P4P5P6, AVector &dP1, AVector &dP2, AVector &dP3, AVector &dP4, AVector &dP5, AVector &dP6)

Detailed Description

Definition at line 146 of file FreeEnergyRestrain.h.


Constructor & Destructor Documentation

ADiheRestraint::ADiheRestraint (  ) 

Definition at line 537 of file FreeEnergyRestrain.C.

References ARestraint::m_NumGroups, ARestraint::m_pCOMs, and ARestraint::m_pGroups.

00537                                {
00538 //----------------------------------------------------------------------------
00539 // each ADiheRestraint restrains the dihedral angle between 4 groups of atoms
00540 //----------------------------------------------------------------------------
00541   m_NumGroups = 4;
00542   m_pGroups = new AGroup[m_NumGroups];
00543   m_pCOMs = new AVector[m_NumGroups];
00544 }


Member Function Documentation

virtual double ADiheRestraint::GetDiheTarget1 (  )  [pure virtual]

Implemented in AFixedDiheRestraint, ABoundDiheRestraint, and AForcingDiheRestraint.

Referenced by PrintInfo().

virtual double ADiheRestraint::GetDiheTarget2 (  )  [pure virtual]

Implemented in AFixedDiheRestraint, ABoundDiheRestraint, and AForcingDiheRestraint.

Referenced by PrintInfo().

double ADiheRestraint::GetE ( double  RefDihe,
double  Const 
) [protected]

Definition at line 587 of file FreeEnergyRestrain.C.

References ARestraint::GetDihe(), and ARestraint::m_pCOMs.

Referenced by AForcingDiheRestraint::GetEnergy(), ABoundDiheRestraint::GetEnergy(), and AFixedDiheRestraint::GetEnergy().

00587                                                          {
00588 //---------------------------------------------------------------------------
00589 // calculate and return the Energy for this angle restraint.
00590 //
00591 //    E = (E0/2) * (1 - cos(Chi - ChiRef))
00592 //
00593 // where Chi is the dihedral angle between 4 centers-of-mass of restrained atoms,
00594 // m_pCOMs[0] -- m_pCOMs[1] -- m_pCOMs[2] -- m_pCOMs[3].
00595 // ChiRef is the reference angle.
00596 //
00597 // Note:  COM's are calculated before this routine is called.
00598 //---------------------------------------------------------------------------
00599   double  Angle;
00600 
00601   Angle = GetDihe(m_pCOMs[0], m_pCOMs[1], m_pCOMs[2], m_pCOMs[3]);
00602   return( (Const/2.0) * (1.0 - cos(Angle-RefAngle)) );
00603 }

AVector ADiheRestraint::GetGrad ( int  WhichGroup,
double  RefDihe,
double  Const 
) [protected]

Definition at line 606 of file FreeEnergyRestrain.C.

References A, ASSERT, B, AVector::cross(), AVector::Dist(), AVector::dot(), ARestraint::GetDihe(), gradU(), kAlmostMinusOne, kAlmostOne, ARestraint::m_pCOMs, and AVector::Set().

Referenced by AForcingDiheRestraint::GetGradient(), ABoundDiheRestraint::GetGradient(), and AFixedDiheRestraint::GetGradient().

00607                                                                {
00608 //---------------------------------------------------------------------------
00609 // calculate and return the gradient for this dihedral angle restraint.
00610 //
00611 //    E = (E0/2) * (1 - cos(Chi - ChiRef))
00612 //
00613 // return:  grad(E)
00614 //
00615 // Notes: COM's are calculated before this routine is called.
00616 //---------------------------------------------------------------------------
00617   AVector A, B, C, D;
00618 
00619   ASSERT((WhichGroup==0)||(WhichGroup==1)||(WhichGroup==2)||(WhichGroup==3));
00620 
00621   if ((WhichGroup==0) || (WhichGroup==1)) {
00622     A = m_pCOMs[0];
00623     B = m_pCOMs[1];
00624     C = m_pCOMs[2];
00625     D = m_pCOMs[3];
00626   }
00627   // re-state the problem so the gradient is solved for either atoms 0 or 1
00628   else {
00629     A = m_pCOMs[3];
00630     B = m_pCOMs[2];
00631     C = m_pCOMs[1];
00632     D = m_pCOMs[0];
00633     if (WhichGroup==3) {WhichGroup=0;}
00634     if (WhichGroup==2) {WhichGroup=1;}
00635   }
00636 
00637   AVector CD(D - C);
00638   AVector CB(B - C);
00639   AVector BC(C - B);
00640   AVector BA(A - B);
00641   AVector AC(C - A);
00642   AVector CDxCB, BCxBA;
00643   AVector Vec;
00644   double  phi;
00645   double  top, bot, u;
00646 
00647   CDxCB = CD.cross(CB);
00648   BCxBA = BC.cross(BA);
00649 
00650   top = CDxCB.dot(BCxBA);
00651   bot = CDxCB.Dist() * BCxBA.Dist();
00652 
00653   u = top/bot;
00654   // protect against acos(<-1.0), acos(>1.0), sqrt(<0), and divide by 0
00655   if (u < kAlmostMinusOne) {u = kAlmostMinusOne;}
00656   if (u > kAlmostOne)      {u = kAlmostOne;}
00657 
00658   // get dihedral using atan
00659   phi = GetDihe(A,B,C,D);
00660 
00661   AVector dP1, dP2, dP3;
00662   AVector dP4, dP5, dP6;
00663   ASSERT((WhichGroup==0) || (WhichGroup==1));
00664   if (WhichGroup==0) {
00665     dP1.Set( 0,      0,      0    );
00666     dP2.Set( 0,      0,      0    );
00667     dP3.Set( 0,      0,      0    );
00668     dP4.Set( 0,     -BC[2],  BC[1]);
00669     dP5.Set( BC[2],  0,     -BC[0]);
00670     dP6.Set(-BC[1],  BC[0],  0    );
00671   }
00672   else {
00673     dP1.Set( 0,     -CD[2],  CD[1]);
00674     dP2.Set( CD[2],  0,     -CD[0]);
00675     dP3.Set(-CD[1],  CD[0],  0    );
00676     dP4.Set( 0,      AC[2], -AC[1]);
00677     dP5.Set(-AC[2],  0,      AC[0]);
00678     dP6.Set( AC[1], -AC[0],  0    );
00679   }
00680 
00681   Vec = gradU(CDxCB, BCxBA, dP1, dP2, dP3, dP4, dP5, dP6);
00682   Vec *= (Const/2.0) * sin(phi-RefAngle) * (-1.0/sqrt(1.0 - u*u));
00683 
00684   // flip gradient for negative angles
00685   if (phi < 0) {
00686     Vec *= -1.0;
00687   }
00688   
00689   return(Vec);
00690 }

AVector ADiheRestraint::gradU ( AVector P1P2P3,
AVector P4P5P6,
AVector dP1,
AVector dP2,
AVector dP3,
AVector dP4,
AVector dP5,
AVector dP6 
) [protected]

Definition at line 693 of file FreeEnergyRestrain.C.

References AVector::Dist(), and AVector::dot().

Referenced by GetGrad().

00695                                                                               {
00696 //----------------------------------------------------------------
00697 // calculate the gradient for ((P1P2P3.dot.P4P5P6)/(mag(P1P2P3)*mag(P4P5P6)))
00698 // P1P2P3 = (P1)i + (P2)j + (P3)k
00699 // P4P5P6 = (P4)i + (P5)j + (P6)k
00700 // dP1 = (d(P1)/dx)i + (d(P1)/dy)j +(d(P1)/dz)k
00701 // dP2 = (d(P2)/dx)i + (d(P2)/dy)j +(d(P2)/dz)k
00702 // dP3 = (d(P3)/dx)i + (d(P3)/dy)j +(d(P3)/dz)k
00703 // dP4 = (d(P4)/dx)i + (d(P4)/dy)j +(d(P4)/dz)k
00704 // dP5 = (d(P5)/dx)i + (d(P5)/dy)j +(d(P5)/dz)k
00705 // dP6 = (d(P6)/dx)i + (d(P6)/dy)j +(d(P6)/dz)k
00706 //----------------------------------------------------------------
00707   double  Mag123, Mag456, Dot;
00708   double  Const1, Const2, Const3;
00709   double  P1, P2, P3, P4, P5, P6;
00710   AVector RetVec;
00711 
00712   P1 = P1P2P3[0];  P2 = P1P2P3[1];  P3 = P1P2P3[2];
00713   P4 = P4P5P6[0];  P5 = P4P5P6[1];  P6 = P4P5P6[2];
00714 
00715   Mag123 = P1P2P3.Dist();
00716   Mag456 = P4P5P6.Dist();
00717   Dot    = P1P2P3.dot(P4P5P6);
00718 
00719   Const1 =         1.0 / (Mag123*Mag456);
00720   Const2 = -Dot * (1.0 / (Mag123*Mag456*Mag456*Mag456));
00721   Const3 = -Dot * (1.0 / (Mag456*Mag123*Mag123*Mag123));
00722 
00723   RetVec = (dP4*P1 + dP1*P4 + dP5*P2 + dP2*P5 + dP6*P3 + dP3*P6) * Const1 +
00724            (dP4*P4 + dP5*P5 + dP6*P6)                            * Const2 +
00725            (dP1*P1 + dP2*P2 + dP3*P3)                            * Const3;
00726 
00727   return(RetVec);
00728 }

void ADiheRestraint::PrintInfo (  )  [virtual]

Implements ARestraint.

Definition at line 547 of file FreeEnergyRestrain.C.

References endi(), ARestraint::GetDihe(), GetDiheTarget1(), GetDiheTarget2(), iout, kPi, ARestraint::m_pCOMs, and TwoTargets().

00547                                {
00548 //--------------------------------------------------------------------
00549 // print the dihedral angle for this dihedral restraint
00550 //--------------------------------------------------------------------
00551   double  Dihedral;
00552   char    Str1[20], Str2[20], Str3[20];
00553 
00554   Dihedral = GetDihe(m_pCOMs[0], m_pCOMs[1], m_pCOMs[2], m_pCOMs[3]) * (180/kPi);
00555   sprintf(Str1, "%8.3f", Dihedral);
00556   Dihedral = GetDiheTarget1() * (180/kPi);
00557   sprintf(Str2, "%8.3f", Dihedral);
00558   Dihedral = GetDiheTarget2() * (180/kPi);
00559   sprintf(Str3, "%8.3f", Dihedral);
00560 
00561 #if defined(_VERBOSE_PMF)
00562   iout << "Dihedral = ";
00563   iout << Str1;
00564   iout << " degrees";
00565   iout << "  Target = ";
00566   iout << Str2;
00567   iout << " degrees";
00568   if (TwoTargets()) {
00569     iout << " to ";
00570     iout << Str3;
00571     iout << " degrees";
00572   }
00573   iout << std::endl << endi;
00574 #else
00575   iout << Str1;
00576   iout << "  ";
00577   iout << Str2;
00578   if (TwoTargets()) {
00579     iout << ", ";
00580     iout << Str3;
00581   }
00582   iout << " | ";
00583 #endif
00584 }

virtual Bool_t ADiheRestraint::TwoTargets (  )  [pure virtual]

Implemented in AFixedDiheRestraint, ABoundDiheRestraint, and AForcingDiheRestraint.

Referenced by PrintInfo().


The documentation for this class was generated from the following files:
Generated on Fri Jun 22 01:17:17 2018 for NAMD by  doxygen 1.4.7