49 else if ((j == 0) && (k > 0))
76 for (
int i = 0; i <= maxIndex[0]; i++)
77 for (
int j = -maxIndex[1]; j <= maxIndex[1]; j++)
78 for (
int k = -maxIndex[2]; k <= maxIndex[2]; k++)
86 if (
dot(G, G) <= (kc * kc))
91 notZero = notZero || (
norm(rho_G[sp]) > 1.0
e-12);
92 if (notZero || !useStructFact)
98 for (
int i = 0; i <= maxIndex[0]; i++)
99 for (
int j = -maxIndex[1]; j <= maxIndex[1]; j++)
105 if (
dot(G, G) <= (kc * kc))
110 notZero = notZero || (
norm(rho_G[sp]) > 1.0
e-12);
111 if (notZero || !useStructFact)
127 return dot(G1, G1) <
dot(G2, G2);
147 return (!(*
this)(G1, G2) && !(*
this)(G2, G1));
174 std::sort(gvecs.begin(), gvecs.end(), *
this);
178 coef.firstIndex = coef.lastIndex = 0;
179 for (
int i = 1; i < gvecs.size(); i++)
184 coefs.push_back(coef);
185 coef.firstIndex = coef.lastIndex = i;
187 coefs.push_back(coef);
189 else if (symm == ISOTROPIC)
192 std::sort(gvecs.begin(), gvecs.end(), comparator);
197 for (
int i = 1; i < gvecs.size(); i++)
204 coefs.push_back(coef);
209 coefs.push_back(coef);
211 else if (symm == NOSYMM)
213 coefs.resize(gvecs.size());
214 for (
int i = 0; i < gvecs.size(); i++)
217 coefs[i].firstIndex = coefs[i].lastIndex = i;
220 app_log() <<
"Using a total of " << gvecs.size() <<
" G-vectors in " << coefs.size() <<
" symmetry groups.\n";
221 app_log() <<
"kSpace coefficient groups:\n";
222 for (
int i = 0; i < coefs.size(); i++)
224 app_log() <<
" Group " << i <<
":\n";
225 for (
int j = coefs[i].firstIndex; j <= coefs[i].lastIndex; j++)
234 std::string onebodyid,
238 std::string twobodyid,
243 OneBodyID(onebodyid),
251 if (oneBodyCutoff > 0.0)
257 std::stringstream name_real, name_imag;
259 name_imag <<
OneBodyID <<
"_" << 2 * i + 1;
266 if (twoBodyCutoff > 0.0)
272 std::stringstream name;
279 app_log() <<
"One-body k-space Jastrow is spin-dependent.\n";
281 app_log() <<
"Two-body k-space Jastrow is spin-dependent.\n";
297 for (
int iat = 0; iat < nelecs; iat++)
298 for (
int i = 0; i < nTwo; i++)
319 app_warning() <<
"Warning! Wrong number of coefficients specified in " 320 <<
"kSpaceJastrow's one-body coefficients.\n" 321 << oneBodyCoefs.size() <<
" were specified. Should have been " << 2 *
OneBodySymmCoefs.size()
336 myVars[kk++] = oneBodyCoefs[2 * i + 0];
337 myVars[kk++] = oneBodyCoefs[2 * i + 1];
343 app_warning() <<
"Warning! Wrong number of coefficients specified in " 344 <<
"kSpaceJastrow's two-body coefficients.\n" 345 << twoBodyCoefs.size() <<
" were specified. Should have been " <<
TwoBodySymmCoefs.size()
359 myVars[kk++] = twoBodyCoefs[i];
377 for (
int iat = 0; iat <
N; iat++)
380 for (
int i = 0; i < nOne; i++)
383 for (
int i = 0; i < nOne; i++)
393 for (
int i = 0; i < nTwo; i++)
395 for (
int iat = 0; iat <
N; iat++)
398 for (
int iG = 0; iG < nTwo; iG++)
401 for (
int iG = 0; iG < nTwo; iG++)
408 for (
int i = 0; i < nTwo; i++)
410 for (
int iat = 0; iat <
N; iat++)
413 for (
int i = 0; i < nTwo; i++)
416 for (
int i = 0; i < nTwo; i++)
438 for (
int i = 0; i < nOne; i++)
441 for (
int i = 0; i < nOne; i++)
451 for (
int i = 0; i < nTwo; i++)
453 for (
int iat2 = 0; iat2 <
N; iat2++)
456 for (
int iG = 0; iG < nTwo; iG++)
459 for (
int iG = 0; iG < nTwo; iG++)
470 for (
int i = 0; i < nTwo; i++)
473 for (
int i = 0; i < nTwo; i++)
487 RealType J1new(0.0), J1old(0.0), J2new(0.0), J2old(0.0);
491 for (
int i = 0; i < nOne; i++)
494 for (
int i = 0; i < nOne; i++)
500 for (
int i = 0; i < nOne; i++)
503 for (
int i = 0; i < nOne; i++)
507 for (
int i = 0; i < nTwo; i++)
510 for (
int i = 0; i < nTwo; i++)
513 for (
int i = 0; i < nTwo; i++)
518 for (
int i = 0; i < nTwo; i++)
523 for (
int i = 0; i < nTwo; i++)
530 return std::exp(static_cast<PsiValue>(J1new + J2new - (J1old + J2old)));
538 RealType J1new(0.0), J1old(0.0), J2new(0.0), J2old(0.0);
542 for (
int i = 0; i < nOne; i++)
545 for (
int i = 0; i < nOne; i++)
547 for (
int i = 0; i < nOne; i++)
550 for (
int i = 0; i < nOne; i++)
554 for (
int i = 0; i < nTwo; i++)
557 for (
int i = 0; i < nTwo; i++)
560 for (
int i = 0; i < nTwo; i++)
565 for (
int i = 0; i < nTwo; i++)
570 return std::exp(static_cast<PsiValue>(J1new + J2new - (J1old + J2old)));
581 for (
int i = 0; i < nOne; i++)
585 for (
int i = 0; i < nOne; i++)
589 for (
int i = 0; i < nTwo; i++)
593 for (
int n = 0;
n <
N;
n++)
597 for (
int i = 0; i < nOne; i++)
600 for (
int i = 0; i < nOne; i++)
602 for (
int i = 0; i < nTwo; i++)
605 for (
int i = 0; i < nTwo; i++)
611 ratios[
n] =
std::exp(J1new - J1old + J2Rat);
665 for (
int iat = 0; iat <
num_elecs; iat++)
683 for (
int i = 0; i < nOne; i++)
694 for (
int i = 0; i < nTwo; i++)
717 myVars[ii] = active[loc_r];
727 myVars[ii] = active[loc_i];
758 auto kj = std::make_unique<kSpaceJastrow>(
Ions);
834 bool recalculate(
false);
851 for (
int iat = 0; iat <
N; iat++)
854 for (
int i = 0; i < nOne; i++)
857 for (
int i = 0; i < nOne; i++)
882 for (
int i = 0; i < nTwo; i++)
884 for (
int iat = 0; iat <
N; iat++)
887 for (
int iG = 0; iG < nTwo; iG++)
890 for (
int iG = 0; iG < nTwo; iG++)
893 for (
int i = 0; i < nTwo; i++)
901 for (
int iat = 0; iat <
N; iat++)
904 for (
int i = 0; i < nTwo; i++)
907 for (
int i = 0; i < nTwo; i++)
931 os << std::fixed << std::setprecision(6) << std::setw(12) << gvec[0] << std::setw(12) << gvec[1] << std::setw(12)
932 << gvec[2] << std::setw(24) << coeff.real() << std::setw(24) << coeff.imag() << std::endl;
942 os << std::fixed << std::setprecision(6) << std::setw(12) << gvec[0] << std::setw(12) << gvec[1] << std::setw(12)
943 << gvec[2] << std::setw(24) << coeff.real() << std::setw(24) << coeff.imag() << std::endl;
bool operator()(PosType G1, PosType G2)
void checkInVariablesExclusive(opt_variables_type &active) final
check in variational parameters to the global list of parameters used by the optimizer.
bool recompute(int i) const
std::unique_ptr< WaveFunctionComponent > makeClone(ParticleSet &tqp) const override
make clone
std::vector< ComplexType > OneBody_e2iGr
std::ostream & app_warning()
helper functions for EinsplineSetBuilder
std::vector< kSpaceCoef< ComplexType > > OneBodySymmCoefs
QTBase::RealType RealType
void evaluateRatiosAlltoOne(ParticleSet &P, std::vector< ValueType > &ratios) override
evaluate the ratio
void printTwoBody(std::ostream &os)
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
GradType evalGrad(ParticleSet &P, int iat) override
return the current gradient for the iat-th particle
void registerData(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
size_t getTotalNum() const
void copyFromBuffer(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
std::vector< ComplexType > OneBody_rhoG
void restore(int iat) override
If a move for iat-th particle is rejected, restore to the content.
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
LogValue updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
For particle-by-particle move.
void convertToReal(const T1 &in, T2 &out)
generic conversion from type T1 to type T2 using implicit conversion
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
void setCoefficients(std::vector< RealType > &oneBodyCoefs, std::vector< RealType > &twoBodyCoefs)
void resize(size_type n, size_type m)
Resize the container.
SymmetryType TwoBodySymmType
Attaches a unit to a Vector for IO.
ParticleLaplacian L
laplacians of the particles
std::vector< int > OneBodyVarMap
ParticleIndex GroupID
Species ID.
Matrix< ComplexType > Delta_e2iGr
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
std::complex< QTFull::RealType > LogValue
std::vector< ComplexType > TwoBody_e2iGr_new
An abstract class for a component of a many-body trial wave function.
const PosType & getActivePos() const
bool operator()(kSpaceJastrow::PosType a, kSpaceJastrow::PosType b)
Specialized paritlce class for atomistic simulations.
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
double norm(const zVec &c)
std::vector< PosType > OneBodyGvecs
QTBase::ValueType ValueType
void insert(const std::string &vname, real_type v, bool enable=true, int type=OTHER_P)
void checkOutVariables(const opt_variables_type &active) override
check out variational optimizable variables
bool put(xmlNodePtr cur)
process input file
ParticleGradient G
gradients of the particles
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
Declaration of Long-range TwoBody Jastrow.
std::vector< RealType > TwoBodyPhase
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
std::vector< RealType > TwoBodyCoefs
QTFull::ValueType PsiValue
size_type size() const
return the size
std::vector< ComplexType > Ion_rhoG
std::complex< RealType > ComplexType
float conj(const float &c)
Workaround to allow conj on scalar to return real instead of complex.
std::vector< ComplexType > OneBodyCoefs
void printOneBody(std::ostream &os)
output jastrow coefficients
LogValue log_value_
Current .
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
void copyFrom(const kSpaceJastrow &old)
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate the value of the WaveFunctionComponent from scratch
PsiValue ratio(ParticleSet &P, int iat) override
evaluate the ratio of the new to old WaveFunctionComponent value
std::vector< ComplexType > TwoBody_rhoG
kSpaceJastrow(const ParticleSet &ions, ParticleSet &elecs, SymmetryType oneBodySymm, RealType oneBodyCutoff, std::string onebodyid, bool oneBodySpin, SymmetryType twoBodySymm, RealType twoBodyCutoff, std::string twobodyid, bool twoBodySpin)
void sortGvecs(std::vector< PosType > &gvecs, std::vector< kSpaceCoef< T >> &coefs, SymmetryType symm)
const auto & getLattice() const
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
void insertFrom(const VariableSet &input)
insert a VariableSet to the list
bool Include(int i, int j, int k)
std::vector< kSpaceCoef< RealType > > TwoBodySymmCoefs
std::vector< int > TwoBodyVarMap
void setupGvecs(RealType kcut, std::vector< PosType > &gvecs, bool useStructFact)
std::vector< ComplexType > TwoBody_e2iGr_old
int getIndex(const std::string &vname) const
return the Index vaule for the named parameter
void StructureFactor(PosType G, std::vector< ComplexType > &rho_G)
std::vector< RealType > OneBodyPhase
SymmetryType OneBodySymmType
bool Equivalent(PosType G1, PosType G2)
void eval_e2iphi(int n, const T *restrict phi, T *restrict phase_r, T *restrict phase_i)
PsiValue ratioGrad(ParticleSet &P, int iat, GradType &grad_iat) override
evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient ...
std::vector< PosType > TwoBodyGvecs
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false) override
a move for iat-th particle is accepted.
MakeReturn< UnaryNode< FnFloor, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t floor(const Vector< T1, C1 > &l)
void resetParametersExclusive(const opt_variables_type &active) final
reset the parameters during optimizations.