Path Integral Quantum Monte Carlo
Public Member Functions | Protected Member Functions | Protected Attributes
TabulatedPotential Class Referenceabstract

Pre-tabulated potential for complicated functions. More...

#include <potential.h>

+ Inheritance diagram for TabulatedPotential:

Public Member Functions

 TabulatedPotential ()
 Constructor.
 
virtual ~TabulatedPotential ()
 Destructor.
 

Protected Member Functions

void initLookupTable (const double, const double)
 Given a discretization factor and the system size, create and fill the lookup tables for the potential and its derivative.
 
virtual double newtonGregory (const Array< double, 1 > &, const TinyVector< double, 2 > &, const double)
 Use the Newton-Gregory forward difference method to do a 2-point lookup on the potential table. More...
 
virtual double direct (const Array< double, 1 > &, const TinyVector< double, 2 > &, const double)
 Use a direct lookup for the potential table. More...
 
virtual double valueV (const double)=0
 The functional value of V.
 
virtual double valuedVdr (const double)=0
 The functional value of dV/dr.
 
virtual double valued2Vdr2 (const double)=0
 The functional value of d2V/dr2.
 

Protected Attributes

Array< double, 1 > lookupV
 A potential lookup table.
 
Array< double, 1 > lookupdVdr
 A lookup table for dVint/dr.
 
Array< double, 1 > lookupd2Vdr2
 A lookup table for d2Vint/dr2.
 
double dr
 The discretization for the lookup table.
 
int tableLength
 The number of elements in the lookup table.
 
TinyVector< double, 2 > extV
 Extremal value of V.
 
TinyVector< double, 2 > extdVdr
 Extremal value of dV/dr.
 
TinyVector< double, 2 > extd2Vdr2
 Extremal value of d2V/dr2.
 

Detailed Description

Pre-tabulated potential for complicated functions.

In order to speed up the evaluation of complicated potentials, we use a 2-point Newton-Gregory spline fit to perform the actual interpolation.

Definition at line 80 of file potential.h.

Member Function Documentation

◆ direct()

double TabulatedPotential::direct ( const Array< double, 1 > &  VTable,
const TinyVector< double, 2 > &  extVal,
const double  r 
)
protectedvirtual

Use a direct lookup for the potential table.

This is faster thant Newton-Gregory and may give similar results for a fine enough mesh.

Definition at line 255 of file potential.cpp.

256  {
257 
258  int k = int(r/dr);
259  if (k <= 0)
260  return extVal[0];
261 
262  if (k >= tableLength)
263  return extVal[1];
264 
265  return VTable(k);
266 }
int tableLength
The number of elements in the lookup table.
Definition: potential.h:91
double dr
The discretization for the lookup table.
Definition: potential.h:90
+ Here is the caller graph for this function:

◆ newtonGregory()

double TabulatedPotential::newtonGregory ( const Array< double, 1 > &  VTable,
const TinyVector< double, 2 > &  extVal,
const double  r 
)
protectedvirtual

Use the Newton-Gregory forward difference method to do a 2-point lookup on the potential table.


See also
M.P. Allen and D.J. Tildesley, "Computer Simulation of Liquids" (Oxford Press, London, England) p 144 (2004).

Definition at line 226 of file potential.cpp.

227  {
228 
229  double rdr = r/dr;
230  int k = int(rdr);
231 
232  if (k <= 0)
233  return extVal[0];
234 
235  if (k >= tableLength)
236  return extVal[1];
237 
238  double xi = rdr - 1.0*k;
239  double vkm1 = VTable(k-1);
240  double vk = VTable(k);
241  double vkp1 = VTable(k+1);
242 
243  double T1 = vkm1 + (vk - vkm1) * xi;
244  double T2 = vk + (vkp1 - vk) * (xi - 1.0);
245 
246  return (T1 + 0.5 * (T2 - T1) * xi);
247 }

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