From e85c1487f484efa3c45e4316a4f6231ee210fec1 Mon Sep 17 00:00:00 2001 From: Peter Doak Date: Tue, 5 Dec 2023 17:56:56 -0500 Subject: [PATCH 1/5] small changes to make floats always full precision --- src/Estimators/InputSection.cpp | 16 ++++++++---- src/Estimators/InputSection.h | 16 ++++++++---- src/Estimators/tests/test_InputSection.cpp | 30 ++++++++++------------ 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/src/Estimators/InputSection.cpp b/src/Estimators/InputSection.cpp index ad1f1c4713..5e52d69e2d 100644 --- a/src/Estimators/InputSection.cpp +++ b/src/Estimators/InputSection.cpp @@ -2,7 +2,7 @@ // This file is distributed under the University of Illinois/NCSA Open Source License. // See LICENSE file in top directory for details. // -// Copyright (c) 2022 QMCPACK developers. +// Copyright (c) 2023 QMCPACK developers. // // File developed by: Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory // Peter W. Doak, doakpw@ornl.gov, Oak Ridge National Laboratory @@ -49,7 +49,6 @@ void InputSection::readAttributes(xmlNodePtr cur, setFromStreamCustom(element_name, qualified_name, stream); else setFromStream(qualified_name, stream); - att = att->next; } } @@ -65,6 +64,7 @@ void InputSection::handleDelegate(const std::string& ename, const xmlNodePtr ele void InputSection::readXML(xmlNodePtr cur) { + assert(cur != nullptr); // For historical reasons that actual "type" of the element/input section is expressed in a very inconsistent way. // It could be coded via the element name i.e. the tag, or at minimum a method, type, or name attribute. std::string section_ename{lowerCase(castXMLCharToChar(cur->name))}; @@ -200,7 +200,7 @@ void InputSection::setFromStream(const std::string& name, std::istringstream& sv else if (isMultiReal(name)) { std::vector real_values; - for (FullPrecReal value; svalue >> value;) + for (Real value; svalue >> value;) real_values.push_back(static_cast(value)); assignValue(name, real_values); } @@ -219,7 +219,7 @@ void InputSection::setFromStream(const std::string& name, std::istringstream& sv } else if (isReal(name)) { - FullPrecReal value; + Real value; svalue >> value; assignValue(name, Real(value)); } @@ -249,7 +249,7 @@ void InputSection::assignValue(const std::string& name, const T& value) else { if (has(name)) - std::any_cast>(values_[name]).push_back(value); + std::any_cast&>(values_[name]).push_back(value); else values_[name] = std::vector{value}; } @@ -318,6 +318,12 @@ void InputSection::report(std::ostream& out) const out << "\n\n"; } +void InputSection::report() const +{ + auto& out = app_log(); + report(out); +} + std::any InputSection::lookupAnyEnum(const std::string& enum_name, const std::string& enum_value, const std::unordered_map& enum_map) diff --git a/src/Estimators/InputSection.h b/src/Estimators/InputSection.h index e69ee735cf..ad86a8c3c9 100644 --- a/src/Estimators/InputSection.h +++ b/src/Estimators/InputSection.h @@ -28,16 +28,22 @@ namespace qmcplusplus { + /** Input section provides basic parsing and a uniform method of access to the raw parsed input. + * It is still expected to be a composed part of the actual input class for a simulation class. + * It does not operate at reduced precision, i.e. numerical input is always parsed and retrieved + * at full precision. Gettting values from input section is strongly typed so you will get errors + * if you try to get numeric types at reduced precision. + */ class InputSection { public: - using FullPrecReal = QMCTraits::FullPrecRealType; - using Real = QMCTraits::RealType; - using Position = QMCTraits::PosType; + using Real = QMCTraits::FullPrecRealType; + using Position = typename QMCTypes::PosType; InputSection() = default; InputSection(const InputSection& other) = default; - + InputSection& operator=(const InputSection& other) = default; + protected: // Internal data below comprise the input specification. // Most apply attributes to input variables. @@ -233,11 +239,11 @@ class InputSection static std::any lookupAnyEnum(const std::string& enum_name, const std::string& enum_value, const std::unordered_map& enum_map); - protected: // Simple dump of contents. Useful for developing and as // debugging function useful when input sections local error reports // may be insufficient. + void report() const; void report(std::ostream& out) const; private: diff --git a/src/Estimators/tests/test_InputSection.cpp b/src/Estimators/tests/test_InputSection.cpp index 4741260298..21c43d419c 100644 --- a/src/Estimators/tests/test_InputSection.cpp +++ b/src/Estimators/tests/test_InputSection.cpp @@ -25,7 +25,8 @@ namespace qmcplusplus { -using Real = QMCTraits::RealType; +// Take note that all input is done at full precision. +using Real = QMCTraits::FullPrecRealType; enum class TestEnum1 { @@ -51,11 +52,11 @@ class TestInputSection : public InputSection TestInputSection() { section_name = "Test"; - attributes = {"name", "samples", "kmax", "full","width::type"}; + attributes = {"name", "samples", "kmax", "full", "width::type"}; parameters = {"label", "count", "width", "rational", "testenum1", "testenum2", "sposets", "center", "density", "target"}; required = {"count", "full"}; - strings = {"name", "label","width::type"}; + strings = {"name", "label", "width::type"}; multi_strings = {"sposets"}; multi_reals = {"density"}; multiple = {"target"}; @@ -227,28 +228,27 @@ TEST_CASE("InputSection::readXML", "[estimators]") // required attribute/parameter is missing // unrecognized attribute/parameter encountered - std::unordered_map invalid_inputs = { - {"missing_attribute", R"( + std::unordered_map invalid_inputs = + {{"missing_attribute", R"( 15 )"}, - {"missing_parameter", R"( + {"missing_parameter", R"( )"}, - {"foreign_attribute", R"( + {"foreign_attribute", R"( 15 )"}, - {"foreign_parameter", R"( + {"foreign_parameter", R"( 15 51 )"}, - {"invalid_section_name", R"()"} - }; + {"invalid_section_name", R"()"}}; for (auto& [label, xml] : invalid_inputs) { @@ -430,9 +430,6 @@ class CustomTestInput : public InputSection { std::string cus_at; std::getline(svalue, cus_at); - // if (ename != section_name) - // values_[ename + " " + name] = cus_at; - // else values_[name] = cus_at; } else @@ -490,7 +487,6 @@ TEST_CASE("InputSection::custom", "[estimators]") CHECK(ws.numbers == exp_numbers); cti.report(std::cout); - std::string custom_attribute = cti.get("with_custom::custom_attribute"); CHECK(custom_attribute == "This is a custom attribute."); custom_attribute = cti.get("custom_attribute"); @@ -520,10 +516,10 @@ class AnotherInput public: AnotherInputSection() { - section_name = "AnotherInput"; + section_name = "AnotherInput"; section_name_alternates = {"ainput"}; - attributes = {"name", "optional"}; - strings = {"name", "optional"}; + attributes = {"name", "optional"}; + strings = {"name", "optional"}; } }; From 06675b71ab4e79e2e00f3273132dd32476950063 Mon Sep 17 00:00:00 2001 From: Doak P W Date: Wed, 6 Dec 2023 10:24:39 -0500 Subject: [PATCH 2/5] rippled changes due to InputSection going FPReal only --- src/Estimators/MagnetizationDensityInput.cpp | 4 ++++ src/Estimators/MagnetizationDensityInput.h | 4 ++-- src/Estimators/MomentumDistribution.cpp | 3 ++- src/Estimators/MomentumDistributionInput.h | 4 ++-- src/Estimators/OneBodyDensityMatricesInput.cpp | 5 ++++- src/Estimators/OneBodyDensityMatricesInput.h | 4 ++-- src/Estimators/ReferencePointsInput.cpp | 4 +++- 7 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/Estimators/MagnetizationDensityInput.cpp b/src/Estimators/MagnetizationDensityInput.cpp index 1f5847336a..0012192a70 100644 --- a/src/Estimators/MagnetizationDensityInput.cpp +++ b/src/Estimators/MagnetizationDensityInput.cpp @@ -17,6 +17,10 @@ #include "EstimatorInput.h" namespace qmcplusplus { +template bool InputSection::setIfInInput( + qmcplusplus::MagnetizationDensityInput::Integrator& var, + const std::string& tag); + MagnetizationDensityInput::MagnetizationDensityInput(xmlNodePtr cur) { input_section_.readXML(cur); diff --git a/src/Estimators/MagnetizationDensityInput.h b/src/Estimators/MagnetizationDensityInput.h index 31417b5e9f..821a7a2c1b 100644 --- a/src/Estimators/MagnetizationDensityInput.h +++ b/src/Estimators/MagnetizationDensityInput.h @@ -35,10 +35,10 @@ class MagnetizationDensityInput lookup_input_enum_value{{"integrator-simpsons", Integrator::SIMPSONS}, {"integrator-montecarlo", Integrator::MONTECARLO}}; // clang-format on - using Real = QMCTraits::RealType; + using Real = QMCTraits::FullPrecRealType; using POLT = PtclOnLatticeTraits; using Lattice = POLT::ParticleLayout; - using PosType = QMCTraits::PosType; + using PosType = TinyVector; using Consumer = MagnetizationDensity; static constexpr int DIM = QMCTraits::DIM; diff --git a/src/Estimators/MomentumDistribution.cpp b/src/Estimators/MomentumDistribution.cpp index bc24a684c4..c9221af86f 100644 --- a/src/Estimators/MomentumDistribution.cpp +++ b/src/Estimators/MomentumDistribution.cpp @@ -43,7 +43,8 @@ MomentumDistribution::MomentumDistribution(MomentumDistributionInput&& mdi, for (int i = 0; i < OHMMS_DIM; i++) vec_length[i] = 2.0 * M_PI * std::sqrt(dot(Lattice.Gv[i], Lattice.Gv[i])); RealType kmax = input_.get_kmax(); - PosType kmaxs = {input_.get_kmax0(), input_.get_kmax1(), input_.get_kmax2()}; + auto realCast = [](auto& real) { return static_cast(real); }; + PosType kmaxs = {realCast(input_.get_kmax0()), realCast(input_.get_kmax1()), realCast(input_.get_kmax2())}; RealType sum_kmaxs = kmaxs[0] + kmaxs[1] + kmaxs[2]; RealType sphere_kmax; bool sphere = input_.get_kmax() > 0.0 ? true : false; diff --git a/src/Estimators/MomentumDistributionInput.h b/src/Estimators/MomentumDistributionInput.h index 21f93569a7..df1c487707 100644 --- a/src/Estimators/MomentumDistributionInput.h +++ b/src/Estimators/MomentumDistributionInput.h @@ -2,7 +2,7 @@ // This file is distributed under the University of Illinois/NCSA Open Source License. // See LICENSE file in top directory for details. // -// Copyright (c) 2021 QMCPACK developers. +// Copyright (c) 2023 QMCPACK developers. // // File developed by: Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory // @@ -24,7 +24,7 @@ class MomentumDistributionInput { public: using Consumer = MomentumDistribution; - using Real = QMCTraits::RealType; + using Real = QMCTraits::FullPrecRealType; class MomentumDistributionInputSection : public InputSection { diff --git a/src/Estimators/OneBodyDensityMatricesInput.cpp b/src/Estimators/OneBodyDensityMatricesInput.cpp index d4a3fc90a8..50d8c6076a 100644 --- a/src/Estimators/OneBodyDensityMatricesInput.cpp +++ b/src/Estimators/OneBodyDensityMatricesInput.cpp @@ -2,7 +2,7 @@ // This file is distributed under the University of Illinois/NCSA Open Source License. // See LICENSE file in top directory for details. // -// Copyright (c) 2021 QMCPACK developers. +// Copyright (c) 2023 QMCPACK developers. // // File developed by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Laboratory // @@ -16,6 +16,9 @@ namespace qmcplusplus { +template bool InputSection::setIfInInput(qmcplusplus::OneBodyDensityMatricesInput::Integrator& var, const std::string& tag); + + OneBodyDensityMatricesInput::OneBodyDensityMatricesInput(xmlNodePtr cur) { // This results in checkParticularValidity being called on OneBodyDensityMatrixInputSection diff --git a/src/Estimators/OneBodyDensityMatricesInput.h b/src/Estimators/OneBodyDensityMatricesInput.h index 8bac77c643..0d9c1da856 100644 --- a/src/Estimators/OneBodyDensityMatricesInput.h +++ b/src/Estimators/OneBodyDensityMatricesInput.h @@ -94,8 +94,8 @@ class OneBodyDensityMatricesInput std::any assignAnyEnum(const std::string& name) const override; }; - using Position = QMCTraits::PosType; - using Real = QMCTraits::RealType; + using Real = QMCTraits::FullPrecRealType; + using Position = TinyVector; /** default copy constructor * This is required due to OBDMI being part of a variant used as a vector element. diff --git a/src/Estimators/ReferencePointsInput.cpp b/src/Estimators/ReferencePointsInput.cpp index b169836c6c..80cbf135c8 100644 --- a/src/Estimators/ReferencePointsInput.cpp +++ b/src/Estimators/ReferencePointsInput.cpp @@ -2,7 +2,7 @@ // This file is distributed under the University of Illinois/NCSA Open Source License. // See LICENSE file in top directory for details. // -// Copyright (c) 2022 QMCPACK developers. +// Copyright (c) 2023 QMCPACK developers. // // File developed by: Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory @@ -20,6 +20,8 @@ namespace qmcplusplus { +template bool InputSection::setIfInInput(ReferencePointsInput::Coord& var, + const std::string& tag); ReferencePointsInput::ReferencePointsInput(xmlNodePtr cur) { From d618b0ea7ed902f26baec27ded0027631c001ccd Mon Sep 17 00:00:00 2001 From: Peter Doak Date: Tue, 5 Dec 2023 17:56:56 -0500 Subject: [PATCH 3/5] small changes to make floats always full precision --- src/Estimators/InputSection.cpp | 16 ++++++++---- src/Estimators/InputSection.h | 16 ++++++++---- src/Estimators/tests/test_InputSection.cpp | 30 ++++++++++------------ 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/src/Estimators/InputSection.cpp b/src/Estimators/InputSection.cpp index ad1f1c4713..5e52d69e2d 100644 --- a/src/Estimators/InputSection.cpp +++ b/src/Estimators/InputSection.cpp @@ -2,7 +2,7 @@ // This file is distributed under the University of Illinois/NCSA Open Source License. // See LICENSE file in top directory for details. // -// Copyright (c) 2022 QMCPACK developers. +// Copyright (c) 2023 QMCPACK developers. // // File developed by: Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory // Peter W. Doak, doakpw@ornl.gov, Oak Ridge National Laboratory @@ -49,7 +49,6 @@ void InputSection::readAttributes(xmlNodePtr cur, setFromStreamCustom(element_name, qualified_name, stream); else setFromStream(qualified_name, stream); - att = att->next; } } @@ -65,6 +64,7 @@ void InputSection::handleDelegate(const std::string& ename, const xmlNodePtr ele void InputSection::readXML(xmlNodePtr cur) { + assert(cur != nullptr); // For historical reasons that actual "type" of the element/input section is expressed in a very inconsistent way. // It could be coded via the element name i.e. the tag, or at minimum a method, type, or name attribute. std::string section_ename{lowerCase(castXMLCharToChar(cur->name))}; @@ -200,7 +200,7 @@ void InputSection::setFromStream(const std::string& name, std::istringstream& sv else if (isMultiReal(name)) { std::vector real_values; - for (FullPrecReal value; svalue >> value;) + for (Real value; svalue >> value;) real_values.push_back(static_cast(value)); assignValue(name, real_values); } @@ -219,7 +219,7 @@ void InputSection::setFromStream(const std::string& name, std::istringstream& sv } else if (isReal(name)) { - FullPrecReal value; + Real value; svalue >> value; assignValue(name, Real(value)); } @@ -249,7 +249,7 @@ void InputSection::assignValue(const std::string& name, const T& value) else { if (has(name)) - std::any_cast>(values_[name]).push_back(value); + std::any_cast&>(values_[name]).push_back(value); else values_[name] = std::vector{value}; } @@ -318,6 +318,12 @@ void InputSection::report(std::ostream& out) const out << "\n\n"; } +void InputSection::report() const +{ + auto& out = app_log(); + report(out); +} + std::any InputSection::lookupAnyEnum(const std::string& enum_name, const std::string& enum_value, const std::unordered_map& enum_map) diff --git a/src/Estimators/InputSection.h b/src/Estimators/InputSection.h index e69ee735cf..ad86a8c3c9 100644 --- a/src/Estimators/InputSection.h +++ b/src/Estimators/InputSection.h @@ -28,16 +28,22 @@ namespace qmcplusplus { + /** Input section provides basic parsing and a uniform method of access to the raw parsed input. + * It is still expected to be a composed part of the actual input class for a simulation class. + * It does not operate at reduced precision, i.e. numerical input is always parsed and retrieved + * at full precision. Gettting values from input section is strongly typed so you will get errors + * if you try to get numeric types at reduced precision. + */ class InputSection { public: - using FullPrecReal = QMCTraits::FullPrecRealType; - using Real = QMCTraits::RealType; - using Position = QMCTraits::PosType; + using Real = QMCTraits::FullPrecRealType; + using Position = typename QMCTypes::PosType; InputSection() = default; InputSection(const InputSection& other) = default; - + InputSection& operator=(const InputSection& other) = default; + protected: // Internal data below comprise the input specification. // Most apply attributes to input variables. @@ -233,11 +239,11 @@ class InputSection static std::any lookupAnyEnum(const std::string& enum_name, const std::string& enum_value, const std::unordered_map& enum_map); - protected: // Simple dump of contents. Useful for developing and as // debugging function useful when input sections local error reports // may be insufficient. + void report() const; void report(std::ostream& out) const; private: diff --git a/src/Estimators/tests/test_InputSection.cpp b/src/Estimators/tests/test_InputSection.cpp index 4741260298..21c43d419c 100644 --- a/src/Estimators/tests/test_InputSection.cpp +++ b/src/Estimators/tests/test_InputSection.cpp @@ -25,7 +25,8 @@ namespace qmcplusplus { -using Real = QMCTraits::RealType; +// Take note that all input is done at full precision. +using Real = QMCTraits::FullPrecRealType; enum class TestEnum1 { @@ -51,11 +52,11 @@ class TestInputSection : public InputSection TestInputSection() { section_name = "Test"; - attributes = {"name", "samples", "kmax", "full","width::type"}; + attributes = {"name", "samples", "kmax", "full", "width::type"}; parameters = {"label", "count", "width", "rational", "testenum1", "testenum2", "sposets", "center", "density", "target"}; required = {"count", "full"}; - strings = {"name", "label","width::type"}; + strings = {"name", "label", "width::type"}; multi_strings = {"sposets"}; multi_reals = {"density"}; multiple = {"target"}; @@ -227,28 +228,27 @@ TEST_CASE("InputSection::readXML", "[estimators]") // required attribute/parameter is missing // unrecognized attribute/parameter encountered - std::unordered_map invalid_inputs = { - {"missing_attribute", R"( + std::unordered_map invalid_inputs = + {{"missing_attribute", R"( 15 )"}, - {"missing_parameter", R"( + {"missing_parameter", R"( )"}, - {"foreign_attribute", R"( + {"foreign_attribute", R"( 15 )"}, - {"foreign_parameter", R"( + {"foreign_parameter", R"( 15 51 )"}, - {"invalid_section_name", R"()"} - }; + {"invalid_section_name", R"()"}}; for (auto& [label, xml] : invalid_inputs) { @@ -430,9 +430,6 @@ class CustomTestInput : public InputSection { std::string cus_at; std::getline(svalue, cus_at); - // if (ename != section_name) - // values_[ename + " " + name] = cus_at; - // else values_[name] = cus_at; } else @@ -490,7 +487,6 @@ TEST_CASE("InputSection::custom", "[estimators]") CHECK(ws.numbers == exp_numbers); cti.report(std::cout); - std::string custom_attribute = cti.get("with_custom::custom_attribute"); CHECK(custom_attribute == "This is a custom attribute."); custom_attribute = cti.get("custom_attribute"); @@ -520,10 +516,10 @@ class AnotherInput public: AnotherInputSection() { - section_name = "AnotherInput"; + section_name = "AnotherInput"; section_name_alternates = {"ainput"}; - attributes = {"name", "optional"}; - strings = {"name", "optional"}; + attributes = {"name", "optional"}; + strings = {"name", "optional"}; } }; From 4c4c09d34fec6ae3f927f7d982603fe565a35ea1 Mon Sep 17 00:00:00 2001 From: Doak P W Date: Wed, 6 Dec 2023 10:24:39 -0500 Subject: [PATCH 4/5] rippled changes due to InputSection going FPReal only --- src/Estimators/MagnetizationDensityInput.cpp | 4 ++++ src/Estimators/MagnetizationDensityInput.h | 4 ++-- src/Estimators/MomentumDistribution.cpp | 3 ++- src/Estimators/MomentumDistributionInput.h | 4 ++-- src/Estimators/OneBodyDensityMatricesInput.cpp | 5 ++++- src/Estimators/OneBodyDensityMatricesInput.h | 4 ++-- src/Estimators/ReferencePointsInput.cpp | 4 +++- 7 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/Estimators/MagnetizationDensityInput.cpp b/src/Estimators/MagnetizationDensityInput.cpp index 1f5847336a..0012192a70 100644 --- a/src/Estimators/MagnetizationDensityInput.cpp +++ b/src/Estimators/MagnetizationDensityInput.cpp @@ -17,6 +17,10 @@ #include "EstimatorInput.h" namespace qmcplusplus { +template bool InputSection::setIfInInput( + qmcplusplus::MagnetizationDensityInput::Integrator& var, + const std::string& tag); + MagnetizationDensityInput::MagnetizationDensityInput(xmlNodePtr cur) { input_section_.readXML(cur); diff --git a/src/Estimators/MagnetizationDensityInput.h b/src/Estimators/MagnetizationDensityInput.h index 31417b5e9f..821a7a2c1b 100644 --- a/src/Estimators/MagnetizationDensityInput.h +++ b/src/Estimators/MagnetizationDensityInput.h @@ -35,10 +35,10 @@ class MagnetizationDensityInput lookup_input_enum_value{{"integrator-simpsons", Integrator::SIMPSONS}, {"integrator-montecarlo", Integrator::MONTECARLO}}; // clang-format on - using Real = QMCTraits::RealType; + using Real = QMCTraits::FullPrecRealType; using POLT = PtclOnLatticeTraits; using Lattice = POLT::ParticleLayout; - using PosType = QMCTraits::PosType; + using PosType = TinyVector; using Consumer = MagnetizationDensity; static constexpr int DIM = QMCTraits::DIM; diff --git a/src/Estimators/MomentumDistribution.cpp b/src/Estimators/MomentumDistribution.cpp index bc24a684c4..c9221af86f 100644 --- a/src/Estimators/MomentumDistribution.cpp +++ b/src/Estimators/MomentumDistribution.cpp @@ -43,7 +43,8 @@ MomentumDistribution::MomentumDistribution(MomentumDistributionInput&& mdi, for (int i = 0; i < OHMMS_DIM; i++) vec_length[i] = 2.0 * M_PI * std::sqrt(dot(Lattice.Gv[i], Lattice.Gv[i])); RealType kmax = input_.get_kmax(); - PosType kmaxs = {input_.get_kmax0(), input_.get_kmax1(), input_.get_kmax2()}; + auto realCast = [](auto& real) { return static_cast(real); }; + PosType kmaxs = {realCast(input_.get_kmax0()), realCast(input_.get_kmax1()), realCast(input_.get_kmax2())}; RealType sum_kmaxs = kmaxs[0] + kmaxs[1] + kmaxs[2]; RealType sphere_kmax; bool sphere = input_.get_kmax() > 0.0 ? true : false; diff --git a/src/Estimators/MomentumDistributionInput.h b/src/Estimators/MomentumDistributionInput.h index 21f93569a7..df1c487707 100644 --- a/src/Estimators/MomentumDistributionInput.h +++ b/src/Estimators/MomentumDistributionInput.h @@ -2,7 +2,7 @@ // This file is distributed under the University of Illinois/NCSA Open Source License. // See LICENSE file in top directory for details. // -// Copyright (c) 2021 QMCPACK developers. +// Copyright (c) 2023 QMCPACK developers. // // File developed by: Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory // @@ -24,7 +24,7 @@ class MomentumDistributionInput { public: using Consumer = MomentumDistribution; - using Real = QMCTraits::RealType; + using Real = QMCTraits::FullPrecRealType; class MomentumDistributionInputSection : public InputSection { diff --git a/src/Estimators/OneBodyDensityMatricesInput.cpp b/src/Estimators/OneBodyDensityMatricesInput.cpp index d4a3fc90a8..50d8c6076a 100644 --- a/src/Estimators/OneBodyDensityMatricesInput.cpp +++ b/src/Estimators/OneBodyDensityMatricesInput.cpp @@ -2,7 +2,7 @@ // This file is distributed under the University of Illinois/NCSA Open Source License. // See LICENSE file in top directory for details. // -// Copyright (c) 2021 QMCPACK developers. +// Copyright (c) 2023 QMCPACK developers. // // File developed by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Laboratory // @@ -16,6 +16,9 @@ namespace qmcplusplus { +template bool InputSection::setIfInInput(qmcplusplus::OneBodyDensityMatricesInput::Integrator& var, const std::string& tag); + + OneBodyDensityMatricesInput::OneBodyDensityMatricesInput(xmlNodePtr cur) { // This results in checkParticularValidity being called on OneBodyDensityMatrixInputSection diff --git a/src/Estimators/OneBodyDensityMatricesInput.h b/src/Estimators/OneBodyDensityMatricesInput.h index 8bac77c643..0d9c1da856 100644 --- a/src/Estimators/OneBodyDensityMatricesInput.h +++ b/src/Estimators/OneBodyDensityMatricesInput.h @@ -94,8 +94,8 @@ class OneBodyDensityMatricesInput std::any assignAnyEnum(const std::string& name) const override; }; - using Position = QMCTraits::PosType; - using Real = QMCTraits::RealType; + using Real = QMCTraits::FullPrecRealType; + using Position = TinyVector; /** default copy constructor * This is required due to OBDMI being part of a variant used as a vector element. diff --git a/src/Estimators/ReferencePointsInput.cpp b/src/Estimators/ReferencePointsInput.cpp index b169836c6c..80cbf135c8 100644 --- a/src/Estimators/ReferencePointsInput.cpp +++ b/src/Estimators/ReferencePointsInput.cpp @@ -2,7 +2,7 @@ // This file is distributed under the University of Illinois/NCSA Open Source License. // See LICENSE file in top directory for details. // -// Copyright (c) 2022 QMCPACK developers. +// Copyright (c) 2023 QMCPACK developers. // // File developed by: Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory @@ -20,6 +20,8 @@ namespace qmcplusplus { +template bool InputSection::setIfInInput(ReferencePointsInput::Coord& var, + const std::string& tag); ReferencePointsInput::ReferencePointsInput(xmlNodePtr cur) { From 2b1f1dc6baae223abe2fe9acdfaf81423aaedd3a Mon Sep 17 00:00:00 2001 From: Doak P W Date: Wed, 6 Dec 2023 13:24:55 -0500 Subject: [PATCH 5/5] extern template functions, remove explicit reference --- src/Estimators/InputSection.cpp | 3 +-- src/Estimators/MagnetizationDensityInput.h | 5 +++++ src/Estimators/OneBodyDensityMatricesInput.h | 4 ++++ src/Estimators/ReferencePointsInput.h | 10 ++++++---- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Estimators/InputSection.cpp b/src/Estimators/InputSection.cpp index 5e52d69e2d..fe60c5b9a6 100644 --- a/src/Estimators/InputSection.cpp +++ b/src/Estimators/InputSection.cpp @@ -320,8 +320,7 @@ void InputSection::report(std::ostream& out) const void InputSection::report() const { - auto& out = app_log(); - report(out); + report(app_log()); } std::any InputSection::lookupAnyEnum(const std::string& enum_name, diff --git a/src/Estimators/MagnetizationDensityInput.h b/src/Estimators/MagnetizationDensityInput.h index 821a7a2c1b..de69118cfc 100644 --- a/src/Estimators/MagnetizationDensityInput.h +++ b/src/Estimators/MagnetizationDensityInput.h @@ -127,5 +127,10 @@ class MagnetizationDensityInput bool have_center_ = false; bool have_corner_ = false; }; + +extern template bool InputSection::setIfInInput( + qmcplusplus::MagnetizationDensityInput::Integrator& var, + const std::string& tag); + } // namespace qmcplusplus #endif /* QMCPLUSPLUS_MAGNETIZATION_DENSITY_INPUT_H */ diff --git a/src/Estimators/OneBodyDensityMatricesInput.h b/src/Estimators/OneBodyDensityMatricesInput.h index 0d9c1da856..60750efd7f 100644 --- a/src/Estimators/OneBodyDensityMatricesInput.h +++ b/src/Estimators/OneBodyDensityMatricesInput.h @@ -155,6 +155,10 @@ class OneBodyDensityMatricesInput friend class testing::OneBodyDensityMatricesTests; }; +extern template bool InputSection::setIfInInput( + qmcplusplus::OneBodyDensityMatricesInput::Integrator& var, + const std::string& tag); + } // namespace qmcplusplus #endif diff --git a/src/Estimators/ReferencePointsInput.h b/src/Estimators/ReferencePointsInput.h index becd1e16fd..4f096fb7cd 100644 --- a/src/Estimators/ReferencePointsInput.h +++ b/src/Estimators/ReferencePointsInput.h @@ -79,12 +79,13 @@ class ReferencePointsInput * the same CoordType. */ ReferencePointsInput() = default; - + ReferencePointsInput(xmlNodePtr cur); ReferencePointsInput(const ReferencePointsInput& rpi) = default; Coord get_coord_form() const { return coord_form_; } const Points& get_points() const { return points_; } + private: void readRefPointsXML(xmlNodePtr cur); // As far as I can tell if not specified in input this is what is happening in legacy. @@ -94,11 +95,12 @@ class ReferencePointsInput static constexpr std::string_view error_tag{"ReferencePointsInput input: "}; }; - /** factory function used by InputSection to make reference points Input +/** factory function used by InputSection to make reference points Input * \param[out] value_label key value in delegating InputSection for storing the constructed Input from processed node. */ - std::any makeReferencePointsInput(xmlNodePtr, std::string& value_label); +std::any makeReferencePointsInput(xmlNodePtr, std::string& value_label); +extern template bool InputSection::setIfInInput(ReferencePointsInput::Coord& var, + const std::string& tag); } // namespace qmcplusplus - #endif