38 TEST_CASE(
"BSpline builder Jastrow J2",
"[wavefunction]")
48 ions_.
R[0] = {2.0, 0.0, 0.0};
51 elec_.
R[0] = {1.00, 0.0, 0.0};
52 elec_.
R[1] = {0.0, 0.0, 0.0};
57 tspecies(chargeIdx, upIdx) = -1;
58 tspecies(chargeIdx, downIdx) = -1;
61 const char* particles = R
"(<tmp> 62 <jastrow name="J2" type="Two-Body" function="Bspline" print="yes" gpu="no"> 63 <correlation rcut="10" size="10" speciesA="u" speciesB="d"> 64 <coefficients id="ud" type="Array"> 0.02904699284 -0.1004179 -0.1752703883 -0.2232576505 -0.2728029201 -0.3253286875 -0.3624525145 -0.3958223107 -0.4268582166 -0.4394531176</coefficients> 75 xmlNodePtr jas1 = xmlFirstElementChild(root);
81 J2Type* j2 =
dynamic_cast<J2Type*
>(j2_uptr.get());
87 double logpsi_real =
std::real(j2->evaluateLog(elec_, elec_.
G, elec_.
L));
88 CHECK(logpsi_real == Approx(0.1012632641));
90 double KE = -0.5 * (
Dot(elec_.
G, elec_.
G) +
Sum(elec_.
L));
91 CHECK(KE == Approx(-0.1616624771));
94 j2->extractOptimizableObjectRefs(opt_obj_refs);
95 REQUIRE(opt_obj_refs.size() == 1);
102 obj.checkInVariablesExclusive(optvars);
103 optvars.resetIndex();
104 const int NumOptimizables(optvars.size());
105 j2->checkOutVariables(optvars);
106 dlogpsi.
resize(NumOptimizables);
107 dhpsioverpsi.
resize(NumOptimizables);
108 j2->evaluateDerivatives(elec_, optvars, dlogpsi, dhpsioverpsi);
110 app_log() << std::endl <<
"reporting dlogpsi and dhpsioverpsi" << std::scientific << std::endl;
111 for (
int iparam = 0; iparam < NumOptimizables; iparam++)
112 app_log() <<
"param=" << iparam <<
" : " << dlogpsi[iparam] <<
" " << dhpsioverpsi[iparam] << std::endl;
124 app_log() <<
"eval hess" << std::endl;
125 j2->evaluateHessian(elec_, grad_grad_psi);
126 std::vector<double> hess_values = {
127 -0.0627236, 0, 0, 0, 0.10652, 0, 0, 0, 0.10652, -0.0627236, 0, 0, 0, 0.10652, 0, 0, 0, 0.10652,
149 JValues Vals[
N] = {{0.00, 0.1374071801, -0.5, 0.7866949593},
150 {0.60, -0.04952403966, -0.1706645865, 0.3110897524},
151 {1.20, -0.121361995, -0.09471371432, 0.055337302},
152 {1.80, -0.1695590431, -0.06815900213, 0.0331784053},
153 {2.40, -0.2058414025, -0.05505192964, 0.01049597156},
154 {3.00, -0.2382237097, -0.05422744821, -0.002401552969},
155 {3.60, -0.2712606182, -0.05600918024, -0.003537553803},
156 {4.20, -0.3047843679, -0.05428535477, 0.0101841028},
157 {4.80, -0.3347515004, -0.04506573714, 0.01469003611},
158 {5.40, -0.3597048574, -0.03904232165, 0.005388015505},
159 {6.00, -0.3823503292, -0.03657502025, 0.003511355265},
160 {6.60, -0.4036800017, -0.03415678101, 0.007891305516},
161 {7.20, -0.4219818468, -0.02556305518, 0.02075444724},
162 {7.80, -0.4192355508, 0.06799438701, 0.3266190181},
163 {8.40, -0.3019238309, 0.32586994, 0.2880861726},
164 {9.00, -0.09726352421, 0.2851358014, -0.4238666348},
165 {9.60, -0.006239062395, 0.04679296796, -0.2339648398},
173 for (
int i = 0; i <
N; i++)
178 CHECK(Vals[i].u == Approx(val));
179 CHECK(Vals[i].du == Approx(dv));
180 CHECK(Vals[i].ddu == Approx(ddv));
183 #ifdef PRINT_SPLINE_DATA 186 printf(
"NumParams = %d\n", bf->
NumParams);
187 printf(
"CuspValue = %g\n", bf->
CuspValue);
188 printf(
"DeltaR = %g\n", bf->
DeltaR);
189 printf(
"SplineCoeffs size = %d\n", bf->SplineCoefs.size());
190 for (
int j = 0; j < bf->SplineCoefs.size(); j++)
192 printf(
"%d %g\n", j, bf->SplineCoefs[j]);
196 for (
int i = 0; i < 20; i++)
201 double logpsi_real =
std::real(j2->evaluateLog(elec_, elec_.
G, elec_.
L));
205 double alt_val = bf->
evaluate(r, dv, ddv);
206 printf(
"%g %g %g %g %g\n", r, logpsi_real, alt_val, dv, ddv);
217 std::vector<ValueType> ratios(elec_.
getTotalNum());
218 j2->evaluateRatiosAlltoOne(elec_, ratios);
224 PsiValue ratio_0 = j2->ratio(elec_, 0);
230 std::vector<PosType> newpos2(2);
231 std::vector<ValueType> ratios2(2);
232 newpos2[0] = newpos - elec_.
R[1];
233 newpos2[1] =
PosType(0.2, 0.5, 0.3) - elec_.
R[1];
235 j2->evaluateRatios(VP, ratios2);
242 PsiValue ratio_1 = j2->ratio(elec_, 1);
243 j2->acceptMove(elec_, 1);
void resize(size_type n, Type_t val=Type_t())
Resize the container.
void setName(const std::string &aname)
T Sum(const ParticleAttrib< T > &pa)
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...
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
JastrowBuilder using an analytic 1d functor Should be able to eventually handle all one and two body ...
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 ...
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
Wrapping information on parallelism.
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
class to handle a set of variables that can be modified during optimizations
QTFull::ValueType PsiValue
Specialization for two-body Jastrow function using multiple functors.
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>
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
TinyVector< double, 3 > PosType
OrbitalSetTraits< ValueType >::HessVector HessVector
LatticeGaussianProduct::ValueType ValueType
Declaration of WaveFunctionComponent.
Custom container for set of attributes for a set of species.
Real evaluate(Real r) const
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.