QMCPACK
LogGrid Class Reference

LogGrid is a function whose gridpoints increase exponentially with the index. More...

+ Inheritance diagram for LogGrid:
+ Collaboration diagram for LogGrid:

Public Member Functions

GridType Type () override
 Returns the type of the grid (i.e. linear, optimal, etc) More...
 
int ReverseMap (double r) override
 Returns the index of the nearest point below r. More...
 
 LogGrid ()
 
void Init (double R0, double spacing, int numpoints)
 
void Write (IOSectionClass &outSection) override
 
void Read (IOSectionClass &inSection) override
 
 LogGrid (double R0, double spacing, int numpoints)
 
 LogGrid (int numpoints, double z, double R0, double spacing)
 
- Public Member Functions inherited from Grid
double operator() (int i) const
 The i'th point in the grid. More...
 
double * data ()
 
Array< double, 1 > & Points ()
 
virtual ~Grid ()
 

Public Attributes

double Z
 
double r0
 
double Spacing
 
- Public Attributes inherited from Grid
double Start
 First and last grid points. More...
 
double End
 
int NumPoints
 Number of points in the grid. More...
 

Additional Inherited Members

- Protected Attributes inherited from Grid
Array< double, 1 > grid
 Contains the grid points. More...
 

Detailed Description

LogGrid is a function whose gridpoints increase exponentially with the index.

That is, it has the analytic form

\[ r_k = \frac{r_0}{Z} \Delta^k.\]

It is appropriate for functions which change rapidly near the origin but vary smoothly further out.

Definition at line 509 of file Grid.h.

Constructor & Destructor Documentation

◆ LogGrid() [1/3]

LogGrid ( )
inline

Definition at line 518 of file Grid.h.

519  {
520  // Do nothing
521  }

◆ LogGrid() [2/3]

LogGrid ( double  R0,
double  spacing,
int  numpoints 
)
inline

Definition at line 556 of file Grid.h.

References Init().

556 { Init(R0, spacing, numpoints); }
void Init(double R0, double spacing, int numpoints)
Definition: Grid.h:523

◆ LogGrid() [3/3]

LogGrid ( int  numpoints,
double  z,
double  R0,
double  spacing 
)
inline

Definition at line 558 of file Grid.h.

References Grid::End, Grid::grid, Grid::NumPoints, qmcplusplus::pow(), r0, Array< T, D, ALLOC >::resize(), Spacing, Grid::Start, and Z.

559  {
560  NumPoints = numpoints;
561  Z = z;
562  r0 = R0;
563  Spacing = spacing;
564 
565  Start = r0 / Z;
566  End = r0 / Z * pow(Spacing, (double)(NumPoints - 1));
567 
569 
570  for (int i = 0; i < NumPoints; i++)
571  grid(i) = r0 / Z * pow(Spacing, (double)i);
572  }
double r0
Definition: Grid.h:512
Array< double, 1 > grid
Contains the grid points.
Definition: Grid.h:47
int NumPoints
Number of points in the grid.
Definition: Grid.h:54
double Z
Definition: Grid.h:512
void resize(const std::array< SIZET, D > &dims)
Resize the container.
Definition: OhmmsArray.h:65
MakeReturn< BinaryNode< FnPow, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t, typename CreateLeaf< Vector< T2, C2 > >::Leaf_t > >::Expression_t pow(const Vector< T1, C1 > &l, const Vector< T2, C2 > &r)
double Spacing
Definition: Grid.h:512
double Start
First and last grid points.
Definition: Grid.h:51
double End
Definition: Grid.h:51

Member Function Documentation

◆ Init()

void Init ( double  R0,
double  spacing,
int  numpoints 
)
inline

Definition at line 523 of file Grid.h.

References Grid::End, Grid::grid, Grid::NumPoints, qmcplusplus::pow(), r0, Array< T, D, ALLOC >::resize(), Spacing, Grid::Start, and Z.

Referenced by LogGrid(), and Read().

524  {
525  NumPoints = numpoints;
526  Z = 1.0;
527  r0 = R0;
528  Spacing = spacing;
529  Start = r0;
530  End = r0 * pow(Spacing, (double)NumPoints - 1);
532 
533  for (int i = 0; i < NumPoints; i++)
534  grid(i) = r0 * pow(Spacing, (double)i);
535  }
double r0
Definition: Grid.h:512
Array< double, 1 > grid
Contains the grid points.
Definition: Grid.h:47
int NumPoints
Number of points in the grid.
Definition: Grid.h:54
double Z
Definition: Grid.h:512
void resize(const std::array< SIZET, D > &dims)
Resize the container.
Definition: OhmmsArray.h:65
MakeReturn< BinaryNode< FnPow, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t, typename CreateLeaf< Vector< T2, C2 > >::Leaf_t > >::Expression_t pow(const Vector< T1, C1 > &l, const Vector< T2, C2 > &r)
double Spacing
Definition: Grid.h:512
double Start
First and last grid points.
Definition: Grid.h:51
double End
Definition: Grid.h:51

◆ Read()

void Read ( IOSectionClass inSection)
inlineoverridevirtual

Implements Grid.

Definition at line 546 of file Grid.h.

References Init(), and IOSectionClass::ReadVar().

547  {
548  double tempr0, tempSpacing;
549  int tempNumPoints;
550  assert(inSection.ReadVar("r0", tempr0));
551  assert(inSection.ReadVar("Spacing", tempSpacing));
552  assert(inSection.ReadVar("NumPoints", tempNumPoints));
553  Init(tempr0, tempSpacing, tempNumPoints);
554  }
void Init(double R0, double spacing, int numpoints)
Definition: Grid.h:523
bool ReadVar(std::string name, T &var)
Template function which reads a variable in the present section into the passed-by-reference T variab...
Definition: IO.h:168

◆ ReverseMap()

int ReverseMap ( double  r)
inlineoverridevirtual

Returns the index of the nearest point below r.

Implements Grid.

Definition at line 516 of file Grid.h.

References qmcplusplus::floor(), qmcplusplus::log(), r0, Spacing, and Z.

516 { return ((int)(floor(log(Z * r / r0) / log(Spacing)))); }
double r0
Definition: Grid.h:512
double Z
Definition: Grid.h:512
double Spacing
Definition: Grid.h:512
MakeReturn< UnaryNode< FnLog, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t log(const Vector< T1, C1 > &l)
MakeReturn< UnaryNode< FnFloor, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t floor(const Vector< T1, C1 > &l)

◆ Type()

GridType Type ( )
inlineoverridevirtual

Returns the type of the grid (i.e. linear, optimal, etc)

Implements Grid.

Definition at line 514 of file Grid.h.

References LOG.

514 { return (LOG); }
Definition: Grid.h:35

◆ Write()

void Write ( IOSectionClass outSection)
inlineoverridevirtual

Implements Grid.

Definition at line 538 of file Grid.h.

References Grid::grid, r0, Spacing, and IOSectionClass::WriteVar().

539  {
540  outSection.WriteVar("Points", grid);
541  outSection.WriteVar("Type", std::string("Log"));
542  outSection.WriteVar("r0", r0);
543  outSection.WriteVar("Spacing", Spacing);
544  }
double r0
Definition: Grid.h:512
Array< double, 1 > grid
Contains the grid points.
Definition: Grid.h:47
bool WriteVar(std::string name, T val)
Writes a variable under the current section.
Definition: IO.h:184
double Spacing
Definition: Grid.h:512

Member Data Documentation

◆ r0

double r0

Definition at line 512 of file Grid.h.

Referenced by Init(), LogGrid(), ReverseMap(), and Write().

◆ Spacing

double Spacing

Definition at line 512 of file Grid.h.

Referenced by Init(), LogGrid(), ReverseMap(), and Write().

◆ Z

double Z

Definition at line 512 of file Grid.h.

Referenced by Init(), LogGrid(), and ReverseMap().


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