diff --git a/src/Estimators/StructureFactorEstimator.cpp b/src/Estimators/StructureFactorEstimator.cpp index d48fe2b86d..16a100fe4b 100644 --- a/src/Estimators/StructureFactorEstimator.cpp +++ b/src/Estimators/StructureFactorEstimator.cpp @@ -10,21 +10,25 @@ ////////////////////////////////////////////////////////////////////////////////////// #include "StructureFactorEstimator.h" +#include "StructureFactorInput.h" #include "ParticleSet.h" #include namespace qmcplusplus { -StructureFactorEstimator::StructureFactorEstimator(StructureFactorInput& sfi, - ParticleSet& pset_ions, - ParticleSet& pset_elec, +StructureFactorEstimator::StructureFactorEstimator(const StructureFactorInput& sfi, + const ParticleSet& pset_ions, + const ParticleSet& pset_elec, DataLocality data_locality) - : OperatorEstBase(data_locality), elns_(pset_elec), ions_(pset_ions) + : OperatorEstBase(data_locality), + input_(sfi), + elns_(pset_elec), + elec_num_species_(elns_.getSpeciesSet().getTotalNum()), + ions_(pset_ions), + ion_num_species_(ions_.getSpeciesSet().getTotalNum()) { - my_name_ = "StructureFactorEstimator"; - elec_species_ = elns_.getSpeciesSet().getTotalNum(); - ion_species_ = ions_.getSpeciesSet().getTotalNum(); + my_name_ = "StructureFactorEstimator"; num_kpoints_ = pset_ions.getSimulationCell().getKLists().numk; kshell_offsets_ = pset_ions.getSimulationCell().getKLists().kshell; @@ -68,10 +72,10 @@ void StructureFactorEstimator::accumulate(const RefVector& walkers, //sum over species std::copy(psets[iw].get().getSK().rhok_r[0], psets[iw].get().getSK().rhok_r[0] + num_kpoints_, rhok_tot_r_.begin()); std::copy(psets[iw].get().getSK().rhok_i[0], psets[iw].get().getSK().rhok_i[0] + num_kpoints_, rhok_tot_i_.begin()); - for (int i = 1; i < elec_species_; ++i) + for (int i = 1; i < elec_num_species_; ++i) accumulate_elements(psets[iw].get().getSK().rhok_r[i], psets[iw].get().getSK().rhok_r[i] + num_kpoints_, rhok_tot_r_.begin()); - for (int i = 1; i < elec_species_; ++i) + for (int i = 1; i < elec_num_species_; ++i) accumulate_elements(psets[iw].get().getSK().rhok_i[i], psets[iw].get().getSK().rhok_i[i] + num_kpoints_, rhok_tot_i_.begin()); diff --git a/src/Estimators/StructureFactorEstimator.h b/src/Estimators/StructureFactorEstimator.h index f4d111f6f9..0f375fe98d 100644 --- a/src/Estimators/StructureFactorEstimator.h +++ b/src/Estimators/StructureFactorEstimator.h @@ -13,7 +13,6 @@ #define QMCPLUSPLUS_STRUCTUREFACTORESTIMATOR_H #include "OperatorEstBase.h" -#include "StructureFactorInput.h" namespace qmcplusplus { @@ -23,6 +22,8 @@ namespace testing class StructureFactorAccess; } +class StructureFactorInput; + class StructureFactorEstimator : public OperatorEstBase { public: @@ -31,9 +32,9 @@ class StructureFactorEstimator : public OperatorEstBase using FullPrecReal = QMCT::FullPrecRealType; using KPt = TinyVector; - StructureFactorEstimator(StructureFactorInput& sfi, - ParticleSet& pset_ions, - ParticleSet& pset_elec, + StructureFactorEstimator(const StructureFactorInput& sfi, + const ParticleSet& pset_ions, + const ParticleSet& pset_elec, DataLocality data_locality = DataLocality::crowd); StructureFactorEstimator(const StructureFactorEstimator& sfe, DataLocality dl); @@ -66,11 +67,12 @@ class StructureFactorEstimator : public OperatorEstBase private: StructureFactorEstimator(const StructureFactorEstimator& obdm) = default; - int elec_species_; - ParticleSet& elns_; - int ion_species_; - ParticleSet& ions_; - + const StructureFactorInput& input_; + const ParticleSet& elns_; + const int elec_num_species_; + const ParticleSet& ions_; + const int ion_num_species_; + /// number of k points long long num_kpoints_; diff --git a/src/Estimators/tests/GenerateRandomParticleSets.cpp b/src/Estimators/tests/GenerateRandomParticleSets.cpp index 0c3051e7dd..95b9e102c0 100644 --- a/src/Estimators/tests/GenerateRandomParticleSets.cpp +++ b/src/Estimators/tests/GenerateRandomParticleSets.cpp @@ -32,7 +32,7 @@ std::vector generateRandomParticleSets(ParticleSet& pset_target, std::vector psets(num_psets, pset_target); if (generate_test_data) { - std::cout << "Initialize psets with:\n{"; + std::cout << "Initialize ParticleSets with:\n{"; std::vector psets; for (int iw = 0; iw < nwalkers; ++iw) { diff --git a/src/Estimators/tests/test_StructureFactorEstimator.cpp b/src/Estimators/tests/test_StructureFactorEstimator.cpp index 94d3fec5c3..dee50bfd5a 100644 --- a/src/Estimators/tests/test_StructureFactorEstimator.cpp +++ b/src/Estimators/tests/test_StructureFactorEstimator.cpp @@ -12,6 +12,7 @@ #include "catch.hpp" #include "StructureFactorEstimator.h" +#include "StructureFactorInput.h" #include "ValidStructureFactorInput.h" #include "Particle/tests/MinimalParticlePool.h" #include "QMCWaveFunctions/tests/MinimalWaveFunctionPool.h" diff --git a/src/type_traits/tests/test_template_types.cpp b/src/type_traits/tests/test_template_types.cpp index f8cb0c2a0a..49fecf0e3e 100644 --- a/src/type_traits/tests/test_template_types.cpp +++ b/src/type_traits/tests/test_template_types.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) 2019 QMCPACK developers +// Copyright (c) 2024 QMCPACK developers // // File developed by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab // @@ -79,8 +79,6 @@ TEST_CASE("convertUPtrToRefvector", "[type_traits]") // This should cause a compilation error. a DerivedDummy cannot be converted to an OtherDummy. // RefVector od_ref_vec = convertUPtrToRefVector(ddv); - - } TEST_CASE("convertPtrToRefvectorSubset", "[type_traits]")