QMCPACK
test_VirtualParticleSet.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) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
8 //
9 // File created by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "catch.hpp"
14 
15 #include "MinimalParticlePool.h"
17 #include "ResourceCollection.h"
18 #include "DistanceTable.h"
19 
20 namespace qmcplusplus
21 {
22 TEST_CASE("VirtualParticleSet", "[particle]")
23 {
25 
26  auto& ions = *pset_pool.getParticleSet("i");
27  auto& elecs = *pset_pool.getParticleSet("e");
28 
29  elecs.R[0] = {1, 2, 3};
30  elecs.R[1] = {2, 1, 3};
31  elecs.R[2] = {3, 1, 2};
32  elecs.R[3] = {3, 2, 1};
33 
34  ions.addTable(ions);
35  ions.update();
36  elecs.addTable(ions);
37  elecs.addTable(elecs);
38  elecs.update();
39 
40 
41  ParticleSet elecs_clone(elecs);
42  elecs_clone.update();
43 
44  VirtualParticleSet vp_Ni(elecs, 3);
45  VirtualParticleSet vp_O(elecs, 5);
46 
47  VirtualParticleSet vp_Ni_clone(elecs_clone, 3);
48  VirtualParticleSet vp_O_clone(elecs_clone, 5);
49 
50  vp_Ni_clone.makeMoves(elecs_clone, 3, {{0.1, 0.2, 0.3}, {0.2, 0.1, 0.3}, {0.3, 0.1, 0.2}});
51  const DistanceTableAB& dt_vp_ion = vp_Ni_clone.getDistTableAB(0);
52  CHECK(Approx(dt_vp_ion.getDistances()[2][1]) == 2.5020600118);
53 
54  // two walkers form a workgroup.
55  // One electron of the first walker gets inside O sphere and one electron of the other gets inside Ni sphere.
56  RefVectorWithLeader<VirtualParticleSet> vp_list(vp_Ni, {vp_O, vp_Ni_clone});
57  ResourceCollection collection{"NLPPcollection"};
58  vp_Ni.createResource(collection);
59 
60  {
61  ResourceCollectionTeamLock<VirtualParticleSet> vp_res_lock(collection, vp_list);
62  }
63 
64  vp_Ni_clone.makeMoves(elecs_clone, 3, {{0.1, 0.2, 0.3}, {0.3, 0.1, 0.2}, {0.2, 0.1, 0.3}});
65  CHECK(Approx(vp_Ni_clone.R[2][0]) == 3.2);
66  CHECK(Approx(vp_Ni_clone.R[2][1]) == 2.1);
67  CHECK(Approx(vp_Ni_clone.R[2][2]) == 1.3);
68 
69  REQUIRE(dt_vp_ion.getDistances().size() == 3);
70  CHECK(Approx(dt_vp_ion.getDistances()[2][1]) == 2.5784519198);
71 }
72 } // namespace qmcplusplus
const std::vector< DistRow > & getDistances() const
return full table distances
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
void createResource(ResourceCollection &collection) const
initialize a shared resource and hand it to a collection
TEST_CASE("complex_helper", "[type_traits]")
A ParticleSet that handles virtual moves of a selected particle of a given physical ParticleSet Virtu...
void makeMoves(const ParticleSet &refp, int jel, const std::vector< PosType > &deltaV, bool sphere=false, int iat=-1)
move virtual particles to new postions and update distance tables
void update(bool skipSK=false)
update the internal data
Communicate * Controller
Global Communicator for a process.
Definition: Communicate.cpp:35
A proxy class to the quantum ParticleSet.
const DistanceTableAB & getDistTableAB(int table_ID) const
get a distance table by table_ID and dyanmic_cast to DistanceTableAB
static ParticleSetPool make_NiO_a4(Communicate *c)
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
REQUIRE(std::filesystem::exists(filename))
AB type of DistanceTable containing storage.
ParticlePos R
Position.
Definition: ParticleSet.h:79
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
handles acquire/release resource by the consumer (RefVectorWithLeader type).