AnAngleRestraint Class Reference

#include <FreeEnergyRestrain.h>

Inheritance diagram for AnAngleRestraint:

ARestraint ABoundAngleRestraint AFixedAngleRestraint AForcingAngleRestraint List of all members.

Public Member Functions

 AnAngleRestraint ()
void PrintInfo ()
virtual double GetAngleTarget ()=0

Protected Member Functions

double GetE (double RefAngle, double LambdaKf=1.0)
AVector GetGrad (int WhichGroup, double RefAngle, double LambdaKf=1.0)

Detailed Description

Definition at line 132 of file FreeEnergyRestrain.h.


Constructor & Destructor Documentation

AnAngleRestraint::AnAngleRestraint (  ) 

Definition at line 421 of file FreeEnergyRestrain.C.

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

00421                                    {
00422 //-----------------------------------------------------------------------
00423 // each AnAngleRestraint restrains the angle between 3 groups of atoms
00424 //-----------------------------------------------------------------------
00425   m_NumGroups = 3;
00426   m_pGroups = new AGroup[m_NumGroups];
00427   m_pCOMs = new AVector[m_NumGroups];
00428 }


Member Function Documentation

virtual double AnAngleRestraint::GetAngleTarget (  )  [pure virtual]

Implemented in AFixedAngleRestraint, ABoundAngleRestraint, and AForcingAngleRestraint.

Referenced by PrintInfo().

double AnAngleRestraint::GetE ( double  RefAngle,
double  LambdaKf = 1.0 
) [protected]

Definition at line 460 of file FreeEnergyRestrain.C.

References ARestraint::GetAngle(), ARestraint::m_Kf, and ARestraint::m_pCOMs.

Referenced by AForcingAngleRestraint::GetEnergy(), ABoundAngleRestraint::GetEnergy(), and AFixedAngleRestraint::GetEnergy().

00460                                                               {
00461 //---------------------------------------------------------------------------
00462 // calculate and return the Energy for this angle restraint.
00463 //
00464 //     E = (Kf/2) * (Theta-ThetaRef)**2
00465 //
00466 // where Theta is the angle between 3 centers-of-mass of restrained atoms,
00467 // m_pCOMs[0] -- m_pCOMs[1] -- m_pCOMs[2].
00468 // ThetaRef is the reference angle.
00469 //
00470 // Note:  COM's are calculated before this routine is called.
00471 //---------------------------------------------------------------------------
00472   double Angle, Diff;
00473 
00474   Angle = GetAngle(m_pCOMs[0], m_pCOMs[1], m_pCOMs[2]);
00475   Diff = Angle - RefAngle;
00476   return( ((m_Kf*LambdaKf)/2.0) * (Diff*Diff) );
00477 }

AVector AnAngleRestraint::GetGrad ( int  WhichGroup,
double  RefAngle,
double  LambdaKf = 1.0 
) [protected]

Definition at line 480 of file FreeEnergyRestrain.C.

References A, ASSERT, B, kAlmostOne, ARestraint::m_Kf, and ARestraint::m_pCOMs.

Referenced by AForcingAngleRestraint::GetGradient(), ABoundAngleRestraint::GetGradient(), and AFixedAngleRestraint::GetGradient().

00481                                                                     {
00482 //---------------------------------------------------------------------------
00483 // calculate and return the gradient for this angle restraint.
00484 //
00485 //     E = (Kf/2) * (Theta-ThetaRef)**2
00486 //
00487 // return:  grad(E)
00488 //
00489 // Notes: COM's are calculated before this routine is called.
00490 //---------------------------------------------------------------------------
00491   AVector A, B, C;
00492   double  Angle;
00493   double  a, b, c;
00494   double  u;
00495   double  Const1, Const2, Const3, Const4, Const5;
00496   AVector Vec1, Vec2;
00497 
00498   ASSERT( (WhichGroup==0) || (WhichGroup==1) || (WhichGroup==2) );
00499   A = m_pCOMs[0];
00500   B = m_pCOMs[1];
00501   C = m_pCOMs[2];
00502 
00503   a = B.Dist(C);
00504   b = A.Dist(C);
00505   c = A.Dist(B);
00506 
00507   u = (a*a + c*c - b*b) / (2.0*a*c);
00508 
00509   // protect against acos(<-1.0), acos(>1.0), sqrt(<0), and divide by 0
00510   if (u < -1.0)       {u = -1.0;}
00511   if (u > kAlmostOne) {u = kAlmostOne;}
00512   Angle = acos(u);
00513 
00514   Const1 = -1.0 / sqrt(1.0 - u*u);
00515   Const2 = m_Kf * LambdaKf * (Angle-RefAngle) * Const1;
00516 
00517   Const3 = -a/(2.0*c*c) + 1.0/(a+a) + (b*b)/(2.0*a*c*c);
00518   Const4 = -c/(2.0*a*a) + 1.0/(c+c) + (b*b)/(2.0*c*a*a);
00519   Const5 = -b/(a*c);
00520 
00521   if (WhichGroup == 0) {
00522     Vec1 = (A-C) * (Const5/b);
00523     Vec2 = (A-B) * (Const3/c);
00524   }
00525   else if (WhichGroup == 1) {
00526     Vec1 = (B-A) * (Const3/c);
00527     Vec2 = (B-C) * (Const4/a);
00528   }
00529   else {
00530     Vec1 = (C-A) * (Const5/b);
00531     Vec2 = (C-B) * (Const4/a);
00532   }
00533   return( (Vec1+Vec2)*Const2);
00534 }

void AnAngleRestraint::PrintInfo (  )  [virtual]

Implements ARestraint.

Definition at line 431 of file FreeEnergyRestrain.C.

References endi(), ARestraint::GetAngle(), GetAngleTarget(), iout, kPi, and ARestraint::m_pCOMs.

00431                                  {
00432 //--------------------------------------------------------------------
00433 // print the angle for this angle restraint
00434 //--------------------------------------------------------------------
00435   double  Angle;
00436   char    Str1[20], Str2[20];
00437 
00438   Angle = GetAngle(m_pCOMs[0], m_pCOMs[1], m_pCOMs[2]) * (180/kPi);
00439   sprintf(Str1, "%8.3f", Angle);
00440   Angle = GetAngleTarget() * (180/kPi);
00441   sprintf(Str2, "%8.3f", Angle);
00442 
00443 #if defined(_VERBOSE_PMF)
00444   iout << "Angle = ";
00445   iout << Str1;
00446   iout << " degrees";
00447   iout << "  Target = ";
00448   iout << Str2;
00449   iout << " degrees";
00450   iout << std::endl << endi;
00451 #else
00452   iout << Str1;
00453   iout << "  ";
00454   iout << Str2;
00455   iout << " | ";
00456 #endif
00457 }


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