35 std::unique_ptr<Resource>
makeClone()
const override {
return std::make_unique<MultiWalkerResource>(*this); }
54 int massind = tspecies.addAttribute(
"mass");
58 for (
int i = 0; i < tspecies.size(); ++i)
74 #if !defined(REMOVE_TRACEMANAGER) 108 #if !defined(REMOVE_TRACEMANAGER) 131 for (
int j = P.
first(i); j < P.
last(i); ++j)
157 for (
int i = 0; i < o_list.size(); i++)
197 ParticleLaplacian term2_(Nelec);
198 ParticleGradient term4_(Nelec);
201 ParticleGradient iongradpsi_(Nions), pulaytmp_(Nions);
203 ParticlePos pulaytmpreal_(Nions), iongradpsireal_(Nions);
209 for (
int iondim = 0; iondim <
OHMMS_DIM; iondim++)
211 iongrad_grad_[iondim].resize(Nelec);
212 iongrad_lapl_[iondim].resize(Nelec);
221 for (
int iat = 0; iat < Nions; iat++)
224 for (
int iondim = 0; iondim <
OHMMS_DIM; iondim++)
226 iongrad_grad_[iondim] = 0;
227 iongrad_lapl_[iondim] = 0;
229 iongradpsi_[iat] = psi.
evalGradSource(P, ions, iat, iongrad_grad_, iongrad_lapl_);
234 for (
int iondim = 0; iondim <
OHMMS_DIM; iondim++)
238 term2_ = P.
L * iongradpsi_[iat][iondim];
239 term4_ = P.
G * iongradpsi_[iat][iondim];
241 (
Sum(iongrad_lapl_[iondim]) +
Sum(term2_) + 2.0 *
Dot(iongrad_grad_[iondim], P.
G) +
Dot(P.
G, term4_));
246 for (
int iondim = 0; iondim <
OHMMS_DIM; iondim++)
250 for (
int iel = P.
first(g); iel < P.
last(g); iel++)
253 (
dlaplacian(P.
G[iel], P.
L[iel], iongrad_grad_[iondim][iel], iongrad_lapl_[iondim][iel],
254 iongradpsi_[iat][iondim]));
273 for (
int j = P.
first(i); j < P.
last(i); ++j)
278 pulaytmpreal_ -=
value_ * iongradpsireal_;
281 pulay_terms += pulaytmpreal_;
287 std::vector<ValueMatrix>&
B)
297 assert(
B.size() == ngroups);
298 std::vector<ValueMatrix> M;
299 std::vector<GradMatrix> grad_M;
300 std::vector<ValueMatrix> lapl_M;
301 std::vector<ValueMatrix> gradJdotgradPhi;
302 for (
int ig = 0; ig < ngroups; ig++)
312 zeromat.resize(nptcls, norbs);
313 zerogradmat.resize(nptcls, norbs);
315 M.push_back(zeromat);
316 grad_M.push_back(zerogradmat);
317 lapl_M.push_back(zeromat);
318 gradJdotgradPhi.push_back(zeromat);
324 for (
int ig = 0; ig < ngroups; ig++)
331 for (
int iel = first; iel < last; iel++)
333 for (
int iorb = 0; iorb < norbs; iorb++)
335 gradJdotgradPhi[sid][iel - first][iorb] =
RealType(2.0) *
dot(
GradType(G[iel]), grad_M[sid][iel - first][iorb]);
337 (lapl_M[sid][iel - first][iorb] + gradJdotgradPhi[sid][iel - first][iorb] +
338 ValueType(L[iel] +
dot(G[iel], G[iel])) * M[sid][iel - first][iorb]);
348 std::vector<std::vector<ValueMatrix>>& Bforce)
360 std::vector<ValueMatrix> M;
361 std::vector<GradMatrix> grad_M;
362 std::vector<ValueMatrix> lapl_M;
367 for (
int dim = 0; dim <
OHMMS_DIM; dim++)
374 assert(Bforce[0].size() == ngroups);
375 std::vector<ValueMatrix> mtmp;
376 for (
int ig = 0; ig < ngroups; ig++)
387 zeromat.resize(nptcls, norbs);
388 zerogradmat.resize(nptcls, norbs);
390 mtmp.push_back(zeromat);
391 M.push_back(zeromat);
392 grad_M.push_back(zerogradmat);
393 lapl_M.push_back(zeromat);
397 std::vector<std::vector<ValueMatrix>> dm, dlapl;
398 std::vector<std::vector<GradMatrix>> dgmat;
403 dlapl.push_back(mtmp);
404 dlapl.push_back(mtmp);
405 dlapl.push_back(mtmp);
407 dgmat.push_back(grad_M);
408 dgmat.push_back(grad_M);
409 dgmat.push_back(grad_M);
415 for (
int idim = 0; idim <
OHMMS_DIM; idim++)
416 for (
int ig = 0; ig < ngroups; ig++)
424 for (
int iel = first; iel < last; iel++)
426 for (
int iorb = 0; iorb < norbs; iorb++)
429 (dlapl[idim][sid][iel - first][iorb] +
431 (
dot(
GradType(G[iel]), dgmat[idim][sid][iel - first][iorb]) +
432 dot(
GradType(dG[idim][iel]), grad_M[sid][iel - first][iorb])) +
433 M[sid][iel - first][iorb] *
ValueType(dL[idim][iel] + 2.0 *
dot(dG[idim][iel], G[iel])) +
434 ValueType(L[iel] +
dot(G[iel], G[iel])) * dm[idim][sid][iel - first][iorb]);
442 auto new_res = std::make_unique<MultiWalkerResource>();
443 auto resource_index = collection.
addResource(std::move(new_res));
470 auto num_particles = p_leader.getTotalNum();
471 auto& name = o_leader.
name_;
475 auto num_species = p_leader.getSpeciesSet().getTotalNum();
476 t_samp.
resize(num_particles);
477 tcmp_samp.
resize(num_particles);
479 auto evaluate_walker_per_particle = [num_particles, name, &t_samp, &tcmp_samp,
482 const std::vector<ListenerVector<RealType>>& listeners) {
484 std::fill(t_samp.begin(), t_samp.end(), 0.0);
485 std::fill(tcmp_samp.begin(), tcmp_samp.end(), 0.0);
487 std::complex<RealType> t1 = 0.0;
489 for (
int i = 0; i < num_particles; i++)
493 t_samp[i] =
real(t1);
499 for (
int s = 0;
s < bke.minus_over_2m_.size(); ++
s)
502 for (
int i =
pset.first(
s); i <
pset.last(
s); ++i)
506 t_samp[i] =
real(t1);
512 for (
auto& listener : listeners)
514 listener.report(walker_index, name, t_samp);
519 for (
int iw = 0; iw < o_list.size(); iw++)
522 bare_kinetic_energy.
value_ = evaluate_walker_per_particle(iw, bare_kinetic_energy, p_list[iw], listeners);
536 #if !defined(REMOVE_TRACEMANAGER) 542 std::complex<RealType> t1 = 0.0;
549 t1 = P.
L[i] +
dot(P.
G[i], P.
G[i]);
551 T_samp(i) =
real(t1);
553 for (
int d = 0; d <
DIM; ++d)
554 p_samp(i, d) = P.
G[i][d];
565 t1 = P.
L[i] +
dot(P.
G[i], P.
G[i]);
567 T_samp(i) =
real(t1);
569 for (
int d = 0; d <
DIM; ++d)
570 p_samp(i, d) = P.
G[i][d];
575 #if defined(TRACE_CHECK) 581 app_log() <<
"accumtest: BareKineticEnergy::evaluate()" << std::endl;
582 app_log() <<
"accumtest: tot:" << Vnow << std::endl;
583 app_log() <<
"accumtest: sum:" << Vsum << std::endl;
588 app_log() <<
"versiontest: BareKineticEnergy::evaluate()" << std::endl;
589 app_log() <<
"versiontest: orig:" << Vold << std::endl;
590 app_log() <<
"versiontest: mod:" << Vnow << std::endl;
612 for (
int j = P.
first(i); j < P.
last(i); ++j)
628 os <<
"Kinetic energy";
634 return std::make_unique<BareKineticEnergy>(qp, psi);
~BareKineticEnergy() override
destructor
virtual void mw_evaluate(const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list) const
Evaluate the contribution of this component of multiple walkers.
void resize(size_type n, Type_t val=Type_t())
Resize the container.
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
bool streaming_particles_
HamiltonianRef::FullPrecRealType FullPrecRealType
T Sum(const ParticleAttrib< T > &pa)
size_t addResource(std::unique_ptr< Resource > &&res, bool noprint=false)
Array< TraceComp, D > * checkout_complex(const std::string &name, int n1=1, int n2=0, int n3=0, int n4=0)
void takebackResource(ResourceHandle< RS > &res_handle)
std::complex< T > CplxDot(const ParticleAttrib< TinyVector< std::complex< T >, D >> &pa, const ParticleAttrib< TinyVector< std::complex< T >, D >> &pb)
std::unique_ptr< Resource > makeClone() const override
helper functions for EinsplineSetBuilder
QTBase::GradType GradType
Vector< std::complex< RealType > > tcmp_samples
bool dependsOnWaveFunction() const override
return true if this operator depends on a wavefunction
bool streaming_array(const std::string &name)
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
T dlaplacian(const TinyVector< T, D > &g, const T l, const TinyVector< T, D > &gg, const T gl, const T ideriv)
Convenience function to compute .
void resetTargetParticleSet(ParticleSet &p) override
Reset the data with the target ParticleSet.
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
Return_t evaluate_orig(ParticleSet &P)
FullPrecRealType particle_mass_
mass of the particle
size_t getTotalNum() const
std::unique_ptr< OperatorBase > makeClone(ParticleSet &qp, TrialWaveFunction &psi) final
void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const override
acquire a shared resource from a collection
void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const override
return a shared resource to a collection
std::complex< T > CplxSum(const ParticleAttrib< std::complex< T >> &pa)
void convertToReal(const T1 &in, T2 &out)
generic conversion from type T1 to type T2 using implicit conversion
Declaration of OperatorBase.
std::string getClassName() const override
return class name
GradType evaluateJastrowGradSource(ParticleSet &P, ParticleSet &source, const int iat) const
Return ionic gradient of J(r).
An object of this type is a listener expecting a callback to the report function with a vector of val...
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
SPOSet::GradMatrix GradMatrix
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
void evaluateOneBodyOpMatrixForceDeriv(ParticleSet &P, ParticleSet &source, const TWFFastDerivWrapper &psi, const int iat, std::vector< std::vector< ValueMatrix >> &Bforce) override
Evaluate "dB/dR" matrices for observable.
Return_t evaluateWithIonDerivs(ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_terms, ParticleSet::ParticlePos &pulay_terms) override
Function to compute the value, direct ionic gradient terms, and pulay terms for the local kinetic ene...
int first(int igroup) const
return the first index of a group i
void getEGradELaplM(const ParticleSet &P, std::vector< ValueMatrix > &mvec, std::vector< GradMatrix > &gmat, std::vector< ValueMatrix > &lmat) const
Returns value, gradient, and laplacian matrices for all orbitals and all particles, species by species.
IndexType numOrbitals(const IndexType sid) const
Attaches a unit to a Vector for IO.
ParticleLaplacian L
laplacians of the particles
TWFFastDerivWrapper is a wrapper class for TrialWavefunction that provides separate and low level acc...
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
TraceRequest request_
whether traces are being collected
int groups() const
return the number of groups
std::string name_
name of this object
bool same_mass_
true, if all the species have the same mass
Specialized paritlce class for atomistic simulations.
void evaluateOneBodyOpMatrix(ParticleSet &P, const TWFFastDerivWrapper &psi, std::vector< ValueMatrix > &B) override
Evaluate "B" matrix for observable.
WalkerProperties::Indexes WP
FullPrecRealType one_over_2m_
void createResource(ResourceCollection &collection) const override
initialize a shared resource and hand it to a collection
QTBase::ValueType ValueType
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
void oneBodyQuantumDomain(const ParticleSet &P)
set quantum domain for one-body operator
CASTTYPE & getCastedElement(size_t i) const
SPOSet::ValueMatrix ValueMatrix
For fast derivative evaluation.
Array< TraceComp, 1 > * t_sample_comp_
class to handle a set of variables that can be modified during optimizations
GradType evalGradSource(ParticleSet &P, ParticleSet &source, int iat)
Returns the logarithmic gradient of the trial wave function with respect to the iat^th atom of the so...
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
void checkoutParticleQuantities(TraceManager &tm) override
int last(int igroup) const
return the last index of a group i
void setEnergyDomain(EnergyDomains edomain)
Set the Energy Domain.
T laplacian(const TinyVector< T, D > &g, T l)
compute real(laplacian)
OHMMS_INDEXTYPE IndexType
define other types
bool get(std::ostream &os) const override
write about the class
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
Array< TraceReal, D > * checkout_real(const std::string &name, int n1=1, int n2=0, int n3=0, int n4=0)
Declaration of a TrialWaveFunction.
Return_t evaluateValueAndDerivatives(ParticleSet &P, const opt_variables_type &optvars, const Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
FullPrecRealType Return_t
type of return value of evaluate
Array< TraceComp, 2 > * p_sample_
void mw_evaluatePerParticleWithToperator(const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< ListenerVector< RealType >> &listeners, const std::vector< ListenerVector< RealType >> &ion_listeners) const override
For BareKineticEnergy since it does override any Toperator evals this needs to decay to mw_evaluatePe...
CASTTYPE & getCastedLeader() const
BareKineticEnergy(ParticleSet &p, TrialWaveFunction &psi)
constructor with particleset
ResourceHandle< MultiWalkerResource > mw_res_
Class to represent a many-body trial wave function.
Return_t evaluate(ParticleSet &P) override
Evaluate the local energy contribution of this component.
Return_t value_
current value
Indexes
an enum denoting index of physical properties
ParticleAttrib< SingleParticlePos > ParticlePos
void contribute_array(const std::string &name, bool default_quantity=false)
void getIonGradIonGradELaplM(const ParticleSet &P, const ParticleSet &source, int iat, std::vector< std::vector< ValueMatrix >> &dmvec, std::vector< std::vector< GradMatrix >> &dgmat, std::vector< std::vector< ValueMatrix >> &dlmat) const
Returns x,y,z components of ion gradient of slater matrices and their laplacians. ...
std::vector< FullPrecRealType > minus_over_2m_
minus_over_2m_[i] = for the ith species
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
bool put(xmlNodePtr) override
implements the virtual function.
ParticleAttrib< QTFull::GradType > ParticleGradient
ResourceHandle< RS > lendResource()
IndexType getTWFGroupIndex(const IndexType gid) const
Takes particle set groupID and returns the TWF internal index for it.
Custom container for set of attributes for a set of species.
void mw_evaluatePerParticle(const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< ListenerVector< RealType >> &listeners, const std::vector< ListenerVector< RealType >> &ion_listeners) const override
Evaluate the contribution of this component for multiple walkers reporting to registered listeners fr...
void contributeParticleQuantities() override
double B(double x, int k, int i, const std::vector< double > &t)
RealType evaluateJastrowVGL(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
Evaluates value, gradient, and laplacian of the total jastrow.
Vector< RealType > t_samples
void mw_evaluateWithParameterDerivatives(const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< ParticleSet > &p_list, const opt_variables_type &optvars, const RecordArray< ValueType > &dlogpsi, RecordArray< ValueType > &dhpsioverpsi) const override
std::bitset< 8 > update_mode_
set the current update mode
BareKineticEnergy::Return_t Return_t
Return_t evaluate_sp(ParticleSet &P)
Evaluate the kinetic energy with a single mass.
void deleteParticleQuantities() override
Array< TraceReal, 1 > * t_sample_