NAMD
Public Member Functions | List of all members
ARestraintManager Class Reference

#include <FreeEnergyRMgr.h>

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.

27  {
28 //------------------------------------------------------------------------
29 // allocate space for restraint POINTERS
30 //------------------------------------------------------------------------
31  m_ppRestraints = new pRestr[kNumToStart];
32  m_NumRestraints = 0;
33  m_MaxNum = kNumToStart;
34 }
const int kNumToStart
ARestraintManager::~ARestraintManager ( )

Definition at line 37 of file FreeEnergyRMgr.C.

37  {
38 //------------------------------------------------------------------------
39 // when the RestraintManager goes out of scope,
40 // free the space that was allocated for each restraint
41 // (see: ARestraint* GetRestraint(char*, int&)
42 // then, free the space that was allocated for the pointers
43 //------------------------------------------------------------------------
44  for (int i=0; i<m_NumRestraints; i++) {
45  delete m_ppRestraints[i];
46  }
47  delete []m_ppRestraints;
48 }

Member Function Documentation

void ARestraintManager::Add ( ARestraint pRestraint)

Definition at line 60 of file FreeEnergyRMgr.C.

References kMultiplier.

Referenced by ReadRestraints().

60  {
61 //------------------------------------------------------------------------
62 // add a pointer to the list. if there's not enough room, make room.
63 //------------------------------------------------------------------------
64  ARestraint** ppRestraints;
65 
66  // if there's no room for a new pointer
67  if (m_NumRestraints == m_MaxNum) {
68  // create an array with more space
69  m_MaxNum *= kMultiplier;
70  ppRestraints = new pRestr[m_MaxNum];
71  // fast copy from the full array to the new one (memcpy(dest, src, bytes))
72  memcpy(ppRestraints, m_ppRestraints, sizeof(ARestraint*)*m_NumRestraints);
73  // return the space used for the full array
74  delete []m_ppRestraints;
75  // point to the bigger array
76  m_ppRestraints = ppRestraints;
77  }
78 
79  // add the int to the int array
80  m_ppRestraints[m_NumRestraints] = pRestraint;
81  m_NumRestraints++;
82 }
const int kMultiplier
void ARestraintManager::AddForces ( GlobalMasterFreeEnergy CFE)

Definition at line 98 of file FreeEnergyRMgr.C.

References ARestraint::DistributeForce(), ARestraint::GetGradient(), and ARestraint::GetNumGroups().

98  {
99 //---------------------------------------------------------------------------
100 // for each restraint, apply restraining force to each COM (center-of-mass).
101 //---------------------------------------------------------------------------
102  int i, j, NumCOMs;
103  AVector Force;
104 
105  // for each restraint
106  for (i=0; i<m_NumRestraints; i++) {
107  // for each center-of-mass
108  NumCOMs = m_ppRestraints[i]->GetNumGroups();
109  for (j=0; j<NumCOMs; j++) {
110  Force = m_ppRestraints[i]->GetGradient(j);
111  // apply restraining force in opposite direction from gradient
112  Force *= -1.0;
113  m_ppRestraints[i]->DistributeForce(j, Force, CFE);
114  }
115  }
116 }
Vector Force
Definition: NamdTypes.h:26
void DistributeForce(int WhichGroup, AVector Force, GlobalMasterFreeEnergy &CFE)
virtual AVector GetGradient(int WhichGroup)=0
int ARestraintManager::GetNumRestraints ( )
inline

Definition at line 35 of file FreeEnergyRMgr.h.

35 {return(m_NumRestraints);}
ARestraint * ARestraintManager::operator[] ( int  Index)

Definition at line 51 of file FreeEnergyRMgr.C.

References ASSERT.

51  {
52 //------------------------------------------------------------------------
53 // get a pointer
54 //------------------------------------------------------------------------
55  ASSERT( (Index>=0) && (Index<m_NumRestraints) );
56  return(m_ppRestraints[Index]);
57 }
int Index
Definition: structures.h:26
#define ASSERT(E)
void ARestraintManager::Print_dU_dLambda_Info ( )

Definition at line 175 of file FreeEnergyRMgr.C.

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

175  {
176 //---------------------------------------------------------------------------
177 // if restraint is a forcing restraint, print dU/dLambda.
178 //---------------------------------------------------------------------------
179 #if defined(_VERBOSE_PMF)
180  for (int i=0; i<m_NumRestraints; i++) {
181  if (m_ppRestraints[i]->IsForcing()) {
182  PrintPreInfo(i);
183  iout << "dU/dLambda = ";
184  iout << m_ppRestraints[i]->Get_dU_dLambda() << std::endl << endi;
185  }
186  }
187 #endif
188 }
void PrintPreInfo(int Index)
#define iout
Definition: InfoStream.h:87
virtual double Get_dU_dLambda()
infostream & endi(infostream &s)
Definition: InfoStream.C:38
void ARestraintManager::PrintEnergyInfo ( )

Definition at line 145 of file FreeEnergyRMgr.C.

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

145  {
146 //---------------------------------------------------------------------------
147 // for a restraint, print restraint type and Energy.
148 //---------------------------------------------------------------------------
149 #if defined(_VERBOSE_PMF)
150  for (int i=0; i<m_NumRestraints; i++) {
151  PrintPreInfo(i);
152  iout << "Energy = ";
153  iout << m_ppRestraints[i]->GetEnergy() << std::endl << endi;
154  }
155 #endif
156 }
void PrintPreInfo(int Index)
#define iout
Definition: InfoStream.h:87
virtual double GetEnergy()=0
infostream & endi(infostream &s)
Definition: InfoStream.C:38
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().

191  {
192 //---------------------------------------------------------------------------
193 // print "Restraint xxx: Type of Restraint: "
194 //---------------------------------------------------------------------------
195  char Str[100];
196  char NumStr[20];
197 
198  sprintf(NumStr, "%3d", Index+1);
199  iout << "FreeEnergy: " << "Restraint " << NumStr << ": ";
200  m_ppRestraints[Index]->GetStr(Str);
201  iout << Str << ": ";
202 }
#define iout
Definition: InfoStream.h:87
int Index
Definition: structures.h:26
virtual void GetStr(char *Str)=0
void ARestraintManager::PrintRestraintInfo ( )

Definition at line 159 of file FreeEnergyRMgr.C.

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

159  {
160 //---------------------------------------------------------------------------
161 // for a restraint, print its position, distance, angle, or dihedral angle.
162 //---------------------------------------------------------------------------
163  for (int i=0; i<m_NumRestraints; i++) {
164 #if defined(_VERBOSE_PMF)
165  PrintPreInfo(i);
166 #endif
167  m_ppRestraints[i]->PrintInfo();
168  }
169 #if !defined(_VERBOSE_PMF)
170  iout << std::endl << endi;
171 #endif
172 }
void PrintPreInfo(int Index)
#define iout
Definition: InfoStream.h:87
virtual void PrintInfo()=0
infostream & endi(infostream &s)
Definition: InfoStream.C:38
void ARestraintManager::SetLambdaKf ( double  LambdaKf)
inline

Definition at line 44 of file FreeEnergyRMgr.h.

References ARestraint::SetLambdaKf().

44 {m_Dummy.SetLambdaKf(LambdaKf);}
void SetLambdaKf(double LambdaKf)
void ARestraintManager::SetLambdaRef ( double  LambdaRef)
inline

Definition at line 45 of file FreeEnergyRMgr.h.

References ARestraint::SetLambdaRef().

45 {m_Dummy.SetLambdaRef(LambdaRef);}
void SetLambdaRef(double LambdaRef)
void ARestraintManager::SetLambdas ( double  LambdaKf,
double  LambdaRef 
)
inline

Definition at line 46 of file FreeEnergyRMgr.h.

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

47  {
48  m_Dummy.SetLambdaKf(LambdaKf);
49  m_Dummy.SetLambdaRef(LambdaRef);
50  }
void SetLambdaKf(double LambdaKf)
void SetLambdaRef(double LambdaRef)
double ARestraintManager::Sum_dU_dLambdas ( )

Definition at line 119 of file FreeEnergyRMgr.C.

References ARestraint::Get_dU_dLambda().

119  {
120 //---------------------------------------------------------------------------
121 // sum up dU/dLambda from each forcing restraint
122 //---------------------------------------------------------------------------
123  double Sum=0;
124 
125  for (int i=0; i<m_NumRestraints; i++) {
126  Sum += m_ppRestraints[i]->Get_dU_dLambda();
127  }
128  return(Sum);
129 }
virtual double Get_dU_dLambda()
Bool_t ARestraintManager::ThereIsAForcingRestraint ( )

Definition at line 132 of file FreeEnergyRMgr.C.

References kFalse, and kTrue.

132  {
133 //---------------------------------------------------------------------------
134 // return kTrue if there's at least one forcing restraint
135 //---------------------------------------------------------------------------
136  for (int i=0; i<m_NumRestraints; i++) {
137  if (m_ppRestraints[i]->IsForcing()) {
138  return(kTrue);
139  }
140  }
141  return(kFalse);
142 }
void ARestraintManager::UpdateCOMs ( GlobalMasterFreeEnergy CFE)

Definition at line 85 of file FreeEnergyRMgr.C.

References ARestraint::UpdateCOMs().

85  {
86 //------------------------------------------------------------------------
87 // update the centers-of-mass in each restraint in the list
88 // note: m_ppRestraints points to a list of restraint pointers
89 // m_ppRestraints[i] references one of the pointers
90 // m_ppRestraints[i]-> accesses a restraint function
91 //------------------------------------------------------------------------
92  for (int i=0; i<m_NumRestraints; i++) {
93  m_ppRestraints[i]->UpdateCOMs(CFE);
94  }
95 }
void UpdateCOMs(GlobalMasterFreeEnergy &CFE)

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