12 #ifndef QMC_PLUS_PLUS_COUNTING_JASTROW_ORBITAL_H 13 #define QMC_PLUS_PLUS_COUNTING_JASTROW_ORBITAL_H 22 template<
class RegionType>
40 std::unique_ptr<RegionType>
C;
64 std::vector<RealType>
Jlap;
95 std::unique_ptr<RegionType> c,
104 std::string
getClassName()
const override {
return "CountingJastrow"; }
112 active.insertFrom(
myVars);
113 C->checkInVariables(active);
119 C->checkOutVariables(active);
146 C->resetParameters(active);
175 std::ostringstream err;
176 err <<
"CountingJastrow::initialize: F, C dimension mismatch: F: " <<
F.
size() <<
", C: " <<
num_regions 182 int max_num_derivs =
C->max_num_derivs();
188 std::ostringstream os;
194 os <<
"F_" <<
I <<
"_" <<
J;
206 os <<
" Number of counting regions: " <<
num_regions << std::endl;
207 os <<
" Total optimizable parameters: " <<
C->total_num_derivs() +
myVars.
size_of_active() << std::endl;
211 os <<
" Debug sample sequence length: " <<
debug_seqlen << std::endl;
212 os <<
" Debug sample periodicity: " <<
debug_period << std::endl;
226 for (
int i = 0; i <
num_els; ++i)
251 std::fill(
Jlap.begin(),
Jlap.end(), 0);
259 for (
int i = 0; i <
num_els; ++i)
270 for (
int i = 0; i <
num_els; ++i)
279 static int exp_print_index = 0;
293 os <<
"CountingJastrow::evaluateExponents_print: ";
294 os << std::endl <<
"FCsum: ";
296 os << std::endl <<
"FCgrad: ";
298 os << std::endl <<
"FClap: ";
301 os << std::endl <<
"Jval: " <<
Jval;
302 os << std::endl <<
"Jgrad: ";
304 os << std::endl <<
"Jlap: ";
306 os << std::endl << std::endl;
313 C->evaluateTemp(P, iat);
335 for (
int i = 0; i <
num_els; ++i)
352 static int expt_print_index = 0;
363 C->evaluateTemp_print(
app_log(), P);
365 os <<
"CountingJastrow::evaluateTempExponents_print: iat: " << iat;
366 os << std::endl <<
"FCsum_t: ";
368 os << std::endl <<
"FCgrad_t: ";
370 os << std::endl <<
"FClap_t: ";
373 os << std::endl <<
"Jval_t: " <<
Jval_t;
374 os << std::endl <<
"Jgrad_t: ";
376 os << std::endl <<
"Jlap_t: ";
378 os << std::endl << std::endl;
397 C->acceptMove(P, iat);
409 for (
int i = 0; i <
num_els; ++i)
416 void restore(
int iat)
override {
C->restore(iat); }
433 buf.
add(Jlap_begin, Jlap_end);
434 buf.
add(Jgrad_begin, Jgrad_end);
447 buf.
put(Jlap_begin, Jlap_end);
448 buf.
put(Jgrad_begin, Jgrad_end);
461 buf.
get(Jlap_begin, Jlap_end);
462 buf.
get(Jgrad_begin, Jgrad_end);
469 auto cjc = std::make_unique<CountingJastrow>(tqp,
C->makeClone(),
F,
opt_C,
opt_F);
481 APP_ABORT(
"CountingJastrow::evaluateDerivatives is not available on complex builds.");
485 static int deriv_print_index = 0;
501 for (
int i = 0; i <
num_els; ++i)
504 dJF_gg += x * (
dot(
C->grad(
I, i), grad_i) *
C->sum[
J] +
C->sum[
I] *
dot(
C->grad(
J, i), grad_i));
505 dJF_lap += x * (
C->lap(
I, i) *
C->sum[
J] + 2 *
dot(
C->grad(
I, i),
C->grad(
J, i)) +
C->lap(
J, i) *
C->sum[
I]);
507 dlogpsi[ia] += dJF_val;
508 dhpsioverpsi[ia] += -0.5 * dJF_lap - dJF_gg;
511 app_log() <<
" dJ/dF[" <<
I <<
"][" <<
J <<
"]; ia: " << ia <<
", dlogpsi: " << dlogpsi[ia]
512 <<
", dhpsioverpsi: " << dhpsioverpsi[ia] << std::endl;
538 for (
int i = 0; i <
num_els; ++i)
553 app_log() << std::endl <<
"=== evaluateDerivatives ===" << std::endl;
554 app_log() <<
"== print current exponent values ==" << std::endl;
556 app_log() <<
"== additional counting function terms ==" << std::endl;
559 app_log() << std::endl <<
"FCgrad: ";
561 app_log() << std::endl <<
"FClap: ";
563 app_log() << std::endl <<
"FCggsum: ";
565 app_log() << std::endl <<
"FClapsum: ";
574 int I_num_derivs = I_vars.
size();
586 app_log() <<
" == evaluateDerivatives for counting region " <<
I <<
", num_derivs: " << I_num_derivs
587 <<
" ==" << std::endl;
590 app_log() << std::endl <<
" Names: ";
592 app_log() << (*it).first <<
", ";
593 app_log() << std::endl <<
" Values: ";
595 app_log() << (*it).second <<
", ";
597 app_log() << std::endl <<
" dCsum: ";
599 app_log() << std::endl <<
" dCggsum: ";
601 app_log() << std::endl <<
" dClapsum: ";
603 app_log() << std::endl <<
" dCFCggsum: ";
608 for (
int pI = 0; pI < I_num_derivs; ++pI)
611 int ia = I_vars.
Index[pI];
615 dhpsioverpsi[ia] += -0.5 * (4.0 *
dCFCggsum[pI]);
618 app_log() <<
" == evaluateDerivatives calculations ==" << std::endl;
619 app_log() <<
" pI: " << pI <<
", name: " << I_vars.
name(pI) <<
", ia: " << ia << std::endl;
631 app_log() <<
" J: " <<
J << std::endl;
633 app_log() <<
" dhpsi/psi, graddotgrad: " 635 app_log() <<
" dhpsi/psi, laplacian : " 646 app_log() <<
"Final derivatives: " << std::endl;
647 app_log() <<
" F derivatives: " << std::endl;
654 app_log() <<
" ia: " << ia <<
", dlogpsi: " << dlogpsi[ia] <<
", dhpsioverpsi: " << dhpsioverpsi[ia]
657 app_log() <<
" C derivatives: " << std::endl;
660 app_log() <<
" C[" <<
I <<
"] derivs: " << std::endl;
663 int I_num_derivs = I_vars.
size();
664 for (
int pI = 0; pI < I_num_derivs; ++pI)
667 int ia = I_vars.
Index[pI];
670 app_log() <<
" ia: " << ia <<
", dlogpsi: " << dlogpsi[ia] <<
", dhpsioverpsi: " << dhpsioverpsi[ia]
680 void addDebug(
bool debug_flag,
int seqlen,
int period)
Container_t::iterator begin()
PsiValue ratioGrad(ParticleSet &P, int iat, GradType &grad_iat) override
evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient ...
helper functions for EinsplineSetBuilder
std::unique_ptr< RegionType > C
void resetParametersExclusive(const opt_variables_type &active) override
reset the parameters during optimizations.
std::vector< RealType > Jlap_t
void checkInVariablesExclusive(opt_variables_type &active) final
check in variational parameters to the global list of parameters used by the optimizer.
PsiValue ratio(ParticleSet &P, int iat) override
evaluate the ratio of the new to old WaveFunctionComponent value
size_t getTotalNum() const
GradType evalGrad(ParticleSet &P, int iat) override
return the current gradient for the iat-th particle
void addDebug(bool debug_flag, int seqlen, int period)
std::vector< int > Index
store locator of the named variable
int getLoc(const std::string &vname) const
void resize(size_type n, size_type m)
Resize the container.
void resetIndex()
reset Index
Attaches a unit to a Vector for IO.
ParticleLaplacian L
laplacians of the particles
void evaluateExponents_print(std::ostream &os, const ParticleSet &P)
void evaluateTempExponents(ParticleSet &P, int iat)
std::string getClassName() const override
return class name
std::unique_ptr< WaveFunctionComponent > makeClone(ParticleSet &tqp) const override
make clone
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
std::complex< QTFull::RealType > LogValue
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
std::vector< RealType > dCsum_t
An abstract class for a component of a many-body trial wave function.
Matrix< RealType > dCggsum
void evaluateExponents(const ParticleSet &P)
Specialized paritlce class for atomistic simulations.
void insert(const std::string &vname, real_type v, bool enable=true, int type=OTHER_P)
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false) override
a move for iat-th particle is accepted.
void restore(int iat) override
If a move for iat-th particle is rejected, restore to the content.
std::array< std::vector< std::string >, NUM_OPT_VAR > opt_id
ParticleGradient G
gradients of the particles
std::vector< RealType > FCggsum
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
std::vector< RealType > dCFCggsum
std::vector< RealType > FClap_t
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
void recompute(const ParticleSet &P) override
recompute the value of the WaveFunctionComponents which require critical accuracy.
LogValue updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
For particle-by-particle move.
int size_of_active() const
return the number of active variables
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
QTFull::ValueType PsiValue
#define DEBUG_PSIBUFFER(who, msg)
std::array< std::vector< int >, NUM_OPT_VAR > opt_index
std::vector< PosType > Jgrad_t
size_type size() const
return the size
std::vector< RealType > FClapsum
LogValue log_value_
Current .
size_type current() const
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate the value of the WaveFunctionComponent from scratch
std::vector< RealType > FCsum_t
Matrix< RealType > dClapsum
std::vector< int > dCindex
std::vector< pair_type > NameAndValue
std::vector< RealType > FCsum
const std::string & name(int i) const
return the name of i-th variable
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
CountingJastrow(ParticleSet &P, std::unique_ptr< RegionType > c, const Matrix< RealType > &f, bool opt_C_flag, bool opt_F_flag)
Declaration of WaveFunctionComponent.
void registerData(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
void extractOptimizableObjectRefs(UniqueOptObjRefs &opt_obj_refs) override
extract underlying OptimizableObject references
std::vector< RealType > Jlap
void copyFromBuffer(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
Container_t::iterator end()
bool isOptimizable() const override
if true, this contains optimizable components
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
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
void push_back(OptimizableObject &obj)
void reportStatus(std::ostream &os) override
print the state, e.g., optimizables
void put(std::complex< T1 > &x)
std::vector< PosType > FCgrad_t
std::vector< PosType > Jgrad
void checkOutVariables(const opt_variables_type &active) override
check out variational optimizable variables
void evaluateTempExponents_print(std::ostream &os, ParticleSet &P, int iat)
void add(std::complex< T1 > &x)
void get(std::complex< T1 > &x)