QMCPACK
test_qmcfstool.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) 2020 QMCPACK developers.
6 //
7 // File developed by: Cody A. Melton, cmelton@sandia.gov, Sandia National Laboratories
8 //
9 // File created by: Cody A. Melton, cmelton@sandia.gov, Sandia National Laboratories
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 #include "catch.hpp"
13 #include <iostream>
14 #include <vector>
15 
16 #include "Configuration.h"
20 #include "Particle/ParticleSet.h"
22 #include <string>
23 
24 namespace qmcplusplus
25 {
26 TEST_CASE("FS parse Sk file", "[tools]")
27 {
30  std::unique_ptr<SkParserBase> skparser = std::make_unique<SkParserASCII>();
31  std::string filename = "simple_Sk.dat";
32  skparser->parse(filename);
33  std::vector<RealType> sk = skparser->get_sk_raw();
34  std::vector<RealType> skerr = skparser->get_skerr_raw();
35  std::vector<PosType> grid = skparser->get_grid_raw();
36 
37  CHECK(grid[0][0] == Approx(0.0));
38  CHECK(grid[0][1] == Approx(0.0));
39  CHECK(grid[0][2] == Approx(-6.283185307179586));
40  CHECK(sk[0] == Approx(0.07225651367144714));
41  CHECK(skerr[0] == Approx(0.01));
42 
43  int last = sk.size() - 1;
44  CHECK(grid[last][0] == Approx(-18.84955592153876));
45  CHECK(grid[last][1] == Approx(18.84955592153876));
46  CHECK(grid[last][2] == Approx(75.39822368615503));
47  CHECK(sk[last] == Approx(0.9999947116274186));
48  CHECK(skerr[last] == Approx(0.01));
49 }
50 
51 TEST_CASE("FS evaluate", "[tools]")
52 {
55 
56  std::unique_ptr<SkParserBase> skparser = std::make_unique<SkParserASCII>();
57  std::string filename = "simple_Sk.dat";
58  skparser->parse(filename);
59 
60  QMCFiniteSize qfs(skparser.get());
61  qfs.parse(std::string("simple_input.xml"));
62  qfs.validateXML();
63  qfs.initialize();
64 
65  /// reference numbers and simple_Sk.dat created by fs_ref.py
66  std::vector<RealType> skr = skparser->get_sk_raw();
67  RealType vsum = qfs.calcPotentialDiscrete(skr);
68  CHECK(vsum == Approx(1.0547517220577185));
69 
70  std::vector<RealType> sk, skerr;
71  skparser->get_sk(sk, skerr);
72  RealType vint = qfs.calcPotentialInt(sk);
73  CHECK(vint == Approx(1.066688342657357).epsilon(0.001));
74 }
75 
76 } // namespace qmcplusplus
bool parse(const std::string &infile)
parse an input file
Definition: QMCAppBase.cpp:64
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
QTBase::RealType RealType
Definition: Configuration.h:58
TEST_CASE("complex_helper", "[type_traits]")
QTBase::PosType PosType
Definition: Configuration.h:61
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
Class to handle FS corrections.
Definition: QMCFiniteSize.h:19
Declaration of ParticleSetPool.