ARestraintManager Class Reference

#include <FreeEnergyRMgr.h>

List of all members.

Public Member Functions

 ARestraintManager ()
 ~ARestraintManager ()
ARestraintoperator[] (int Index)
void Add (ARestraint *pRestraint)
int GetNumRestraints ()
void UpdateCOMs (GlobalMasterFreeEnergy &CFE)
void AddForces (GlobalMasterFreeEnergy &CFE)
void PrintEnergyInfo ()
void PrintRestraintInfo ()
void Print_dU_dLambda_Info ()
double Sum_dU_dLambdas ()
Bool_t ThereIsAForcingRestraint ()
void PrintPreInfo (int Index)
void SetLambdaKf (double LambdaKf)
void SetLambdaRef (double LambdaRef)
void SetLambdas (double LambdaKf, double LambdaRef)


Detailed Description

Definition at line 23 of file FreeEnergyRMgr.h.


Constructor & Destructor Documentation

ARestraintManager::ARestraintManager (  ) 

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 27 of file FreeEnergyRMgr.C.

References kNumToStart.

00027                                      {
00028 //------------------------------------------------------------------------
00029 // allocate space for restraint POINTERS
00030 //------------------------------------------------------------------------
00031   m_ppRestraints = new pRestr[kNumToStart];
00032   m_NumRestraints = 0;
00033   m_MaxNum = kNumToStart;
00034 }

ARestraintManager::~ARestraintManager (  ) 

Definition at line 37 of file FreeEnergyRMgr.C.

00037                                       {
00038 //------------------------------------------------------------------------
00039 // when the RestraintManager goes out of scope,
00040 // free the space that was allocated for each restraint
00041 // (see: ARestraint* GetRestraint(char*, int&)
00042 // then, free the space that was allocated for the pointers
00043 //------------------------------------------------------------------------
00044   for (int i=0; i<m_NumRestraints; i++) {
00045     delete m_ppRestraints[i];
00046   }
00047   delete []m_ppRestraints;
00048 }


Member Function Documentation

void ARestraintManager::Add ( ARestraint pRestraint  ) 

Definition at line 60 of file FreeEnergyRMgr.C.

References kMultiplier.

Referenced by ReadRestraints().

00060                                                   {
00061 //------------------------------------------------------------------------
00062 // add a pointer to the list.  if there's not enough room, make room.
00063 //------------------------------------------------------------------------
00064   ARestraint**  ppRestraints;
00065 
00066   // if there's no room for a new pointer
00067   if (m_NumRestraints == m_MaxNum) {
00068     // create an array with more space
00069     m_MaxNum *= kMultiplier;
00070     ppRestraints = new pRestr[m_MaxNum];
00071     // fast copy from the full array to the new one (memcpy(dest, src, bytes))
00072     memcpy(ppRestraints, m_ppRestraints, sizeof(ARestraint*)*m_NumRestraints);
00073     // return the space used for the full array
00074     delete []m_ppRestraints;
00075     // point to the bigger array
00076     m_ppRestraints = ppRestraints;
00077   }
00078 
00079   // add the int to the int array
00080   m_ppRestraints[m_NumRestraints] = pRestraint;
00081   m_NumRestraints++;
00082 }

void ARestraintManager::AddForces ( GlobalMasterFreeEnergy CFE  ) 

Definition at line 98 of file FreeEnergyRMgr.C.

References ARestraint::DistributeForce(), and j.

00098                                                              {
00099 //---------------------------------------------------------------------------
00100 // for each restraint, apply restraining force to each COM (center-of-mass).
00101 //---------------------------------------------------------------------------
00102   int      i, j, NumCOMs;
00103   AVector  Force;
00104 
00105   // for each restraint
00106   for (i=0; i<m_NumRestraints; i++) {
00107     // for each center-of-mass
00108     NumCOMs = m_ppRestraints[i]->GetNumGroups();
00109     for (j=0; j<NumCOMs; j++) {
00110       Force = m_ppRestraints[i]->GetGradient(j);
00111       // apply restraining force in opposite direction from gradient
00112       Force *= -1.0;
00113       m_ppRestraints[i]->DistributeForce(j, Force, CFE);
00114     }
00115   }
00116 }

int ARestraintManager::GetNumRestraints (  )  [inline]

Definition at line 35 of file FreeEnergyRMgr.h.

00035 {return(m_NumRestraints);}

ARestraint * ARestraintManager::operator[] ( int  Index  ) 

Definition at line 51 of file FreeEnergyRMgr.C.

References ASSERT.

00051                                                     {
00052 //------------------------------------------------------------------------
00053 // get a pointer
00054 //------------------------------------------------------------------------
00055   ASSERT( (Index>=0) && (Index<m_NumRestraints) );
00056   return(m_ppRestraints[Index]);
00057 }

void ARestraintManager::Print_dU_dLambda_Info (  ) 

Definition at line 175 of file FreeEnergyRMgr.C.

References endi(), ARestraint::Get_dU_dLambda(), iout, and PrintPreInfo().

00175                                               {
00176 //---------------------------------------------------------------------------
00177 // if restraint is a forcing restraint, print dU/dLambda.
00178 //---------------------------------------------------------------------------
00179 #if defined(_VERBOSE_PMF)
00180   for (int i=0; i<m_NumRestraints; i++) {
00181     if (m_ppRestraints[i]->IsForcing()) {
00182       PrintPreInfo(i);
00183       iout << "dU/dLambda = ";
00184       iout << m_ppRestraints[i]->Get_dU_dLambda() << std::endl << endi;
00185     }
00186   }
00187 #endif
00188 }

void ARestraintManager::PrintEnergyInfo (  ) 

Definition at line 145 of file FreeEnergyRMgr.C.

References endi(), ARestraint::GetEnergy(), iout, and PrintPreInfo().

00145                                         {
00146 //---------------------------------------------------------------------------
00147 // for a restraint, print restraint type and Energy.
00148 //---------------------------------------------------------------------------
00149 #if defined(_VERBOSE_PMF)
00150   for (int i=0; i<m_NumRestraints; i++) {
00151     PrintPreInfo(i);
00152     iout << "Energy = ";
00153     iout << m_ppRestraints[i]->GetEnergy() << std::endl << endi;
00154   }
00155 #endif
00156 }

void ARestraintManager::PrintPreInfo ( int  Index  ) 

Definition at line 191 of file FreeEnergyRMgr.C.

References ARestraint::GetStr(), and iout.

Referenced by Print_dU_dLambda_Info(), PrintEnergyInfo(), and PrintRestraintInfo().

00191                                               {
00192 //---------------------------------------------------------------------------
00193 // print "Restraint xxx:  Type of Restraint:  "
00194 //---------------------------------------------------------------------------
00195   char  Str[100];
00196   char  NumStr[20];
00197 
00198   sprintf(NumStr, "%3d", Index+1);
00199   iout << "FreeEnergy: " << "Restraint " << NumStr << ":  ";
00200   m_ppRestraints[Index]->GetStr(Str);
00201   iout << Str << ":  ";
00202 }

void ARestraintManager::PrintRestraintInfo (  ) 

Definition at line 159 of file FreeEnergyRMgr.C.

References endi(), iout, ARestraint::PrintInfo(), and PrintPreInfo().

00159                                            {
00160 //---------------------------------------------------------------------------
00161 // for a restraint, print its position, distance, angle, or dihedral angle.
00162 //---------------------------------------------------------------------------
00163   for (int i=0; i<m_NumRestraints; i++) {
00164 #if defined(_VERBOSE_PMF)
00165     PrintPreInfo(i);
00166 #endif
00167     m_ppRestraints[i]->PrintInfo();
00168   }
00169 #if !defined(_VERBOSE_PMF)
00170   iout << std::endl << endi;
00171 #endif
00172 }

void ARestraintManager::SetLambdaKf ( double  LambdaKf  )  [inline]

Definition at line 44 of file FreeEnergyRMgr.h.

References ARestraint::SetLambdaKf().

00044 {m_Dummy.SetLambdaKf(LambdaKf);}

void ARestraintManager::SetLambdaRef ( double  LambdaRef  )  [inline]

Definition at line 45 of file FreeEnergyRMgr.h.

References ARestraint::SetLambdaRef().

00045 {m_Dummy.SetLambdaRef(LambdaRef);}

void ARestraintManager::SetLambdas ( double  LambdaKf,
double  LambdaRef 
) [inline]

Definition at line 46 of file FreeEnergyRMgr.h.

References ARestraint::SetLambdaKf(), and ARestraint::SetLambdaRef().

00047   {
00048      m_Dummy.SetLambdaKf(LambdaKf);
00049      m_Dummy.SetLambdaRef(LambdaRef);
00050   }

double ARestraintManager::Sum_dU_dLambdas (  ) 

Definition at line 119 of file FreeEnergyRMgr.C.

00119                                           {
00120 //---------------------------------------------------------------------------
00121 // sum up dU/dLambda from each forcing restraint
00122 //---------------------------------------------------------------------------
00123   double Sum=0;
00124 
00125   for (int i=0; i<m_NumRestraints; i++) {
00126     Sum += m_ppRestraints[i]->Get_dU_dLambda();
00127   }
00128   return(Sum);
00129 }

Bool_t ARestraintManager::ThereIsAForcingRestraint (  ) 

Definition at line 132 of file FreeEnergyRMgr.C.

References kFalse, and kTrue.

00132                                                    {
00133 //---------------------------------------------------------------------------
00134 // return kTrue if there's at least one forcing restraint
00135 //---------------------------------------------------------------------------
00136   for (int i=0; i<m_NumRestraints; i++) {
00137     if (m_ppRestraints[i]->IsForcing()) {
00138       return(kTrue);
00139     }
00140   }
00141   return(kFalse);
00142 }

void ARestraintManager::UpdateCOMs ( GlobalMasterFreeEnergy CFE  ) 

Definition at line 85 of file FreeEnergyRMgr.C.

00085                                                               {
00086 //------------------------------------------------------------------------
00087 // update the centers-of-mass in each restraint in the list
00088 // note:  m_ppRestraints points to a list of restraint pointers
00089 //        m_ppRestraints[i] references one of the pointers
00090 //        m_ppRestraints[i]-> accesses a restraint function
00091 //------------------------------------------------------------------------
00092   for (int i=0; i<m_NumRestraints; i++) {
00093     m_ppRestraints[i]->UpdateCOMs(CFE);
00094   }
00095 }


The documentation for this class was generated from the following files:
Generated on Sat Sep 23 01:17:17 2017 for NAMD by  doxygen 1.4.7