71 ions_.
R[0] = {2.0, 0.0, 0.0};
74 int ichargeIdx =
ispecies.addAttribute(
"charge");
81 elec_.
R[0] = {1.00, 0.0, 0.0};
82 elec_.
R[1] = {0.0, 0.0, 0.0};
87 tspecies(chargeIdx, upIdx) = -1;
88 tspecies(chargeIdx, downIdx) = -1;
91 const char* j1_xml_char = R
"XML(<tmp> 92 <jastrow type="One-Body" name="J1" function="bspline" source="ion" print="yes" gpu="no"> 93 <correlation elementType="C" rcut="10" size="8" cusp="0.0"> 94 <coefficients id="eC" type="Array"> 95 -0.2032153051 -0.1625595974 -0.143124599 -0.1216434956 -0.09919771951 -0.07111729038 -0.04445345869 -0.02135082917 101 const char* j1_omptarget_xml_char = R
"XML(<tmp> 102 <jastrow type="One-Body" name="J1" function="bspline" source="ion" print="yes" gpu="omptarget"> 103 <correlation elementType="C" rcut="10" size="8" cusp="0.0"> 104 <coefficients id="eC" type="Array"> 105 -0.2032153051 -0.1625595974 -0.143124599 -0.1216434956 -0.09919771951 -0.07111729038 -0.04445345869 -0.02135082917 118 xmlNodePtr jas1 = xmlFirstElementChild(root);
124 J1Type* j1 =
dynamic_cast<J1Type*
>(j1_uptr.get());
130 double logpsi_real =
std::real(j1->evaluateLog(elec_, elec_.
G, elec_.
L));
131 CHECK(logpsi_real == Approx(0.3160552244));
139 for (
int dim = 0; dim <
OHMMS_DIM; dim++)
141 grad_grad_source[dim].resize(nelecs);
142 lapl_grad_source[dim].resize(nelecs);
153 gsource = j1->evalGradSource(elec_, ions_, 0);
161 gsource = j1->evalGradSource(elec_, ions_, 0, grad_grad_source, lapl_grad_source);
169 CHECK(
std::real(grad_grad_source[0][0][0]) == Approx(-0.008883672));
170 CHECK(
std::real(grad_grad_source[0][1][0]) == Approx(-0.002111879));
171 CHECK(
std::real(grad_grad_source[1][0][1]) == Approx(0.028489287));
172 CHECK(
std::real(grad_grad_source[1][1][1]) == Approx(0.009231375));
173 CHECK(
std::real(grad_grad_source[2][0][2]) == Approx(0.028489287));
174 CHECK(
std::real(grad_grad_source[2][1][2]) == Approx(0.009231375));
178 CHECK(
std::real(lapl_grad_source[0][1]) == Approx(-0.0056182539));
190 j1->evaluateHessian(elec_, grad_grad_psi);
192 std::vector<double> hess_values = {
193 0.00888367, 0, 0, 0, -0.0284893, 0, 0, 0, -0.0284893, 0.00211188, 0, 0, 0, -0.00923137, 0, 0, 0, -0.00923137,
204 j1->evaluateLog(elec_, elec_.
G, elec_.
L);
217 JValues Vals[
N] = {{0.00, -0.1896634025, 0, 0.06586224647},
218 {0.60, -0.1804990512, 0.02606308248, 0.02101469513},
219 {1.20, -0.1637586749, 0.0255799351, -0.01568108497},
220 {1.80, -0.1506226948, 0.01922435549, -0.005504180392},
221 {2.40, -0.1394848415, 0.01869442683, 0.001517191423},
222 {3.00, -0.128023472, 0.01946283614, 0.00104417293},
223 {3.60, -0.1161729491, 0.02009651096, 0.001689229059},
224 {4.20, -0.1036884223, 0.02172284322, 0.003731878464},
225 {4.80, -0.08992443283, 0.0240346508, 0.002736384838},
226 {5.40, -0.07519614609, 0.02475121662, -0.000347832122},
227 {6.00, -0.06054074137, 0.02397053075, -0.001842295859},
228 {6.60, -0.04654631918, 0.0225837382, -0.002780345968},
229 {7.20, -0.03347994129, 0.02104406699, -0.00218107833},
230 {7.80, -0.0211986378, 0.01996899618, -0.00173646255},
231 {8.40, -0.01004416026, 0.01635533409, -0.01030907776},
232 {9.00, -0.002594125744, 0.007782377232, -0.01556475446},
233 {9.60, -0.0001660240476, 0.001245180357, -0.006225901786},
240 for (
int i = 0; i <
N; i++)
245 CHECK(Vals[i].u == Approx(val));
246 CHECK(Vals[i].du == Approx(dv));
247 CHECK(Vals[i].ddu == Approx(ddv));
250 #ifdef PRINT_SPLINE_DATA 253 printf(
"NumParams = %d\n", bf->
NumParams);
254 printf(
"CuspValue = %g\n", bf->
CuspValue);
255 printf(
"DeltaR = %g\n", bf->
DeltaR);
256 printf(
"SplineCoeffs size = %d\n", bf->SplineCoefs.size());
257 for (
int j = 0; j < bf->SplineCoefs.size(); j++)
259 printf(
"%d %g\n", j, bf->SplineCoefs[j]);
263 for (
int i = 0; i < 20; i++)
268 double logpsi_real =
std::real(j1->evaluateLog(elec_, elec_.
G, elec_.
L));
272 double alt_val = bf->
evaluate(r, dv, ddv);
273 printf(
"%g %g %g %g %g\n", r, logpsi_real, alt_val, dv, ddv);
284 std::vector<ValueType> ratios(elec_.
getTotalNum());
285 j1->evaluateRatiosAlltoOne(elec_, ratios);
291 PsiValue ratio_0 = j1->ratio(elec_, 0);
298 PsiValue ratio_1 = j1->ratio(elec_, 1);
299 j1->acceptMove(elec_, 1);
306 const char* j1_xml_char_2 = R
"XML(<tmp> 307 <jastrow type="One-Body" name="J1" function="bspline" source="ion" print="yes" gpu="no"> 308 <correlation elementType="C" rcut="10" size="8" cusp="2.0"> 309 <coefficients id="eC" type="Array"> 310 -0.2032153051 -0.1625595974 -0.143124599 -0.1216434956 -0.09919771951 -0.07111729038 -0.04445345869 -0.02135082917 316 const char* j1_omptarget_xml_char_2 = R
"XML(<tmp> 317 <jastrow type="One-Body" name="J1" function="bspline" source="ion" print="yes" gpu="omptarget"> 318 <correlation elementType="C" rcut="10" size="8" cusp="2.0"> 319 <coefficients id="eC" type="Array"> 320 -0.2032153051 -0.1625595974 -0.143124599 -0.1216434956 -0.09919771951 -0.07111729038 -0.04445345869 -0.02135082917 331 xmlNodePtr root2 = doc2.
getRoot();
333 xmlNodePtr jas2 = xmlFirstElementChild(root2);
338 J1Type* j12 =
dynamic_cast<J1Type*
>(j12_uptr.get());
344 JValues Vals2[N2] = {{0.00, -0.9304041433, 2, -3.534137754},
345 {0.60, -0.252599792, 0.4492630825, -1.634985305},
346 {1.20, -0.1637586749, 0.0255799351, -0.01568108497},
347 {1.80, -0.1506226948, 0.01922435549, -0.005504180392},
348 {2.40, -0.1394848415, 0.01869442683, 0.001517191423},
349 {3.00, -0.128023472, 0.01946283614, 0.00104417293},
350 {3.60, -0.1161729491, 0.02009651096, 0.001689229059},
351 {4.20, -0.1036884223, 0.02172284322, 0.003731878464},
352 {4.80, -0.08992443283, 0.0240346508, 0.002736384838},
353 {5.40, -0.07519614609, 0.02475121662, -0.000347832122},
354 {6.00, -0.06054074137, 0.02397053075, -0.001842295859},
355 {6.60, -0.04654631918, 0.0225837382, -0.002780345968},
356 {7.20, -0.03347994129, 0.02104406699, -0.00218107833},
357 {7.80, -0.0211986378, 0.01996899618, -0.00173646255},
358 {8.40, -0.01004416026, 0.01635533409, -0.01030907776},
359 {9.00, -0.002594125744, 0.007782377232, -0.01556475446},
360 {9.60, -0.0001660240476, 0.001245180357, -0.006225901786},
367 for (
int i = 0; i < N2; i++)
372 CHECK(Vals2[i].du == Approx(dv));
373 CHECK(Vals2[i].u == Approx(val));
374 CHECK(Vals2[i].ddu == Approx(ddv));
378 j12->extractOptimizableObjectRefs(opt_obj_refs);
379 REQUIRE(opt_obj_refs.size() == 1);
386 j12->createResource(wfc_res);
390 auto j12_clone = j12->makeClone(elec_clone);
399 std::vector<bool> isAccepted(2,
true);
401 j12->mw_recompute(j1_ref_list, p_ref_list, isAccepted);
408 vp.createResource(vp_res);
411 const int ei_table_index = elec_.
addTable(ions_);
414 NLPPJob<RealType> job1(1, 0, ei_table1.getDistances()[0][1], -ei_table1.getDisplacements()[0][1]);
415 const auto& ei_table2 = elec_clone.
getDistTableAB(ei_table_index);
417 NLPPJob<RealType> job2(3, 1, ei_table2.getDistances()[1][3], -ei_table2.getDisplacements()[1][3]);
419 std::vector<PosType> deltaV1{{0.1, 0.2, 0.3}, {0.1, 0.3, 0.2}, {0.2, 0.1, 0.3}};
420 std::vector<PosType> deltaV2{{0.02, 0.01, 0.03}, {0.02, 0.03, 0.01}, {0.03, 0.01, 0.02}};
424 std::vector<std::vector<ValueType>> nlpp_ratios(2);
425 nlpp_ratios[0].resize(nknot);
426 nlpp_ratios[1].resize(nknot);
437 TEST_CASE(
"BSpline builder Jastrow J1",
"[wavefunction]")
DynamicCoordinateKind
enumerator for DynamicCoordinates kinds
void setName(const std::string &aname)
class that handles xmlDoc
WaveFunctionComponent::PsiValue PsiValue
int addSpecies(const std::string &aname)
When a name species does not exist, add a new species.
helper functions for EinsplineSetBuilder
BsplineFunctor class for the Jastrows REAL is the real type used by offload target, it is the correct type for the mw data pointers and is also used to coerce/implicitly convert the Real type inherited OptimizableFunctorBase into that buffer if offload is off this happens too but is just an implementation quirk.
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
A ParticleSet that handles virtual moves of a selected particle of a given physical ParticleSet Virtu...
JastrowBuilder using an analytic 1d functor Should be able to eventually handle all one and two body ...
void createResource(ResourceCollection &collection) const
initialize a shared resource and hand it to a collection
void update(bool skipSK=false)
update the internal data
Communicate * Controller
Global Communicator for a process.
ParticleLaplacian L
laplacians of the particles
int addAttribute(const std::string &aname)
for a new attribute, allocate the data, !More often used to get the index of a species ...
const DistanceTableAB & getDistTableAB(int table_ID) const
get a distance table by table_ID and dyanmic_cast to DistanceTableAB
Wrapping information on parallelism.
int addTable(const ParticleSet &psrc, DTModes modes=DTModes::ALL_OFF)
add a distance table
Specialization for one-body Jastrow function using multiple functors.
Specialized paritlce class for atomistic simulations.
QTBase::ValueType ValueType
REQUIRE(std::filesystem::exists(filename))
void rejectMove(Index_t iat)
reject a proposed move in regular mode
ParticleGradient G
gradients of the particles
QTFull::ValueType PsiValue
static void mw_makeMoves(const RefVectorWithLeader< VirtualParticleSet > &vp_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< const std::vector< PosType >> &deltaV_list, const RefVector< const NLPPJob< RealType >> &joblist, bool sphere)
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
void create(const std::vector< int > &agroup)
create grouped particles
QMCTraits::RealType RealType
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)
Declaraton of ParticleAttrib<T>
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).
OrbitalSetTraits< ValueType >::HessVector HessVector
LatticeGaussianProduct::ValueType ValueType
meta data for NLPP calculation of a pair of ion and electron This is not just meta data...
Declaration of WaveFunctionComponent.
Custom container for set of attributes for a set of species.
Real evaluate(Real r) const
void test_J1_spline(const DynamicCoordinateKind kind_selected)
void acceptMove(Index_t iat)
accept the move and update the particle attribute by the proposed move in regular mode ...
void makeVirtualMoves(const SingleParticlePos &newpos)
Handles virtual moves for all the particles to a single newpos.