NAMD
Public Member Functions | Protected Member Functions | List of all members
AnAngleRestraint Class Referenceabstract

#include <FreeEnergyRestrain.h>

Inheritance diagram for AnAngleRestraint:
ARestraint ABoundAngleRestraint AFixedAngleRestraint AForcingAngleRestraint

Public Member Functions

 AnAngleRestraint ()
 
void PrintInfo ()
 
virtual double GetAngleTarget ()=0
 
- Public Member Functions inherited from ARestraint
 ARestraint ()
 
virtual ~ARestraint ()
 
int GetNumGroups ()
 
void SetKf (double Kf)
 
double GetKf ()
 
void SetLambdaKf (double LambdaKf)
 
void SetLambdaRef (double LambdaRef)
 
double GetLambdaKf ()
 
double GetLambdaRef ()
 
void SetGroup (AGroup &Group, int GroupIndex)
 
void SetGroups (AGroup &Group1)
 
void SetGroups (AGroup &Group1, AGroup &Group2)
 
void SetGroups (AGroup &Group1, AGroup &Group2, AGroup &Group3)
 
void SetGroups (AGroup &Group1, AGroup &Group2, AGroup &Group3, AGroup &Group4)
 
void UpdateCOMs (GlobalMasterFreeEnergy &CFE)
 
void DistributeForce (int WhichGroup, AVector Force, GlobalMasterFreeEnergy &CFE)
 
virtual AVector GetGradient (int WhichGroup)=0
 
virtual double GetEnergy ()=0
 
virtual void GetStr (char *Str)=0
 
virtual Bool_t IsForcing ()
 
virtual double Get_dU_dLambda ()
 
virtual void SetRefPos (AVector)
 
virtual void SetRefDist (double)
 
virtual void SetRefAngle (double)
 
virtual void SetBound (Bound_t)
 
virtual void SetLowerAngle (double)
 
virtual void SetUpperAngle (double)
 
virtual void SetIntervalAngle (double)
 
virtual void SetStartPos (AVector)
 
virtual void SetStopPos (AVector)
 
virtual void SetStartDist (double)
 
virtual void SetStopDist (double)
 
virtual void SetStartAngle (double)
 
virtual void SetStopAngle (double)
 

Protected Member Functions

double GetE (double RefAngle, double LambdaKf=1.0)
 
AVector GetGrad (int WhichGroup, double RefAngle, double LambdaKf=1.0)
 
- Protected Member Functions inherited from ARestraint
double GetAngle (AVector &A, AVector &B, AVector &C)
 
double GetDihe (AVector &A, AVector &B, AVector &C, AVector &D)
 
void EarlyExit (const char *Str, int AtomID)
 

Additional Inherited Members

- Protected Attributes inherited from ARestraint
double m_Kf
 
int m_NumGroups
 
AGroupm_pGroups
 
AVectorm_pCOMs
 
- Static Protected Attributes inherited from ARestraint
static double m_LambdaKf = 1.0
 
static double m_LambdaRef = 0.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.

421  {
422 //-----------------------------------------------------------------------
423 // each AnAngleRestraint restrains the angle between 3 groups of atoms
424 //-----------------------------------------------------------------------
425  m_NumGroups = 3;
427  m_pCOMs = new AVector[m_NumGroups];
428 }
AGroup * m_pGroups
AVector * m_pCOMs

Member Function Documentation

virtual double AnAngleRestraint::GetAngleTarget ( )
pure virtual
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 AFixedAngleRestraint::GetEnergy(), ABoundAngleRestraint::GetEnergy(), and AForcingAngleRestraint::GetEnergy().

460  {
461 //---------------------------------------------------------------------------
462 // calculate and return the Energy for this angle restraint.
463 //
464 // E = (Kf/2) * (Theta-ThetaRef)**2
465 //
466 // where Theta is the angle between 3 centers-of-mass of restrained atoms,
467 // m_pCOMs[0] -- m_pCOMs[1] -- m_pCOMs[2].
468 // ThetaRef is the reference angle.
469 //
470 // Note: COM's are calculated before this routine is called.
471 //---------------------------------------------------------------------------
472  double Angle, Diff;
473 
474  Angle = GetAngle(m_pCOMs[0], m_pCOMs[1], m_pCOMs[2]);
475  Diff = Angle - RefAngle;
476  return( ((m_Kf*LambdaKf)/2.0) * (Diff*Diff) );
477 }
struct angle Angle
double GetAngle(AVector &A, AVector &B, AVector &C)
AVector * m_pCOMs
AVector AnAngleRestraint::GetGrad ( int  WhichGroup,
double  RefAngle,
double  LambdaKf = 1.0 
)
protected

Definition at line 480 of file FreeEnergyRestrain.C.

References A, ASSERT, B, AVector::Dist(), kAlmostOne, ARestraint::m_Kf, and ARestraint::m_pCOMs.

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

481  {
482 //---------------------------------------------------------------------------
483 // calculate and return the gradient for this angle restraint.
484 //
485 // E = (Kf/2) * (Theta-ThetaRef)**2
486 //
487 // return: grad(E)
488 //
489 // Notes: COM's are calculated before this routine is called.
490 //---------------------------------------------------------------------------
491  AVector A, B, C;
492  double Angle;
493  double a, b, c;
494  double u;
495  double Const1, Const2, Const3, Const4, Const5;
496  AVector Vec1, Vec2;
497 
498  ASSERT( (WhichGroup==0) || (WhichGroup==1) || (WhichGroup==2) );
499  A = m_pCOMs[0];
500  B = m_pCOMs[1];
501  C = m_pCOMs[2];
502 
503  a = B.Dist(C);
504  b = A.Dist(C);
505  c = A.Dist(B);
506 
507  u = (a*a + c*c - b*b) / (2.0*a*c);
508 
509  // protect against acos(<-1.0), acos(>1.0), sqrt(<0), and divide by 0
510  if (u < -1.0) {u = -1.0;}
511  if (u > kAlmostOne) {u = kAlmostOne;}
512  Angle = acos(u);
513 
514  Const1 = -1.0 / sqrt(1.0 - u*u);
515  Const2 = m_Kf * LambdaKf * (Angle-RefAngle) * Const1;
516 
517  Const3 = -a/(2.0*c*c) + 1.0/(a+a) + (b*b)/(2.0*a*c*c);
518  Const4 = -c/(2.0*a*a) + 1.0/(c+c) + (b*b)/(2.0*c*a*a);
519  Const5 = -b/(a*c);
520 
521  if (WhichGroup == 0) {
522  Vec1 = (A-C) * (Const5/b);
523  Vec2 = (A-B) * (Const3/c);
524  }
525  else if (WhichGroup == 1) {
526  Vec1 = (B-A) * (Const3/c);
527  Vec2 = (B-C) * (Const4/a);
528  }
529  else {
530  Vec1 = (C-A) * (Const5/b);
531  Vec2 = (C-B) * (Const4/a);
532  }
533  return( (Vec1+Vec2)*Const2);
534 }
struct angle Angle
const BigReal A
#define ASSERT(E)
const BigReal B
double Dist()
const double kAlmostOne
AVector * m_pCOMs
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.

431  {
432 //--------------------------------------------------------------------
433 // print the angle for this angle restraint
434 //--------------------------------------------------------------------
435  double Angle;
436  char Str1[20], Str2[20];
437 
438  Angle = GetAngle(m_pCOMs[0], m_pCOMs[1], m_pCOMs[2]) * (180/kPi);
439  sprintf(Str1, "%8.3f", Angle);
440  Angle = GetAngleTarget() * (180/kPi);
441  sprintf(Str2, "%8.3f", Angle);
442 
443 #if defined(_VERBOSE_PMF)
444  iout << "Angle = ";
445  iout << Str1;
446  iout << " degrees";
447  iout << " Target = ";
448  iout << Str2;
449  iout << " degrees";
450  iout << std::endl << endi;
451 #else
452  iout << Str1;
453  iout << " ";
454  iout << Str2;
455  iout << " | ";
456 #endif
457 }
struct angle Angle
#define iout
Definition: InfoStream.h:87
double GetAngle(AVector &A, AVector &B, AVector &C)
const double kPi
infostream & endi(infostream &s)
Definition: InfoStream.C:38
virtual double GetAngleTarget()=0
AVector * m_pCOMs

The documentation for this class was generated from the following files: