QMCPACK
Grid.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Paul R. C. Kent, kentpr@ornl.gov, Oak Ridge National Laboratory
8 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
9 //
10 // File created by: Paul R. C. Kent, kentpr@ornl.gov, Oak Ridge National Laboratory
11 //////////////////////////////////////////////////////////////////////////////////////
12 
13 
14 // http://pathintegrals.info //
15 /////////////////////////////////////////////////////////////
16 
17 #ifndef GRID_H
18 #define GRID_H
19 
20 #include "IO.h"
21 
22 #include "Blitz.h"
23 
24 using IO::IOSectionClass;
25 
26 //Ken's Grid Class
27 
28 /// The different types of grids that we currently allow
29 typedef enum
30 {
35  LOG,
39 } GridType;
40 
41 
42 /// Parent class for all grids
43 class Grid
44 {
45 protected:
46  /// Contains the grid points
48 
49 public:
50  /// First and last grid points
51  double Start, End;
52 
53  /// Number of points in the grid
54  int NumPoints;
55 
56  /// The i'th point in the grid
57  inline double operator()(int i) const { return (grid(i)); }
58  inline double* data() { return grid.data(); }
59  inline Array<double, 1>& Points() { return grid; }
60 
61  /// Returns the type of the grid (i.e. linear, optimal, etc)
62  virtual GridType Type() = 0;
63 
64  ///Returns the index of the nearest point below r.
65  virtual int ReverseMap(double r) = 0;
66  virtual void Write(IOSectionClass& out) = 0;
67  virtual void Read(IOSectionClass& inSection) = 0;
68  virtual ~Grid(){}
69 };
70 
71 
72 /// Linear Grid inherets from Grid.
73 class LinearGrid : public Grid
74 {
75 private:
76  /// The value between successive grid points.
77  double delta, deltainv;
78  inline void CheckRoundingMode();
79 
80 public:
81  /// Returns the type of the grid (in this case LINEAR)
82  GridType Type() override { return (LINEAR); }
83 
84  /// Returns the index of the nearest point below r.
85  int ReverseMap(double r) override { return ((int)nearbyint((r - Start) * deltainv - 0.5)); }
86 
87  /// Initializes the linear grid.
88  inline void Init(double start, double end, int numpoints)
89  {
90  Start = start;
91  End = end;
92  NumPoints = numpoints;
94  delta = (End - Start) / (double)(NumPoints - 1);
95  deltainv = 1.0 / delta;
96  for (int i = 0; i < NumPoints; i++)
97  grid(i) = Start + (double)i * delta;
99  }
100 
101  void Write(IOSectionClass& outSection) override
102  {
103  outSection.WriteVar("Points", grid);
104  outSection.WriteVar("Type", std::string("Linear"));
105  outSection.WriteVar("Start", Start);
106  outSection.WriteVar("End", End);
107  outSection.WriteVar("NumPoints", NumPoints);
108  }
109 
110  void Read(IOSectionClass& inSection) override
111  {
112  assert(inSection.ReadVar("Start", Start));
113  assert(inSection.ReadVar("End", End));
114  assert(inSection.ReadVar("NumPoints", NumPoints));
115  Init(Start, End, NumPoints);
116  }
117 
118  /// Useless constructor
120  { /* Do nothing */
121  }
122 
124  {
125  grid.resize(lin.grid.shape());
126  Start = lin.Start;
127  End = lin.End;
128  grid = lin.grid;
129  delta = lin.delta;
130  deltainv = lin.deltainv;
131  return *this;
132  }
133 
134  /// Constructor that sets the number of points, start and end point
135  /// of the original grid
136  LinearGrid(double start, double end, int numpoints) { Init(start, end, numpoints); }
137 };
138 
139 
140 /// General Grid inherets from Grid.
141 class GeneralGrid : public Grid
142 {
143 public:
144  /// Returns the type of the grid (in this case GENERAL)
145  GridType Type() override { return (GENERAL); }
146 
147  /// Returns the index of the nearest point below r.
148  int ReverseMap(double r) override
149  {
150  if (r <= grid(0))
151  return (0);
152  else if (r >= grid(NumPoints - 1))
153  return (NumPoints - 1);
154  else
155  {
156  int hi = NumPoints - 1;
157  int lo = 0;
158  bool done = false;
159  while (!done)
160  {
161  int i = (hi + lo) >> 1;
162  if (grid(i) > r)
163  hi = i;
164  else
165  lo = i;
166  done = (hi - lo) < 2;
167  }
168  return std::min(lo, NumPoints - 2);
169  }
170  }
171 
172  void Write(IOSectionClass& outSection) override
173  {
174  outSection.WriteVar("Points", grid);
175  outSection.WriteVar("Type", std::string("General"));
176  }
177 
178  void Read(IOSectionClass& inSection) override
179  {
180  assert(inSection.ReadVar("Points", grid));
181  Start = grid(0);
182  End = grid(grid.size() - 1);
183  NumPoints = grid.size();
184  }
185 
186  void Init(Array<double, 1>& points)
187  {
188  NumPoints = points.size();
190  grid = points;
191  Start = grid(0);
192  End = grid(NumPoints - 1);
193  }
194 
195  /// Useless constructor
197  { /* Do nothing */
198  }
199 };
200 
201 
202 /// The OptimalGrid class stores a grid which has linear spacing at
203 /// the origin and exponential spacing further out. It has the
204 /// analytic form \f[r_k = a\left(e^{kb}-1\right)\f].
205 class OptimalGrid : public Grid
206 {
207 private:
208  double a, b;
209 
210 public:
211  GridType Type() override { return (OPTIMAL); }
212 
213  int ReverseMap(double r) override
214  {
215  if ((r / a) < 1e-6)
216  return ((int)floor(r / (a * b) + 0.5) - 1);
217  else
218  return ((int)floor(log(r / a + 1.0) / b + 0.5) - 1);
219  }
220 
221  /// Returns a parameter
222  double Geta() const { return (a); }
223 
224  /// Returns b parameter
225  double Getb() const { return (b); }
226 
228  {
229  // Do nothing
230  }
231 
232  /// This form of the constructor takes the number of points, the
233  /// maximum radius and the value of b.
234  void Init(int numpoints, double rmax, double bval)
235  {
236  NumPoints = numpoints;
237  b = bval;
238  End = rmax;
239  a = End / (exp(b * (double)NumPoints) - 1.0);
240  Start = a * (exp(b) - 1.0);
242 
243  for (int i = 0; i < NumPoints; i++)
244  grid(i) = a * (exp(b * (i + 1)) - 1.0);
245  }
246 
247  OptimalGrid(int numPoints, double rmax, double bval) { Init(numPoints, rmax, bval); }
248 
249  void Init(double aval, double bval, int numPoints)
250  {
251  a = aval;
252  b = bval;
253  NumPoints = numPoints;
254  Start = a * (exp(b) - 1.0);
255  End = a * (exp(b * NumPoints) - 1.0);
256 
258 
259  for (int i = 0; i < NumPoints; i++)
260  grid(i) = a * (exp(b * (i + 1)) - 1.0);
261  }
262 
263 
264  /// This form of the constructor takes a, b, and the number of points.
265  OptimalGrid(double aval, double bval, int numPoints) { Init(aval, bval, numPoints); }
266 
267  void Write(IOSectionClass& outSection) override
268  {
269  outSection.WriteVar("Points", grid);
270  outSection.WriteVar("Type", std::string("Optimal"));
271  outSection.WriteVar("a", a);
272  outSection.WriteVar("b", b);
273  outSection.WriteVar("NumPoints", NumPoints);
274  }
275 
276  void Read(IOSectionClass& inSection) override
277  {
278  double aval, bval;
279  int numPoints;
280  if (inSection.ReadVar("a", aval))
281  {
282  assert(inSection.ReadVar("b", bval));
283  assert(inSection.ReadVar("NumPoints", numPoints));
284  Init(aval, bval, numPoints);
285  }
286  else
287  {
288  double Z, rmax;
289  assert(inSection.ReadVar("Z", Z));
290  assert(inSection.ReadVar("rmax", rmax));
291  Init(Z, rmax);
292  }
293  }
294 
295  void InitRatio(double end, double ratio, int numpoints)
296  {
297  End = end;
298  NumPoints = numpoints;
299 
300  b = log(ratio) / (double)(numpoints - 2);
301  a = end / (exp(b * (double)(numpoints - 1)) - 1);
302 
304 
305  for (int i = 0; i < NumPoints; i++)
306  grid(i) = a * (exp(b * i) - 1.0);
307  }
308 
309 
310  /// This form of the constructor takes a nuclear charge and a
311  /// maxmimum radius and chooses an appropriate number of points for
312  /// that atom.
313  void Init(double Z, double rmax)
314  {
315  a = 4.34e-6 / Z;
316  //a = 4.0e-2;
317  b = 0.002304;
318  //b = 0.004;
319 
320  NumPoints = (int)ceil(log(rmax / a + 1.0) / b);
321  b = log(rmax / a + 1.0) / (double)NumPoints;
322  Start = a * (exp(b) - 1.0);
323  End = rmax;
324  //End = a * (exp(b*NumPoints) - 1.0);
325 
327 
328  for (int i = 0; i < NumPoints; i++)
329  {
330  grid(i) = a * (exp(b * (i + 1)) - 1.0);
331  //fprintf (stdout, "%1.12e\n", grid(i));
332  }
333  }
334 
335  inline OptimalGrid& operator=(const OptimalGrid& opt)
336  {
337  grid.resize(opt.grid.shape());
338  a = opt.a;
339  b = opt.b;
340  NumPoints = opt.NumPoints;
341  Start = opt.Start;
342  End = opt.End;
343  grid = opt.grid;
344  return *this;
345  }
346 
347  OptimalGrid(double Z, double rmax) { Init(Z, rmax); }
348 };
349 
350 
351 /// The OptimalGrid class stores a grid which has linear spacing at
352 /// the origin and exponential spacing further out. It has the
353 /// analytic form \f[r_k = a\left(e^{kb}-1\right)\f].
354 class OptimalGrid2 : public Grid
355 {
356 private:
357  double a, b, c;
358  double Ratio;
359 
360 public:
361  GridType Type() override { return (OPTIMAL2); }
362 
363  int ReverseMap(double r) override
364  {
365  // if ((r/a) < 1e-6)
366  // return ((int)floor(r/(a*b)));
367  // else
368  return ((int)floor(log1p((r - c) / a) / b));
369  }
370 
371  /// Returns a parameter
372  double Geta() const { return (a); }
373 
374  /// Returns b parameter
375  double Getb() const { return (b); }
376 
378  {
379  // Do nothing
380  }
381 
382  /// This form of the constructor takes the number of points, the
383  /// maximum radius and the value of b.
384  OptimalGrid2(int numpoints, double rmax, double bval)
385  {
386  NumPoints = numpoints;
387  b = bval;
388  End = rmax;
389  a = End / (exp(b * (double)NumPoints) - 1.0);
390  Start = a * (exp(b) - 1.0);
392  c = 0.0;
393 
394  for (int i = 0; i < NumPoints; i++)
395  grid(i) = c + a * expm1(b * i);
396  }
397 
398  void Init(double start, double end, double ratio, int numpoints)
399  {
400  Start = start;
401  End = end;
402  Ratio = ratio;
403  NumPoints = numpoints;
404 
405  b = log(ratio) / (double)(numpoints - 2);
406  c = Start;
407  a = (end - c) / expm1(b * (double)(numpoints - 1));
408 
410 
411  for (int i = 0; i < NumPoints; i++)
412  grid(i) = c + a * expm1(b * i);
413  }
414 
415 
416  /// This form of the constructor takes a, b, and the number of points.
417  OptimalGrid2(double start, double end, double ratio, int numpoints) { Init(start, end, ratio, numpoints); }
418 
419  void Write(IOSectionClass& outSection) override
420  {
421  outSection.WriteVar("Points", grid);
422  outSection.WriteVar("Type", std::string("Optimal2"));
423  outSection.WriteVar("Start", Start);
424  outSection.WriteVar("End", End);
425  outSection.WriteVar("Ratio", Ratio);
426  outSection.WriteVar("NumPoints", NumPoints);
427  }
428 
429  void Read(IOSectionClass& inSection) override
430  {
431  double start, end, ratio;
432  int numPoints;
433  assert(inSection.ReadVar("Start", start));
434  assert(inSection.ReadVar("End", end));
435  assert(inSection.ReadVar("Ratio", ratio));
436  assert(inSection.ReadVar("NumPoints", numPoints));
437  Init(start, end, ratio, numPoints);
438  }
439 };
440 
441 
442 class CenterGrid : public Grid
443 {
444 private:
445  double a, aInv, b, bInv, center;
447  bool Odd;
448  double EvenHalf;
449  int OddOne;
450 
451 public:
452  // ratio gives approximately the largest grid spacing divided by the
453  // smallest.
454  GridType Type() override { return CENTER; }
455 
456  int ReverseMap(double x) override
457  {
458  x -= center;
459  double index = copysign(log1p(std::abs(x) * aInv) * bInv, x);
460  return (int)floor(HalfPoints + index - EvenHalf);
461  }
462  void Write(IOSectionClass& out) override {}
463  void Read(IOSectionClass& in) override {}
464  void Init(double start, double end, double ratio, int numPoints)
465  {
466  assert(ratio > 1.0);
467  Start = start;
468  End = end;
469  center = 0.5 * (start + end);
470  NumPoints = numPoints;
471  HalfPoints = numPoints / 2;
472  Odd = ((numPoints % 2) == 1);
473  b = log(ratio) / (double)(HalfPoints - 1);
474  bInv = 1.0 / b;
475  grid.resize(numPoints);
476  if (Odd)
477  {
478  EvenHalf = 0.0;
479  OddOne = 1;
480  a = 0.5 * (end - start) / expm1(b * HalfPoints);
481  aInv = 1.0 / a;
482  for (int i = -HalfPoints; i <= HalfPoints; i++)
483  {
484  double sign = (i < 0) ? -1.0 : 1.0;
485  grid(i + HalfPoints) = sign * a * expm1(b * std::abs(i)) + center;
486  }
487  }
488  else
489  {
490  EvenHalf = 0.5;
491  OddOne = 0;
492  a = 0.5 * (end - start) / expm1(b * (-0.5 + HalfPoints));
493  aInv = 1.0 / a;
494  for (int i = -HalfPoints; i < HalfPoints; i++)
495  {
496  double sign = (i < 0) ? -1.0 : 1.0;
497  grid(i + HalfPoints) = sign * a * expm1(b * std::abs(0.5 + i)) + center;
498  }
499  }
500  }
501 };
502 
503 
504 /// LogGrid is a function whose gridpoints increase exponentially with
505 /// the index. That is, it has the analytic form
506 /// \f[ r_k = \frac{r_0}{Z} \Delta^k.\f] It is appropriate for
507 /// functions which change rapidly near the origin but vary smoothly
508 /// further out.
509 class LogGrid : public Grid
510 {
511 public:
512  double Z, r0, Spacing;
513 
514  GridType Type() override { return (LOG); }
515 
516  int ReverseMap(double r) override { return ((int)(floor(log(Z * r / r0) / log(Spacing)))); }
517 
519  {
520  // Do nothing
521  }
522 
523  void Init(double R0, double spacing, int numpoints)
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  }
536 
537 
538  void Write(IOSectionClass& outSection) override
539  {
540  outSection.WriteVar("Points", grid);
541  outSection.WriteVar("Type", std::string("Log"));
542  outSection.WriteVar("r0", r0);
543  outSection.WriteVar("Spacing", Spacing);
544  }
545 
546  void Read(IOSectionClass& inSection) override
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  }
555 
556  LogGrid(double R0, double spacing, int numpoints) { Init(R0, spacing, numpoints); }
557 
558  LogGrid(int numpoints, double z, double R0, double spacing)
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  }
573 };
574 
575 
576 /// ClusterGrid is a function whose gridpoints are clustered tightly
577 /// around the origin.
578 class ClusterGrid : public Grid
579 {
580 private:
581  double x0, dri, rr;
582 
583 public:
584  double Start, End, Cluster;
585 
586  GridType Type() override { return (CLUSTER); }
587 
588  int ReverseMap(double r) override { return ((int)floor(dri / (r - rr) - 1.0 + x0)); }
589 
590  void Init(double start, double end, double cluster, int numpoints)
591  {
592  Start = start;
593  End = end;
594  Cluster = cluster;
595  NumPoints = numpoints;
596 
597  x0 = (NumPoints - Cluster) / (1.0 - Cluster);
598  dri = -(End - Start) * ((double)NumPoints - x0) * (1.0 - x0) / ((double)NumPoints - 1.0);
599  rr = Start - dri / (1.0 - x0);
601  for (int i = 0; i < NumPoints; i++)
602  grid(i) = rr + dri / (i + 1.0 - x0);
603  }
604 
605  void Write(IOSectionClass& outSection) override
606  {
607  outSection.WriteVar("Points", grid);
608  outSection.WriteVar("Type", std::string("Cluster"));
609  outSection.WriteVar("Start", Start);
610  outSection.WriteVar("End", End);
611  outSection.WriteVar("Cluster", Cluster);
612  outSection.WriteVar("NumPoints", NumPoints);
613  }
614 
615  void Read(IOSectionClass& inSection) override
616  {
617  double start, end, cluster;
618  int numpoints;
619  assert(inSection.ReadVar("Start", start));
620  assert(inSection.ReadVar("End", end));
621  assert(inSection.ReadVar("Cluster", cluster));
622  assert(inSection.ReadVar("NumPoints", numpoints));
623  Init(start, end, cluster, numpoints);
624  }
625 
626  ClusterGrid(double start, double end, double cluster, int numpoints) { Init(start, end, cluster, numpoints); }
628  { /* Do nothing */
629  }
630 };
631 
632 
633 inline std::shared_ptr<Grid> ReadGrid(IOSectionClass& inSection)
634 {
635  std::string Type;
636  assert(inSection.ReadVar("Type", Type));
637 
638  std::shared_ptr<Grid> newGrid;
639  if (Type == "Linear")
640  newGrid = std::make_shared<LinearGrid>();
641  else if (Type == "General")
642  newGrid = std::make_shared<GeneralGrid>();
643  else if (Type == "Optimal")
644  newGrid = std::make_shared<OptimalGrid>();
645  else if (Type == "Optimal2")
646  newGrid = std::make_shared<OptimalGrid2>();
647  else if (Type == "Log")
648  newGrid = std::make_shared<LogGrid>();
649  else if (Type == "Cluster")
650  newGrid = std::make_shared<ClusterGrid>();
651  else
652  {
653  std::cerr << "Unrecognized Grid type " << Type << "\n";
654  exit(1);
655  }
656  newGrid->Read(inSection);
657  return newGrid;
658 }
659 
660 
662 {
663  for (int i = 0; i < 100; i++)
664  {
665  double x = 100.0 * drand48() - 50.0;
666  if (nearbyint(x) != round(x))
667  {
668  std::cerr << "Error in rounding mode detected in LinearGrid. Abort.\n";
669  abort();
670  }
671  }
672 }
673 
674 
675 #endif
OptimalGrid(double Z, double rmax)
Definition: Grid.h:347
Definition: Grid.h:35
double Getb() const
Returns b parameter.
Definition: Grid.h:375
void Init(double start, double end, double ratio, int numPoints)
Definition: Grid.h:464
std::shared_ptr< Grid > ReadGrid(IOSectionClass &inSection)
Definition: Grid.h:633
void Write(IOSectionClass &outSection) override
Definition: Grid.h:605
GridType Type() override
Returns the type of the grid (in this case LINEAR)
Definition: Grid.h:82
void Read(IOSectionClass &inSection) override
Definition: Grid.h:276
double r0
Definition: Grid.h:512
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
Array< double, 1 > grid
Contains the grid points.
Definition: Grid.h:47
Parent class for all grids.
Definition: Grid.h:43
int ReverseMap(double r) override
Returns the index of the nearest point below r.
Definition: Grid.h:85
OptimalGrid(double aval, double bval, int numPoints)
This form of the constructor takes a, b, and the number of points.
Definition: Grid.h:265
int NumPoints
Number of points in the grid.
Definition: Grid.h:54
void Write(IOSectionClass &out) override
Definition: Grid.h:462
void Write(IOSectionClass &outSection) override
Definition: Grid.h:172
Type_t * data()
Definition: OhmmsArray.h:87
Array< double, 1 > & Points()
Definition: Grid.h:59
void Write(IOSectionClass &outSection) override
Definition: Grid.h:267
double Geta() const
Returns a parameter.
Definition: Grid.h:222
GridType Type() override
Returns the type of the grid (i.e. linear, optimal, etc)
Definition: Grid.h:514
void Init(double start, double end, double ratio, int numpoints)
Definition: Grid.h:398
void Read(IOSectionClass &inSection) override
Definition: Grid.h:546
void Init(Array< double, 1 > &points)
Definition: Grid.h:186
Definition: Grid.h:37
double Z
Definition: Grid.h:512
int ReverseMap(double r) override
Returns the index of the nearest point below r.
Definition: Grid.h:516
General Grid inherets from Grid.
Definition: Grid.h:141
bool WriteVar(std::string name, T val)
Writes a variable under the current section.
Definition: IO.h:184
GridType Type() override
Returns the type of the grid (i.e. linear, optimal, etc)
Definition: Grid.h:361
double c
Definition: Grid.h:357
void resize(const std::array< SIZET, D > &dims)
Resize the container.
Definition: OhmmsArray.h:65
void Read(IOSectionClass &inSection) override
Definition: Grid.h:110
double EvenHalf
Definition: Grid.h:448
double a
Definition: Grid.h:445
double Getb() const
Returns b parameter.
Definition: Grid.h:225
Definition: Grid.h:32
void Init(double aval, double bval, int numPoints)
Definition: Grid.h:249
T min(T a, T b)
void Init(double start, double end, double cluster, int numpoints)
Definition: Grid.h:590
LogGrid(double R0, double spacing, int numpoints)
Definition: Grid.h:556
double aInv
Definition: Grid.h:445
double b
Definition: Grid.h:357
ClusterGrid is a function whose gridpoints are clustered tightly around the origin.
Definition: Grid.h:578
virtual ~Grid()
Definition: Grid.h:68
void Write(IOSectionClass &outSection) override
Definition: Grid.h:538
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)
virtual void Read(IOSectionClass &inSection)=0
double b
Definition: Grid.h:445
OptimalGrid & operator=(const OptimalGrid &opt)
Definition: Grid.h:335
double Spacing
Definition: Grid.h:512
MakeReturn< UnaryNode< FnCeil, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t ceil(const Vector< T1, C1 > &l)
virtual GridType Type()=0
Returns the type of the grid (i.e. linear, optimal, etc)
double * data()
Definition: Grid.h:58
void Init(int numpoints, double rmax, double bval)
This form of the constructor takes the number of points, the maximum radius and the value of b...
Definition: Grid.h:234
void Init(double start, double end, int numpoints)
Initializes the linear grid.
Definition: Grid.h:88
void Write(IOSectionClass &outSection) override
Definition: Grid.h:101
double rr
Definition: Grid.h:581
double a
Definition: Grid.h:357
double x0
Definition: Grid.h:581
double a
Definition: Grid.h:208
void Read(IOSectionClass &inSection) override
Definition: Grid.h:615
GeneralGrid()
Useless constructor.
Definition: Grid.h:196
double Ratio
Definition: Grid.h:358
The OptimalGrid class stores a grid which has linear spacing at the origin and exponential spacing fu...
Definition: Grid.h:354
Definition: Grid.h:33
size_t size() const
Definition: OhmmsArray.h:57
void Init(double Z, double rmax)
This form of the constructor takes a nuclear charge and a maxmimum radius and chooses an appropriate ...
Definition: Grid.h:313
GridType Type() override
Returns the type of the grid (in this case GENERAL)
Definition: Grid.h:145
virtual int ReverseMap(double r)=0
Returns the index of the nearest point below r.
OptimalGrid2(double start, double end, double ratio, int numpoints)
This form of the constructor takes a, b, and the number of points.
Definition: Grid.h:417
double Cluster
Definition: Grid.h:584
Linear Grid inherets from Grid.
Definition: Grid.h:73
double Geta() const
Returns a parameter.
Definition: Grid.h:372
double deltainv
Definition: Grid.h:77
void Read(IOSectionClass &in) override
Definition: Grid.h:463
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
void Read(IOSectionClass &inSection) override
Definition: Grid.h:178
LinearGrid & operator=(const LinearGrid &lin)
Definition: Grid.h:123
void InitRatio(double end, double ratio, int numpoints)
Definition: Grid.h:295
double b
Definition: Grid.h:208
OptimalGrid(int numPoints, double rmax, double bval)
Definition: Grid.h:247
double sign(double x)
Definition: Standard.h:73
OptimalGrid()
Definition: Grid.h:227
GridType Type() override
Returns the type of the grid (i.e. linear, optimal, etc)
Definition: Grid.h:586
MakeReturn< UnaryNode< FnLog, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t log(const Vector< T1, C1 > &l)
GridType Type() override
Returns the type of the grid (i.e. linear, optimal, etc)
Definition: Grid.h:211
LogGrid is a function whose gridpoints increase exponentially with the index.
Definition: Grid.h:509
ClusterGrid(double start, double end, double cluster, int numpoints)
Definition: Grid.h:626
LinearGrid()
Useless constructor.
Definition: Grid.h:119
int HalfPoints
Definition: Grid.h:446
GridType
The different types of grids that we currently allow.
Definition: Grid.h:29
The OptimalGrid class stores a grid which has linear spacing at the origin and exponential spacing fu...
Definition: Grid.h:205
int ReverseMap(double x) override
Returns the index of the nearest point below r.
Definition: Grid.h:456
constexpr double done
Definition: BLAS.hpp:48
double Start
First and last grid points.
Definition: Grid.h:51
double operator()(int i) const
The i&#39;th point in the grid.
Definition: Grid.h:57
Definition: Grid.h:31
int ReverseMap(double r) override
Returns the index of the nearest point below r.
Definition: Grid.h:148
double Start
Definition: Grid.h:584
double End
Definition: Grid.h:584
LinearGrid(double start, double end, int numpoints)
Constructor that sets the number of points, start and end point of the original grid.
Definition: Grid.h:136
double center
Definition: Grid.h:445
Wrapper class for IOTreeClass that gives a nearly identical interface as the OutputSectionClass.
Definition: IO.h:110
bool Odd
Definition: Grid.h:447
int ReverseMap(double r) override
Returns the index of the nearest point below r.
Definition: Grid.h:213
int ReverseMap(double r) override
Returns the index of the nearest point below r.
Definition: Grid.h:588
GridType Type() override
Returns the type of the grid (i.e. linear, optimal, etc)
Definition: Grid.h:454
virtual void Write(IOSectionClass &out)=0
LogGrid(int numpoints, double z, double R0, double spacing)
Definition: Grid.h:558
OptimalGrid2(int numpoints, double rmax, double bval)
This form of the constructor takes the number of points, the maximum radius and the value of b...
Definition: Grid.h:384
Definition: Grid.h:38
void Read(IOSectionClass &inSection) override
Definition: Grid.h:429
double delta
The value between successive grid points.
Definition: Grid.h:77
OptimalGrid2()
Definition: Grid.h:377
const std::array< size_t, D > & shape() const
Definition: OhmmsArray.h:56
void CheckRoundingMode()
Definition: Grid.h:661
void Write(IOSectionClass &outSection) override
Definition: Grid.h:419
double dri
Definition: Grid.h:581
void Init(double R0, double spacing, int numpoints)
Definition: Grid.h:523
double bInv
Definition: Grid.h:445
double End
Definition: Grid.h:51
int OddOne
Definition: Grid.h:449
Definition: Grid.h:34
Definition: Grid.h:36
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
LogGrid()
Definition: Grid.h:518
MakeReturn< UnaryNode< FnFloor, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t floor(const Vector< T1, C1 > &l)
ClusterGrid()
Definition: Grid.h:627
int ReverseMap(double r) override
Returns the index of the nearest point below r.
Definition: Grid.h:363