QMCPACK
test_ScalarEstimatorInputs.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) 2024 QMCPACK developers.
6 //
7 // File developed by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab
8 //
9 // File created by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "catch.hpp"
14 
15 #include "OhmmsData/Libxml2Doc.h"
16 #include "ScalarEstimatorInputs.h"
18 #include "ModernStringUtils.hpp"
19 
20 namespace qmcplusplus
21 {
22 
23 TEST_CASE("Scalar Estimator Input", "[estimators]")
24 {
26 
27  for (auto input_xml : input::xml)
28  {
30  bool okay = doc.parseFromString(input_xml);
31  REQUIRE(okay);
32  xmlNodePtr node = doc.getRoot();
33  std::string atype(lowerCase(getXMLAttributeValue(node, "type")));
34  std::string aname(lowerCase(getXMLAttributeValue(node, "name")));
35  // Since legacy inconsistently used name instead of type attribute to specify scalar estimator type
36  if (atype.empty() && !aname.empty())
37  atype = aname;
38  if (aname.empty() && !atype.empty())
39  aname = atype;
40  if (atype == "localenergy" || atype == "elocal")
41  {
43  CHECK(lowerCase(lei.get_type()) == "localenergy");
44  }
45  else if (atype == "cslocalenergy")
46  {
47  CSLocalEnergyInput cslei(node);
48  CHECK(lowerCase(cslei.get_type()) == "cslocalenergy");
49  }
50  else if (atype == "rmc")
51  {
52  RMCLocalEnergyInput rmclei(node);
53  CHECK(lowerCase(rmclei.get_type()) == "rmclocalenergy");
54  }
55  else
56  {
57  FAIL("Unhandled scalar estimator " << atype);
58  }
59  }
60 }
61 
62 
63 } // namespace qmcplusplus
class that handles xmlDoc
Definition: Libxml2Doc.h:76
This file contains the input classes for the supported "main estimator" classes derived from ScalarEs...
const std::string & get_type() const
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
if(!okay) throw std xmlNodePtr node
TEST_CASE("complex_helper", "[type_traits]")
xmlNodePtr getRoot()
Definition: Libxml2Doc.h:88
const std::string & get_type() const
const std::string & get_type() const
static constexpr std::array< std::string_view, 3 > xml
REQUIRE(std::filesystem::exists(filename))
std::string lowerCase(const std::string_view s)
++17
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...
bool parseFromString(const std::string_view data)
Definition: Libxml2Doc.cpp:204
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))