33 #if defined(ENABLE_CUDA) && !defined(QMC_CUDA2HIP) 34 using DiracDet = DiracDeterminant<DelayedUpdateCUDA<QMCTraits::ValueType, QMCTraits::QTFull::ValueType>>;
43 TEST_CASE(
"TrialWaveFunction_diamondC_1x1x1",
"[wavefunction]")
47 #if defined(ENABLE_OFFLOAD) 54 lattice.R = {3.37316115, 3.37316115, 0.0, 0.0, 3.37316115, 3.37316115, 3.37316115, 0.0, 3.37316115};
60 auto ions_uptr = std::make_unique<ParticleSet>(ptcl.
getSimulationCell(), kind_selected);
61 auto elec_uptr = std::make_unique<ParticleSet>(ptcl.
getSimulationCell(), kind_selected);
68 ions_.R[0] = {0.0, 0.0, 0.0};
69 ions_.R[1] = {1.68658058, 1.68658058, 1.68658058};
76 elec_.
R[0] = {0.0, 0.0, 0.0};
77 elec_.
R[1] = {0.0, 1.0, 1.0};
78 elec_.
R[2] = {1.0, 1.0, 0.0};
79 elec_.
R[3] = {1.0, 0.0, 1.0};
85 tspecies(chargeIdx, upIdx) = -1;
86 tspecies(chargeIdx, downIdx) = -1;
96 const char* spo_xml = R
"(<tmp> \ 97 <determinantset type="einspline" href="diamondC_1x1x1.pwscf.h5" tilematrix="1 0 0 0 1 0 0 0 1" twistnum="0" source="ion" meshfactor="1.0" precision="float" size="2"/> 106 xmlNodePtr ein1 = xmlFirstElementChild(spo_root);
112 std::vector<std::unique_ptr<DiracDeterminantBase>> dets;
113 dets.push_back(std::make_unique<DiracDet>(spo->makeClone(), 0, 2));
114 dets.push_back(std::make_unique<DiracDet>(spo->makeClone(), 2, 4));
116 auto slater_det = std::make_unique<SlaterDet>(elec_, std::move(dets));
122 const char* jas_input = R
"(<tmp> 123 <jastrow name="J2" type="Two-Body" function="Bspline" print="yes"> 124 <correlation size="10" speciesA="u" speciesB="u"> 125 <coefficients id="uu" type="Array"> 0.02904699284 -0.1004179 -0.1752703883 -0.2232576505 -0.2728029201 -0.3253286875 -0.3624525145 -0.3958223107 -0.4268582166 -0.4394531176</coefficients> 135 xmlNodePtr jas1 = xmlFirstElementChild(jas_root); 148 #if defined(QMC_COMPLEX) 149 CHECK(logpsi == Approx(-0.1201465271523596));
151 CHECK(logpsi == Approx(-1.471840358291562));
155 std::unique_ptr<TrialWaveFunction> psi_clone(psi.
makeClone(elec_clone));
158 double logpsi_clone = psi_clone->evaluateLog(elec_clone);
159 #if defined(QMC_COMPLEX) 160 CHECK(logpsi_clone == Approx(-0.1201465271523596));
162 CHECK(logpsi_clone == Approx(-1.471840358291562));
165 const int moved_elec_id = 0;
172 elec_.makeMove(moved_elec_id, delta);
181 #if defined(QMC_COMPLEX) 182 CHECK(r_all_val == ComplexApprox(
ValueType(1.653821746120792, 0.5484992491019633)));
183 CHECK(r_fermionic_val == ComplexApprox(
ValueType(1.804065087219802, 0.598328295048828)));
185 CHECK(r_all_val == Approx(2.305591774210242));
186 CHECK(r_fermionic_val == ValueApprox(2.515045914101833));
188 CHECK(r_bosonic_val == ValueApprox(0.9167195562048454));
191 elec_.acceptMove(moved_elec_id);
192 #if defined(QMC_COMPLEX) 200 #if defined(QMC_COMPLEX) 207 REQUIRE(opt_obj_refs.size() == 1);
213 elec_.createResource(pset_res);
226 #if defined(QMC_COMPLEX) 227 REQUIRE(std::complex<RealType>(wf_ref_list[0].getLogPsi(), wf_ref_list[0].getPhase()) ==
228 LogComplexApprox(std::complex<RealType>(0.4351202455204972, 6.665972664860828)));
229 REQUIRE(std::complex<RealType>(wf_ref_list[1].getLogPsi(), wf_ref_list[1].getPhase()) ==
230 LogComplexApprox(std::complex<RealType>(-0.1201465271523596, 6.345732826640545)));
232 REQUIRE(std::complex<RealType>(wf_ref_list[0].getLogPsi(), wf_ref_list[0].getPhase()) ==
233 LogComplexApprox(std::complex<RealType>(-0.6365029797784554, 3.141592653589793)));
234 REQUIRE(std::complex<RealType>(wf_ref_list[1].getLogPsi(), wf_ref_list[1].getPhase()) ==
235 LogComplexApprox(std::complex<RealType>(-1.471840358291562, 3.141592653589793)));
240 grad_old.
grads_positions[0] = wf_ref_list[0].evalGrad(p_ref_list[0], moved_elec_id);
241 grad_old.
grads_positions[1] = wf_ref_list[1].evalGrad(p_ref_list[1], moved_elec_id);
249 #if defined(QMC_COMPLEX) 265 PosType delta_sign_changed(0.1, 0.1, -0.2);
267 std::vector<PosType> displs{delta_sign_changed, delta_sign_changed};
272 ValueType r_0 = wf_ref_list[0].calcRatio(p_ref_list[0], moved_elec_id);
274 ValueType r_1 = wf_ref_list[1].calcRatioGrad(p_ref_list[1], moved_elec_id, grad_temp);
275 #if defined(QMC_COMPLEX) 276 CHECK(r_0 == ComplexApprox(
ValueType(-0.045474407700114, -0.59956233350555)));
277 CHECK(r_1 == ComplexApprox(
ValueType(-0.44602867091608, -1.8105588403509)));
278 CHECK(grad_temp[0] == ComplexApprox(
ValueType(-6.6139971152489, 22.82304260002)));
279 CHECK(grad_temp[1] == ComplexApprox(
ValueType(8.3367501707711, -23.362154838104)));
280 CHECK(grad_temp[2] == ComplexApprox(
ValueType(-2.6347597529645, 0.67383144279783)));
282 CHECK(r_0 == Approx(-0.4138835449));
283 CHECK(r_1 == Approx(-2.5974770159));
284 CHECK(grad_temp[0] == Approx(-17.865723259764));
285 CHECK(grad_temp[1] == Approx(19.854257889369));
286 CHECK(grad_temp[2] == Approx(-2.9669578650441));
291 displs = {delta_zero, delta};
294 std::vector<PsiValue> ratios(2);
296 app_log() <<
"calcRatio " << std::setprecision(14) << ratios[0] <<
" " << ratios[1] << std::endl;
297 #if defined(QMC_COMPLEX) 299 CHECK(ratios[1] == ComplexApprox(
PsiValue(1.6538214581548, 0.54849918598717)));
301 CHECK(ratios[0] == Approx(1));
302 CHECK(ratios[1] == Approx(2.3055913093424));
305 std::fill(ratios.begin(), ratios.end(), 0);
310 ratios[0] = wf_ref_list[0].calcRatioGrad(p_ref_list[0], moved_elec_id, grad_new.grads_positions[0]);
311 ratios[1] = wf_ref_list[1].calcRatioGrad(p_ref_list[1], moved_elec_id, grad_new.grads_positions[1]);
313 app_log() <<
"calcRatioGrad " << std::setprecision(14) << ratios[0] <<
" " << ratios[1] << std::endl
314 << grad_new.grads_positions[0][0] <<
" " << grad_new.grads_positions[0][1] <<
" " 315 << grad_new.grads_positions[0][2] <<
" " << grad_new.grads_positions[1][0] <<
" " 316 << grad_new.grads_positions[1][1] <<
" " << grad_new.grads_positions[1][2] << std::endl;
322 #if defined(QMC_COMPLEX) 324 CHECK(grad_new.grads_positions[0][0] == ComplexApprox(
ValueType(18.817970466022, -6.5837500306076)));
325 CHECK(grad_new.grads_positions[0][1] == ComplexApprox(
ValueType(-22.840838391977, 3.9963373883645)));
326 CHECK(grad_new.grads_positions[0][2] == ComplexApprox(
ValueType(3.8805320617146, 1.5825508129169)));
327 CHECK(ratios[1] == ComplexApprox(
ValueType(1.6538214581548, 0.54849918598717)));
328 CHECK(grad_new.grads_positions[1][0] == ComplexApprox(
ValueType(18.817970466022, -6.5837500306076)));
329 CHECK(grad_new.grads_positions[1][1] == ComplexApprox(
ValueType(-22.840838391977, 3.9963373883645)));
330 CHECK(grad_new.grads_positions[1][2] == ComplexApprox(
ValueType(3.8805320617146, 1.5825508129169)));
332 CHECK(ratios[0] == Approx(1));
333 CHECK(grad_new.grads_positions[0][0] == Approx(14.77249702264));
334 CHECK(grad_new.grads_positions[0][1] == Approx(-20.385235323777));
335 CHECK(grad_new.grads_positions[0][2] == Approx(4.8529516184558));
336 CHECK(ratios[1] == Approx(2.3055913093424));
337 CHECK(grad_new.grads_positions[1][0] == Approx(14.77249702264));
338 CHECK(grad_new.grads_positions[1][1] == Approx(-20.385235323777));
339 CHECK(grad_new.grads_positions[1][2] == Approx(4.8529516184558));
342 std::vector<bool> isAccepted(2,
true);
344 #if defined(QMC_COMPLEX) 345 REQUIRE(std::complex<RealType>(wf_ref_list[0].getLogPsi(), wf_ref_list[0].getPhase()) ==
346 LogComplexApprox(std::complex<RealType>(0.4351202455204972, 6.665972664860828)));
347 REQUIRE(std::complex<RealType>(wf_ref_list[1].getLogPsi(), wf_ref_list[1].getPhase()) ==
348 LogComplexApprox(std::complex<RealType>(0.4351202455204972, 6.665972664860828)));
350 REQUIRE(std::complex<RealType>(wf_ref_list[0].getLogPsi(), wf_ref_list[0].getPhase()) ==
351 LogComplexApprox(std::complex<RealType>(-0.6365029797784554, 3.141592653589793)));
352 REQUIRE(std::complex<RealType>(wf_ref_list[1].getLogPsi(), wf_ref_list[1].getPhase()) ==
353 LogComplexApprox(std::complex<RealType>(-0.6365029797784554, 3.141592653589793)));
357 #if defined(QMC_COMPLEX) 374 #if defined(QMC_COMPLEX) && !defined(ENABLE_CUDA) 386 TEST_CASE(
"TrialWaveFunction::mw_evalGrad for spinors",
"[wavefunction]")
399 auto logpsi = psi_noJ.evaluateLog(elec);
404 auto wavefunction_pool2 =
406 auto& psi = *(wavefunction_pool2).getWaveFunction(
"wavefunction");
409 ParticleSet elec_clone(elec);
410 std::unique_ptr<TrialWaveFunction> psi_clone(psi.makeClone(elec_clone));
412 ResourceCollection elec_res(
"test_elec_res");
413 ResourceCollection psi_res(
"test_psi_res");
414 elec.createResource(elec_res);
415 psi.createResource(psi_res);
417 RefVectorWithLeader<ParticleSet> elec_ref_list(elec, {elec, elec_clone});
418 RefVectorWithLeader<TrialWaveFunction> psi_ref_list(psi, {psi, *psi_clone});
420 ResourceCollectionTeamLock<ParticleSet> mw_elec_lock(elec_res, elec_ref_list);
421 ResourceCollectionTeamLock<TrialWaveFunction> mw_psi_lock(psi_res, psi_ref_list);
425 TWFGrads<CoordsType::POS_SPIN> grads(2);
427 for (
size_t iw = 0; iw < 2; iw++)
428 CHECK(grads.grads_spins[iw] == ComplexApprox(spingrad_ref));
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.
DynamicCoordinateKind
enumerator for DynamicCoordinates kinds
void setName(const std::string &aname)
WaveFunctionComponent::PsiValue PsiValue
void setSimulationCell(const SimulationCell &simulation_cell)
set simulation cell
class that handles xmlDoc
ValueType calcRatio(ParticleSet &P, int iat, ComputeType ct=ComputeType::ALL)
compute psi(R_new) / psi(R_current) ratio It returns a complex value if the wavefunction is complex...
static void mw_makeMove(const RefVectorWithLeader< ParticleSet > &p_list, int iat, const MCCoords< CT > &displs)
batched version of makeMove
WaveFunctionComponent::PsiValue PsiValue
int addSpecies(const std::string &aname)
When a name species does not exist, add a new species.
helper functions for EinsplineSetBuilder
WaveFunctionComponent::GradType GradType
QTBase::GradType GradType
void createResource(ResourceCollection &collection) const
initialize a shared resource and hand it to a collection
QTBase::RealType RealType
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false)
update the state with the new data
TEST_CASE("complex_helper", "[type_traits]")
std::unique_ptr< WaveFunctionComponent > buildComponent(xmlNodePtr cur) override
process a xml node at cur
static void mw_calcRatioGrad(const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, TWFGrads< CT > &grads)
batched version of ratioGrad
WaveFunctionComponent::LogValue LogValue
void addParticleSet(std::unique_ptr< ParticleSet > &&p)
add a ParticleSet* to the pool with its ownership transferred ParticleSet built outside the ParticleS...
Builder class for einspline-based SPOSet objects.
JastrowBuilder using an analytic 1d functor Should be able to eventually handle all one and two body ...
LatticeGaussianProduct::GradType GradType
static WaveFunctionPool make_O2_spinor(const RuntimeOptions &runtime_options, Communicate *comm, ParticleSetPool &particle_pool)
ProjectData test_project("test", ProjectData::DriverVersion::BATCH)
QTBase::ComplexType ComplexType
void update(bool skipSK=false)
update the internal data
Communicate * Controller
Global Communicator for a process.
static void mw_accept_rejectMove(const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, const std::vector< bool > &isAccepted, bool safe_to_delay=false)
int addAttribute(const std::string &aname)
for a new attribute, allocate the data, !More often used to get the index of a species ...
const RuntimeOptions & getRuntimeOptions() const noexcept
std::unique_ptr< TrialWaveFunction > makeClone(ParticleSet &tqp) const
Catch::Detail::LogComplexApprox LogComplexApprox
RefVector< MultiSlaterDetTableMethod > findMSD() const
find MSD WFCs if exist
UniqueOptObjRefs extractOptimizableObjectRefs()
extract underlying OptimizableObject references
Wrapping information on parallelism.
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > lattice
int addTable(const ParticleSet &psrc, DTModes modes=DTModes::ALL_OFF)
add a distance table
static ParticleSetPool make_O2_spinor(Communicate *c)
Specialized paritlce class for atomistic simulations.
std::vector< QMCTraits::GradType > grads_positions
QTBase::ValueType ValueType
REQUIRE(std::filesystem::exists(filename))
Manage a collection of ParticleSet objects.
static void mw_calcRatio(const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, ComputeType ct=ComputeType::ALL)
batched version of calcRatio
RealType getLogPsi() const
static WaveFunctionPool make_O2_spinor_J12(const RuntimeOptions &runtime_options, Communicate *comm, ParticleSetPool &particle_pool)
static void mw_evalGrad(const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, TWFGrads< CT > &grads)
batched version of evalGrad
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
void create(const std::vector< int > &agroup)
create grouped particles
DiracDeterminant< DelayedUpdate< QMCTraits::ValueType, QMCTraits::QTFull::ValueType > > DiracDet
Declaration of a TrialWaveFunction.
Class to represent a many-body trial wave function.
bool parseFromString(const std::string_view data)
static void mw_update(const RefVectorWithLeader< ParticleSet > &p_list, bool skipSK=false)
batched version of update
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
handles acquire/release resource by the consumer (RefVectorWithLeader type).
LatticeGaussianProduct::ValueType ValueType
Declaration of DiracDeterminant with a S(ingle)P(article)O(rbital)Set.
void createSK()
create Structure Factor with PBCs
std::complex< double > LogValue
Custom container for set of attributes for a set of species.
const PoolType & getPool() const
get the Pool object
std::unique_ptr< SPOSet > createSPOSetFromXML(xmlNodePtr cur) override
initialize the Antisymmetric wave function for electrons
const auto & getSimulationCell() const
get simulation cell
void addComponent(std::unique_ptr< WaveFunctionComponent > &&aterm)
add a WaveFunctionComponent
static void mw_evaluateLog(const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list)
batched version of evaluateLog.
Declaration of ParticleSetPool.