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 541 of file FreeEnergyRestrain.C.

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

00541                                {
00542 //----------------------------------------------------------------------------
00543 // each ADiheRestraint restrains the dihedral angle between 4 groups of atoms
00544 //----------------------------------------------------------------------------
00545   m_NumGroups = 4;
00546   m_pGroups = new AGroup[m_NumGroups];
00547   m_pCOMs = new AVector[m_NumGroups];
00548 }


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 591 of file FreeEnergyRestrain.C.

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

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

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

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

Definition at line 610 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().

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

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

Definition at line 697 of file FreeEnergyRestrain.C.

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

Referenced by GetGrad().

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

void ADiheRestraint::PrintInfo (  )  [virtual]

Implements ARestraint.

Definition at line 551 of file FreeEnergyRestrain.C.

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

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

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 Wed Sep 20 01:17:16 2017 for NAMD by  doxygen 1.4.7