QMCPACK
test_MagnetizationDensityInput.cpp
Go to the documentation of this file.
1 
2 //////////////////////////////////////////////////////////////////////////////////////
3 // This file is distributed under the University of Illinois/NCSA Open Source License.
4 // See LICENSE file in top directory for details.
5 //
6 // Copyright (c) 2023 QMCPACK developers.
7 //
8 // File developed by: Raymond Clay, rclay@sandia.gov, Sandia National Laboratories
9 //
10 // File created by: Raymond Clay, rclay@sandia.gov, Sandia National Laboratories
11 //////////////////////////////////////////////////////////////////////////////////////
12 
13 
14 #include "catch.hpp"
15 
19 #include "EstimatorTesting.h"
20 #include "ParticleSet.h"
21 #include "OhmmsData/Libxml2Doc.h"
23 
24 #include <iostream>
25 
26 namespace qmcplusplus
27 {
28 TEST_CASE("MagnetizationDensityInput::from_xml", "[estimators]")
29 {
30  using POLT = PtclOnLatticeTraits;
33  using namespace testing::magdensity;
34 
36 
37  for (auto input_xml : valid_mag_density_input_sections)
38  {
40  bool okay = doc.parseFromString(input_xml);
41  REQUIRE(okay);
42  xmlNodePtr node = doc.getRoot();
45  }
46 
47  for (auto input_xml : testing::invalid_mag_density_input_sections)
48  {
50  bool okay = doc.parseFromString(input_xml);
51  REQUIRE(okay);
52  xmlNodePtr node = doc.getRoot();
53 
54  CHECK_THROWS(MagnetizationDensityInput(node));
55  }
56 
57  //Lastly, going to check the state variables are consistent with the input.
58  //We'll take the magdensity::Inputs::valid_magdensity_input test case for
59  //thorough checking.
60  {
63  bool okay = doc.parseFromString(input_xml);
64  REQUIRE(okay);
65  xmlNodePtr node = doc.getRoot();
67  int nsamples = magdens.get_nsamples();
68  int integrator = int(magdens.get_integrator());
69  PosType grid = magdens.get_grid();
70  PosType dr = magdens.get_dr();
71  PosType corner = magdens.get_corner();
72 
73 
74  app_log() << "NSAMPLES = " << nsamples << std::endl;
75  app_log() << "INTEGRATOR = " << integrator << std::endl;
76  app_log() << "CORNER = " << corner << std::endl;
77  app_log() << "GRID = " << grid << std::endl;
78  app_log() << "DR = " << dr << std::endl;
79 
80  CHECK(nsamples == 64);
81  CHECK(integrator == 0);
82  CHECK(grid[0] == Approx(4));
83  CHECK(grid[1] == Approx(3));
84  CHECK(grid[2] == Approx(2));
85  CHECK(corner[0] == Approx(0.0));
86  CHECK(corner[1] == Approx(0.0));
87  CHECK(corner[2] == Approx(0.0));
88  CHECK(dr[0] == Approx(0.1));
89  CHECK(dr[1] == Approx(0.1));
90  CHECK(dr[2] == Approx(0.1));
91  }
92 }
93 
94 } // namespace qmcplusplus
a class that defines a supercell in D-dimensional Euclean space.
class that handles xmlDoc
Definition: Libxml2Doc.h:76
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
if(!okay) throw std xmlNodePtr node
std::ostream & app_log()
Definition: OutputManager.h:65
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > ParticleLayout
Definition: Configuration.h:79
TEST_CASE("complex_helper", "[type_traits]")
xmlNodePtr getRoot()
Definition: Libxml2Doc.h:88
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > lattice
REQUIRE(std::filesystem::exists(filename))
constexpr std::array< std::string_view, 4 > valid_mag_density_input_sections
QTBase::PosType PosType
Definition: Configuration.h:61
DerivedParameters calculateDerivedParameters(const Lattice &lattice) const
Derived parameters of SpinDensity.
Particle traits to use UniformGridLayout for the ParticleLayout.
Definition: Configuration.h:77
bool parseFromString(const std::string_view data)
Definition: Libxml2Doc.cpp:204
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
constexpr std::array< std::string_view, 3 > invalid_mag_density_input_sections