30 TEST_CASE(
"distance_open_z",
"[distance_table][xml]")
35 const char* particles = R
"(<tmp> 36 <particleset name="e" random="yes"> 37 <group name="u" size="1" mass="1.0"> 38 <parameter name="charge" > -1 </parameter> 39 <parameter name="mass" > 1.0 </parameter> 40 <attrib name="position" datatype="posArray" condition="0"> 41 0.00000000 0.00000000 0.20000000 44 <group name="d" size="1" mass="1.0"> 45 <parameter name="charge" > -1 </parameter> 46 <parameter name="mass" > 1.0 </parameter> 47 <attrib name="position" datatype="posArray" condition="0"> 48 0.00000000 0.00000000 -0.20000000 52 <particleset name="ion0"> 53 <group name="H" size="2" mass="1836.15"> 54 <parameter name="charge" > 1 </parameter> 55 <parameter name="valence" > 1 </parameter> 56 <parameter name="atomicnumber" > 1 </parameter> 57 <parameter name="mass" > 1836.15 </parameter> 58 <attrib name="position" datatype="posArray" condition="0"> 59 0.00000000 0.00000000 0.00000000 60 0.00000000 0.00000000 0.50000000 72 xmlNodePtr part1 = xmlFirstElementChild(root);
73 xmlNodePtr part2 = xmlNextElementSibling(part1);
77 ParticleSet ions(simulation_cell), electrons(simulation_cell);
86 REQUIRE(ions.getName() ==
"ion0");
91 const int tid = electrons.
addTable(ions);
96 REQUIRE(dtable.getName() ==
"ion0_e");
98 REQUIRE(dtable.sources() == ions.getTotalNum());
101 double expect[] = {0.2, 0.2, 0.3, 0.7};
103 for (
int iat = 0; iat < dtable.sources(); iat++)
105 for (
int jat = 0; jat < dtable.targets(); jat++, idx++)
107 double dist = dtable.getDistRow(jat)[iat];
108 CHECK(dist == Approx(expect[idx]));
113 CHECK(displ1[0] == Approx(0.0));
114 CHECK(displ1[1] == Approx(0.0));
115 CHECK(displ1[2] == Approx(-0.2));
118 CHECK(displ2[0] == Approx(0.0));
119 CHECK(displ2[1] == Approx(0.0));
120 CHECK(displ2[2] == Approx(0.3));
128 const char* particles = R
"(<tmp> 129 <particleset name="e" random="yes"> 130 <group name="u" size="2" mass="1.0"> 131 <parameter name="charge" > -1 </parameter> 132 <parameter name="mass" > 1.0 </parameter> 133 <attrib name="position" datatype="posArray" condition="0"> 134 0.70000000 0.00000000 0.00000000 135 0.00000000 1.00000000 0.00000000 138 <group name="d" size="1" mass="1.0"> 139 <parameter name="charge" > -1 </parameter> 140 <parameter name="mass" > 1.0 </parameter> 141 <attrib name="position" datatype="posArray" condition="0"> 142 -0.90000000 0.00000000 0.00000000 146 <particleset name="ion0"> 147 <group name="H" size="2" mass="1836.15"> 148 <parameter name="charge" > 1 </parameter> 149 <parameter name="valence" > 1 </parameter> 150 <parameter name="atomicnumber" > 1 </parameter> 151 <parameter name="mass" > 1836.15 </parameter> 152 <attrib name="position" datatype="posArray" condition="0"> 153 0.00000000 0.00000000 0.00000000 154 1.00000000 0.00000000 0.00000000 166 xmlNodePtr part1 = xmlFirstElementChild(root);
167 xmlNodePtr part2 = xmlNextElementSibling(part1);
171 ParticleSet ions(simulation_cell), electrons(simulation_cell);
174 parse_electrons.
readXML(part1);
180 REQUIRE(ions.getName() ==
"ion0");
185 const int tid = electrons.
addTable(ions);
190 REQUIRE(dtable.getName() ==
"ion0_e");
192 REQUIRE(dtable.sources() == ions.getTotalNum());
201 double expect[] = {0.7, 1.0, 0.9, 0.3,
std::sqrt(2), 1.9};
203 for (
int iat = 0; iat < dtable.sources(); iat++)
205 for (
int jat = 0; jat < dtable.targets(); jat++, idx++)
207 double dist = dtable.getDistRow(jat)[iat];
208 CHECK(dist == Approx(expect[idx]));
214 TEST_CASE(
"distance_open_species_deviation",
"[distance_table][xml]")
219 const char* particles = R
"(<tmp> 220 <particleset name="e" random="yes"> 221 <group name="u" size="2" mass="1.0"> 222 <parameter name="charge" > -1 </parameter> 223 <parameter name="mass" > 1.0 </parameter> 224 <attrib name="position" datatype="posArray" condition="0"> 225 0.70000000 0.00000000 0.00000000 226 0.00000000 1.00000000 0.00000000 229 <group name="d" size="1" mass="1.0"> 230 <parameter name="charge" > -1 </parameter> 231 <parameter name="mass" > 1.0 </parameter> 232 <attrib name="position" datatype="posArray" condition="0"> 233 -0.90000000 0.00000000 0.00000000 237 <particleset name="ion0"> 238 <group name="H" size="2" mass="1836.15"> 239 <parameter name="charge" > 1 </parameter> 240 <parameter name="valence" > 1 </parameter> 241 <parameter name="atomicnumber" > 1 </parameter> 242 <parameter name="mass" > 1836.15 </parameter> 243 <attrib name="position" datatype="posArray" condition="0"> 244 0.00000000 0.00000000 0.00000000 245 1.00000000 0.00000000 0.00000000 257 xmlNodePtr part1 = xmlFirstElementChild(root);
258 xmlNodePtr part2 = xmlNextElementSibling(part1);
262 ParticleSet ions(simulation_cell), electrons(simulation_cell);
265 parse_electrons.
readXML(part1);
271 REQUIRE(ions.getName() ==
"ion0");
276 const int tid = electrons.
addTable(ions);
281 REQUIRE(dtable.getName() ==
"ion0_e");
286 REQUIRE(dtable.sources() == ions.getTotalNum());
290 double latdev2 = 0.0;
294 for (
int iat = 0; iat < dtable.sources(); iat++, idx++)
296 for (
int jat = cur_jat + 1; jat < dtable.targets(); jat++, idx++)
299 int species_id = electrons.
GroupID[jat];
300 string species_name = especies.speciesName[species_id];
301 if (species_name !=
"u")
305 double dist = dtable.getDistRow(jat)[iat];
307 CHECK(dist == Approx(expect[idx]));
312 CHECK(latdev2 / ions.getTotalNum() == Approx(1.245));
318 const char* particles = R
"(<tmp> 320 <parameter name="lattice" units="bohr"> 321 6.00000000 6.00000000 0.00000000 322 0.00000000 6.00000000 6.00000000 323 6.00000000 0.00000000 6.00000000 325 <parameter name="bconds"> 328 <parameter name="LR_dim_cutoff" > 15 </parameter> 338 xmlNodePtr part1 = xmlFirstElementChild(root);
351 const char* particles = R
"(<tmp> 353 <parameter name="lattice" units="bohr"> 354 6.00000000 0.00000000 0.00000000 355 0.00000000 6.00000000 0.00000000 356 0.00000000 0.00000000 6.00000000 358 <parameter name="bconds"> 361 <parameter name="LR_dim_cutoff" > 15 </parameter> 371 xmlNodePtr part1 = xmlFirstElementChild(root);
384 const char* particles = R
"(<tmp> 385 <particleset name="e"> 386 <group name="u" size="2" mass="1.0"> 387 <parameter name="charge" > -1 </parameter> 388 <parameter name="mass" > 1.0 </parameter> 389 <attrib name="position" datatype="posArray" condition="0"> 390 0.00000000 0.00000000 0.00000000 391 3.00000000 0.00000000 0.00000000 394 <group name="d" size="1" mass="1.0"> 395 <parameter name="charge" > -1 </parameter> 396 <parameter name="mass" > 1.0 </parameter> 397 <attrib name="position" datatype="posArray" condition="0"> 398 0.00000000 0.00000000 3.00000000 402 <particleset name="ion0"> 403 <group name="H" size="8" mass="1836.15"> 404 <parameter name="charge" > 1 </parameter> 405 <parameter name="valence" > 1 </parameter> 406 <parameter name="atomicnumber" > 1 </parameter> 407 <parameter name="mass" > 1836.15 </parameter> 408 <attrib name="position" datatype="posArray" condition="0"> 409 0.00000000 0.00000000 0.00000000 410 3.00000000 0.00000000 0.00000000 411 0.00000000 3.00000000 0.00000000 412 3.00000000 3.00000000 0.00000000 413 0.00000000 0.00000000 3.00000000 414 3.00000000 0.00000000 3.00000000 415 0.00000000 3.00000000 3.00000000 416 3.00000000 3.00000000 3.00000000 428 xmlNodePtr part1 = xmlFirstElementChild(root);
429 xmlNodePtr part2 = xmlNextElementSibling(part1);
433 parse_electrons.
readXML(part1);
450 ParticleSet ions(simulation_cell), electrons(simulation_cell);
454 const int ei_tid = electrons.
addTable(ions);
460 CHECK(ei_dtable.getName() ==
"ion0_e");
462 CHECK(ei_dtable.sources() == ions.getTotalNum());
465 int num_src = ions.getTotalNum();
467 std::vector<double> expect;
468 expect.resize(num_src * num_tar);
470 for (
int iat = 0; iat < num_src; iat++)
472 for (
int jat = 0; jat < num_tar; jat++, idx++)
474 double dist = ei_dtable.getDistRow(jat)[iat];
490 for (
int iat = 0; iat < num_src; iat++)
492 for (
int jat = 0; jat < num_tar; jat++, idx++)
494 double dist = ei_dtable.getDistRow(jat)[iat];
495 CHECK(expect[idx] == Approx(dist));
499 const int ee_tid = electrons.
addTable(electrons);
502 CHECK(ee_dtable.getName() ==
"e_e");
515 CHECK(ee_dtable.getTempDists()[1] == Approx(2.7239676944));
516 CHECK(ee_dtable.getTempDispls()[1][0] == Approx(2.7));
517 CHECK(ee_dtable.getTempDispls()[1][1] == Approx(-0.3));
518 CHECK(ee_dtable.getTempDispls()[1][2] == Approx(-0.2));
519 CHECK(ee_dtable.getDistRow(1)[0] == Approx(2.908607914));
520 CHECK(ee_dtable.getDisplRow(1)[0][0] == Approx(-2.9));
521 CHECK(ee_dtable.getDisplRow(1)[0][1] == Approx(0.2));
522 CHECK(ee_dtable.getDisplRow(1)[0][2] == Approx(-0.1));
526 CHECK(ee_dtable.getTempDists()[1] == Approx(2.7239676944));
527 CHECK(ee_dtable.getTempDispls()[1][0] == Approx(2.7));
528 CHECK(ee_dtable.getTempDispls()[1][1] == Approx(-0.3));
529 CHECK(ee_dtable.getTempDispls()[1][2] == Approx(-0.2));
530 CHECK(ee_dtable.getOldDists()[1] == Approx(2.908607914));
531 CHECK(ee_dtable.getOldDispls()[1][0] == Approx(2.9));
532 CHECK(ee_dtable.getOldDispls()[1][1] == Approx(-0.2));
533 CHECK(ee_dtable.getOldDispls()[1][2] == Approx(0.1));
534 CHECK(ee_dtable.getDistRow(1)[0] == Approx(2.908607914));
535 CHECK(ee_dtable.getDisplRow(1)[0][0] == Approx(-2.9));
536 CHECK(ee_dtable.getDisplRow(1)[0][1] == Approx(0.2));
537 CHECK(ee_dtable.getDisplRow(1)[0][2] == Approx(-0.1));
540 CHECK(ee_dtable.getDistRow(1)[0] == Approx(2.7239676944));
541 CHECK(ee_dtable.getDisplRow(1)[0][0] == Approx(-2.7));
542 CHECK(ee_dtable.getDisplRow(1)[0][1] == Approx(0.3));
543 CHECK(ee_dtable.getDisplRow(1)[0][2] == Approx(0.2));
553 CHECK(ee_dtable.getDistRow(1)[0] == Approx(2.908607914));
554 CHECK(ee_dtable.getDisplRow(1)[0][0] == Approx(-2.9));
555 CHECK(ee_dtable.getDisplRow(1)[0][1] == Approx(0.2));
556 CHECK(ee_dtable.getDisplRow(1)[0][2] == Approx(-0.1));
560 CHECK(ee_dtable.getDistRow(1)[0] == Approx(2.7239676944));
561 CHECK(ee_dtable.getDisplRow(1)[0][0] == Approx(-2.7));
562 CHECK(ee_dtable.getDisplRow(1)[0][1] == Approx(0.3));
563 CHECK(ee_dtable.getDisplRow(1)[0][2] == Approx(0.2));
572 ParticleSet ions(simulation_cell), electrons(simulation_cell, test_kind);
580 CHECK(ee_dtable.getName() ==
"e_e");
591 p_list.push_back(electrons);
592 p_list.push_back(electrons_clone);
598 std::vector<ParticleSet::SingleParticlePos> disp{{0.2, 0.1, 0.3}, {0.2, 0.1, 0.3}};
606 CHECK(ee_dtable.getDistRow(1)[0] == Approx(2.7239676944));
607 CHECK(ee_dtable.getDisplRow(1)[0][0] == Approx(-2.7));
608 CHECK(ee_dtable.getDisplRow(1)[0][1] == Approx(0.3));
609 CHECK(ee_dtable.getDisplRow(1)[0][2] == Approx(0.2));
618 ParticleSet ions(simulation_cell), electrons(simulation_cell, test_kind);
626 CHECK(ee_dtable.getName() ==
"e_e");
637 p_list.push_back(electrons);
638 p_list.push_back(electrons_clone);
644 std::vector<ParticleSet::SingleParticlePos> disp{{0.2, 0.1, 0.3}, {0.2, 0.1, 0.3}};
652 CHECK(ee_dtable.getDistRow(1)[0] == Approx(2.7239676944));
653 CHECK(ee_dtable.getDisplRow(1)[0][0] == Approx(-2.7));
654 CHECK(ee_dtable.getDisplRow(1)[0][1] == Approx(0.3));
655 CHECK(ee_dtable.getDisplRow(1)[0][2] == Approx(0.2));
658 TEST_CASE(
"distance_pbc_z batched APIs",
"[distance_table][xml]")
672 ParticleSet ions(simulation_cell), electrons(simulation_cell, test_kind);
680 CHECK(ee_dtable.getName() ==
"e_e");
691 p_list.push_back(electrons);
692 p_list.push_back(electrons_clone);
698 std::vector<ParticleSet::SingleParticlePos> disp{{0.2, 0.1, 0.3}, {0.2, 0.1, 0.3}};
701 CHECK(ee_dtable.getTempDists()[1] == Approx(2.7239676944));
702 CHECK(ee_dtable.getTempDispls()[1][0] == Approx(2.7));
703 CHECK(ee_dtable.getTempDispls()[1][1] == Approx(-0.3));
704 CHECK(ee_dtable.getTempDispls()[1][2] == Approx(-0.2));
705 CHECK(ee_dtable.getOldDists()[1] == Approx(2.908607914));
706 CHECK(ee_dtable.getOldDispls()[1][0] == Approx(2.9));
707 CHECK(ee_dtable.getOldDispls()[1][1] == Approx(-0.2));
708 CHECK(ee_dtable.getOldDispls()[1][2] == Approx(0.1));
709 CHECK(ee_dtable.getDistRow(1)[0] == Approx(2.908607914));
710 CHECK(ee_dtable.getDisplRow(1)[0][0] == Approx(-2.9));
711 CHECK(ee_dtable.getDisplRow(1)[0][1] == Approx(0.2));
712 CHECK(ee_dtable.getDisplRow(1)[0][2] == Approx(-0.1));
715 CHECK(ee_dtable.getDistRow(1)[0] == Approx(2.908607914));
716 CHECK(ee_dtable.getDisplRow(1)[0][0] == Approx(-2.9));
717 CHECK(ee_dtable.getDisplRow(1)[0][1] == Approx(0.2));
718 CHECK(ee_dtable.getDisplRow(1)[0][2] == Approx(-0.1));
722 CHECK(ee_dtable.getDistRow(1)[0] == Approx(2.7239676944));
723 CHECK(ee_dtable.getDisplRow(1)[0][0] == Approx(-2.7));
724 CHECK(ee_dtable.getDisplRow(1)[0][1] == Approx(0.3));
725 CHECK(ee_dtable.getDisplRow(1)[0][2] == Approx(0.2));
728 TEST_CASE(
"distance_pbc_z batched APIs ee NEED_TEMP_DATA_ON_HOST",
"[distance_table][xml]")
734 TEST_CASE(
"test_distance_pbc_diamond",
"[distance_table][xml]")
738 auto& ions = *pset_pool.getParticleSet(
"ion");
739 auto& elecs = *pset_pool.getParticleSet(
"e");
743 elecs.addTable(ions);
744 elecs.addTable(elecs);
a class that defines a supercell in D-dimensional Euclean space.
void test_distance_pbc_z_batched_APIs(DynamicCoordinateKind test_kind)
DynamicCoordinateKind
enumerator for DynamicCoordinates kinds
class that handles xmlDoc
const std::string & getName() const
return the name
static void mw_makeMove(const RefVectorWithLeader< ParticleSet > &p_list, int iat, const MCCoords< CT > &displs)
batched version of makeMove
helper functions for EinsplineSetBuilder
const DistanceTableAA & getDistTableAA(int table_ID) const
get a distance table by table_ID and dyanmic_cast to DistanceTableAA
void test_distance_pbc_z_batched_APIs_ee_NEED_TEMP_DATA_ON_HOST(DynamicCoordinateKind test_kind)
size_t getTotalNum() const
static ParticleSetPool make_diamondC_1x1x1(Communicate *c)
TEST_CASE("complex_helper", "[type_traits]")
void createResource(ResourceCollection &collection) const
initialize a shared resource and hand it to a collection
SimulationCell parse_pbc_lattice()
void update(bool skipSK=false)
update the internal data
Communicate * Controller
Global Communicator for a process.
static void mw_accept_rejectMove(const RefVectorWithLeader< ParticleSet > &p_list, Index_t iat, const std::vector< bool > &isAccepted, bool forward_mode=true)
batched version of acceptMove and rejectMove fused, templated on CoordsType
ParticleIndex GroupID
Species ID.
const DistanceTableAB & getDistTableAB(int table_ID) const
get a distance table by table_ID and dyanmic_cast to DistanceTableAB
MakeReturn< BinaryNode< FnPow, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t, typename CreateLeaf< Vector< T2, C2 > >::Leaf_t > >::Expression_t pow(const Vector< T1, C1 > &l, const Vector< T2, C2 > &r)
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > lattice
int addTable(const ParticleSet &psrc, DTModes modes=DTModes::ALL_OFF)
add a distance table
Specialized paritlce class for atomistic simulations.
void test_distance_fcc_pbc_z_batched_APIs(DynamicCoordinateKind test_kind)
REQUIRE(std::filesystem::exists(filename))
void rejectMove(Index_t iat)
reject a proposed move in regular mode
void accept_rejectMove(Index_t iat, bool accepted, bool forward_mode=true)
accept or reject a proposed move Two operation modes: The using and updating distance tables via Part...
bool readXML(xmlNodePtr cur)
process xmlnode <particleset/> which contains everything about the particle set to initialize ...
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
SimulationCell parse_pbc_fcc_lattice()
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
void makeMove(Index_t iat, const SingleParticlePos &displ, bool maybe_accept=true)
move the iat-th particle to active_pos_
bool parseFromString(const std::string_view data)
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
static void mw_donePbyP(const RefVectorWithLeader< ParticleSet > &p_list, bool skipSK=false)
batched version of donePbyP
handles acquire/release resource by the consumer (RefVectorWithLeader type).
void parse_electron_ion_pbc_z(ParticleSet &ions, ParticleSet &electrons)
Custom container for set of attributes for a set of species.
void acceptMove(Index_t iat)
accept the move and update the particle attribute by the proposed move in regular mode ...
whether full table needs to be ready at anytime or not after donePbyP Optimization can be implemented...
void donePbyP(bool skipSK=false)
update structure factor and unmark active_ptcl_
whether temporary data set on the host is updated or not when a move is proposed. ...