QMCPACK
RungeKutta2< IntegrandClass > Class Template Reference
+ Collaboration diagram for RungeKutta2< IntegrandClass >:

Public Member Functions

void Integrate (const Grid &grid, int startPoint, int endPoint, Array< double, 2 > &result)
 
 RungeKutta2 (IntegrandClass &integrand)
 

Private Member Functions

void IntegrateForw (const Grid &grid, int startPoint, int endPoint, Array< double, 2 > &result)
 
void IntegrateRev (const Grid &grid, int startPoint, int endPoint, Array< double, 2 > &result)
 

Private Attributes

IntegrandClass & Integrand
 

Detailed Description

template<class IntegrandClass>
class RungeKutta2< IntegrandClass >

Definition at line 109 of file RungeKutta.h.

Constructor & Destructor Documentation

◆ RungeKutta2()

RungeKutta2 ( IntegrandClass &  integrand)
inline

Definition at line 177 of file RungeKutta.h.

177  : Integrand(integrand)
178  {
179  // Do nothing
180  }
IntegrandClass & Integrand
Definition: RungeKutta.h:112

Member Function Documentation

◆ Integrate()

void Integrate ( const Grid grid,
int  startPoint,
int  endPoint,
Array< double, 2 > &  result 
)
inline

Definition at line 169 of file RungeKutta.h.

References RungeKutta2< IntegrandClass >::IntegrateForw(), and RungeKutta2< IntegrandClass >::IntegrateRev().

170  {
171  if (endPoint > startPoint)
172  IntegrateForw(grid, startPoint, endPoint, result);
173  else
174  IntegrateRev(grid, startPoint, endPoint, result);
175  }
void IntegrateForw(const Grid &grid, int startPoint, int endPoint, Array< double, 2 > &result)
Definition: RungeKutta.h:115
void IntegrateRev(const Grid &grid, int startPoint, int endPoint, Array< double, 2 > &result)
Definition: RungeKutta.h:141

◆ IntegrateForw()

void IntegrateForw ( const Grid grid,
int  startPoint,
int  endPoint,
Array< double, 2 > &  result 
)
inlineprivate

Definition at line 115 of file RungeKutta.h.

References Range::all(), Array< T, D, ALLOC >::cols(), and RungeKutta2< IntegrandClass >::Integrand.

Referenced by RungeKutta2< IntegrandClass >::Integrate().

116  {
117  int numVars = result.cols();
118  Array<double, 1> k1(numVars), k2(numVars), k3(numVars), k4(numVars);
119  Array<double, 1> y(numVars), yplus(numVars);
120  double h, x;
121 
122  const static double OneSixth = 1.0 / 6.0;
123  const static double OneThird = 1.0 / 3.0;
124 
125  for (int i = startPoint; i < endPoint; i++)
126  {
127  x = grid(i);
128  h = grid(i + 1) - x;
129  y = result(i, Range::all());
130  k1 = h * Integrand(x, y);
131  yplus = y + 0.5 * k1;
132  k2 = h * Integrand(x + 0.5 * h, yplus);
133  yplus = y + 0.5 * k2;
134  k3 = h * Integrand(x + 0.5 * h, yplus);
135  yplus = y + k3;
136  k4 = h * Integrand(x + h, yplus);
137  result(i + 1, Range::all()) = y + (OneSixth * (k1 + k4) + OneThird * (k2 + k3));
138  }
139  }
static auto all()
Definition: Blitz.h:176
auto cols() const
Definition: Blitz.h:90
IntegrandClass & Integrand
Definition: RungeKutta.h:112

◆ IntegrateRev()

void IntegrateRev ( const Grid grid,
int  startPoint,
int  endPoint,
Array< double, 2 > &  result 
)
inlineprivate

Definition at line 141 of file RungeKutta.h.

References Range::all(), Array< T, D, ALLOC >::cols(), and RungeKutta2< IntegrandClass >::Integrand.

Referenced by RungeKutta2< IntegrandClass >::Integrate().

142  {
143  int numVars = result.cols();
144  Array<double, 1> k1(numVars), k2(numVars), k3(numVars), k4(numVars);
145  Array<double, 1> y(numVars), yplus(numVars);
146  double h, x;
147 
148  const static double OneSixth = 1.0 / 6.0;
149  const static double OneThird = 1.0 / 3.0;
150 
151  for (int i = startPoint; i > endPoint; i--)
152  {
153  x = grid(i);
154  h = grid(i - 1) - x;
155  y = result(i, Range::all());
156  k1 = h * Integrand(x, y);
157  yplus = y + 0.5 * k1;
158  k2 = h * Integrand(x + 0.5 * h, yplus);
159  yplus = y + 0.5 * k2;
160  k3 = h * Integrand(x + 0.5 * h, yplus);
161  yplus = y + k3;
162  k4 = h * Integrand(x + h, yplus);
163  result(i - 1)/*, Range::all())*/ = y + (OneSixth * (k1 + k4) + OneThird * (k2 + k3));
164  }
165  }
static auto all()
Definition: Blitz.h:176
auto cols() const
Definition: Blitz.h:90
IntegrandClass & Integrand
Definition: RungeKutta.h:112

Member Data Documentation

◆ Integrand

IntegrandClass& Integrand
private

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