15 #ifndef QMCPLUSPLUS_ONEBODYJASTROW_OPTIMIZED_SOA_H 16 #define QMCPLUSPLUS_ONEBODYJASTROW_OPTIMIZED_SOA_H 40 struct J1OrbitalSoAMultiWalkerMem;
117 for (
size_t iat = 0; iat <
Nelec; ++iat)
128 bool fromscratch =
false)
override 141 for (
int jat = 0; jat <
Nions; ++jat)
142 lap += d2u[jat] + lapfac * du[jat];
143 for (
int idim = 0; idim <
OHMMS_DIM; ++idim)
145 const valT* restrict dX = displ.
data(idim);
148 for (
int jat = 0; jat <
Nions; ++jat)
149 s += du[jat] * dX[jat];
219 void addFunc(
int source_type, std::unique_ptr<FT> afunc,
int target_type = -1)
243 for (
int iat = 0; iat <
Nelec; ++iat)
268 for (
int iel = 0; iel <
Nelec; ++iel)
270 const auto& dist = d_ie.getDistRow(iel);
271 const auto& displ = d_ie.getDisplRow(iel);
272 for (
int iat = 0; iat <
Nions; iat++)
281 func->evaluate(r, dudr, d2udr2);
282 grad_grad_psi[iel] -= rinv * rinv *
outerProduct(dr, dr) * (d2udr2 - dudr * rinv) + ident * dudr * rinv;
297 for (
int k = 0; k < ratios.size(); ++k)
303 std::vector<std::vector<ValueType>>& ratios)
const override;
311 bool recalculate(
false);
312 std::vector<bool> rcsingles(
myVars.
size(),
false);
340 bool recalculate(
false);
341 std::vector<bool> rcsingles(
myVars.
size(),
false);
354 for (
int p = 0; p < NumVars; ++p)
362 std::vector<TinyVector<RealType, 3>> derivs(NumVars);
366 const size_t ns = d_table.sources();
371 std::vector<PosType> displ(nt);
373 for (
size_t i = 0; i <
ns; ++i)
378 int first(
OffSet[i].first);
380 bool recalcFunc(
false);
381 for (
int rcs = first; rcs < last; rcs++)
382 if (rcsingles[rcs] ==
true)
386 for (
size_t j = 0; j < nt; ++j)
388 std::fill(derivs.begin(), derivs.end(), 0);
390 if (!func->evaluateDerivatives(dist, derivs))
394 for (
int p = first, ip = 0; p < last; ++p, ++ip)
397 RealType dudr(rinv * derivs[ip][1]);
399 lapLogPsi[p][j] -= derivs[ip][2] + lapfac * dudr;
427 for (
int i = 0; i <
Nelec; ++i)
515 j1copy->addFunc(i, std::move(fc));
568 std::vector<ValueType>& ratios,
572 bool recalculate(
false);
573 std::vector<bool> rcsingles(
myVars.
size(),
false);
588 std::vector<RealType> derivs_ref(NumVars);
589 std::vector<RealType> derivs(NumVars);
591 const size_t ns = d_table.sources();
596 for (
size_t i = 0; i <
ns; ++i)
601 int first(
OffSet[i].first);
603 bool recalcFunc(
false);
604 for (
int rcs = first; rcs < last; rcs++)
605 if (rcsingles[rcs] ==
true)
610 std::fill(derivs_ref.begin(), derivs_ref.end(), 0);
611 func->evaluateDerivatives(dist_ref[i], derivs_ref);
612 for (
size_t j = 0; j < nt; ++j)
614 std::fill(derivs.begin(), derivs.end(), 0);
618 for (
int ip = 0, p = func->myVars.Index.front(); ip < func->myVars.Index.size(); ++ip, ++p)
619 dratios[j][p] += derivs_ref[ip] - derivs[ip];
630 for (
int iat = 0; iat <
Nelec; ++iat)
632 const auto& dist = d_ie.getDistRow(iat);
633 const auto& displ = d_ie.getDisplRow(iat);
642 g_return -=
dU[isrc] * rinv * dr;
656 for (
int iat = 0; iat <
Nelec; ++iat)
658 const auto& dist = d_ie.getDistRow(iat);
659 const auto& displ = d_ie.getDisplRow(iat);
671 APP_ABORT(
"J1OrbitalSoa::evaluateGradSource: J1UniqueFunctors[gid]==nullptr")
674 g_return -=
dU[isrc] * rinv * dr;
679 valT grad_component = (
d2U[isrc] -
dU[isrc] * rinv);
680 valT lapl_component =
d3U[isrc] + 2 * rinv * grad_component;
682 for (
int idim = 0; idim <
OHMMS_DIM; idim++)
684 grad_grad[idim][iat] += dr[idim] * dr * rinv * rinv * grad_component;
685 grad_grad[idim][iat][idim] += rinv *
dU[isrc];
687 lapl_grad[idim][iat] -= lapl_component * rinv * dr[idim];
694 extern template class J1OrbitalSoA<BsplineFunctor<QMCTraits::RealType>>;
695 extern template class J1OrbitalSoA<
696 CubicSplineSingle<QMCTraits::RealType, CubicBspline<QMCTraits::RealType, LINEAR_1DGRID, FIRSTDERIV_CONSTRAINTS>>>;
697 extern template class J1OrbitalSoA<UserFunctor<QMCTraits::RealType>>;
698 extern template class J1OrbitalSoA<ShortRangeCuspFunctor<QMCTraits::RealType>>;
699 extern template class J1OrbitalSoA<PadeFunctor<QMCTraits::RealType>>;
700 extern template class J1OrbitalSoA<Pade2ndOrderFunctor<QMCTraits::RealType>>;
void resize(size_type n, Type_t val=Type_t())
Resize the container.
void checkSanity() const override
Validate the internal consistency of the object.
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
const int NumGroups
number of ion groups
QTBase::RealType RealType
const DistRow & getDistRow(int iel) const
return a row of distances for a given target particle
std::vector< FT * > GroupFunctors
functor for each ion group Conceptually, this is different from unique functions. ...
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 functions
ResourceHandle manages the temporary resource referenced from a collection.
constexpr std::complex< float > czero
Functor designed to encode short-ranged structure near a nuclear cusp.
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
size_t getTotalNum() const
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
const bool use_offload_
if true use offload
aligned_vector< valT > DistCompressed
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
return a shared resource to a collection
std::vector< ValueDerivVec > lapLogPsi
opt_variables_type myVars
variables handled by this orbital
std::complex< QTFull::RealType > LogValue
int getTotalNum() const
return the number of species
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)
ResourceHandle< J1OrbitalSoAMultiWalkerMem< RealType > > mw_mem_handle_
Specialization for one-body Jastrow function using multiple functors.
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
void mw_evaluateRatios(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, std::vector< std::vector< ValueType >> &ratios) const override
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
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)
valT computeU(const DistRow &dist)
void createResource(ResourceCollection &collection) const override
initialize a shared resource and hand it to a collection
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
Functors which implement Pade functions.
int where(int i) const
return the locator of the i-th Index
GradType evalGradSource(ParticleSet &P, ParticleSet &source, int isrc) override
return the logarithmic gradient for the iat-th particle of the source particleset ...
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
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
void initialize(const ParticleSet &els)
bool isOptimizable() const override
aligned_vector< valT > dU
typename FT::real_type valT
type of each component U, dU, d2U;
void evaluateDerivRatios(const VirtualParticleSet &VP, const opt_variables_type &optvars, std::vector< ValueType > &ratios, Matrix< ValueType > &dratios) override
void clear()
clear the variable set
size_type size() const
return the size
T * data()
return the base
aligned_vector< int > DistIndice
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
void resizeWFOptVectors()
void diagonal(const T &rhs)
J1OrbitalSoA(const std::string &obj_name, const ParticleSet &ions, ParticleSet &els, bool use_offload)
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< int, OffloadPinnedAllocator< int > > grp_ids
the group_id of each particle
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 acquireResource(ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
acquire a shared resource from a collection
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 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.
std::vector< FT * > J1Functors
Container for .
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.
int getIndex(const std::string &vname) const
return the Index vaule for the named parameter
ParticleAttrib< QTFull::ValueType > ValueDerivVec
T1 * lendReference(size_type n)
void push_back(OptimizableObject &obj)
const auto & getFunctors() const
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