51 psiM.resize(nel, norb);
52 dpsiM.resize(nel, norb);
61 dFa.resize(nel, norb);
63 Qmat.resize(nel, norb);
64 Fmat.resize(nel, norb);
94 grad_grad_grad_logdet);
131 buf.
add(
psiM.first_address(),
psiM.last_address());
134 buf.
add(
myL.first_address(),
myL.last_address());
155 buf.
put(
psiM.first_address(),
psiM.last_address());
158 buf.
put(
myL.first_address(),
myL.last_address());
169 buf.
get(
psiM.first_address(),
psiM.last_address());
172 buf.
get(
myL.first_address(),
myL.last_address());
200 if (*it < FirstIndex || *it >=
LastIndex)
209 for (
int orb = 0; orb <
psiV.size(); orb++)
226 APP_ABORT(
" Need to implement DiracDeterminantWithBackflow::evaluateRatiosAlltoOne. \n");
244 APP_ABORT(
" Need to implement DiracDeterminantWithBackflow::evalGradSource() \n");
255 APP_ABORT(
" Need to implement DiracDeterminantWithBackflow::evalGradSource() \n");
272 if (*it < FirstIndex || *it >=
LastIndex)
281 for (
int orb = 0; orb <
psiV.size(); orb++)
354 for (
int i = 0; i < num; i++)
356 for (
int a = 0; a < 3; a++)
358 for (
int i = 0; i < num; i++)
366 for (
int a = 0; a < 3; a++)
368 for (
int b = 0; b < 3; b++)
375 for (
int c = 0; c < 3; c++)
381 for (
int c = 0; c < 3; c++)
390 for (
int i = 0; i < num; i++)
392 for (
int a = 0; a < 3; a++)
407 for (
int b = 0; b < 3; b++)
411 (P.
R[i])[a] -= 2.0 * dr;
424 for (
int b = 0; b < 3; b++)
432 for (
int b = 0; b < 3; b++)
434 (Kij(i, j))(a, b) = ((Fdiag_p[j])[b] - (Fdiag_m[j])[b]) / ((
RealType)2.0 * dr);
437 for (
int b = 0; b < 3; b++)
439 (dAij(i, j))[b] += ((Aij_p(i, j))(a, b) - (Aij_m(i, j))(a, b)) / ((
RealType)2.0 * dr);
443 std::cout <<
"Testing derivative of Fjj in complex case: \n";
444 for (
int i = 0; i < num; i++)
447 std::cout <<
"i,j: " << i <<
" " << j << std::endl;
448 for (
int a = 0; a < 3; a++)
449 for (
int b = 0; b < 3; b++)
451 std::cout << a <<
" " << b <<
" " << ((Kij(i, j))(a, b)) - ((Qij(i, j))(a, b)) <<
" -- " 452 << ((Kij(i, j))(a, b)) <<
" -- " << ((Qij(i, j))(a, b)) << std::endl;
455 std::cout <<
"Testing derivative of Aij in complex case: \n";
456 for (
int i = 0; i < num; i++)
459 std::cout <<
"i,j: " << i <<
" " << j << std::endl;
460 for (
int a = 0; a < 3; a++)
462 std::cout << a <<
" " << ((dAij(i, j))[a]) - ((Bij(i, j))[a]) <<
" -- " << ((dAij(i, j))[a]) <<
" -- " 463 << ((Bij(i, j))[a]) << std::endl;
467 APP_ABORT(
"Finished testL: Aborting \n");
510 for (
int i = 0; i < num; i++)
531 for (
int i = 0; i < num; i++)
540 for (
int i = 0; i < num; i++)
550 for (
int i = 0; i < num; i++)
642 for (
int n = 0;
n < num;
n++)
668 for (
int i = 0; i < num; i++)
680 for (
int i = 0; i < num; i++)
689 for (
int i = 0; i < num; i++)
716 for (
int i = 0; i < num; i++)
725 #if defined(QMC_COMPLEX) 727 dlogpsi[kk] += dpsia;
731 dlogpsi[kk] += dpsia;
785 for (
int n = 0;
n < num;
n++)
811 for (
int i = 0; i < num; i++)
822 for (
int i = 0; i < num; i++)
830 for (
int i = 0; i < num; i++)
852 for (
int i = 0; i < num; i++)
859 #if defined(QMC_COMPLEX) 863 dlogpsi(offset, pa) = dpsia;
864 dL(offset, pa) = dLa + sumL * dpsia + dotG * dpsia +
static_cast<ValueType>(2.0 *
Dot(
myG,
Gtemp));
867 for (
int k = 0; k < num; k++)
875 std::vector<RealType>& dlogpsi,
876 std::vector<RealType>& dhpsioverpsi,
921 for (
int i = 0; i < num; i++)
932 for (
int i = 0; i < num; i++)
944 for (
int i = 0; i < num; i++)
947 for (
int i = 0; i < num; i++)
970 for (
int i = 0; i < num; i++)
973 for (
int i = 0; i < num; i++)
981 #if defined(QMC_COMPLEX) 982 dlogpsi[kk] +=
real(dpsia);
983 dhpsioverpsi[kk] -=
real(0.5 * static_cast<ParticleSet::SingleParticleValue>(
La1 +
La2 +
La3) +
Dot(P.
G,
Gtemp));
985 dlogpsi[kk] += dpsia;
994 std::unique_ptr<SPOSet>&& spo,
997 return std::make_unique<DiracDeterminantWithBackflow>(std::move(spo), BF,
FirstIndex,
LastIndex);
1020 app_log() <<
"Testing GGType calculation: " << std::endl;
1021 for (
int lx = 0; lx < 3; lx++)
1023 for (
int ly = 0; ly < 3; ly++)
1045 (dgM(i, j))(lx, ly) = (psiM_1(i, j) + psiM_2(i, j) - (
RealType)2.0 * psiM_3(i, j)) / (dh * dh);
1083 (dgM(i, j))(lx, ly) =
1084 (psiM_1(i, j) + psiM_2(i, j) - psiM_3(i, j) - psiM_4(i, j)) / ((
RealType)4.0 * dh * dh);
1091 std::cout <<
"i,j: " << i <<
" " << j << std::endl;
1092 for (
int lx = 0; lx < 3; lx++)
1093 for (
int ly = 0; ly < 3; ly++)
1095 std::cout <<
"a,b: " << lx <<
" " << ly << (dgM(i, j))(lx, ly) - (ggM(i, j))(lx, ly) <<
" -- " 1096 << (dgM(i, j))(lx, ly) <<
" -- " << (ggM(i, j))(lx, ly) << std::endl;
1124 app_log() <<
"Testing GGGType calculation: " << std::endl;
1125 for (
int lc = 0; lc < 3; lc++)
1146 for (
int la = 0; la < 9; la++)
1150 #if defined(QMC_COMPLEX) 1158 app_log() << i <<
" " << j <<
"\n" 1164 app_log() <<
"lc, av, max: " << lc <<
" " << av / cnt <<
" " << maxD << std::endl;
1173 app_log() <<
" Testing derivatives of the F matrix, prm: " << pa << std::endl;
1177 int Nvars = wfVars.
size();
1178 wfvar_prime = wfVars;
1185 for (
int j = 0; j < Nvars; j++)
1186 wfvar_prime[j] = wfVars[j];
1187 wfvar_prime[pr] = wfVars[pr] + dh;
1204 for (
int j = 0; j < Nvars; j++)
1205 wfvar_prime[j] = wfVars[j];
1206 wfvar_prime[pr] = wfVars[pr] - dh;
1223 for (
int j = 0; j < Nvars; j++)
1224 wfvar_prime[j] = wfVars[j];
1245 for (
int lb = 0; lb < 3; lb++)
1247 dpsiM_0(i, j)[lb] = 0.0;
1249 for (
int lc = 0; lc < 3; lc++)
1255 #if defined(QMC_COMPLEX) 1256 RealType t =
real(dpsiM_0(i, j)[lb] - (dpsiM_1(i, j)[lb] - dpsiM_2(i, j)[lb])) / (2 * dh);
1258 maxD = std::max(maxD,
std::abs(t));
1260 av += dpsiM_0(i, j)[lb] - (dpsiM_1(i, j)[lb] - dpsiM_2(i, j)[lb]) / (2 * dh);
1261 if (
std::abs(dpsiM_0(i, j)[lb] - (dpsiM_1(i, j)[lb] - dpsiM_2(i, j)[lb]) / (2 * dh)) > maxD)
1262 maxD = dpsiM_0(i, j)[lb] - (dpsiM_1(i, j)[lb] - dpsiM_2(i, j)[lb]) / (2 * dh);
1265 app_log() <<
" av,max : " << av / cnt <<
" " << maxD << std::endl;
1276 int Nvars = wfVars.
size();
1277 wfvar_prime = wfVars;
1288 app_log() << std::endl <<
" Testing derivatives of L[i] matrix. " << std::endl;
1289 for (
int j = 0; j < Nvars; j++)
1290 wfvar_prime[j] = wfVars[j];
1291 wfvar_prime[pa] = wfVars[pa] + dh;
1295 for (
int j = 0; j < Nvars; j++)
1296 wfvar_prime[j] = wfVars[j];
1297 wfvar_prime[pa] = wfVars[pa] - dh;
1303 std::vector<RealType> dlogpsi;
1304 std::vector<RealType> dhpsi;
1305 dlogpsi.resize(Nvars);
1306 dhpsi.resize(Nvars);
1308 app_log() <<
"pa: " << pa << std::endl
1309 <<
"dL Numrical: " << (L1a - L1b) / (2 * dh) <<
" " << (L2a - L2b) / (2 * dh) <<
" " 1310 << (L3a - L3b) / (2 * dh) <<
"\n" 1311 <<
"dL Analitival: " <<
La1 <<
" " <<
La2 <<
" " <<
La3 << std::endl
1312 <<
" dLDiff: " << (L1a - L1b) / (2 * dh) -
La1 <<
" " << (L2a - L2b) / (2 * dh) -
La2 <<
" " 1313 << (L3a - L3b) / (2 * dh) -
La3 << std::endl;
1333 for (
int i = 0; i < num; i++)
1344 for (
int i = 0; i < num; i++)
1350 for (
int i = 0; i < num; i++)
SPOSet::GradVector GradVector
void resize(size_type n, Type_t val=Type_t())
Resize the container.
std::map< int, int > optIndexMap
ParticleSet::ParticleGradient myG_temp
T Sum(const ParticleAttrib< T > &pa)
GradType evalGradSource(ParticleSet &P, ParticleSet &source, int iat) override
return the logarithmic gradient for the iat-th particle of the source particleset ...
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
Compute the derivatives of both the log of the wavefunction and kinetic energy with respect to optimi...
ParticleSet::ParticleGradient myG
GradType evalGrad(ParticleSet &P, int iat) override
return the current gradient for the iat-th particle
static T convert(const std::complex< T1 > &logpsi)
helper functions for EinsplineSetBuilder
QTBase::GradType GradType
ValueType * LastAddressOfdV
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
QTBase::RealType RealType
ValueType * FirstAddressOfGGG
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
size_t getTotalNum() const
ParticleSet::ParticlePos newQP
new qp coordinates for pbyp moves.
ValueVector psiV
value of single-particle orbital for particle-by-particle update
void dummyEvalLi(ValueType &L1, ValueType &L2, ValueType &L3)
void convertToReal(const T1 &in, T2 &out)
generic conversion from type T1 to type T2 using implicit conversion
std::unique_ptr< DiracDeterminantWithBackflow > makeCopyWithBF(std::unique_ptr< SPOSet > &&spo, BackflowTransformation &BF) const
cloning function
ParticleSet::ParticleGradient Gtemp
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
void transpose(const T *restrict A, size_t m, size_t lda, TO *restrict B, size_t n, size_t ldb)
transpose of A(m,n) to B(n,m)
ValueType * FirstAddressOfFm
ValueMatrix psiMinv
temporary container for testing
void resize(size_type n, size_type m)
Resize the container.
void update(bool skipSK=false)
update the internal data
Attaches a unit to a Vector for IO.
std::complex< T > convertValueToLog(const std::complex< T > &logpsi)
evaluate log(psi) as log(|psi|) and phase
ParticleLaplacian L
laplacians of the particles
OrbitalSetTraits< ValueType >::HessType HessType
T traceAtB(const Tensor< T, D > &a, const Tensor< T, D > &b)
Tr(a^t *b), .
const int FirstIndex
index of the first particle with respect to the particle set
GradMatrix dpsiM
dpsiM(i,j)
QTFull::ValueType SingleParticleValue
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
void testDerivFjj(ParticleSet &P, int pa)
void evaluateDerivatives(const ParticleSet &P)
for(int i=0;i< size_test;++i) CHECK(Approx(gauss_random_vals[offset_for_rs+i])
std::complex< QTFull::RealType > LogValue
ValueType * FirstAddressOfdV
void evaluate_SPO(ValueMatrix &logdet, GradMatrix &dlogdet, HessMatrix &grad_grad_logdet)
replace of SPOSet::evaluate function with the removal of t_logpsi
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
ValueType * LastAddressOfFm
Specialized paritlce class for atomistic simulations.
void testGGG(ParticleSet &P)
ParticleSet::ParticleLaplacian myL
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
void testL(ParticleSet &P)
Tensor<T,D> class for D by D tensor.
void checkOutVariables(const opt_variables_type &active)
DiracDeterminantWithBackflow(std::unique_ptr< SPOSet > &&spos, BackflowTransformation &BF, int first, int last)
constructor
SPOSet::GGGMatrix GGGMatrix
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > outerProduct(const TinyVector< T1, D > &lhs, const TinyVector< T2, D > &rhs)
void rejectMove(Index_t iat)
reject a proposed move in regular mode
Vector< IndexType > Pivot
void InvertWithLog(T *restrict x, int n, int m, T *restrict work, int *restrict pivot, std::complex< T1 > &logdet)
BackflowTransformation & BFTrans_
ParticleGradient G
gradients of the particles
class to handle a set of variables that can be modified during optimizations
const int LastIndex
index of the last particle with respect to the particle set
PsiValue ratio(ParticleSet &P, int iat) override
return the ratio only for the iat-th partcle move
ParticleSet::ParticleLaplacian myL_temp
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
QTFull::ValueType PsiValue
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false) override
move was accepted, update the real container
HessMatrix grad_grad_psiM_temp
AntiSymTensor< T, D > transpose(const AntiSymTensor< T, D > &rhs)
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
size_type size() const
return the size
ParticleSet::SingleParticleValue * LastAddressOfG
void checkInVariables(opt_variables_type &active)
LogValue log_value_
Current .
Vector< ValueType > WorkSpace
Define determinant operators.
~DiracDeterminantWithBackflow() override
default destructor
GGGMatrix grad_grad_grad_psiM
ValueMatrix psiM
psiM(j,i)
void makeMove(Index_t iat, const SingleParticlePos &displ, bool maybe_accept=true)
move the iat-th particle to active_pos_
void resetParameters(const opt_variables_type &active)
NewTimer & UpdateTimer
Timers.
void evaluate(const ParticleSet &P)
calculate quasi-particle coordinates, Bmat and Amat
HessMatrix grad_grad_psiM
void registerData(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
LatticeGaussianProduct::ValueType ValueType
ParticleAttrib< QTFull::GradType > ParticleGradient
PsiValue ratioGrad(ParticleSet &P, int iat, GradType &grad_iat) override
evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient ...
void testDerivLi(ParticleSet &P, int pa)
LogValue updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
For particle-by-particle move.
void resize(int nel, int morb)
reset the size: with the number of particles and number of orbtials
ValueType * LastAddressOfGGG
SPOSet::GradMatrix GradMatrix
Declaration of DiracDeterminantWithBackflow with a S(ingle)P(article)O(rbital)Set.
const int NumPtcls
number of particles which belong to this Dirac determinant
A D-dimensional Array class based on PETE.
void evaluateRatiosAlltoOne(ParticleSet &P, std::vector< ValueType > &ratios) override
evaluate the ratios of one virtual move with respect to all the particles
SPOSet::HessMatrix HessMatrix
void copyFromBuffer(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
void put(std::complex< T1 > &x)
void restore(int iat) override
move was rejected.
void testGG(ParticleSet &P)
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
Calculate the log value of the Dirac determinant for particles.
ParticleSet::SingleParticleValue * FirstAddressOfG
ValueType rcdot(TinyVector< RealType, OHMMS_DIM > &lhs, TinyVector< ValueType, OHMMS_DIM > &rhs)
ParticleSet QP
quasiparticle coordinates
SPOSet::ValueMatrix ValueMatrix
std::vector< int > indexQP
store index of qp coordinates that changed during pbyp move
void add(std::complex< T1 > &x)
int NP
total number of particles. Ye: used to track first time allocation but I still feel it very strange...
int UpdateMode
current update mode
void get(std::complex< T1 > &x)