27 TEST_CASE(
"J1 spin evaluate derivatives Jastrow",
"[wavefunction]")
37 ions_.setName(
"ion0");
40 ions_.R[0] = {0.0, 0.0, 0.0};
43 int ichargeIdx =
ispecies.addAttribute(
"charge");
49 elec_.
R[0] = {0.5, 0.5, 0.5};
50 elec_.
R[1] = {-0.5, -0.5, -0.5};
57 tspecies(massIdx, upIdx) = 1.0;
58 tspecies(massIdx, downIdx) = 1.0;
59 tspecies(chargeIdx, upIdx) = -1.0;
60 tspecies(massIdx, downIdx) = -1.0;
69 const char* jasxml = R
"(<wavefunction name="psi0" target="e"> 70 <jastrow name="J1" type="One-Body" function="Bspline" print="yes" source="ion0" spin="yes"> 71 <correlation speciesA="H" speciesB="u" cusp="0.0" size="2" rcut="5.0"> 72 <coefficients id="J1uH" type="Array"> 0.5 0.1 </coefficients> 74 <correlation speciesA="H" speciesB="d" cusp="0.0" size="2" rcut="5.0"> 75 <coefficients id="J1dH" type="Array"> 0.5 0.1 </coefficients> 86 auto twf_ptr = wf_factory.buildTWF(jas1, runtime_options);
88 twf.setMassTerm(elec_);
89 auto& twf_component_list =
twf.getOrbitals();
90 auto cloned_j1spin = twf_component_list[0]->makeClone(elec_);
93 twf.checkInVariables(active);
102 LogValue log = twf_component_list[0]->evaluateLog(elec_, elec_.
G, elec_.
L);
103 LogValue expected_log{-0.568775, 0.0};
108 LogValue cloned_log = cloned_j1spin->evaluateLog(elec_, elec_.
G, elec_.
L);
112 twf.evaluateLog(elec_);
118 twf_component_list[0]->evaluateDerivatives(elec_, active, dlogpsi, dhpsioverpsi);
119 cloned_j1spin->evaluateDerivatives(elec_, active, cloned_dlogpsi, cloned_dhpsioverpsi);
121 std::vector<ValueType> expected_dlogpsi = {-0.46681472435, -0.5098025897, -0.46681472435, -0.5098025897};
122 std::vector<ValueType> expected_dhpsioverpsi = {-0.5798216548, 0.37977462695, -0.5798216548, 0.37977462695};
123 for (
int i = 0; i < nparam; i++)
125 CHECK(dlogpsi[i] == ValueApprox(expected_dlogpsi[i]));
126 CHECK(cloned_dlogpsi[i] == ValueApprox(expected_dlogpsi[i]));
127 CHECK(dhpsioverpsi[i] == ValueApprox(expected_dhpsioverpsi[i]));
128 CHECK(cloned_dhpsioverpsi[i] == ValueApprox(expected_dhpsioverpsi[i]));
132 TEST_CASE(
"J1 spin evaluate derivatives multiparticle Jastrow",
"[wavefunction]")
142 ions_.setName(
"ion0");
145 ions_.R[0] = {-1.0, 0.0, 0.0};
146 ions_.R[1] = {1.0, 0.0, 0.0};
148 int BeIdx =
ispecies.addSpecies(
"Be");
149 int ichargeIdx =
ispecies.addAttribute(
"charge");
155 elec_.
R[0] = {0.5, 0.5, 0.5};
156 elec_.
R[1] = {-0.5, 0.5, 0.5};
157 elec_.
R[2] = {0.5, -0.5, 0.5};
158 elec_.
R[3] = {0.5, 0.5, -0.5};
159 elec_.
R[4] = {-0.5, -0.5, 0.5};
160 elec_.
R[5] = {0.5, -0.5, -0.5};
161 elec_.
R[6] = {-0.5, 0.5, -0.5};
162 elec_.
R[7] = {-0.5, -0.5, -0.5};
163 elec_.
R[8] = {1.5, 1.5, 1.5};
171 tspecies(massIdx, upIdx) = 1.0;
172 tspecies(massIdx, downIdx) = 1.0;
173 tspecies(massIdx, posIdx) = 1.0;
174 tspecies(chargeIdx, upIdx) = -1.0;
175 tspecies(massIdx, downIdx) = -1.0;
176 tspecies(massIdx, posIdx) = 1.0;
185 const char* jasxml = R
"(<wavefunction name="psi0" target="e"> 186 <jastrow name="J1" type="One-Body" function="Bspline" print="yes" source="ion0" spin="yes"> 187 <correlation speciesA="Be" speciesB="u" cusp="0.0" size="2" rcut="5.0"> 188 <coefficients id="J1uH" type="Array"> 0.5 0.1 </coefficients> 190 <correlation speciesA="Be" speciesB="d" cusp="0.0" size="2" rcut="5.0"> 191 <coefficients id="J1dH" type="Array"> 0.5 0.1 </coefficients> 193 <correlation speciesA="Be" speciesB="p" cusp="0.0" size="2" rcut="5.0"> 194 <coefficients id="J1pH" type="Array"> 0.5 0.1 </coefficients> 205 auto twf_ptr = wf_factory.buildTWF(jas1, runtime_options);
207 twf.setMassTerm(elec_);
208 auto& twf_component_list =
twf.getOrbitals();
209 auto cloned_j1spin = twf_component_list[0]->makeClone(elec_);
212 twf.checkInVariables(active);
221 LogValue log = twf_component_list[0]->evaluateLog(elec_, elec_.
G, elec_.
L);
222 LogValue expected_log{-3.58983, 0.0};
227 LogValue cloned_log = cloned_j1spin->evaluateLog(elec_, elec_.
G, elec_.
L);
231 twf.evaluateLog(elec_);
237 twf_component_list[0]->evaluateDerivatives(elec_, active, dlogpsi, dhpsioverpsi);
238 cloned_j1spin->evaluateDerivatives(elec_, active, cloned_dlogpsi, cloned_dhpsioverpsi);
240 std::vector<ValueType> expected_dlogpsi = {-2.544, -4.70578, -2.544, -4.70578, -0.055314, -0.770138};
241 std::vector<ValueType> expected_dhpsioverpsi = {-2.45001, 0.0794429, -2.45001, 0.0794429, 0.0462761, -0.330801};
242 for (
int i = 0; i < nparam; i++)
244 CHECK(dlogpsi[i] == ValueApprox(expected_dlogpsi[i]));
245 CHECK(cloned_dlogpsi[i] == ValueApprox(expected_dlogpsi[i]));
246 CHECK(dhpsioverpsi[i] == ValueApprox(expected_dhpsioverpsi[i]));
247 CHECK(cloned_dhpsioverpsi[i] == ValueApprox(expected_dhpsioverpsi[i]));
void setName(const std::string &aname)
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
QTBase::RealType RealType
TEST_CASE("complex_helper", "[type_traits]")
void addParticleSet(std::unique_ptr< ParticleSet > &&p)
add a ParticleSet* to the pool with its ownership transferred ParticleSet built outside the ParticleS...
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 ...
Catch::Detail::LogComplexApprox LogComplexApprox
std::complex< QTFull::RealType > LogValue
Wrapping information on parallelism.
int addTable(const ParticleSet &psrc, DTModes modes=DTModes::ALL_OFF)
add a distance table
Specialized paritlce class for atomistic simulations.
QTBase::ValueType ValueType
REQUIRE(std::filesystem::exists(filename))
Manage a collection of ParticleSet objects.
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
int size_of_active() const
return the number of active variables
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
void create(const std::vector< int > &agroup)
create grouped particles
MakeReturn< UnaryNode< FnLog, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t log(const Vector< T1, C1 > &l)
QMCTraits::RealType RealType
bool parseFromString(const std::string_view data)
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
LatticeGaussianProduct::ValueType ValueType
Declaration of a WaveFunctionFactory.
std::complex< double > LogValue
Custom container for set of attributes for a set of species.
const PoolType & getPool() const
get the Pool object
void removeInactive()
remove inactive variables and trim the internal data
const auto & getSimulationCell() const
get simulation cell
Declaration of ParticleSetPool.