QMCPACK
ParameterSet Struct Reference

class to handle a set of parameters More...

+ Inheritance diagram for ParameterSet:
+ Collaboration diagram for ParameterSet:

Public Member Functions

 ParameterSet (const char *aname="parameter")
 
bool get (std::ostream &os) const override
 write to a std::ostream More...
 
bool put (std::istream &is) override
 read from std::istream More...
 
bool put (xmlNodePtr cur) override
 assign parameters to the set More...
 
void reset () override
 reset member data More...
 
template<class PDT >
void add (PDT &aparam, const std::string &aname_in, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
 add a new parameter corresponding to an xmlNode <parameter> More...
 
template<class PDT >
void setValue (const std::string &aname_in, PDT aval)
 
- Public Member Functions inherited from OhmmsElementBase
 OhmmsElementBase (const char *aname="none")
 constructor with a name More...
 
virtual ~OhmmsElementBase ()
 destructor More...
 
const std::string & getName () const
 return the name More...
 
void setName (const std::string &aname)
 set name More...
 
void setIOMode (int imode)
 set iomode More...
 
virtual bool add (xmlNodePtr parent)
 add a xmlNode to the children list of parent More...
 
void put (const std::string &s)
 read from string More...
 
virtual void begin_node (std::ostream &os) const
 write the start of a node More...
 
virtual void end_node (std::ostream &os) const
 write the end of a node More...
 

Public Attributes

std::map< std::string, std::unique_ptr< OhmmsElementBase > > m_param
 

Additional Inherited Members

- Public Types inherited from OhmmsElementBase
enum  { useLIBXML = 0, useLIBXMLPP, usePLAIN }
 enumeration to choose the xml parser More...
 
- Protected Attributes inherited from OhmmsElementBase
int myIOMode
 the type of IO mode: default is useLIBXML More...
 
std::string myName
 the name of the node, corresponds to the xml tag More...
 

Detailed Description

class to handle a set of parameters

Definition at line 27 of file ParameterSet.h.

Constructor & Destructor Documentation

◆ ParameterSet()

ParameterSet ( const char *  aname = "parameter")
inline

Definition at line 33 of file ParameterSet.h.

33 : OhmmsElementBase(aname) {}
OhmmsElementBase(const char *aname="none")
constructor with a name

Member Function Documentation

◆ add()

template void add< float > ( PDT &  aparam,
const std::string &  aname_in,
std::vector< PDT >  candidate_values = {},
TagStatus  status = TagStatus::OPTIONAL 
)

add a new parameter corresponding to an xmlNode <parameter>

Parameters
aparamreference the object which this parameter is assigned to.
aname_inthe value of the name attribute
candidate_valuescandidate values to be checked against, the first element is the default value
statusTag status, See OhmmsParameter.h for more details

Definition at line 58 of file ParameterSet.cpp.

References qmcplusplus::lowerCase(), and m_param.

Referenced by qmcplusplus::createDriftModifier(), RadialJastrowBuilder::createJ1(), qmcplusplus::createWalkerController(), CSUpdateBase::CSUpdateBase(), CSVMC::CSVMC(), DMC::DMC(), DriftModifierUNR::parseXML(), QMCFixedSampleLinearOptimizeBatched::process(), HybridEngine::processXML(), DescentEngine::processXML(), FiniteDiffErrData::put(), VMC::put(), DMC::put(), CSVMC::put(), RPAJastrow::put(), RMCUpdateAllWithDrift::put(), RMCUpdatePbyPWithDrift::put(), NonLocalTOperator::put(), QMCFixedSampleLinearOptimize::put(), ProjectData::put(), ForceCeperley::put(), WalkerControl::put(), QMCCostFunctionBase::put(), SymmetryBuilder::put(), ForceChiesaPBCAA::put(), WalkerControlBase::put(), PWParameterSet::PWParameterSet(), QMCDriver::QMCDriver(), QMCFixedSampleLinearOptimize::QMCFixedSampleLinearOptimize(), QMCFixedSampleLinearOptimizeBatched::QMCFixedSampleLinearOptimizeBatched(), WFOptDriverInput::readXML(), GradientTestInput::readXML(), VMCDriverInput::readXML(), DMCDriverInput::readXML(), QMCDriverInput::readXML(), SFNBranch::registerParameters(), SimpleFixedNodeBranch::registerParameters(), SimpleFixedNodeBranch::resetRun(), RMC::RMC(), WaveFunctionTester::runNodePlot(), QMCUpdateBase::setDefaults(), TEST_CASE(), VMC::VMC(), and WaveFunctionTester::WaveFunctionTester().

59 {
60  using namespace qmcplusplus;
61  std::string aname(lowerCase(aname_in));
62  if (auto it = m_param.find(aname); it == m_param.end())
63  {
64  m_param[aname] = std::make_unique<OhmmsParameter<PDT>>(aparam, aname, std::move(candidate_values), status);
65  }
66 }
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
std::map< std::string, std::unique_ptr< OhmmsElementBase > > m_param
Definition: ParameterSet.h:31
std::string lowerCase(const std::string_view s)
++17

◆ get()

bool get ( std::ostream &  ) const
inlineoverridevirtual

write to a std::ostream

Implements OhmmsElementBase.

Definition at line 35 of file ParameterSet.h.

References OhmmsElementBase::get(), and m_param.

Referenced by VMC::put(), and CSVMC::put().

36  {
37  for (const auto& [name, param] : m_param)
38  param->get(os);
39  return true;
40  }
std::map< std::string, std::unique_ptr< OhmmsElementBase > > m_param
Definition: ParameterSet.h:31

◆ put() [1/2]

◆ put() [2/2]

bool put ( xmlNodePtr  cur)
overridevirtual

assign parameters to the set

Parameters
curthe xml node to work on
Returns
true, if any valid parameter is processed.

Accept both

  • <aname> value </aname>
  • <parameter name="aname"> value </parameter> aname is converted into lower cases.

Implements OhmmsElementBase.

Definition at line 22 of file ParameterSet.cpp.

References castXMLCharToChar(), getXMLAttributeValue(), qmcplusplus::lowerCase(), m_param, and OhmmsElementBase::myName.

23 {
24  using namespace qmcplusplus;
25  if (cur == NULL)
26  return true; //handle empty node
27  cur = cur->xmlChildrenNode;
28  bool something = false;
29  while (cur != NULL)
30  {
31  std::string cname(lowerCase(castXMLCharToChar(cur->name)));
32  if (auto it_tag = m_param.find(cname); it_tag == m_param.end())
33  {
34  if (cname == myName)
35  {
36  std::string aname(lowerCase(getXMLAttributeValue(cur, "name")));
37  if (!aname.empty())
38  {
39  if (auto it = m_param.find(aname); it != m_param.end())
40  {
41  something = true;
42  it->second->put(cur);
43  }
44  }
45  }
46  }
47  else
48  {
49  something = true;
50  it_tag->second->put(cur);
51  }
52  cur = cur->next;
53  }
54  return something;
55 }
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
std::string myName
the name of the node, corresponds to the xml tag
std::map< std::string, std::unique_ptr< OhmmsElementBase > > m_param
Definition: ParameterSet.h:31
std::string lowerCase(const std::string_view s)
++17
char * castXMLCharToChar(xmlChar *c)
assign a value from a node. Use specialization for classes.
Definition: libxmldefs.h:62
std::string getXMLAttributeValue(const xmlNodePtr cur, const std::string_view name)
get the value string for attribute name if name is unfound in cur you get an empty string back this i...

◆ reset()

void reset ( )
inlineoverridevirtual

reset member data

Implements OhmmsElementBase.

Definition at line 55 of file ParameterSet.h.

55 {}

◆ setValue()

template void setValue< int > ( const std::string &  aname_in,
PDT  aval 
)

Definition at line 69 of file ParameterSet.cpp.

References qmcplusplus::lowerCase(), and m_param.

Referenced by QMCDriver::setValue().

70 {
71  using namespace qmcplusplus;
72  std::string aname(lowerCase(aname_in));
73  if (auto it = m_param.find(aname); it != m_param.end())
74  {
75  (dynamic_cast<OhmmsParameter<PDT>&>(*it->second)).setValue(aval);
76  }
77 }
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
std::map< std::string, std::unique_ptr< OhmmsElementBase > > m_param
Definition: ParameterSet.h:31
std::string lowerCase(const std::string_view s)
++17

Member Data Documentation

◆ m_param

std::map<std::string, std::unique_ptr<OhmmsElementBase> > m_param

Definition at line 31 of file ParameterSet.h.

Referenced by add(), get(), put(), and setValue().


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