36 auto elec_ptr = std::make_unique<ParticleSet>(simulation_cell);
37 auto& elec(*elec_ptr);
39 std::vector<int> agroup(1);
44 elec.R[0] = {1.0, 2.0, 3.0};
45 elec.R[1] = {0.0, 1.1, 2.2};
50 tspecies(massIdx, upIdx) = 1.0;
51 tspecies(massIdx, downIdx) = 1.0;
53 auto ions_ptr = std::make_unique<ParticleSet>(simulation_cell);
54 auto& ions(*ions_ptr);
58 ions.R[0] = {0.0, 0.0, 0.0};
62 tspecies(chargeIdx, He_Idx) = 2.0;
63 tspecies(massIdx, upIdx) = 1.0;
66 particle_set_map.emplace(elec_ptr->getName(), std::move(elec_ptr));
67 particle_set_map.emplace(ions_ptr->getName(), std::move(ions_ptr));
71 const char* wavefunction_xml = R
"(<wavefunction> 72 <example_he name="mine" source="ion0"> 73 <var id="B" name="B">0.8</var> 82 auto twf_ptr = wff.
buildTWF(root, runtime_options);
87 auto& base_example_he = twf_ptr->getOrbitals()[0];
88 REQUIRE(base_example_he !=
nullptr);
110 grad0 = example_he->
evalGrad(elec, iat);
112 CHECK(grad0[0] == ValueApprox(all_grad[0][0]));
113 CHECK(grad0[1] == ValueApprox(all_grad[0][1]));
114 CHECK(grad0[2] == ValueApprox(all_grad[0][2]));
118 grad1 = example_he->
evalGrad(elec, iat);
120 CHECK(grad1[0] == ValueApprox(all_grad[1][0]));
121 CHECK(grad1[1] == ValueApprox(all_grad[1][1]));
122 CHECK(grad1[2] == ValueApprox(all_grad[1][2]));
128 elec.makeMove(iat, zero_displ);
134 ratio = example_he->
ratioGrad(elec, iat, grad0);
138 CHECK(grad0[0] == ValueApprox(all_grad[0][0]));
139 CHECK(grad0[1] == ValueApprox(all_grad[0][1]));
140 CHECK(grad0[2] == ValueApprox(all_grad[0][2]));
143 elec.makeMove(iat, zero_displ);
144 ratio = example_he->
ratio(elec, iat);
148 ratio = example_he->
ratioGrad(elec, iat, grad1);
151 CHECK(grad1[0] == ValueApprox(all_grad[1][0]));
152 CHECK(grad1[1] == ValueApprox(all_grad[1][1]));
153 CHECK(grad1[2] == ValueApprox(all_grad[1][2]));
159 elec.R[0] = oldpos + displ;
172 elec.makeMove(iat, displ);
174 ratio = example_he->
ratio(elec, iat);
177 ratio = example_he->
ratioGrad(elec, iat, grad0);
181 CHECK(grad0[0] == ValueApprox(new_grad[0][0]));
182 CHECK(grad0[1] == ValueApprox(new_grad[0][1]));
183 CHECK(grad0[2] == ValueApprox(new_grad[0][2]));
187 const int nparam = 1;
199 var_param[
"B"] = new_B;
201 CHECK(example_he->
B == Approx(new_B));
205 grad_plus_h.
resize(nelec);
220 CHECK(dlogpsi[0] == ValueApprox(
std::real(fd_logpsi)).epsilon(h));
223 ValueType eloc_h = -0.5 * (
Sum(lap_plus_h) +
Dot(grad_plus_h, grad_plus_h));
227 CHECK(dhpsioverpsi[0] == ValueApprox(fd_eloc).epsilon(h));
void resize(size_type n, Type_t val=Type_t())
Resize the container.
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate the value of the WaveFunctionComponent from scratch
T Sum(const ParticleAttrib< T > &pa)
class that handles xmlDoc
void checkInVariablesExclusive(OptVariablesType &active) override
check in variational parameters to the global list of parameters used by the optimizer.
WaveFunctionComponent::PsiValue PsiValue
int addSpecies(const std::string &aname)
When a name species does not exist, add a new species.
helper functions for EinsplineSetBuilder
QTBase::RealType RealType
An example wavefunction component for a simple wavefunction for a helium atom.
TEST_CASE("complex_helper", "[type_traits]")
evaluate psi based on log(psi)
GradType evalGrad(ParticleSet &P, int iat) override
return the current gradient for the iat-th particle
void evaluateDerivatives(ParticleSet &P, const OptVariablesType &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
Compute the derivatives of both the log of the wavefunction and kinetic energy with respect to optimi...
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 ...
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
std::complex< QTFull::RealType > LogValue
Wrapping information on parallelism.
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
PsiValue ratio(ParticleSet &P, int iat) override
evaluate the ratio of the new to old WaveFunctionComponent value
std::unique_ptr< TrialWaveFunction > buildTWF(xmlNodePtr cur, const RuntimeOptions &runtime_options)
read from xmlNode
QTBase::ValueType ValueType
REQUIRE(std::filesystem::exists(filename))
void resetParametersExclusive(const OptVariablesType &active) override
reset the parameters during optimizations.
Factory class to build a many-body wavefunction.
class to handle a set of variables that can be modified during optimizations
int size_of_active() const
return the number of active variables
QTFull::ValueType PsiValue
QMCTraits::RealType RealType
std::map< std::string, const std::unique_ptr< ParticleSet > > PSetMap
bool parseFromString(const std::string_view data)
Declaraton of ParticleAttrib<T>
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
PsiValue ratioGrad(ParticleSet &P, int iat, GradType &grad_iat) override
evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient ...
LatticeGaussianProduct::ValueType ValueType
Declaration of a WaveFunctionFactory.
std::complex< double > LogValue
Custom container for set of attributes for a set of species.
void checkOutVariables(const OptVariablesType &active) override
check out variational optimizable variables