45 auto it(tr.
bfFuns.begin());
46 for (
int i = 0; i < (tr.
bfFuns).size(); i++, it++)
47 bfFuns[i] = (*it)->makeClone(targetPtcl);
53 auto clone = std::make_unique<BackflowTransformation>(tqp);
54 clone->copyFrom(*
this, tqp);
89 for (
int i = 0; i <
bfFuns.size(); i++)
96 for (
int i = 0; i <
bfFuns.size(); i++)
102 for (
int i = 0; i <
bfFuns.size(); i++)
108 for (
int i = 0; i <
bfFuns.size(); i++)
114 for (
int i = 0; i <
bfFuns.size(); i++)
120 for (
int i = 0; i <
bfFuns.size(); i++)
129 for (
int i = 0; i <
bfFuns.size(); i++)
158 for (
int i = 0; i <
bfFuns.size(); i++)
171 for (
int i = 0; i <
bfFuns.size(); i++)
183 for (
int i = 0; i <
bfFuns.size(); i++)
205 for (
int i = 0; i <
bfFuns.size(); i++)
211 newQP[iat] -= myTable.getTempDispls()[iat];
213 for (
int i = 0; i <
bfFuns.size(); i++)
250 for (
int i = 0; i <
bfFuns.size(); i++)
256 newQP[iat] -= myTable.getTempDispls()[iat];
259 for (
int i = 0; i <
bfFuns.size(); i++)
275 for (
int i = 0; i <
bfFuns.size(); i++)
288 for (
int i = 0; i <
bfFuns.size(); i++)
306 for (
int i = 0; i <
bfFuns.size(); i++)
321 Amat(i, i).diagonal(1.0);
323 for (
int i = 0; i <
bfFuns.size(); i++)
355 for (
int i = 0; i <
bfFuns.size(); i++)
368 for (
int i = 0; i <
bfFuns.size(); i++)
395 Amat(i, i).diagonal(1.0);
397 for (
int i = 0; i <
bfFuns.size(); i++)
420 Amat(i, i).diagonal(1.0);
422 for (
int i = 0; i <
bfFuns.size(); i++)
443 app_log() <<
" Testing derivatives of backflow transformation. \n";
448 int Nvars = wfVars.
size();
449 wfvar_prime = wfVars;
450 wfVars.
print(std::cout);
451 for (
int i = 0; i < Nvars; i++)
453 for (
int j = 0; j < Nvars; j++)
454 wfvar_prime[j] = wfVars[j];
455 wfvar_prime[i] = wfVars[i] + dh;
462 Amat_1(k, k).diagonal(1.0);
464 for (
int k = 0; k <
bfFuns.size(); k++)
468 for (
int j = 0; j < Nvars; j++)
469 wfvar_prime[j] = wfVars[j];
470 wfvar_prime[i] = wfVars[i] - dh;
477 Amat_2(k, k).diagonal(1.0);
479 for (
int k = 0; k <
bfFuns.size(); k++)
484 <<
"i, AvDiff, max: \n";
494 df = (((qp_1[k])[q] - (qp_2[k])[q]) / (2.0 * dh) -
Cmat(i, k)[q]);
503 app_log() << i <<
" " << av / cnt <<
" " << maxD << std::endl;
504 av = cnt = maxD = 0.0;
508 for (
int q = 0; q < 3; q++)
512 dB += (Bmat_full_1(j, k)[q] - Bmat_full_2(j, k)[q]);
514 df = (dB / (2.0 * dh) -
Ymat(i, k)[q]);
523 app_log() << i <<
" " << av / cnt <<
" " << maxD << std::endl;
524 av = cnt = maxD = 0.0;
529 for (
int q1 = 0; q1 < 3; q1++)
531 for (
int q2 = 0; q2 < 3; q2++)
533 RealType dB = (Amat_1(k1, k2))(q1, q2) - (Amat_2(k1, k2))(q1, q2);
535 df = (dB / (2.0 * dh) - (
Xmat(i, k1, k2))(q1, q2));
544 app_log() << i <<
" " << av / cnt <<
" " << maxD << std::endl;
545 av = cnt = maxD = 0.0;
568 size_t BufferCursor = tbuffer.
current();
570 tbuffer.
rewind(BufferCursor);
577 app_log() << jat <<
" " << P.
R[jat] -
QP.
R[jat] << std::endl;
579 for (
int iat = 0; iat < 1; iat++)
596 for (
int i = 0; i <
indexQP.size(); i++)
604 tbuffer.
rewind(BufferCursor);
608 Amat_1 = Amat_0 -
Amat;
615 Amdiff += Amat_1(i, k)[j] * Amat_1(i, k)[j];
616 app_log() <<
"Error in pbyp QP transformation: " << qpdiff << std::endl;
617 app_log() <<
"Error in pbyp QP Amat: " << Amdiff << std::endl;
618 app_log() <<
"i, diff, newPbyP, newEval: \n";
620 app_log() << i <<
"\n" << qp_0[i] -
QP.
R[i] <<
"\n" << qp_0[i] <<
"\n" <<
QP.
R[i] << std::endl << std::endl;
621 APP_ABORT(
"Finished BackflowTransformation::testPbyP() \n.");
void resize(size_type n, Type_t val=Type_t())
Resize the container.
std::map< int, int > optIndexMap
void evaluateBmatOnly(const ParticleSet &P, int iat)
calculate only Bmat.
void evaluatePbyP(const ParticleSet &P, int iat)
calculate new quasi-particle coordinates after pbyp move
const int myTableIndex_
Distance Table.
helper functions for EinsplineSetBuilder
const DistanceTableAA & getDistTableAA(int table_ID) const
get a distance table by table_ID and dyanmic_cast to DistanceTableAA
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
size_t getTotalNum() const
void fill_n(T *x, size_t count, const T &value)
ParticleSet::ParticlePos newQP
new qp coordinates for pbyp moves.
ParticleSet::ParticlePos oldQP
void updateBuffer(ParticleSet &P, WFBufferType &buf, bool redo)
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.
void resize(const std::array< SIZET, D > &dims)
Resize the container.
void registerData(ParticleSet &P, WFBufferType &buf)
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
void evaluateDerivatives(const ParticleSet &P)
for(int i=0;i< size_test;++i) CHECK(Approx(gauss_random_vals[offset_for_rs+i])
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
void evaluatePbyPAll(const ParticleSet &P, int iat)
calculate new quasi-particle coordinates after pbyp move
Specialized paritlce class for atomistic simulations.
void testPbyP(ParticleSet &P)
void checkOutVariables(const opt_variables_type &active)
void testDeriv(const ParticleSet &P)
class to handle a set of variables that can be modified during optimizations
int UpdateMode
current update mode
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Vector< PosType > storeQP
size_type size() const
return the size
void checkInVariables(opt_variables_type &active)
void diagonal(const T &rhs)
size_type current() const
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
int NumTargets
number of quantum particles
void reportStatus(std::ostream &os) final
print the state, e.g., optimizables
std::vector< std::unique_ptr< BackflowFunctionBase > > bfFuns
void makeMove(Index_t iat, const SingleParticlePos &displ, bool maybe_accept=true)
move the iat-th particle to active_pos_
void copyFrom(const BackflowTransformation &tr, ParticleSet &targetPtcl)
void resetParameters(const opt_variables_type &active)
Declaraton of ParticleAttrib<T>
BackflowTransformation(ParticleSet &els)
void evaluate(const ParticleSet &P)
calculate quasi-particle coordinates, Bmat and Amat
~BackflowTransformation()
void acceptMove(const ParticleSet &P, int iat)
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
bool isOptimizable() const
void evaluatePbyPWithGrad(const ParticleSet &P, int iat)
calculate new quasi-particle coordinates after pbyp move
std::unique_ptr< BackflowTransformation > makeClone(ParticleSet &tqp) const
void acceptMove(Index_t iat)
accept the move and update the particle attribute by the proposed move in regular mode ...
void rewind(size_type cur=0, size_type cur_scalar=0)
set the cursors
void print(std::ostream &os, int leftPadSpaces=0, bool printHeader=false) const
int activeParticle
active particle in pbyp moves
void copyFromBuffer(ParticleSet &P, WFBufferType &buf)
void put(std::complex< T1 > &x)
void transformOnly(const ParticleSet &P)
calculate quasi-particle coordinates only
ParticleSet QP
quasiparticle coordinates
std::vector< int > indexQP
store index of qp coordinates that changed during pbyp move
void add(std::complex< T1 > &x)
void get(std::complex< T1 > &x)