QMCPACK
OneDimGridFactory.cpp
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: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
9 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
10 //
11 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
12 //////////////////////////////////////////////////////////////////////////////////////
13 
14 
15 #include "OneDimGridFactory.h"
16 #include "OhmmsData/AttributeSet.h"
18 
19 namespace qmcplusplus
20 {
21 std::unique_ptr<OneDimGridFactory::GridType> OneDimGridFactory::createGrid(xmlNodePtr cur)
22 {
23  std::unique_ptr<GridType> agrid;
24  RealType ri = 1e-5;
25  RealType rf = 100.0;
26  RealType ascale = -1.0e0;
27  RealType astep = 1.25e-2;
28  IndexType npts = 1001;
29  std::string gridType("log");
30  std::string gridID("invalid");
31  OhmmsAttributeSet radAttrib;
32  radAttrib.add(gridType, "type");
33  radAttrib.add(npts, "npts");
34  radAttrib.add(ri, "ri");
35  radAttrib.add(rf, "rf");
36  radAttrib.add(ascale, "ascale");
37  radAttrib.add(astep, "astep");
38  radAttrib.add(ascale, "scale");
39  radAttrib.add(astep, "step");
40  radAttrib.add(gridID, "id");
41  radAttrib.add(gridID, "name");
42  radAttrib.add(gridID, "ref");
43  if (cur != NULL)
44  radAttrib.put(cur);
45  if (gridType == "log")
46  {
47  if (ascale > 0.0)
48  {
49  LOGMSG("Using log grid with default values: scale = " << ascale << " step = " << astep << " npts = " << npts)
50  agrid = std::make_unique<LogGridZero<RealType>>();
51  agrid->set(astep, ascale, npts);
52  }
53  else
54  {
55  LOGMSG("Using log grid with default values: ri = " << ri << " rf = " << rf << " npts = " << npts)
56  if (ri < std::numeric_limits<RealType>::epsilon())
57  {
58  ri = std::numeric_limits<RealType>::epsilon();
59  app_error() << " LogGrid cannot accept r=0 for the initial point. Using ri=" << ri << std::endl;
60  }
61  agrid = std::make_unique<LogGrid<RealType>>();
62  agrid->set(ri, rf, npts);
63  }
64  }
65  else if (gridType == "linear")
66  {
67  LOGMSG("Using linear grid with default values: ri = " << ri << " rf = " << rf << " npts = " << npts)
68  agrid = std::make_unique<LinearGrid<RealType>>();
69  agrid->set(ri, rf, npts);
70  }
71  else
72  {
73  throw UniformCommunicateError("Unknown gridtype. Valid settings are \"log\" and \"linear\"\n");
74  }
75  return agrid;
76 }
77 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
QTBase::RealType RealType
Definition: Configuration.h:58
static std::unique_ptr< GridType > createGrid(xmlNodePtr cur)
return a GridType*
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
std::ostream & app_error()
Definition: OutputManager.h:67
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
This a subclass for runtime errors that will occur on all ranks.
OHMMS_INDEXTYPE IndexType
define other types
Definition: Configuration.h:65
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
Definition: AttributeSet.h:42
#define LOGMSG(msg)
Definition: OutputManager.h:82