46 TEST_CASE(
"ReadFileBuffer_no_file",
"[hamiltonian]")
49 bool open_okay = buf.
open_file(
"does_not_exist");
53 TEST_CASE(
"ReadFileBuffer_simple_serial",
"[hamiltonian]")
59 bool open_okay = buf.
open_file(
"simple.txt");
68 TEST_CASE(
"ReadFileBuffer_simple_mpi",
"[hamiltonian]")
73 bool open_okay = buf.
open_file(
"simple.txt");
107 double rlist[5] = {0.001, 0.500, 1.000, 2.000, 10.000};
108 double so_p[5] = {0.999999000005, 0.778800783071, 0.3678794411714, 0.01831563888873418, 0.000};
109 double so_d[5] = {9.99998000e-01, 6.06530660e-01, 1.35335283e-01, 3.35462628e-04, 0.000};
110 double so_f[5] = {9.99997000e-01, 4.72366553e-01, 4.97870684e-02, 6.14421235e-06, 0.000};
112 for (
int i = 0; i < 5; i++)
115 double so_p_ref = so_p[i];
116 double so_d_ref = so_d[i];
117 double so_f_ref = so_f[i];
123 CHECK(so_p_val == Approx(so_p_ref));
124 CHECK(so_d_val == Approx(so_d_ref));
125 CHECK(so_f_val == Approx(so_f_ref));
138 bool open_okay = buf.
open_file(
"simple.txt");
178 ions.
R[0] = {0.0, 0.0, 0.0};
179 ions.
R[1] = {6.0, 0.0, 0.0};
183 int iatnumber = ion_species.
addAttribute(
"atomic_number");
184 ion_species(pChargeIdx, pIdx) = 1;
185 ion_species(iatnumber, pIdx) = 11;
189 std::vector<int> agroup(2, 1);
191 elec.
R[0] = {2.0, 0.0, 0.0};
192 elec.
R[1] = {3.0, 0.0, 0.0};
198 tspecies(chargeIdx, upIdx) = -1;
199 tspecies(chargeIdx, downIdx) = -1;
200 tspecies(massIdx, upIdx) = 1.0;
201 tspecies(massIdx, downIdx) = 1.0;
216 const char* particles = R
"(<tmp> 217 <jastrow name="J2" type="Two-Body" function="Bspline" print="yes" gpu="no"> 218 <correlation speciesA="u" speciesB="d" rcut="10" size="8"> 219 <coefficients id="ud" type="Array"> 2.015599059 1.548994099 1.17959447 0.8769687661 0.6245736507 0.4133517767 0.2333851935 0.1035636904</coefficients> 230 xmlNodePtr jas2 = xmlFirstElementChild(root);
237 const char* particles2 = R
"(<tmp> 238 <jastrow name="J1" type="One-Body" function="Bspline" source="ion0" print="yes"> 239 <correlation elementType="Na" rcut="10" size="10" cusp="0"> 240 <coefficients id="eNa" type="Array"> 1.244201343 -1.188935609 -1.840397253 -1.803849126 -1.612058635 -1.35993202 -1.083353212 -0.8066295188 -0.5319252448 -0.3158819772</coefficients> 250 xmlNodePtr jas1 = xmlFirstElementChild(root);
269 const int myTableIndex = elec.
addTable(ions);
279 CHECK(logpsi == Approx(5.1497823982));
281 auto test_evaluateOne = [&]() {
286 const auto& dist = myTable.getDistRow(jel);
287 const auto& displ = myTable.getDisplRow(jel);
289 if (nlpp !=
nullptr && dist[iat] < nlpp->
getRmax())
290 Value1 += nlpp->
evaluateOne(elec, iat, psi, jel, dist[iat], -displ[iat],
false);
293 CHECK(Value1 == Approx(6.9015710211
e-02));
309 const int NumOptimizables(optvars.
size());
311 auto test_evaluateValueAndDerivatives = [&]() {
331 const auto& dist = myTable.getDistRow(jel);
332 const auto& displ = myTable.getDisplRow(jel);
334 if (nlpp !=
nullptr && dist[iat] < nlpp->
getRmax())
338 CHECK(Value1 == Approx(6.9015710211
e-02));
349 test_evaluateValueAndDerivatives();
351 test_evaluateValueAndDerivatives();
366 const auto& dist = myTable.getDistRow(jel);
367 const auto& displ = myTable.getDisplRow(jel);
369 if (nlpp !=
nullptr && dist[iat] < nlpp->
getRmax())
373 nlpp->
evaluateOneWithForces(elec, ions, iat, psi, jel, dist[iat], -displ[iat], HFTerm2[iat], PulayTerm);
381 CHECK(Value2 == Approx(6.9015710211
e-02));
382 CHECK(Value3 == Approx(6.9015710211
e-02));
393 CHECK(HFTerm[0][0] == Approx(-0.3557369031));
394 CHECK(HFTerm[0][1] == Approx(0.0));
395 CHECK(HFTerm[0][2] == Approx(0.0));
396 CHECK(HFTerm[1][0] == Approx(0.001068673105));
397 CHECK(HFTerm[1][1] == Approx(0.0));
398 CHECK(HFTerm[1][2] == Approx(0.0));
400 CHECK(HFTerm2[0][0] == Approx(-0.3557369031));
401 CHECK(HFTerm2[0][1] == Approx(0.0));
402 CHECK(HFTerm2[0][2] == Approx(0.0));
403 CHECK(HFTerm2[1][0] == Approx(0.001068673105));
404 CHECK(HFTerm2[1][1] == Approx(0.0));
405 CHECK(HFTerm2[1][2] == Approx(0.0));
407 CHECK(PulayTerm[0][0] == Approx(0.008300993315));
408 CHECK(PulayTerm[0][1] == Approx(0.0));
409 CHECK(PulayTerm[0][2] == Approx(0.0));
410 CHECK(PulayTerm[1][0] == Approx(0.001665391103));
411 CHECK(PulayTerm[1][1] == Approx(0.0));
412 CHECK(PulayTerm[1][2] == Approx(0.0));
424 TEST_CASE(
"Evaluate_soecp",
"[hamiltonian]")
426 app_log() <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
427 app_log() <<
"!!!! Evaluate SOECPComponent !!!!\n";
428 app_log() <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
437 CrystalLattice<OHMMS_PRECISION, OHMMS_DIM>
lattice;
443 const SimulationCell simulation_cell(
lattice);
444 auto ions_uptr = std::make_unique<ParticleSet>(simulation_cell);
445 auto elec_uptr = std::make_unique<ParticleSet>(simulation_cell);
446 ParticleSet& ions(*ions_uptr);
447 ParticleSet& elec(*elec_uptr);
449 ions.setName(
"ion0");
451 ions.R[0] = {0.0, 0.0, 0.0};
454 SpeciesSet& ion_species = ions.getSpeciesSet();
455 int pIdx = ion_species.addSpecies(
"H");
456 int pChargeIdx = ion_species.addAttribute(
"charge");
457 int iatnumber = ion_species.addAttribute(
"atomic_number");
458 ion_species(pChargeIdx, pIdx) = 0;
459 ion_species(iatnumber, pIdx) = 1;
464 elec.setSpinor(
true);
466 elec.R[0] = {0.138, -0.24, 0.216};
467 elec.R[1] = {-0.216, 0.24, -0.138};
468 elec.spins = {0.2, 0.51};
470 SpeciesSet& tspecies = elec.getSpeciesSet();
471 int upIdx = tspecies.addSpecies(
"u");
472 int chargeIdx = tspecies.addAttribute(
"charge");
473 int massIdx = tspecies.addAttribute(
"mass");
474 tspecies(chargeIdx, upIdx) = -1;
475 tspecies(massIdx, upIdx) = 1.0;
482 RuntimeOptions runtime_options;
483 TrialWaveFunction psi(runtime_options);
485 std::vector<PosType> kup, kdn;
486 std::vector<RealType> k2up, k2dn;
498 auto spo_up = std::make_unique<FreeOrbital>(
"free_orb_up", kup);
499 auto spo_dn = std::make_unique<FreeOrbital>(
"free_orb_dn", kdn);
501 auto spinor_set = std::make_unique<SpinorSet>(
"free_orb_spinor");
502 spinor_set->set_spos(std::move(spo_up), std::move(spo_dn));
506 auto dd = std::make_unique<DiracDeterminant<>>(std::move(spinor_set), 0, nelec);
508 psi.addComponent(std::move(dd));
513 const char* particles = R
"(<tmp> 514 <jastrow name="J2" type="Two-Body" function="Bspline" print="yes" gpu="no"> 515 <correlation speciesA="u" speciesB="u" rcut="5" size="5"> 516 <coefficients id="uu" type="Array"> 0.02904699284 -0.1004179 -0.1752703883 -0.2232576505 -0.2728029201</coefficients> 525 xmlNodePtr jas2 = xmlFirstElementChild(root);
526 RadialJastrowBuilder jastrow(c, elec);
527 psi.addComponent(jastrow.buildComponent(jas2));
531 ECPComponentBuilder ecp(
"test_read_soecp", c);
533 bool okay2 = ecp.read_pp_file(
"so_ecp_test.xml");
536 SOECPComponent* sopp = ecp.pp_so.get();
540 const int myTableIndex = elec.addTable(ions);
542 const auto& myTable = elec.getDistTableAB(myTableIndex);
549 auto logpsi = psi.evaluateLog(elec);
551 auto test_evaluateOne = [&]() {
553 for (
int jel = 0; jel < elec.getTotalNum(); jel++)
555 const auto& dist = myTable.getDistRow(jel);
556 const auto& displ = myTable.getDisplRow(jel);
557 for (
int iat = 0; iat < ions.getTotalNum(); iat++)
558 if (sopp !=
nullptr && dist[iat] < sopp->getRmax())
559 Value1 += sopp->evaluateOne(elec, iat, psi, jel, dist[iat],
RealType(-1) * displ[iat]);
561 REQUIRE(Value1 == Approx(-3.530511241));
566 sopp->initVirtualParticle(elec);
568 sopp->deleteVirtualParticle();
575 Vector<ValueType> dlogpsi;
576 Vector<ValueType> dhpsioverpsi;
578 psi.checkInVariables(optvars);
580 const int NumOptimizables(optvars.size());
581 psi.checkOutVariables(optvars);
585 std::vector<RealType> dlogpsi_refs = {-0.2622341567, -0.64168132, -0.09608452334, -2.486899575e-14, -2.486899575e-14};
589 std::vector<RealType> dkinpsioverpsi_refs = {-3.807451601, 0.1047251267, 3.702726474, 0, 0};
592 std::vector<RealType> dhpsioverpsi_refs = {-3.855727438, 0.202618546, 3.653108892, -8.169955304e-14,
596 auto test_evaluateValueAndDerivatives = [&]() {
597 dlogpsi.resize(NumOptimizables,
ValueType(0));
598 dhpsioverpsi.resize(NumOptimizables,
ValueType(0));
599 psi.evaluateDerivatives(elec, optvars, dlogpsi, dhpsioverpsi);
600 for (
int ip = 0; ip < NumOptimizables; ip++)
603 CHECK(
std::real(dhpsioverpsi[ip]) == Approx(dkinpsioverpsi_refs[ip]));
608 for (
int jel = 0; jel < elec.getTotalNum(); jel++)
610 const auto& dist = myTable.getDistRow(jel);
611 const auto& displ = myTable.getDisplRow(jel);
612 for (
int iat = 0; iat < ions.getTotalNum(); iat++)
613 if (sopp !=
nullptr && dist[iat] < sopp->getRmax())
614 Value1 += sopp->evaluateValueAndDerivatives(elec, iat, psi, jel, dist[iat], -displ[iat], optvars, dlogpsi,
617 REQUIRE(Value1 == Approx(-3.530511241).epsilon(2.
e-5));
619 for (
int ip = 0; ip < NumOptimizables; ip++)
620 CHECK(
std::real(dhpsioverpsi[ip]) == Approx(dhpsioverpsi_refs[ip]));
624 sopp->initVirtualParticle(elec);
625 test_evaluateValueAndDerivatives();
626 sopp->deleteVirtualParticle();
627 test_evaluateValueAndDerivatives();
void resize(size_type n, Type_t val=Type_t())
Resize the container.
a class that defines a supercell in D-dimensional Euclean space.
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
void setName(const std::string &aname)
Contains a set of radial grid potentials around a center.
class that handles xmlDoc
int addSpecies(const std::string &aname)
When a name species does not exist, add a new species.
helper functions for EinsplineSetBuilder
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)
evaluate derivatives of KE wrt optimizable varibles
QTBase::RealType RealType
size_t getTotalNum() const
TEST_CASE("complex_helper", "[type_traits]")
std::unique_ptr< WaveFunctionComponent > buildComponent(xmlNodePtr cur) override
process a xml node at cur
JastrowBuilder using an analytic 1d functor Should be able to eventually handle all one and two body ...
Declaration of NonLocalTOperator.
class SOECPComponent brief Computes the nonlocal spin-orbit interaction .
void resetIndex()
reset Index
void update(bool skipSK=false)
update the internal data
Attaches a unit to a Vector for IO.
Communicate * Controller
Global Communicator for a process.
int addAttribute(const std::string &aname)
for a new attribute, allocate the data, !More often used to get the index of a species ...
std::unique_ptr< NonLocalECPComponent > pp_nonloc
const DistanceTableAB & getDistTableAB(int table_ID) const
get a distance table by table_ID and dyanmic_cast to DistanceTableAB
QMCTraits::PosType PosType
Wrapping information on parallelism.
bool open_file(const std::string &fname)
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.
RealType evaluateValueAndDerivatives(ParticleSet &P, int iat, TrialWaveFunction &psi, int iel, RealType r, const PosType &dr, const opt_variables_type &optvars, const Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)
evaluate the non-local potential of the iat-th ionic center
SpherGridType rrotsgrid_m
randomized spherical grid
std::unique_ptr< SOECPComponent > pp_so
QTBase::ValueType ValueType
REQUIRE(std::filesystem::exists(filename))
Declaration of a builder class for an ECP component for an ionic type.
class to handle a set of variables that can be modified during optimizations
SpherGridType sgridxyz_m_
RealType evaluateOne(ParticleSet &W, int iat, TrialWaveFunction &Psi, int iel, RealType r, const PosType &dr, bool use_DLA)
Evaluate the nonlocal pp contribution via randomized quadrature grid to total energy from ion "iat" a...
void checkOutVariables(const opt_variables_type &o)
Check out optimizable variables Assign index mappings from global list (o) to local values in each co...
optimize::VariableSet opt_variables_type
OHMMS_INDEXTYPE IndexType
define other types
size_type size() const
return the size
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
std::vector< RadialPotentialType * > sopp_m_
Non-Local part of the pseudo-potential.
void create(const std::vector< int > &agroup)
create grouped particles
bool read_pp_file(const std::string &fname)
Declaration of a TrialWaveFunction.
QMCTraits::RealType RealType
Class to represent a many-body trial wave function.
void deleteVirtualParticle()
bool parseFromString(const std::string_view data)
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
TinyVector< double, 3 > PosType
RealType evaluateOneWithForces(ParticleSet &W, int iat, TrialWaveFunction &Psi, int iel, RealType r, const PosType &dr, PosType &force_iat)
Evaluate the nonlocal pp contribution via randomized quadrature grid to total energy from ion "iat" a...
SpherGridType rrotsgrid_m_
LatticeGaussianProduct::ValueType ValueType
Declaration of DiracDeterminant with a S(ingle)P(article)O(rbital)Set.
void createSK()
create Structure Factor with PBCs
void initVirtualParticle(const ParticleSet &qp)
Declaration of WaveFunctionComponent.
Custom container for set of attributes for a set of species.
void copyGridUnrotatedForTest(NonLocalECPComponent &nlpp)
QMCTraits::RealType getSplinedSOPot(SOECPComponent *so_comp, int l, double r)
SpherGridType sgridxyz_m
fixed Spherical Grid for species
void addComponent(std::unique_ptr< WaveFunctionComponent > &&aterm)
add a WaveFunctionComponent
void checkInVariables(opt_variables_type &o)
Check in an optimizable parameter.