15 #ifndef QMCPLUSPLUS_ONEBODYSPINJASTROW_OPTIMIZED_SOA_H 16 #define QMCPLUSPLUS_ONEBODYSPINJASTROW_OPTIMIZED_SOA_H 81 std::vector<std::pair<int, int>>
OffSet;
96 Nions(ions.getTotalNum()),
97 Nelec(els.getTotalNum()),
103 throw std::runtime_error(
"J1Spin object name cannot be empty!");
148 void addFunc(
int source_type, std::unique_ptr<FT> afunc,
int target_type = -1)
153 if (target_type == -1)
154 throw std::runtime_error(
155 "J1Spin::addFunc is not compatible with spin independent Jastrow factors (target_type == -1");
163 for (
int iat = 0; iat <
Nelec; ++iat)
188 for (
int iel = 0; iel <
Nelec; ++iel)
190 const auto& dist = d_ie.getDistRow(iel);
191 const auto& displ = d_ie.getDisplRow(iel);
192 for (
int iat = 0; iat <
Nions; iat++)
201 func->evaluate(r, dudr, d2udr2);
202 grad_grad_psi[iel] -= rinv * rinv *
outerProduct(dr, dr) * (d2udr2 - dudr * rinv) + ident * dudr * rinv;
217 for (
int k = 0; k < ratios.size(); ++k)
228 bool recalculate(
false);
229 std::vector<bool> rcsingles(
myVars.
size(),
false);
258 bool recalculate(
false);
259 std::vector<bool> rcsingles(
myVars.
size(),
false);
272 for (
int p = 0; p < NumVars; ++p)
280 std::vector<TinyVector<RealType, 3>> derivs(NumVars);
284 const size_t ns = d_table.sources();
289 std::vector<PosType> displ(nt);
291 for (
size_t i = 0; i <
ns; ++i)
293 for (
size_t j = 0; j < nt; ++j)
296 const int first(
OffSet[functor_idx].first);
298 bool recalcFunc(
false);
299 for (
int rcs = first; rcs < last; rcs++)
300 if (rcsingles[rcs] ==
true)
307 std::fill(derivs.begin(), derivs.end(), 0);
309 if (!func->evaluateDerivatives(dist, derivs))
313 for (
int p = first, ip = 0; p < last; ++p, ++ip)
316 RealType dudr(rinv * derivs[ip][1]);
318 lapLogPsi[p][j] -= derivs[ip][2] + lapfac * dudr;
365 for (
int i = 0; i <
Nelec; ++i)
372 for (
size_t iat = 0; iat <
Nelec; ++iat)
383 bool fromscratch =
false)
override 396 for (
int jat = 0; jat <
Nions; ++jat)
397 lap += d2u[jat] + lapfac * du[jat];
398 for (
int idim = 0; idim <
OHMMS_DIM; ++idim)
400 const valT* restrict dX = displ.
data(idim);
403 for (
int jat = 0; jat <
Nions; ++jat)
404 s += du[jat] * dX[jat];
509 auto cloned_J1Spin = std::make_unique<J1Spin<FT>>(*
this, tqp);
510 return cloned_J1Spin;
529 J1UniqueFunctor->myVars.getIndex(active);
562 if (J1UniqueFunctor !=
nullptr)
563 J1UniqueFunctor->checkOutVariables(active);
572 for (
int iat = 0; iat <
Nelec; ++iat)
574 const auto& dist = d_ie.getDistRow(iat);
575 const auto& displ = d_ie.getDisplRow(iat);
583 g_return -=
dU[isrc] * rinv * dr;
597 for (
int iat = 0; iat <
Nelec; ++iat)
599 const auto& dist = d_ie.getDistRow(iat);
600 const auto& displ = d_ie.getDisplRow(iat);
608 throw std::runtime_error(
"J1OrbitalSoa::evaluateGradSource: J1UniqueFunctors[gid]==nullptr");
610 g_return -=
dU[isrc] * rinv * dr;
615 valT grad_component = (
d2U[isrc] -
dU[isrc] * rinv);
616 valT lapl_component =
d3U[isrc] + 2 * rinv * grad_component;
618 for (
int idim = 0; idim <
OHMMS_DIM; idim++)
620 grad_grad[idim][iat] += dr[idim] * dr * rinv * rinv * grad_component;
621 grad_grad[idim][iat][idim] += rinv *
dU[isrc];
623 lapl_grad[idim][iat] -= lapl_component * rinv * dr[idim];
void resize(size_type n, Type_t val=Type_t())
Resize the container.
GradType evalGrad(ParticleSet &P, int iat) override
compute the gradient during particle-by-particle update
T2 accumulate_n(const T1 *restrict in, size_t n, T2 res)
T Sum(const ParticleAttrib< T > &pa)
LogValue evaluateGL(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, bool fromscratch=false) override
compute gradients and laplacian of the TWF with respect to each particle.
bool recompute(int i) const
std::vector< T, aligned_allocator< T > > aligned_vector
const std::string my_name_
Name of the object It is required to be different for objects of the same derived type like multiple ...
const ParticleSet & getRefPS() const
ParticleSet this object refers to.
helper functions for EinsplineSetBuilder
void registerData(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
QTBase::GradType GradType
const DisplRow & getDisplRow(int iel) const
return a row of displacements for a given target particle
QTBase::RealType RealType
const DistRow & getDistRow(int iel) const
return a row of distances for a given target particle
void forward(size_type n)
size_t getTotalNum() const
void fill_n(T *x, size_t count, const T &value)
std::vector< std::unique_ptr< FT > > J1UniqueFunctors
container for the unique Jastrow functors (size NumGroups x NumTargetGroups)
J1Spin(const J1Spin &rhs, ParticleSet &tqp)
constexpr std::complex< float > czero
For distance tables of virtual particle (VP) sets constructed based on this table, whether full table is needed on host The corresponding DT of VP need to set MW_EVALUATE_RESULT_NO_TRANSFER_TO_HOST accordingly.
constexpr std::complex< float > cone
A ParticleSet that handles virtual moves of a selected particle of a given physical ParticleSet Virtu...
std::vector< std::pair< int, int > > OffSet
VectorSoaContainer< RealType, DIM > DisplRow
int refPtcl
Reference particle.
std::vector< int > Index
store locator of the named variable
SoA adaptor class for Vector<TinyVector<T,D> >
void extractOptimizableObjectRefs(UniqueOptObjRefs &opt_obj_refs) override
extract underlying OptimizableObject references
int first(int igroup) const
return the first index of a group i
QTFull::RealType computeGL(ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
compute G and L from internally stored data
Attaches a unit to a Vector for IO.
ParticleLaplacian L
laplacians of the particles
std::unique_ptr< WaveFunctionComponent > makeClone(ParticleSet &tqp) const override
make clone
aligned_vector< valT > DistCompressed
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
std::vector< ValueDerivVec > lapLogPsi
opt_variables_type myVars
variables handled by this orbital
std::complex< QTFull::RealType > LogValue
const int NumTargetGroups
void evaluateDerivativesWF(ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi) override
const DistanceTableAB & getDistTableAB(int table_ID) const
get a distance table by table_ID and dyanmic_cast to DistanceTableAB
void restore(int iat) override
Rejected move.
An abstract class for a component of a many-body trial wave function.
void attachReference(T *ref, size_type n)
Specialized paritlce class for atomistic simulations.
ParticleAttrib< QTFull::GradType > GradDerivVec
const DisplRow & getTempDispls() const
return the temporary displacements when a move is proposed
void recompute(const ParticleSet &P) override
recompute the value of the WaveFunctionComponents which require critical accuracy.
const int Nelec
number of electrons
Tensor<T,D> class for D by D tensor.
QTBase::ValueType ValueType
const DistRow & getTempDists() const
return the temporary distances when a move is proposed
valT computeU(const ParticleSet &P, int iat, const DistRow &dist)
GradType evalGradSource(ParticleSet &P, ParticleSet &source, int isrc, TinyVector< ParticleSet::ParticleGradient, OHMMS_DIM > &grad_grad, TinyVector< ParticleSet::ParticleLaplacian, OHMMS_DIM > &lapl_grad) override
Adds the gradient w.r.t.
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > outerProduct(const TinyVector< T1, D > &lhs, const TinyVector< T2, D > &rhs)
ParticleGradient G
gradients of the particles
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate the value of the WaveFunctionComponent from scratch
class to handle a set of variables that can be modified during optimizations
int where(int i) const
return the locator of the i-th Index
Specialization for one-body Jastrow function using multiple functors.
GradType evalGradSource(ParticleSet &P, ParticleSet &source, int isrc) override
return the logarithmic gradient for the iat-th particle of the source particleset ...
int last(int igroup) const
return the last index of a group i
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
QTFull::ValueType PsiValue
bool isOptimizable() const override
aligned_vector< valT > dU
typename FT::real_type valT
type of each component U, dU, d2U;
void clear()
clear the variable set
size_type size() const
return the size
T * data()
return the base
aligned_vector< int > DistIndice
void resizeWFOptVectors()
void diagonal(const T &rhs)
LogValue log_value_
Current .
void evaluateHessian(ParticleSet &P, HessVector &grad_grad_psi) override
const int Nions
number of ions
size_type current() const
void addFunc(int source_type, std::unique_ptr< FT > afunc, int target_type=-1)
const ParticleSet & Ions
reference to the sources (ions)
LogValue updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
For particle-by-particle move.
OHMMS_PRECISION real_type
Vector< RealType, aligned_allocator< RealType > > DistRow
valT accumulateGL(const valT *restrict du, const valT *restrict d2u, const DisplRow &displ, posT &grad) const
compute gradient and lap
void evaluateRatiosAlltoOne(ParticleSet &P, std::vector< ValueType > &ratios) override
Vector< RealType > dLogPsi
Declaraton of ParticleAttrib<T>
aligned_vector< valT > d3U
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
void evaluateRatios(const VirtualParticleSet &VP, std::vector< ValueType > &ratios) override
OrbitalSetTraits< ValueType >::HessVector HessVector
void initialize(ParticleSet &els)
void checkOutVariables(const opt_variables_type &active) override
check out variational optimizable variables
std::vector< GradDerivVec > gradLogPsi
void insertFrom(const VariableSet &input)
insert a VariableSet to the list
Declaration of WaveFunctionComponent.
PsiValue ratioGrad(ParticleSet &P, int iat, GradType &grad_iat) override
compute the gradient during particle-by-particle update
size_t Bytes_in_WFBuffer
Bytes in WFBuffer.
FT FuncType
alias FuncType
SIMD version of functions in algorithm.
void print(std::ostream &os, int leftPadSpaces=0, bool printHeader=false) const
int getIndex(const std::string &vname) const
return the Index vaule for the named parameter
J1Spin(const std::string &obj_name, const ParticleSet &ions, ParticleSet &els, bool use_offload)
ParticleAttrib< QTFull::ValueType > ValueDerivVec
T1 * lendReference(size_type n)
void push_back(OptimizableObject &obj)
const int myTableID
table index
aligned_vector< valT > d2U
PsiValue ratio(ParticleSet &P, int iat) override
evaluate the ratio of the new to old WaveFunctionComponent value
void copyFromBuffer(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
void computeU3(const ParticleSet &P, int iat, const DistRow &dist)
compute U, dU and d2U
int getGroupID(int iat) const
return the group id of a given particle in the particle set.
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false) override
Accpted move.
void add(std::complex< T1 > &x)
int UpdateMode
current update mode
std::string getClassName() const override
return class name