35 std::vector<int> agroup(2);
40 elec.
R[0] = {1.0, 2.0, 3.0};
41 elec.
R[1] = {1.0, 2.1, 2.2};
49 tspecies(massIdx, upIdx) = 3.0;
50 tspecies(massIdx, downIdx) = 3.0;
51 tspecies(e_chargeIdx, upIdx) = -1.0;
52 tspecies(e_chargeIdx, downIdx) = -1.0;
56 ions.
R[0] = {0.0, 0.0, 0.0};
60 tspecies(chargeIdx, He_Idx) = 2.0;
61 tspecies(massIdx, upIdx) = 2.0;
67 const char* wavefunction_xml = R
"(<wavefunction name="psi0" target="e"> 68 <jastrow name="Jee" type="Two-Body" function="pade"> 69 <correlation speciesA="u" speciesB="d"> 70 <var id="jud_b" name="B">0.8</var> 73 <determinantset type="MO" key="STO" transform="no" source="ion0"> 75 <atomicBasisSet type="STO" elementType="He"> 76 <basisGroup rid="R0" n="1" l="0" m="0" type="Slater"> 77 <radfunc exponent="2.0"/> 82 <determinant id="updet" spin="1" size="1"> 83 <coefficient id="updetC" type="Array" size="1"> 87 <determinant id="downdet" spin="-1" size="1"> 88 <coefficient id="downdetC" type="Array" size="1"> 103 auto twf_ptr = wff.
buildTWF(root, runtime_options);
111 TEST_CASE(
"TrialWaveFunction flex_evaluateParameterDerivatives",
"[wavefunction]")
118 auto ions_ptr = std::make_unique<ParticleSet>(simulation_cell);
119 auto elec_ptr = std::make_unique<ParticleSet>(simulation_cell);
120 auto &ions(*ions_ptr), elec(*elec_ptr);
121 ions.setName(
"ion0");
124 particle_set_map.emplace(ions_ptr->getName(), std::move(ions_ptr));
125 particle_set_map.emplace(elec_ptr->getName(), std::move(elec_ptr));
133 const int nparam = 1;
147 elec.createResource(pset_res);
159 const int nentry = 1;
165 CHECK(dlogpsi[0] == ValueApprox(dlogpsi_list[0][0]));
166 CHECK(dhpsioverpsi[0] == ValueApprox(dhpsi_over_psi_list[0][0]));
170 const int nentry = 2;
190 CHECK(dlogpsi[0] == ValueApprox(dlogpsi_list[0][0]));
191 CHECK(dhpsioverpsi[0] == ValueApprox(dhpsi_over_psi_list[0][0]));
193 CHECK(dlogpsi2[0] == ValueApprox(dlogpsi_list[1][0]));
194 CHECK(dhpsioverpsi2[0] == ValueApprox(dhpsi_over_psi_list[1][0]));
202 for (
int i = 0; i < nentry; i++)
203 G_list.emplace_back(std::make_unique<ParticleSet::ParticleGradient>(nelec));
211 for (
int i = 0; i < nentry; i++)
212 L_list.emplace_back(std::make_unique<ParticleSet::ParticleLaplacian>(nelec));
217 TEST_CASE(
"TrialWaveFunction flex_evaluateDeltaLogSetup",
"[wavefunction]")
224 auto ions_ptr = std::make_unique<ParticleSet>(simulation_cell);
225 auto elec1_ptr = std::make_unique<ParticleSet>(simulation_cell);
226 auto &ions(*ions_ptr), elec1(*elec1_ptr);
227 ions.setName(
"ion0");
230 particle_set_map.emplace(ions_ptr->getName(), std::move(ions_ptr));
231 particle_set_map.emplace(elec1_ptr->getName(), std::move(elec1_ptr));
252 auto orb1 = psi.
getOrbitals()[0]->makeClone(elec2);
254 auto orb2 = psi.
getOrbitals()[1]->makeClone(elec2);
274 const int nentry = 1;
285 std::vector<RealType> logpsi_fixed_list(nentry);
286 std::vector<RealType> logpsi_opt_list(nentry);
298 CHECK(logpsi_fixed_r1 == Approx(logpsi_fixed_list[0]));
299 CHECK(logpsi_opt_r1 == Approx(logpsi_opt_list[0]));
301 CHECK(fixedG1[0][0] == ValueApprox(fixedG_list[0].
get()[0][0]));
302 CHECK(fixedG1[0][1] == ValueApprox(fixedG_list[0].
get()[0][1]));
303 CHECK(fixedG1[0][2] == ValueApprox(fixedG_list[0].
get()[0][2]));
304 CHECK(fixedG1[1][0] == ValueApprox(fixedG_list[0].
get()[1][0]));
305 CHECK(fixedG1[1][1] == ValueApprox(fixedG_list[0].
get()[1][1]));
306 CHECK(fixedG1[1][2] == ValueApprox(fixedG_list[0].
get()[1][2]));
308 CHECK(fixedL1[0] == ValueApprox(fixedL_list[0].
get()[0]));
309 CHECK(fixedL1[1] == ValueApprox(fixedL_list[0].
get()[1]));
313 CHECK(elec1b.
L[0] == ValueApprox(elec1.L[0]));
314 CHECK(elec1b.
L[1] == ValueApprox(elec1.L[1]));
316 CHECK(elec1b.
G[0][0] == ValueApprox(elec1.G[0][0]));
317 CHECK(elec1b.
G[1][1] == ValueApprox(elec1.G[1][1]));
321 const int nentry = 2;
334 std::vector<RealType> logpsi_fixed_list2(nentry);
335 std::vector<RealType> logpsi_opt_list2(nentry);
341 CHECK(logpsi_fixed_r1 == Approx(logpsi_fixed_r1b));
342 CHECK(logpsi_opt_r1 == Approx(logpsi_opt_r1b));
364 CHECK(logpsi_fixed_r1 == Approx(logpsi_fixed_r1b));
365 CHECK(logpsi_opt_r1 == Approx(logpsi_opt_r1b));
367 CHECK(logpsi_fixed_r1 == Approx(logpsi_fixed_list2[0]));
368 CHECK(logpsi_opt_r1 == Approx(logpsi_opt_list2[0]));
370 CHECK(logpsi_fixed_r2 == Approx(logpsi_fixed_list2[1]));
371 CHECK(logpsi_opt_r2 == Approx(logpsi_opt_list2[1]));
374 CHECK(fixedL1[0] == ValueApprox(fixedL_list2[0].
get()[0]));
375 CHECK(fixedL1[1] == ValueApprox(fixedL_list2[0].
get()[1]));
377 CHECK(fixedL2[0] == ValueApprox(fixedL_list2[1].
get()[0]));
378 CHECK(fixedL2[1] == ValueApprox(fixedL_list2[1].
get()[1]));
383 CHECK(fixedG1[0][0] == ValueApprox(fixedG_list2[0].
get()[0][0]));
384 CHECK(fixedG1[0][1] == ValueApprox(fixedG_list2[0].
get()[0][1]));
385 CHECK(fixedG1[0][2] == ValueApprox(fixedG_list2[0].
get()[0][2]));
387 CHECK(fixedG1[1][0] == ValueApprox(fixedG_list2[0].
get()[1][0]));
388 CHECK(fixedG1[1][1] == ValueApprox(fixedG_list2[0].
get()[1][1]));
389 CHECK(fixedG1[1][2] == ValueApprox(fixedG_list2[0].
get()[1][2]));
394 CHECK(fixedG2[0][0] == ValueApprox(fixedG_list2[1].
get()[0][0]));
395 CHECK(fixedG2[0][1] == ValueApprox(fixedG_list2[1].
get()[0][1]));
396 CHECK(fixedG2[0][2] == ValueApprox(fixedG_list2[1].
get()[0][2]));
398 CHECK(fixedG2[1][0] == ValueApprox(fixedG_list2[1].
get()[1][0]));
399 CHECK(fixedG2[1][1] == ValueApprox(fixedG_list2[1].
get()[1][1]));
400 CHECK(fixedG2[1][2] == ValueApprox(fixedG_list2[1].
get()[1][2]));
404 CHECK(elec1b.
L[0] == ValueApprox(elec1.L[0]));
405 CHECK(elec1b.
L[1] == ValueApprox(elec1.L[1]));
406 CHECK(elec2b.
L[0] == ValueApprox(elec2.
L[0]));
407 CHECK(elec2b.
L[1] == ValueApprox(elec2.
L[1]));
409 CHECK(elec2b.
G[0][0] == ValueApprox(elec2.
G[0][0]));
410 CHECK(elec2b.
G[1][1] == ValueApprox(elec2.
G[1][1]));
417 std::vector<RealType> logpsi_variable_list(nentry);
421 CHECK(logpsi1 == Approx(logpsi_variable_list[0]));
424 CHECK(logpsi2 == Approx(logpsi_variable_list[1]));
433 std::vector<RealType> logpsi_variable_list2(nentry);
438 CHECK(logpsi1b == Approx(logpsi_variable_list2[0]));
441 CHECK(logpsi2b == Approx(logpsi_variable_list2[1]));
void resize(size_type n, Type_t val=Type_t())
Resize the container.
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
UPtrVector< ParticleSet::ParticleGradient > create_particle_gradient(int nelec, int nentry)
void createResource(ResourceCollection &collection) const
initialize a shared resource and hand it to a collection
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
TEST_CASE("complex_helper", "[type_traits]")
Builder class for einspline-based SPOSet objects.
void createResource(ResourceCollection &collection) const
initialize a shared resource and hand it to a collection
std::vector< std::unique_ptr< T > > UPtrVector
void update(bool skipSK=false)
update the internal data
Attaches a unit to a Vector for IO.
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 ...
static RefVector< T > convertUPtrToRefVector(const UPtrVector< T > &ptr_list)
convert a vector of std::unique_ptrs<T> to a refvector<T>
void setLogPsi(RealType LogPsi_new)
UPtrVector< ParticleSet::ParticleLaplacian > create_particle_laplacian(int nelec, int nentry)
void evaluateDeltaLogSetup(ParticleSet &P, RealType &logpsi_fixed, RealType &logpsi_opt, ParticleSet::ParticleGradient &fixedG, ParticleSet::ParticleLaplacian &fixedL)
evaluate the sum of log value of optimizable many-body wavefunctions
Wrapping information on parallelism.
int addTable(const ParticleSet &psrc, DTModes modes=DTModes::ALL_OFF)
add a distance table
Specialized paritlce class for atomistic simulations.
std::unique_ptr< TrialWaveFunction > setup_He_wavefunction(Communicate *c, ParticleSet &elec, ParticleSet &ions, const WaveFunctionFactory::PSetMap &particle_set_map)
QTBase::ValueType ValueType
std::unique_ptr< TrialWaveFunction > buildTWF(xmlNodePtr cur, const RuntimeOptions &runtime_options)
read from xmlNode
REQUIRE(std::filesystem::exists(filename))
static void mw_evaluateParameterDerivatives(const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, const opt_variables_type &optvars, RecordArray< ValueType > &dlogpsi, RecordArray< ValueType > &dhpsioverpsi)
ParticleGradient G
gradients of the particles
Factory class to build a many-body wavefunction.
class to handle a set of variables that can be modified during optimizations
static void mw_evaluateDeltaLog(const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, std::vector< RealType > &logpsi_list, RefVector< ParticleSet::ParticleGradient > &dummyG_list, RefVector< ParticleSet::ParticleLaplacian > &dummyL_list, bool recompute=false)
evaluate the log value for optimizable parts of a many-body wave function
std::vector< std::unique_ptr< WaveFunctionComponent > > const & getOrbitals()
static void mw_evaluateDeltaLogSetup(const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, std::vector< RealType > &logpsi_fixed_list, std::vector< RealType > &logpsi_opt_list, RefVector< ParticleSet::ParticleGradient > &fixedG_list, RefVector< ParticleSet::ParticleLaplacian > &fixedL_list)
evaluate the sum of log value of optimizable many-body wavefunctions
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
void create(const std::vector< int > &agroup)
create grouped particles
Declaration of a TrialWaveFunction.
std::vector< std::reference_wrapper< T > > RefVector
std::map< std::string, const std::unique_ptr< ParticleSet > > PSetMap
RealType evaluateDeltaLog(ParticleSet &P, bool recompute=false)
evaluate the log value of a many-body wave function
Class to represent a many-body trial wave function.
bool parseFromString(const std::string_view data)
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 a WaveFunctionFactory.
Declaration of DiracDeterminant with a S(ingle)P(article)O(rbital)Set.
Custom container for set of attributes for a set of species.
void addComponent(std::unique_ptr< WaveFunctionComponent > &&aterm)
add a WaveFunctionComponent
Declaration of ParticleSetPool.
void checkInVariables(opt_variables_type &o)
Check in an optimizable parameter.