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

#include <FreeEnergyLambdMgr.h>

Public Member Functions

 ALambdaManager ()
 
 ~ALambdaManager ()
 
ALambdaControloperator[] (int index)
 
void Clear ()
 
int Add (ALambdaControl &PmfBlock)
 
int GetNumObjects ()
 
Bool_t GetLambdas (double &LambdaKf, double &LambdaRef)
 
Bool_t IsTimeToPrint ()
 
Bool_t IsFirstStep ()
 
Bool_t IsTimeToPrint_dU_dLambda ()
 
Bool_t IsTimeToClearAccumulator ()
 
Bool_t IsEndOf_MCTI_Step ()
 
Bool_t IsEndOf_MCTI ()
 
int GetNumStepsSoFar ()
 
int GetNumAccumStepsSoFar ()
 
void PrintHeader (double dT)
 
void PrintLambdaHeader (double dT)
 
void Print_dU_dLambda_Summary (double Sum_dU_dLambdas)
 
void PrintSomeSpaces ()
 
void Print_MCTI_Integration ()
 
void IncCurrStep ()
 
int GetTotalNumSteps ()
 
void Integrate_MCTI ()
 
void Accumulate (double dU_dLambda)
 
double GetAccumulation ()
 
double GetIntegration ()
 
void ZeroAccumulator ()
 
int GetNum_dU_dLambda ()
 

Detailed Description

Definition at line 18 of file FreeEnergyLambdMgr.h.

Constructor & Destructor Documentation

ALambdaManager::ALambdaManager ( )

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

Definition at line 19 of file FreeEnergyLambdMgr.C.

References kLambdaNumToStart.

19  {
20 //------------------------------------------------------------------------
21 // make room for some LambdaControl objects.
22 //------------------------------------------------------------------------
23  m_ActiveIndex = 0;
24  m_NumObjects = 0;
25  m_pPmfBlocks = new ALambdaControl[kLambdaNumToStart];
26  m_MaxNum = kLambdaNumToStart;
27 }
const int kLambdaNumToStart
ALambdaManager::~ALambdaManager ( )

Definition at line 30 of file FreeEnergyLambdMgr.C.

30  {
31 //------------------------------------------------------------------------
32 // return borrowed memory to the free store.
33 //------------------------------------------------------------------------
34  delete []m_pPmfBlocks;
35 }

Member Function Documentation

void ALambdaManager::Accumulate ( double  dU_dLambda)

Definition at line 56 of file FreeEnergyLambdMgr.C.

References ASSERT.

56  {
57 //------------------------------------------------------------------------
58 // add dU_dLambda to the active accumulator (in one of the lambda objects)
59 //------------------------------------------------------------------------
60  ASSERT((*this)[m_ActiveIndex].IsActive());
61  (*this)[m_ActiveIndex].Accumulate(dU_dLambda);
62 }
#define ASSERT(E)
int ALambdaManager::Add ( ALambdaControl PmfBlock)

Definition at line 273 of file FreeEnergyLambdMgr.C.

References kLambdaMultiplier.

Referenced by ReadInput().

273  {
274 //------------------------------------------------------------------------
275 // add an object to the list. if there's not enough room, make room.
276 // return an index to the added oject.
277 //------------------------------------------------------------------------
278  ALambdaControl* pPmfBlocks;
279 
280  // if there's no room for another object
281  if (m_NumObjects == m_MaxNum) {
282  // create an array with more space
283  m_MaxNum *= kLambdaMultiplier;
284  pPmfBlocks = new ALambdaControl[m_MaxNum];
285  // copy from the full array to the new one
286  for (int i=0; i<m_NumObjects; i++) {
287  pPmfBlocks[i] = m_pPmfBlocks[i];
288  }
289  // return the space used for the full array
290  delete []m_pPmfBlocks;
291  // point to the bigger array
292  m_pPmfBlocks = pPmfBlocks;
293  }
294  // add the object to the array
295  m_pPmfBlocks[m_NumObjects] = PmfBlock;
296  m_NumObjects++;
297  return(m_NumObjects-1);
298 }
const int kLambdaMultiplier
void ALambdaManager::Clear ( )

Definition at line 265 of file FreeEnergyLambdMgr.C.

265  {
266 //------------------------------------------------------------------------
267 // leave memory allocation alone.
268 //------------------------------------------------------------------------
269  m_NumObjects = 0;
270 }
double ALambdaManager::GetAccumulation ( )

Definition at line 65 of file FreeEnergyLambdMgr.C.

References ASSERT.

Referenced by Print_dU_dLambda_Summary().

65  {
66 //------------------------------------------------------------------------
67 // get the accumulation of dU_dLambda from active lambda object.
68 //------------------------------------------------------------------------
69  ASSERT((*this)[m_ActiveIndex].IsActive());
70  return((*this)[m_ActiveIndex].GetAccumulation());
71 }
#define ASSERT(E)
double GetAccumulation()
double ALambdaManager::GetIntegration ( )

Definition at line 74 of file FreeEnergyLambdMgr.C.

References ASSERT.

Referenced by Print_MCTI_Integration().

74  {
75 //------------------------------------------------------------------------
76 // get accumulation of <dU_dLambda> * dLambda from active lambda object.
77 //------------------------------------------------------------------------
78  ASSERT((*this)[m_ActiveIndex].IsActive());
79  return((*this)[m_ActiveIndex].GetIntegration());
80 }
#define ASSERT(E)
Bool_t ALambdaManager::GetLambdas ( double &  LambdaKf,
double &  LambdaRef 
)

Definition at line 233 of file FreeEnergyLambdMgr.C.

References ASSERT, kFalse, and kTrue.

233  {
234 //------------------------------------------------------------------------
235 // get LambdaKf and LambdaRef from the active LambdaControl
236 //
237 // return(kTrue) if an active LambdaControl is found
238 // return(kFalse) if all LambdaControls have expired
239 //------------------------------------------------------------------------
240  // don't continue if all LamdaControl's have expired
241  if (m_ActiveIndex == m_NumObjects) {
242  return(kFalse);
243  }
244 
245  // if the m_ActiveIndex'th LambdaControl is no longer active
246  if ( !(*this)[m_ActiveIndex].IsActive()) {
247  // move on to the next one
248  m_ActiveIndex++;
249  // if there is no next object, return KFalse
250  if (m_ActiveIndex == m_NumObjects) {
251  return(kFalse);
252  }
253  // otherwise, make sure the next one's active
254  else {
255  ASSERT( (*this)[m_ActiveIndex].IsActive() );
256  }
257  }
258  // return LambdaKf and LambdaRef from the active LambdaControl
259  LambdaKf = (*this)[m_ActiveIndex].GetLambdaKf();
260  LambdaRef = (*this)[m_ActiveIndex].GetLambdaRef();
261  return(kTrue);
262 }
#define ASSERT(E)
int ALambdaManager::GetNum_dU_dLambda ( )

Definition at line 38 of file FreeEnergyLambdMgr.C.

References ASSERT.

Referenced by Print_dU_dLambda_Summary().

38  {
39 //------------------------------------------------------------------------
40 // get number times dU_dLambda accumulated from active lambda object.
41 //------------------------------------------------------------------------
42  ASSERT((*this)[m_ActiveIndex].IsActive());
43  return((*this)[m_ActiveIndex].GetNum_dU_dLambda());
44 }
#define ASSERT(E)
int ALambdaManager::GetNumAccumStepsSoFar ( )

Definition at line 179 of file FreeEnergyLambdMgr.C.

References ASSERT.

Referenced by Print_MCTI_Integration().

179  {
180 //------------------------------------------------------------------------
181 // return the total number of steps dU/dLambda has been accumulated
182 //------------------------------------------------------------------------
183  ASSERT((*this)[m_ActiveIndex].IsActive());
184  return((*this)[m_ActiveIndex].GetNumAccumStepsSoFar());
185 }
#define ASSERT(E)
int ALambdaManager::GetNumObjects ( )
inline

Definition at line 33 of file FreeEnergyLambdMgr.h.

33 {return(m_NumObjects);}
int ALambdaManager::GetNumStepsSoFar ( )

Definition at line 170 of file FreeEnergyLambdMgr.C.

References ASSERT.

170  {
171 //------------------------------------------------------------------------
172 // return the number of steps taken in the active LambdaControl block
173 //------------------------------------------------------------------------
174  ASSERT((*this)[m_ActiveIndex].IsActive());
175  return((*this)[m_ActiveIndex].GetNumStepsSoFar());
176 }
#define ASSERT(E)
int ALambdaManager::GetTotalNumSteps ( )

Definition at line 310 of file FreeEnergyLambdMgr.C.

References ALambdaControl::GetNumSteps().

310  {
311 //------------------------------------------------------------------------
312 // calculate and return the total number of steps needed for all
313 // pmf and mcti blocks
314 //------------------------------------------------------------------------
315  int Total, i;
316 
317  Total = 0;
318  for (i=0; i<m_NumObjects; i++) {
319  Total += m_pPmfBlocks[i].GetNumSteps();
320  }
321  return(Total);
322 }
void ALambdaManager::IncCurrStep ( )
inline

Definition at line 48 of file FreeEnergyLambdMgr.h.

References ALambdaControl::IncCurrStep().

48 {m_Dummy.IncCurrStep();}
void ALambdaManager::Integrate_MCTI ( )

Definition at line 47 of file FreeEnergyLambdMgr.C.

References ASSERT.

47  {
48 //------------------------------------------------------------------------
49 // integrate <dU/dLambda> for MCTI
50 //------------------------------------------------------------------------
51  ASSERT((*this)[m_ActiveIndex].IsActive());
52  (*this)[m_ActiveIndex].Integrate_MCTI();
53 }
#define ASSERT(E)
Bool_t ALambdaManager::IsEndOf_MCTI ( )

Definition at line 142 of file FreeEnergyLambdMgr.C.

References ASSERT.

142  {
143 //------------------------------------------------------------------------
144 // ASSUMING that the m_ActiveIndex'th LambdaControl is active,
145 // decide if this is the last time step of an MCTI block
146 //------------------------------------------------------------------------
147  ASSERT((*this)[m_ActiveIndex].IsActive());
148  return((*this)[m_ActiveIndex].IsEndOf_MCTI());
149 }
#define ASSERT(E)
Bool_t ALambdaManager::IsEndOf_MCTI_Step ( )

Definition at line 132 of file FreeEnergyLambdMgr.C.

References ASSERT.

132  {
133 //------------------------------------------------------------------------
134 // ASSUMING that the m_ActiveIndex'th LambdaControl is active,
135 // decide if this is the last time step of an MCTI step
136 //------------------------------------------------------------------------
137  ASSERT((*this)[m_ActiveIndex].IsActive());
138  return((*this)[m_ActiveIndex].IsEndOf_MCTI_Step());
139 }
#define ASSERT(E)
Bool_t IsEndOf_MCTI_Step()
Bool_t ALambdaManager::IsFirstStep ( )

Definition at line 92 of file FreeEnergyLambdMgr.C.

References ASSERT.

92  {
93 //------------------------------------------------------------------------
94 // ASSUMING that the m_ActiveIndex'th LambdaControl is active,
95 // decide if it's time to print restraint information
96 //------------------------------------------------------------------------
97  ASSERT((*this)[m_ActiveIndex].IsActive());
98  return((*this)[m_ActiveIndex].IsFirstStep());
99 }
#define ASSERT(E)
Bool_t ALambdaManager::IsTimeToClearAccumulator ( )

Definition at line 122 of file FreeEnergyLambdMgr.C.

References ASSERT.

122  {
123 //------------------------------------------------------------------------
124 // ASSUMING that the m_ActiveIndex'th LambdaControl is active,
125 // decide if it's time to start accumulating dU/dLambda from zero
126 //------------------------------------------------------------------------
127  ASSERT((*this)[m_ActiveIndex].IsActive());
128  return((*this)[m_ActiveIndex].IsTimeToClearAccumulator());
129 }
Bool_t IsTimeToClearAccumulator()
#define ASSERT(E)
Bool_t ALambdaManager::IsTimeToPrint ( )

Definition at line 102 of file FreeEnergyLambdMgr.C.

References ASSERT.

102  {
103 //------------------------------------------------------------------------
104 // ASSUMING that the m_ActiveIndex'th LambdaControl is active,
105 // decide if it's time to print restraint information
106 //------------------------------------------------------------------------
107  ASSERT((*this)[m_ActiveIndex].IsActive());
108  return((*this)[m_ActiveIndex].IsTimeToPrint());
109 }
#define ASSERT(E)
Bool_t ALambdaManager::IsTimeToPrint_dU_dLambda ( )

Definition at line 112 of file FreeEnergyLambdMgr.C.

References ASSERT.

112  {
113 //------------------------------------------------------------------------
114 // ASSUMING that the m_ActiveIndex'th LambdaControl is active,
115 // decide if it's time to print du/dLambda information
116 //------------------------------------------------------------------------
117  ASSERT((*this)[m_ActiveIndex].IsActive());
118  return((*this)[m_ActiveIndex].IsTimeToPrint_dU_dLambda());
119 }
Bool_t IsTimeToPrint_dU_dLambda()
#define ASSERT(E)
ALambdaControl & ALambdaManager::operator[] ( int  index)

Definition at line 301 of file FreeEnergyLambdMgr.C.

References ASSERT.

301  {
302 //------------------------------------------------------------------------
303 // return an object from this group of objects.
304 //------------------------------------------------------------------------
305  ASSERT((Index>=0) && (Index<m_NumObjects));
306  return(m_pPmfBlocks[Index]);
307 }
int Index
Definition: structures.h:26
#define ASSERT(E)
void ALambdaManager::Print_dU_dLambda_Summary ( double  Sum_dU_dLambdas)

Definition at line 198 of file FreeEnergyLambdMgr.C.

References endi(), GetAccumulation(), GetNum_dU_dLambda(), and iout.

198  {
199 //------------------------------------------------------------------------
200 // print sum of dU/dLambda's for current time-step and
201 // the accumulation of the above.
202 //------------------------------------------------------------------------
203  char Str[100];
204 
205 #if defined(_VERBOSE_PMF)
206  iout << "FreeEnergy: ";
207  iout << "For all forcing restraints, dU/dLambda = ";
208  iout << Sum_dU_dLambdas << std::endl << endi;
209  iout << "FreeEnergy: ";
210  iout << "For all forcing restraints, Free Energy = ";
211  iout << GetAccumulation();
212  iout << " for " << GetNum_dU_dLambda() << " steps" << std::endl << endi;
213 #else
214  sprintf(Str, "%10.2e", GetAccumulation());
215  iout << Str << " ";
216  sprintf(Str, "%6d", GetNum_dU_dLambda());
217  iout << Str << " ";
218 #endif
219 }
#define iout
Definition: InfoStream.h:87
infostream & endi(infostream &s)
Definition: InfoStream.C:38
double GetAccumulation()
void ALambdaManager::Print_MCTI_Integration ( )

Definition at line 222 of file FreeEnergyLambdMgr.C.

References endi(), GetIntegration(), GetNumAccumStepsSoFar(), and iout.

222  {
223 //------------------------------------------------------------------------
224 // print the integral of: <dU/dLambda> * dLambda
225 //------------------------------------------------------------------------
226  iout << "FreeEnergy: ";
227  iout << "For MCTI, Free Energy Integral = ";
228  iout << GetIntegration();
229  iout << " for " << GetNumAccumStepsSoFar() << " steps" << std::endl << endi;
230 }
#define iout
Definition: InfoStream.h:87
infostream & endi(infostream &s)
Definition: InfoStream.C:38
void ALambdaManager::PrintHeader ( double  dT)

Definition at line 161 of file FreeEnergyLambdMgr.C.

References ASSERT.

161  {
162 //------------------------------------------------------------------------
163 // print information about current time step
164 //------------------------------------------------------------------------
165  ASSERT((*this)[m_ActiveIndex].IsActive());
166  (*this)[m_ActiveIndex].PrintHeader(dT);
167 }
#define ASSERT(E)
void ALambdaManager::PrintLambdaHeader ( double  dT)

Definition at line 152 of file FreeEnergyLambdMgr.C.

References ASSERT.

152  {
153 //------------------------------------------------------------------------
154 // print header for a new lambda control object
155 //------------------------------------------------------------------------
156  ASSERT((*this)[m_ActiveIndex].IsActive());
157  (*this)[m_ActiveIndex].PrintLambdaHeader(dT);
158 }
#define ASSERT(E)
void ALambdaManager::PrintSomeSpaces ( )

Definition at line 188 of file FreeEnergyLambdMgr.C.

References iout.

188  {
189 //------------------------------------------------------------------------
190 // some stuff to make the output look nice
191 //------------------------------------------------------------------------
192 #if !defined(_VERBOSE_PMF)
193  iout << " ";
194 #endif
195 }
#define iout
Definition: InfoStream.h:87
void ALambdaManager::ZeroAccumulator ( )

Definition at line 83 of file FreeEnergyLambdMgr.C.

References ASSERT.

83  {
84 //------------------------------------------------------------------------
85 // zero accumulation of dU_dLambda in the active lambda object.
86 //------------------------------------------------------------------------
87  ASSERT((*this)[m_ActiveIndex].IsActive());
88  (*this)[m_ActiveIndex].ZeroAccumulator();
89 }
#define ASSERT(E)

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