Skip to content

Commit

Permalink
improvements suggested in review const, forward decl, naming
Browse files Browse the repository at this point in the history
  • Loading branch information
PDoakORNL committed Dec 2, 2024
1 parent 05dabf0 commit d0340c1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 22 deletions.
22 changes: 13 additions & 9 deletions src/Estimators/StructureFactorEstimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,25 @@
//////////////////////////////////////////////////////////////////////////////////////

#include "StructureFactorEstimator.h"
#include "StructureFactorInput.h"
#include "ParticleSet.h"
#include <LongRange/StructFact.h>

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;
Expand Down Expand Up @@ -68,10 +72,10 @@ void StructureFactorEstimator::accumulate(const RefVector<MCPWalker>& 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());

Expand Down
20 changes: 11 additions & 9 deletions src/Estimators/StructureFactorEstimator.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#define QMCPLUSPLUS_STRUCTUREFACTORESTIMATOR_H

#include "OperatorEstBase.h"
#include "StructureFactorInput.h"

namespace qmcplusplus
{
Expand All @@ -23,6 +22,8 @@ namespace testing
class StructureFactorAccess;
}

class StructureFactorInput;

class StructureFactorEstimator : public OperatorEstBase
{
public:
Expand All @@ -31,9 +32,9 @@ class StructureFactorEstimator : public OperatorEstBase
using FullPrecReal = QMCT::FullPrecRealType;
using KPt = TinyVector<Real, QMCTraits::DIM>;

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);
Expand Down Expand Up @@ -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_;

Expand Down
2 changes: 1 addition & 1 deletion src/Estimators/tests/GenerateRandomParticleSets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ std::vector<ParticleSet> generateRandomParticleSets(ParticleSet& pset_target,
std::vector<ParticleSet> psets(num_psets, pset_target);
if (generate_test_data)
{
std::cout << "Initialize psets with:\n{";
std::cout << "Initialize ParticleSets with:\n{";
std::vector<ParticleSet> psets;
for (int iw = 0; iw < nwalkers; ++iw)
{
Expand Down
1 change: 1 addition & 0 deletions src/Estimators/tests/test_StructureFactorEstimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 1 addition & 3 deletions src/type_traits/tests/test_template_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, [email protected], Oak Ridge National Lab
//
Expand Down Expand Up @@ -79,8 +79,6 @@ TEST_CASE("convertUPtrToRefvector", "[type_traits]")

// This should cause a compilation error. a DerivedDummy cannot be converted to an OtherDummy.
// RefVector<OtherDummy> od_ref_vec = convertUPtrToRefVector<OtherDummy>(ddv);


}

TEST_CASE("convertPtrToRefvectorSubset", "[type_traits]")
Expand Down

0 comments on commit d0340c1

Please sign in to comment.