31 using QMCT = QMCTraits;
54 for (
int iops = 0; iops < ncrowds; ++iops)
56 std::vector<OperatorEstBase::MCPWalker>
walkers;
58 for (
int iw = 0; iw < nwalkers; ++iw)
61 std::vector<ParticleSet> psets;
66 for (
int iw = 0; iw < nwalkers; ++iw)
68 psets.emplace_back(simulation_cell);
75 std::vector<TrialWaveFunction> wfns;
76 std::vector<QMCHamiltonian> hams;
78 auto ref_walkers = makeRefVector<OperatorEstBase::MCPWalker>(
walkers);
79 auto ref_psets = makeRefVector<ParticleSet>(psets);
80 auto ref_wfns = makeRefVector<TrialWaveFunction>(wfns);
81 auto ref_hams = makeRefVector<QMCHamiltonian>(hams);
85 crowd_sdn.
accumulate(ref_walkers, ref_psets, ref_wfns, ref_hams, rng);
92 for (
auto& uptr_crowd_sdn : crowd_sdns)
94 std::vector<OperatorEstBase::MCPWalker>
walkers;
96 for (
int iw = 0; iw < nwalkers; ++iw)
99 std::vector<ParticleSet> psets;
103 std::vector<QMCT::RealType> rng_reals(nwalkers *
QMCT::DIM * 2);
105 auto it_rng_reals = rng_reals.begin();
106 for (
int iw = 0; iw < nwalkers; ++iw)
108 psets.emplace_back(simulation_cell);
115 std::vector<TrialWaveFunction> wfns;
116 std::vector<QMCHamiltonian> hams;
117 auto ref_walkers = makeRefVector<OperatorEstBase::MCPWalker>(
walkers);
118 auto ref_psets = makeRefVector<ParticleSet>(psets);
119 auto ref_wfns = makeRefVector<TrialWaveFunction>(wfns);
120 auto ref_hams = makeRefVector<QMCHamiltonian>(hams);
124 crowd_sdn.
accumulate(ref_walkers, ref_psets, ref_wfns, ref_hams, rng);
128 TEST_CASE(
"SpinDensityNew::SpinDensityNew(SPInput, SpeciesSet)",
"[estimators]")
145 TEST_CASE(
"SpinDensityNew::SpinDensityNew(SPInput, Lattice, SpeciesSet)",
"[estimators]")
148 using input = testing::ValidSpinDensityInput;
160 using namespace testing;
167 TEST_CASE(
"SpinDensityNew::spawnCrowdClone()",
"[estimators]")
170 using input = testing::ValidSpinDensityInput;
207 std::vector<MCPWalker>
walkers;
209 for (
int iw = 0; iw < nwalkers; ++iw)
212 std::vector<ParticleSet> psets;
215 for (
int iw = 0; iw < nwalkers; ++iw)
217 psets.emplace_back(simulation_cell);
224 std::vector<TrialWaveFunction> wfns;
225 std::vector<QMCHamiltonian> hams;
227 auto ref_walkers = makeRefVector<MCPWalker>(
walkers);
228 auto ref_psets = makeRefVector<ParticleSet>(psets);
229 auto ref_wfns = makeRefVector<TrialWaveFunction>(wfns);
230 auto ref_hams = makeRefVector<QMCHamiltonian>(hams);
234 sdn.
accumulate(ref_walkers, ref_psets, ref_wfns, ref_hams, rng);
236 std::vector<QMCT::RealType>& data_ref =
sdn.
get_data();
239 CHECK(data_ref[555] == 4);
240 CHECK(data_ref[1777] == 4);
243 TEST_CASE(
"SpinDensityNew::collect(DataLocality::crowd)",
"[estimators]")
247 using QMCT = QMCTraits;
250 using input = testing::ValidSpinDensityInput;
265 UPtrVector<OperatorEstBase> crowd_sdns;
273 std::vector<QMCT::RealType>& data_ref =
sdn.
get_data();
276 CHECK(data_ref[555] == 4 * ncrowds);
277 CHECK(data_ref[1666] == 4 * ncrowds);
281 TEST_CASE(
"SpinDensityNew::collect(DataLocality::rank)",
"[estimators]")
285 using QMCT = QMCTraits;
288 using input = testing::ValidSpinDensityInput;
305 UPtrVector<OperatorEstBase> crowd_sdns;
313 std::vector<QMCT::RealType>& data_ref =
sdn.
get_data();
316 CHECK(data_ref[555] == 4 * ncrowds);
317 CHECK(data_ref[1666] == 4 * ncrowds);
321 TEST_CASE(
"SpinDensityNew algorithm comparison",
"[estimators]")
324 using QMCT = QMCTraits;
327 using input = testing::ValidSpinDensityInput;
346 UPtrVector<OperatorEstBase> crowd_sdns_rank;
348 testing::RandomForTest<QMCT::RealType> rng_for_test_rank;
349 for (
int i = 0; i < nsteps; ++i)
352 sdn_rank.collect(crowd_oeb_refs_rank);
353 std::vector<QMCT::RealType>& data_ref_rank = sdn_rank.get_data();
356 UPtrVector<OperatorEstBase> crowd_sdns_crowd;
358 testing::RandomForTest<QMCT::RealType> rng_for_test_crowd;
359 for (
int i = 0; i < nsteps; ++i)
362 sdn_crowd.collect(crowd_oeb_refs_crowd);
363 std::vector<QMCT::RealType>& data_ref_crowd = sdn_crowd.get_data();
365 for (
size_t i = 0; i < data_ref_rank.size(); ++i)
367 if (data_ref_crowd[i] != data_ref_rank[i])
368 FAIL_CHECK(
"crowd local " << data_ref_crowd[i] <<
" != rank local " << data_ref_rank[i] <<
" at index " << i);
a class that defines a supercell in D-dimensional Euclean space.
void accumulateFromPsets(int ncrowds, SpinDensityNew &sdn, UPtrVector< OperatorEstBase > &crowd_sdns)
std::vector< QMCT::RealType > & get_data()
class that handles xmlDoc
Lattice makeTestLattice()
void accumulate(const RefVector< MCPWalker > &walkers, const RefVector< ParticleSet > &psets, const RefVector< TrialWaveFunction > &wfns, const RefVector< QMCHamiltonian > &hams, RandomBase< FullPrecRealType > &rng) override
accumulate 1 or more walkers of SpinDensity samples
helper functions for EinsplineSetBuilder
if(!okay) throw std xmlNodePtr node
void testCopyConstructor(const SpinDensityNew &sdn)
Get a known sequence of random numbers for testing.
TEST_CASE("complex_helper", "[type_traits]")
void collect(const RefVector< OperatorEstBase > &operator_estimators) override
this allows the EstimatorManagerNew to reduce without needing to know the details of SpinDensityNew's...
std::vector< std::unique_ptr< T > > UPtrVector
class to preserve access control in MomentumDistribution
std::unique_ptr< OperatorEstBase > spawnCrowdClone() const override
standard interface
static RefVector< T > convertUPtrToRefVector(const UPtrVector< T > &ptr_list)
convert a vector of std::unique_ptrs<T> to a refvector<T>
void randomUpdateAccumulate(testing::RandomForTest< QMCT::RealType > &rft, UPtrVector< OperatorEstBase > &crowd_sdns)
static constexpr std::array< std::string_view, 3 > xml
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > lattice
SpinDensityNew(std::move(sdi), species_set)
void fillVecRng(std::vector< VT > &rng_reals)
Specialized paritlce class for atomistic simulations.
const std::vector< int > species_size_
REQUIRE(std::filesystem::exists(filename))
Native representation for Spin Density Estimators inputs.
Declaration of a TrialWaveFunction.
bool parseFromString(const std::string_view data)
Walker< QMCTraits, PtclOnLatticeTraits > MCPWalker
Class that collects density per species of particle.
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
testing::ValidSpinDensityInput input
Custom container for set of attributes for a set of species.
SpinDensityNew original(std::move(sdi), lattice, species_set)
A container class to represent a walker.
SpinDensityInput sdi(node)
SpinDensityInput sdi_copy
SpinDensityNew sdn(std::move(sdi), lattice, species_set)
Walker< QMCTraits, PtclOnLatticeTraits > MCPWalker