QMCPACK
LogGrid< T, CT > Struct Template Reference

One-Dimensional logarithmic-grid. More...

+ Inheritance diagram for LogGrid< T, CT >:
+ Collaboration diagram for LogGrid< T, CT >:

Public Member Functions

std::unique_ptr< OneDimGridBase< T, CT > > makeClone () const override
 
int locate (T r) const override
 evaluate the index of r More...
 
void set (T ri, T rf, int n) override
 Set the grid given the parameters. More...
 
- Public Member Functions inherited from OneDimGridBase< T, CT >
 OneDimGridBase ()
 
virtual ~OneDimGridBase ()=default
 
int getGridTag () const
 
int getIndex (T r) const
 
T & operator[] (int i)
 assign a value More...
 
T & operator() (int i)
 assign a value More...
 
operator[] (int i) const
 return a value More...
 
operator() (int i) const
 return a value More...
 
const T * data () const
 
T * data ()
 
dh () const
 return the differential spacing of the grid More...
 
r (int i) const
 returns $ r(i)$ More...
 
dr (int i) const
 returns $ r(i+1)-r(i)$ More...
 
int size () const
 returns the size of the grid More...
 
rmin () const
 return the first grid point More...
 
rmax () const
 return the last grid point More...
 
template<typename T1 >
int getIndexAndDistanceFromGridPoint (T r, T1 &dist) const
 

Public Attributes

OneOverLogDelta
 
- Public Attributes inherited from OneDimGridBase< T, CT >
int GridTag
 
int num_points
 
value_type lower_bound
 
value_type upper_bound
 
value_type Delta
 differential spacing of the grid More...
 
double DeltaInv
 
Array_t X
 array to store the radial grid data More...
 

Additional Inherited Members

- Public Types inherited from OneDimGridBase< T, CT >
using value_type = T
 
using Array_t = CT
 

Detailed Description

template<class T, class CT = Vector<T>>
struct qmcplusplus::LogGrid< T, CT >

One-Dimensional logarithmic-grid.

The analytic form $ r_i = r_0 \left( \frac{r_f}{r_0} \right) ^{\frac{i}{N-1}}, $ where $ N $ is the number of points and the index $ i $ runs from 0 to $ N-1 $

Definition at line 187 of file OneDimGridBase.h.

Member Function Documentation

◆ locate()

int locate ( r) const
inlineoverridevirtual

evaluate the index of r

Parameters
rcurrent position

The grid index satisfies $ X[Loc] \ge r < X[Loc+1]$.

Implements OneDimGridBase< T, CT >.

Definition at line 200 of file OneDimGridBase.h.

References qmcplusplus::log(), LogGrid< T, CT >::OneOverLogDelta, OneDimGridBase< T, CT >::r(), and OneDimGridBase< T, CT >::X.

200 { return static_cast<int>(std::log(r / X[0]) * OneOverLogDelta); }
Array_t X
array to store the radial grid data
MakeReturn< UnaryNode< FnLog, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t log(const Vector< T1, C1 > &l)
T r(int i) const
returns

◆ makeClone()

std::unique_ptr<OneDimGridBase<T, CT> > makeClone ( ) const
inlineoverridevirtual

Implements OneDimGridBase< T, CT >.

Definition at line 198 of file OneDimGridBase.h.

198 { return std::make_unique<LogGrid<T, CT>>(*this); }

◆ set()

void set ( ri,
rf,
int  n 
)
inlineoverridevirtual

Set the grid given the parameters.

Parameters
riinitial grid point
rffinal grid point
nnumber of grid points

Implements OneDimGridBase< T, CT >.

Definition at line 202 of file OneDimGridBase.h.

References OneDimGridBase< T, CT >::Delta, qmcplusplus::exp(), OneDimGridBase< T, CT >::GridTag, qmcplusplus::log(), LOG_1DGRID, OneDimGridBase< T, CT >::lower_bound, qmcplusplus::n, OneDimGridBase< T, CT >::num_points, LogGrid< T, CT >::OneOverLogDelta, OneDimGridBase< T, CT >::upper_bound, and OneDimGridBase< T, CT >::X.

203  {
205  lower_bound = ri;
206  upper_bound = rf;
207  num_points = n;
208  // r(i) = ri*(rf/ri)^(i/(n-1))
209  // this expression is equal to:
210  // r(i) = ri*exp(dlog_ratio*i)
211  // where dlog_ratio = (1/(n-1))*log(rf/ri)
212  // dlog_ratio is the differential spacing
213  double ratio = rf / ri;
214  double log_ratio = std::log(ratio);
215  double dlog_ratio = log_ratio / static_cast<double>(n - 1);
216  X.resize(n);
217  X[0] = ri;
218  for (int i = 1; i < n; i++)
219  X[i] = ri * std::exp(i * dlog_ratio);
220  Delta = dlog_ratio;
221  OneOverLogDelta = 1.0 / dlog_ratio;
222  }
Array_t X
array to store the radial grid data
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
value_type Delta
differential spacing of the grid
MakeReturn< UnaryNode< FnLog, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t log(const Vector< T1, C1 > &l)

Member Data Documentation

◆ OneOverLogDelta

T OneOverLogDelta

Definition at line 196 of file OneDimGridBase.h.

Referenced by LogGrid< T, CT >::locate(), and LogGrid< T, CT >::set().


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