QMCPACK
kSpaceJastrow Class Reference
+ Inheritance diagram for kSpaceJastrow:
+ Collaboration diagram for kSpaceJastrow:

Public Types

enum  SymmetryType { CRYSTAL, ISOTROPIC, NOSYMM }
 
- Public Types inherited from WaveFunctionComponent
enum  {
  ORB_PBYP_RATIO, ORB_PBYP_ALL, ORB_PBYP_PARTIAL, ORB_WALKER,
  ORB_ALLWALKER
}
 enum for a update mode More...
 
using Walker_t = ParticleSet::Walker_t
 
using WFBufferType = Walker_t::WFBuffer_t
 
using BufferType = Walker_t::Buffer_t
 
using RealMatrix_t = OrbitalSetTraits< RealType >::ValueMatrix
 
using ValueVector = OrbitalSetTraits< ValueType >::ValueVector
 
using ValueMatrix = OrbitalSetTraits< ValueType >::ValueMatrix
 
using GradMatrix = OrbitalSetTraits< ValueType >::GradMatrix
 
using HessType = OrbitalSetTraits< ValueType >::HessType
 
using HessVector = OrbitalSetTraits< ValueType >::HessVector
 
using LogValue = std::complex< QTFull::RealType >
 
using PsiValue = QTFull::ValueType
 
- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 

Public Member Functions

 kSpaceJastrow (const ParticleSet &ions, ParticleSet &elecs, SymmetryType oneBodySymm, RealType oneBodyCutoff, std::string onebodyid, bool oneBodySpin, SymmetryType twoBodySymm, RealType twoBodyCutoff, std::string twobodyid, bool twoBodySpin)
 
 kSpaceJastrow (const ParticleSet &ions)
 constructor to initialize Ions More...
 
void setCoefficients (std::vector< RealType > &oneBodyCoefs, std::vector< RealType > &twoBodyCoefs)
 
std::string getClassName () const override
 return class name More...
 
bool isOptimizable () const override
 if true, this contains optimizable components More...
 
void checkOutVariables (const opt_variables_type &active) override
 check out variational optimizable variables More...
 
void extractOptimizableObjectRefs (UniqueOptObjRefs &opt_obj_refs) override
 extract underlying OptimizableObject references More...
 
void checkInVariablesExclusive (opt_variables_type &active) final
 check in variational parameters to the global list of parameters used by the optimizer. More...
 
void resetParametersExclusive (const opt_variables_type &active) final
 reset the parameters during optimizations. More...
 
LogValue evaluateLog (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
 evaluate the value of the WaveFunctionComponent from scratch More...
 
PsiValue ratio (ParticleSet &P, int iat) override
 evaluate the ratio of the new to old WaveFunctionComponent value More...
 
GradType evalGrad (ParticleSet &P, int iat) override
 return the current gradient for the iat-th particle More...
 
PsiValue ratioGrad (ParticleSet &P, int iat, GradType &grad_iat) override
 evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient More...
 
void restore (int iat) override
 If a move for iat-th particle is rejected, restore to the content. More...
 
void acceptMove (ParticleSet &P, int iat, bool safe_to_delay=false) override
 a move for iat-th particle is accepted. More...
 
void registerData (ParticleSet &P, WFBufferType &buf) override
 For particle-by-particle move. More...
 
LogValue updateBuffer (ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
 For particle-by-particle move. More...
 
void copyFromBuffer (ParticleSet &P, WFBufferType &buf) override
 For particle-by-particle move. More...
 
bool put (xmlNodePtr cur)
 process input file More...
 
void printOneBody (std::ostream &os)
 output jastrow coefficients More...
 
void printTwoBody (std::ostream &os)
 
bool operator() (PosType G1, PosType G2)
 
std::unique_ptr< WaveFunctionComponentmakeClone (ParticleSet &tqp) const override
 make clone More...
 
void evaluateDerivatives (ParticleSet &P, const opt_variables_type &active, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi) override
 
void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< ValueType > &ratios) override
 evaluate the ratio More...
 
- Public Member Functions inherited from WaveFunctionComponent
const LogValueget_log_value () const
 
 WaveFunctionComponent (const std::string &obj_name="")
 default constructor More...
 
virtual ~WaveFunctionComponent ()
 default destructor More...
 
virtual void checkSanity () const
 Validate the internal consistency of the object. More...
 
const std::string & getName () const
 return object name More...
 
PsiValue getValue () const
 assembles the full value More...
 
virtual bool isFermionic () const
 true, if this component is fermionic More...
 
virtual bool isMultiDet () const
 true, if this component is multi-determinant More...
 
virtual void registerTWFFastDerivWrapper (const ParticleSet &P, TWFFastDerivWrapper &twf) const
 Register the component with the TWFFastDerivWrapper wrapper. More...
 
virtual void mw_evaluateLog (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< ParticleSet::ParticleGradient > &G_list, const RefVector< ParticleSet::ParticleLaplacian > &L_list) const
 evaluate from scratch the same type WaveFunctionComponent of multiple walkers More...
 
virtual void recompute (const ParticleSet &P)
 recompute the value of the WaveFunctionComponents which require critical accuracy. More...
 
virtual void mw_recompute (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute) const
 
virtual void evaluateHessian (ParticleSet &P, HessVector &grad_grad_psi_all)
 
virtual void prepareGroup (ParticleSet &P, int ig)
 Prepare internal data for updating WFC correspond to a particle group It should be called before moving particles of a given group. More...
 
virtual void mw_prepareGroup (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int ig) const
 
virtual GradType evalGradWithSpin (ParticleSet &P, int iat, ComplexType &spingrad)
 return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
template<CoordsType CT>
void mw_evalGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const int iat, TWFGrads< CT > &grads_now) const
 compute the current gradients for the iat-th particle of multiple walkers More...
 
virtual void mw_evalGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< GradType > &grad_now) const
 compute the current gradients for the iat-th particle of multiple walkers More...
 
virtual GradType evalGradSource (ParticleSet &P, ParticleSet &source, int iat)
 return the logarithmic gradient for the iat-th particle of the source particleset More...
 
virtual GradType evalGradSource (ParticleSet &P, ParticleSet &source, int iat, TinyVector< ParticleSet::ParticleGradient, OHMMS_DIM > &grad_grad, TinyVector< ParticleSet::ParticleLaplacian, OHMMS_DIM > &lapl_grad)
 Adds the gradient w.r.t. More...
 
virtual PsiValue ratioGradWithSpin (ParticleSet &P, int iat, GradType &grad_iat, ComplexType &spingrad_iat)
 evaluate the ratio of the new to old WaveFunctionComponent value and the new spin gradient Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
template<CoordsType CT>
void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, TWFGrads< CT > &grad_new) const
 
virtual void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new) const
 compute the ratio of the new to old WaveFunctionComponent value and the new gradient of multiple walkers More...
 
virtual void mw_accept_rejectMove (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, const std::vector< bool > &isAccepted, bool safe_to_delay=false) const
 moves of the iat-th particle on some walkers in a batch is accepted. More...
 
virtual void completeUpdates ()
 complete all the delayed or asynchronous operations before leaving the p-by-p move region. More...
 
virtual void mw_completeUpdates (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 complete all the delayed or asynchronous operations for all the walkers in a batch before leaving the p-by-p move region. More...
 
virtual void mw_calcRatio (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios) const
 compute the ratio of the new to old WaveFunctionComponent value of multiple walkers More...
 
virtual LogValue evaluateGL (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, bool fromscratch)
 compute gradients and laplacian of the TWF with respect to each particle. More...
 
virtual void mw_evaluateGL (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< ParticleSet::ParticleGradient > &G_list, const RefVector< ParticleSet::ParticleLaplacian > &L_list, bool fromscratch) const
 evaluate gradients and laplacian of the same type WaveFunctionComponent of multiple walkers More...
 
virtual void createResource (ResourceCollection &collection) const
 initialize a shared resource and hand it to a collection More...
 
virtual void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 acquire a shared resource from a collection More...
 
virtual void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 return a shared resource to a collection More...
 
virtual RealType KECorrection ()
 Return the Chiesa kinetic energy correction. More...
 
virtual void evaluateDerivatives (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)=0
 Compute the derivatives of both the log of the wavefunction and kinetic energy with respect to optimizable parameters. More...
 
virtual void evaluateDerivativesWF (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi)
 Compute the derivatives of the log of the wavefunction with respect to optimizable parameters. More...
 
virtual void evaluateGradDerivatives (const ParticleSet::ParticleGradient &G_in, std::vector< ValueType > &dgradlogpsi)
 Calculates the derivatives of $ \nabla \textnormal{log} \psi_f $ with respect to the optimizable parameters, and the dot product of this is then performed with the passed-in G_in gradient vector. More...
 
virtual void finalizeOptimization ()
 
virtual void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< ValueType > &ratios)
 evaluate the ratios of one virtual move with respect to all the particles More...
 
virtual void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios)
 evaluate ratios to evaluate the non-local PP More...
 
virtual void evaluateSpinorRatios (const VirtualParticleSet &VP, const std::pair< ValueVector, ValueVector > &spinor_multiplier, std::vector< ValueType > &ratios)
 Used by SOECPComponent for faster SOC evaluation. More...
 
virtual void mw_evaluateRatios (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, std::vector< std::vector< ValueType >> &ratios) const
 evaluate ratios to evaluate the non-local PP multiple walkers More...
 
virtual void evaluateDerivRatios (const VirtualParticleSet &VP, const opt_variables_type &optvars, std::vector< ValueType > &ratios, Matrix< ValueType > &dratios)
 evaluate ratios to evaluate the non-local PP More...
 
virtual void mw_evalGradWithSpin (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< GradType > &grad_now, std::vector< ComplexType > &spingrad_now) const
 compute the current gradients and spin gradients for the iat-th particle of multiple walkers More...
 
virtual void mw_ratioGradWithSpin (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new, std::vector< ComplexType > &spingrad_new) const
 compute the ratio of the new to old WaveFunctionComponent value and the new gradient/spingradient of multiple walkers More...
 
- Public Member Functions inherited from OptimizableObject
 OptimizableObject (const std::string &name)
 
const std::string & getName () const
 
bool isOptimized () const
 
virtual void reportStatus (std::ostream &os)
 print the state, e.g., optimizables More...
 
void setOptimization (bool state)
 
virtual void writeVariationalParameters (hdf_archive &hout)
 Write the variational parameters for this object to the VP HDF file. More...
 
virtual void readVariationalParameters (hdf_archive &hin)
 Read the variational parameters for this object from the VP HDF file. More...
 

Private Types

using ComplexType = std::complex< RealType >
 

Private Member Functions

void setupGvecs (RealType kcut, std::vector< PosType > &gvecs, bool useStructFact)
 
void setupCoefs ()
 
template<typename T >
void sortGvecs (std::vector< PosType > &gvecs, std::vector< kSpaceCoef< T >> &coefs, SymmetryType symm)
 
bool Equivalent (PosType G1, PosType G2)
 
void StructureFactor (PosType G, std::vector< ComplexType > &rho_G)
 
void copyFrom (const kSpaceJastrow &old)
 

Private Attributes

RealType CellVolume
 
RealType NormConstant
 
int num_elecs
 
int NumSpins
 
int NumIons
 
int NumIonSpecies
 
std::vector< PosTypeOneBodyGvecs
 
std::vector< PosTypeTwoBodyGvecs
 
std::vector< kSpaceCoef< ComplexType > > OneBodySymmCoefs
 
std::vector< kSpaceCoef< RealType > > TwoBodySymmCoefs
 
std::vector< ComplexTypeOneBodyCoefs
 
std::vector< RealTypeTwoBodyCoefs
 
SymmetryType OneBodySymmType
 
SymmetryType TwoBodySymmType
 
std::vector< ComplexTypeIon_rhoG
 
std::vector< ComplexTypeOneBody_rhoG
 
std::vector< ComplexTypeTwoBody_rhoG
 
std::vector< RealTypeOneBodyPhase
 
std::vector< RealTypeTwoBodyPhase
 
std::vector< ComplexTypeOneBody_e2iGr
 
std::vector< ComplexTypeTwoBody_e2iGr_new
 
std::vector< ComplexTypeTwoBody_e2iGr_old
 
Matrix< ComplexTypeDelta_e2iGr
 
const ParticleSetIons
 
std::string OneBodyID
 
std::string TwoBodyID
 
double Prefactor
 
std::vector< int > TwoBodyVarMap
 
std::vector< int > OneBodyVarMap
 

Additional Inherited Members

- Public Attributes inherited from WaveFunctionComponent
int UpdateMode
 current update mode More...
 
opt_variables_type myVars
 list of variables this WaveFunctionComponent handles More...
 
size_t Bytes_in_WFBuffer
 Bytes in WFBuffer. More...
 
- Protected Attributes inherited from WaveFunctionComponent
const std::string my_name_
 Name of the object It is required to be different for objects of the same derived type like multiple J1. More...
 
LogValue log_value_
 Current $\log\phi $. More...
 

Detailed Description

Definition at line 68 of file kSpaceJastrow.h.

Member Typedef Documentation

◆ ComplexType

using ComplexType = std::complex<RealType>
private

Definition at line 79 of file kSpaceJastrow.h.

Member Enumeration Documentation

◆ SymmetryType

Constructor & Destructor Documentation

◆ kSpaceJastrow() [1/2]

kSpaceJastrow ( const ParticleSet ions,
ParticleSet elecs,
SymmetryType  oneBodySymm,
RealType  oneBodyCutoff,
std::string  onebodyid,
bool  oneBodySpin,
SymmetryType  twoBodySymm,
RealType  twoBodyCutoff,
std::string  twobodyid,
bool  twoBodySpin 
)

Definition at line 230 of file kSpaceJastrow.cpp.

References qmcplusplus::app_log(), qmcplusplus::cos(), kSpaceJastrow::Delta_e2iGr, qmcplusplus::dot(), ParticleSet::getLattice(), ParticleSet::getTotalNum(), ParticleSet::GroupID, VariableSet::insert(), kSpaceJastrow::Ion_rhoG, optimize::LOGLINEAR_P, WaveFunctionComponent::myVars, kSpaceJastrow::num_elecs, kSpaceJastrow::NumIonSpecies, kSpaceJastrow::OneBody_e2iGr, kSpaceJastrow::OneBody_rhoG, kSpaceJastrow::OneBodyCoefs, kSpaceJastrow::OneBodyGvecs, kSpaceJastrow::OneBodyID, kSpaceJastrow::OneBodyPhase, kSpaceJastrow::OneBodySymmCoefs, kSpaceJastrow::Prefactor, ParticleSet::R, Matrix< T, Alloc >::resize(), kSpaceJastrow::setupGvecs(), qmcplusplus::sin(), kSpaceJastrow::sortGvecs(), kSpaceJastrow::TwoBody_e2iGr_new, kSpaceJastrow::TwoBody_e2iGr_old, kSpaceJastrow::TwoBody_rhoG, kSpaceJastrow::TwoBodyCoefs, kSpaceJastrow::TwoBodyGvecs, kSpaceJastrow::TwoBodyID, kSpaceJastrow::TwoBodyPhase, and kSpaceJastrow::TwoBodySymmCoefs.

240  : WaveFunctionComponent(elecs.getName()),
241  OptimizableObject("kspace_" + elecs.getName()),
242  Ions(ions),
243  OneBodyID(onebodyid),
244  TwoBodyID(twobodyid)
245 {
246  Prefactor = 1.0 / elecs.getLattice().Volume;
247  NumIonSpecies = 0;
248  num_elecs = elecs.getTotalNum();
249  for (int iat = 0; iat < ions.getTotalNum(); iat++)
250  NumIonSpecies = std::max(NumIonSpecies, ions.GroupID[iat] + 1);
251  if (oneBodyCutoff > 0.0)
252  {
253  setupGvecs(oneBodyCutoff, OneBodyGvecs, true);
254  sortGvecs(OneBodyGvecs, OneBodySymmCoefs, oneBodySymm);
255  for (int i = 0; i < OneBodySymmCoefs.size(); i++)
256  {
257  std::stringstream name_real, name_imag;
258  name_real << OneBodyID << "_" << 2 * i;
259  name_imag << OneBodyID << "_" << 2 * i + 1;
260  myVars.insert(name_real.str(), OneBodySymmCoefs[i].cG.real(), true, optimize::LOGLINEAR_P);
261  myVars.insert(name_imag.str(), OneBodySymmCoefs[i].cG.imag(), true, optimize::LOGLINEAR_P);
262  //VarMap[name_real.str()] = &(OneBodySymmCoefs[i].cG.real());
263  //VarMap[name_imag.str()] = &(OneBodySymmCoefs[i].cG.imag());
264  }
265  }
266  if (twoBodyCutoff > 0.0)
267  {
268  setupGvecs(twoBodyCutoff, TwoBodyGvecs, false);
269  sortGvecs(TwoBodyGvecs, TwoBodySymmCoefs, twoBodySymm);
270  for (int i = 0; i < TwoBodySymmCoefs.size(); i++)
271  {
272  std::stringstream name;
273  name << TwoBodyID << "_" << i;
274  myVars.insert(name.str(), TwoBodySymmCoefs[i].cG, true, optimize::LOGLINEAR_P);
275  //VarMap[name.str()] = &(TwoBodySymmCoefs[i].cG);
276  }
277  }
278  if (oneBodySpin)
279  app_log() << "One-body k-space Jastrow is spin-dependent.\n";
280  if (twoBodySpin)
281  app_log() << "Two-body k-space Jastrow is spin-dependent.\n";
282  // Now resize all buffers
283  int nOne = OneBodyGvecs.size();
284  OneBodyCoefs.resize(nOne);
285  OneBody_rhoG.resize(nOne);
286  Ion_rhoG.resize(nOne);
287  OneBodyPhase.resize(nOne);
288  OneBody_e2iGr.resize(nOne);
289  int nTwo = TwoBodyGvecs.size();
290  int nelecs = elecs.getTotalNum();
291  TwoBodyCoefs.resize(nTwo);
292  TwoBody_rhoG.resize(nTwo);
293  TwoBodyPhase.resize(nTwo);
294  TwoBody_e2iGr_new.resize(nTwo);
295  TwoBody_e2iGr_old.resize(nTwo);
296  Delta_e2iGr.resize(nelecs, nTwo);
297  for (int iat = 0; iat < nelecs; iat++)
298  for (int i = 0; i < nTwo; i++)
299  Delta_e2iGr(iat, i) = ComplexType();
300  // Set Ion_rhoG
301  for (int i = 0; i < OneBodyGvecs.size(); i++)
302  {
303  Ion_rhoG[0] = ComplexType();
304  for (int iat = 0; iat < ions.getTotalNum(); iat++)
305  {
306  RealType phase = dot(OneBodyGvecs[i], ions.R[iat]);
307  Ion_rhoG[i] += ComplexType(std::cos(phase), std::sin(phase));
308  }
309  }
310 }
std::vector< ComplexType > OneBody_e2iGr
std::vector< kSpaceCoef< ComplexType > > OneBodySymmCoefs
Definition: kSpaceJastrow.h:95
std::ostream & app_log()
Definition: OutputManager.h:65
std::vector< ComplexType > OneBody_rhoG
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
void resize(size_type n, size_type m)
Resize the container.
Definition: OhmmsMatrix.h:99
Matrix< ComplexType > Delta_e2iGr
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
std::vector< ComplexType > TwoBody_e2iGr_new
const ParticleSet & Ions
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
std::vector< PosType > OneBodyGvecs
Definition: kSpaceJastrow.h:90
void insert(const std::string &vname, real_type v, bool enable=true, int type=OTHER_P)
Definition: VariableSet.h:133
OptimizableObject(const std::string &name)
std::vector< RealType > TwoBodyPhase
std::vector< RealType > TwoBodyCoefs
std::vector< ComplexType > Ion_rhoG
std::complex< RealType > ComplexType
Definition: kSpaceJastrow.h:79
std::vector< ComplexType > OneBodyCoefs
QMCTraits::RealType RealType
std::vector< ComplexType > TwoBody_rhoG
void sortGvecs(std::vector< PosType > &gvecs, std::vector< kSpaceCoef< T >> &coefs, SymmetryType symm)
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
WaveFunctionComponent(const std::string &obj_name="")
default constructor
std::vector< kSpaceCoef< RealType > > TwoBodySymmCoefs
Definition: kSpaceJastrow.h:96
void setupGvecs(RealType kcut, std::vector< PosType > &gvecs, bool useStructFact)
std::vector< ComplexType > TwoBody_e2iGr_old
std::vector< RealType > OneBodyPhase
std::vector< PosType > TwoBodyGvecs
Definition: kSpaceJastrow.h:91

◆ kSpaceJastrow() [2/2]

kSpaceJastrow ( const ParticleSet ions)

constructor to initialize Ions

Definition at line 779 of file kSpaceJastrow.cpp.

780  : WaveFunctionComponent(ions.getName()), OptimizableObject("kspace_" + ions.getName()), Ions(ions)
781 {}
const ParticleSet & Ions
OptimizableObject(const std::string &name)
WaveFunctionComponent(const std::string &obj_name="")
default constructor

Member Function Documentation

◆ acceptMove()

void acceptMove ( ParticleSet P,
int  iat,
bool  safe_to_delay = false 
)
overridevirtual

a move for iat-th particle is accepted.

Update the current content.

Parameters
Ptarget ParticleSet
iatindex of the particle whose new position was proposed
safe_to_delayif true, delayed accept is safe.

Implements WaveFunctionComponent.

Definition at line 622 of file kSpaceJastrow.cpp.

References kSpaceJastrow::Delta_e2iGr, kSpaceJastrow::TwoBody_e2iGr_new, and kSpaceJastrow::TwoBody_rhoG.

623 {
624  for (int i = 0; i < TwoBody_e2iGr_new.size(); i++)
625  TwoBody_rhoG[i] += Delta_e2iGr(iat, i);
626  //TwoBody_e2iGr_new[i] - TwoBody_e2iGr_old[i];
627  // copy(eikr_new.data(),eikr_new.data()+MaxK,eikr[iat]);
628  // U += offU;
629  // dU += offdU;
630  // d2U += offd2U;
631 }
Matrix< ComplexType > Delta_e2iGr
std::vector< ComplexType > TwoBody_e2iGr_new
std::vector< ComplexType > TwoBody_rhoG

◆ checkInVariablesExclusive()

void checkInVariablesExclusive ( opt_variables_type active)
finalvirtual

check in variational parameters to the global list of parameters used by the optimizer.

Parameters
activea super set of optimizable variables

The existing checkInVariables implementation in WFC/SPO/.. are inclusive and it calls checkInVariables of its members class A: public SPOSet {} class B: public WFC { A objA; checkInVariables() { objA.checkInVariables(); } };

With OptimizableObject, class A: public OptimizableObject {} class B: public OptimizableObject { A objA; checkInVariablesExclusive() { // should not call objA.checkInVariablesExclusive() if objA has been extracted; } }; A vector of OptimizableObject, will be created by calling extractOptimizableObjects(). All the checkInVariablesExclusive() will be called through this vector and thus checkInVariablesExclusive implementation should only handle non-OptimizableObject members.

Implements OptimizableObject.

Definition at line 675 of file kSpaceJastrow.cpp.

References VariableSet::insertFrom(), WaveFunctionComponent::myVars, kSpaceJastrow::OneBodyGvecs, kSpaceJastrow::OneBodySymmCoefs, kSpaceJastrow::OneBodyVarMap, kSpaceJastrow::TwoBodyGvecs, kSpaceJastrow::TwoBodySymmCoefs, and kSpaceJastrow::TwoBodyVarMap.

676 {
677  active.insertFrom(myVars);
678  int nOne = OneBodyGvecs.size();
679  int obi = 0;
680  if (nOne)
681  {
682  OneBodyVarMap.resize(nOne);
683  for (int i = 0; i < nOne; i++)
684  {
685  //two coeffs for each of these points, imaginary coefficients.
686  OneBodyVarMap[i] = obi;
687  if (i == OneBodySymmCoefs[obi / 2].lastIndex)
688  obi += 2;
689  }
690  }
691  int nTwo = TwoBodyGvecs.size();
692  TwoBodyVarMap.resize(nTwo);
693  int tbi = 0;
694  for (int i = 0; i < nTwo; i++)
695  {
696  //one coeff for each of these points, real coefficients.
697  TwoBodyVarMap[i] = obi + tbi;
698  if (i == TwoBodySymmCoefs[tbi].lastIndex)
699  tbi += 1;
700  }
701 }
std::vector< kSpaceCoef< ComplexType > > OneBodySymmCoefs
Definition: kSpaceJastrow.h:95
std::vector< int > OneBodyVarMap
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
std::vector< PosType > OneBodyGvecs
Definition: kSpaceJastrow.h:90
std::vector< kSpaceCoef< RealType > > TwoBodySymmCoefs
Definition: kSpaceJastrow.h:96
std::vector< int > TwoBodyVarMap
std::vector< PosType > TwoBodyGvecs
Definition: kSpaceJastrow.h:91

◆ checkOutVariables()

void checkOutVariables ( const opt_variables_type active)
overridevirtual

check out variational optimizable variables

Parameters
activea super set of optimizable variables

Reimplemented from WaveFunctionComponent.

Definition at line 703 of file kSpaceJastrow.cpp.

References VariableSet::getIndex(), and WaveFunctionComponent::myVars.

Referenced by RPAJastrow::checkOutVariables().

703 { myVars.getIndex(active); }
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
int getIndex(const std::string &vname) const
return the Index vaule for the named parameter

◆ copyFrom()

void copyFrom ( const kSpaceJastrow old)
private

Definition at line 783 of file kSpaceJastrow.cpp.

References kSpaceJastrow::CellVolume, kSpaceJastrow::Delta_e2iGr, kSpaceJastrow::Ion_rhoG, WaveFunctionComponent::myVars, kSpaceJastrow::NormConstant, kSpaceJastrow::num_elecs, kSpaceJastrow::NumIons, kSpaceJastrow::NumIonSpecies, kSpaceJastrow::NumSpins, kSpaceJastrow::OneBody_e2iGr, kSpaceJastrow::OneBody_rhoG, kSpaceJastrow::OneBodyCoefs, kSpaceJastrow::OneBodyGvecs, kSpaceJastrow::OneBodyID, kSpaceJastrow::OneBodyPhase, kSpaceJastrow::OneBodySymmCoefs, kSpaceJastrow::OneBodySymmType, kSpaceJastrow::OneBodyVarMap, kSpaceJastrow::Prefactor, kSpaceJastrow::TwoBody_e2iGr_new, kSpaceJastrow::TwoBody_e2iGr_old, kSpaceJastrow::TwoBody_rhoG, kSpaceJastrow::TwoBodyCoefs, kSpaceJastrow::TwoBodyGvecs, kSpaceJastrow::TwoBodyID, kSpaceJastrow::TwoBodyPhase, kSpaceJastrow::TwoBodySymmCoefs, kSpaceJastrow::TwoBodySymmType, and kSpaceJastrow::TwoBodyVarMap.

784 {
785  CellVolume = old.CellVolume;
786  NormConstant = old.NormConstant;
787  num_elecs = old.num_elecs;
788  NumSpins = old.NumSpins;
789  NumIons = old.NumIons;
790  NumIonSpecies = old.NumIonSpecies;
791  OneBodyGvecs = old.OneBodyGvecs;
792  TwoBodyGvecs = old.TwoBodyGvecs;
793  OneBodySymmCoefs = old.OneBodySymmCoefs;
794  TwoBodySymmCoefs = old.TwoBodySymmCoefs;
795  OneBodyCoefs = old.OneBodyCoefs;
796  TwoBodyCoefs = old.TwoBodyCoefs;
797  OneBodySymmType = old.OneBodySymmType;
798  TwoBodySymmType = old.TwoBodySymmType;
799  Ion_rhoG = old.Ion_rhoG;
800  OneBody_rhoG = old.OneBody_rhoG;
801  TwoBody_rhoG = old.TwoBody_rhoG;
802  OneBodyPhase = old.OneBodyPhase;
803  TwoBodyPhase = old.TwoBodyPhase;
804  OneBody_e2iGr = old.OneBody_e2iGr;
805  TwoBody_e2iGr_new = old.TwoBody_e2iGr_new;
806  TwoBody_e2iGr_old = old.TwoBody_e2iGr_old;
807  Delta_e2iGr = old.Delta_e2iGr;
808  OneBodyID = old.OneBodyID;
809  TwoBodyID = old.TwoBodyID;
810  //copy the variable map
811  myVars = old.myVars;
812  TwoBodyVarMap = old.TwoBodyVarMap;
813  OneBodyVarMap = old.OneBodyVarMap;
814  Prefactor = old.Prefactor;
815  //for (int i=0; i<OneBodySymmCoefs.size(); i++) {
816  // std::stringstream name_real, name_imag;
817  // name_real << OneBodyID << "_" << 2*i;
818  // name_imag << OneBodyID << "_" << 2*i+1;
819  // VarMap[name_real.str()] = &(OneBodySymmCoefs[i].cG.real());
820  // VarMap[name_imag.str()] = &(OneBodySymmCoefs[i].cG.imag());
821  //}
822  //for (int i=0; i<TwoBodySymmCoefs.size(); i++) {
823  // std::stringstream name;
824  // name << TwoBodyID << "_" << i;
825  // VarMap[name.str()] = &(TwoBodySymmCoefs[i].cG);
826  //}
827 }
std::vector< ComplexType > OneBody_e2iGr
std::vector< kSpaceCoef< ComplexType > > OneBodySymmCoefs
Definition: kSpaceJastrow.h:95
std::vector< ComplexType > OneBody_rhoG
std::vector< int > OneBodyVarMap
Matrix< ComplexType > Delta_e2iGr
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
std::vector< ComplexType > TwoBody_e2iGr_new
std::vector< PosType > OneBodyGvecs
Definition: kSpaceJastrow.h:90
std::vector< RealType > TwoBodyPhase
std::vector< RealType > TwoBodyCoefs
std::vector< ComplexType > Ion_rhoG
std::vector< ComplexType > OneBodyCoefs
std::vector< ComplexType > TwoBody_rhoG
std::vector< kSpaceCoef< RealType > > TwoBodySymmCoefs
Definition: kSpaceJastrow.h:96
std::vector< int > TwoBodyVarMap
std::vector< ComplexType > TwoBody_e2iGr_old
std::vector< RealType > OneBodyPhase
std::vector< PosType > TwoBodyGvecs
Definition: kSpaceJastrow.h:91

◆ copyFromBuffer()

void copyFromBuffer ( ParticleSet P,
WFBufferType buf 
)
overridevirtual

For particle-by-particle move.

Copy data or attach memory from a walker buffer to the objects of this class. The log value, P.G and P.L contribution from the objects of this class are also added.

Parameters
Pparticle set
bufAnonymous storage

Implements WaveFunctionComponent.

Definition at line 661 of file kSpaceJastrow.cpp.

References qmcplusplus::dot(), eval_e2iphi(), kSpaceJastrow::num_elecs, ParticleSet::R, kSpaceJastrow::TwoBody_e2iGr_new, kSpaceJastrow::TwoBody_rhoG, kSpaceJastrow::TwoBodyCoefs, kSpaceJastrow::TwoBodyGvecs, and kSpaceJastrow::TwoBodyPhase.

662 {
663  for (int i = 0; i < TwoBodyCoefs.size(); i++)
664  TwoBody_rhoG[i] = ComplexType();
665  for (int iat = 0; iat < num_elecs; iat++)
666  {
667  for (int i = 0; i < TwoBodyCoefs.size(); i++)
668  TwoBodyPhase[i] = dot(TwoBodyGvecs[i], P.R[iat]);
670  for (int i = 0; i < TwoBodyCoefs.size(); i++)
672  }
673 }
std::vector< ComplexType > TwoBody_e2iGr_new
std::vector< RealType > TwoBodyPhase
std::vector< RealType > TwoBodyCoefs
std::complex< RealType > ComplexType
Definition: kSpaceJastrow.h:79
std::vector< ComplexType > TwoBody_rhoG
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
void eval_e2iphi(int n, const T *restrict phi, T *restrict phase_r, T *restrict phase_i)
Definition: e2iphi.h:61
std::vector< PosType > TwoBodyGvecs
Definition: kSpaceJastrow.h:91

◆ Equivalent()

bool Equivalent ( PosType  G1,
PosType  G2 
)
private

Definition at line 145 of file kSpaceJastrow.cpp.

References qmcplusplus::abs(), qmcplusplus::conj(), qmcplusplus::dot(), qmcplusplus::Units::charge::e, kSpaceJastrow::NumIonSpecies, and kSpaceJastrow::StructureFactor().

Referenced by kSpaceJastrow::sortGvecs().

146 {
147  return (!(*this)(G1, G2) && !(*this)(G2, G1));
148  if (std::abs(dot(G1, G1) - dot(G2, G2)) > 1.0e-8)
149  return false;
150  std::vector<ComplexType> rho_G1(NumIonSpecies), rho_G2(NumIonSpecies);
151  StructureFactor(G1, rho_G1);
152  StructureFactor(G2, rho_G2);
153  for (int j = 0; j < NumIonSpecies; j++)
154  for (int i = j; i < NumIonSpecies; i++)
155  {
156  ComplexType zG1 = rho_G1[i] * qmcplusplus::conj(rho_G1[j]);
157  ComplexType zG2 = rho_G2[i] * qmcplusplus::conj(rho_G2[j]);
158  RealType SG1 = std::real(zG1);
159  RealType SG2 = std::real(zG2);
160  if (std::abs(SG1 - SG2) > 1.0e-8)
161  return false;
162  }
163  return true;
164 }
QMCTraits::RealType real
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
std::complex< RealType > ComplexType
Definition: kSpaceJastrow.h:79
float conj(const float &c)
Workaround to allow conj on scalar to return real instead of complex.
QMCTraits::RealType RealType
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
void StructureFactor(PosType G, std::vector< ComplexType > &rho_G)

◆ evalGrad()

kSpaceJastrow::GradType evalGrad ( ParticleSet P,
int  iat 
)
overridevirtual

return the current gradient for the iat-th particle

Parameters
Pquantum particle set
iatparticle index
Returns
the gradient of the iat-th particle

Reimplemented from WaveFunctionComponent.

Definition at line 429 of file kSpaceJastrow.cpp.

References qmcplusplus::conj(), qmcplusplus::dot(), eval_e2iphi(), ParticleSet::getTotalNum(), qmcplusplus::imag(), qmcplusplus::Units::force::N, kSpaceJastrow::OneBody_e2iGr, kSpaceJastrow::OneBodyCoefs, kSpaceJastrow::OneBodyGvecs, kSpaceJastrow::OneBodyPhase, kSpaceJastrow::Prefactor, ParticleSet::R, qmcplusplus::real(), kSpaceJastrow::TwoBody_e2iGr_new, kSpaceJastrow::TwoBody_rhoG, kSpaceJastrow::TwoBodyCoefs, kSpaceJastrow::TwoBodyGvecs, and kSpaceJastrow::TwoBodyPhase.

430 {
431  // RealType J1(0.0), J2(0.0);
433  int N = P.getTotalNum();
434  ComplexType eye(0.0, 1.0);
435  int nOne = OneBodyGvecs.size();
436  // for (int iat=0; iat<N; iat++) {
437  PosType r(P.R[iat]);
438  for (int i = 0; i < nOne; i++)
439  OneBodyPhase[i] = dot(OneBodyGvecs[i], r);
441  for (int i = 0; i < nOne; i++)
442  {
444  // J1 += Prefactor*real(z);
445  G += -Prefactor * real(z * eye) * OneBodyGvecs[i];
446  // L[iat] += -Prefactor*dot(OneBodyGvecs[i],OneBodyGvecs[i])*real(z);
447  }
448  // }
449  // Do two-body part
450  int nTwo = TwoBodyGvecs.size();
451  for (int i = 0; i < nTwo; i++)
452  TwoBody_rhoG[i] = ComplexType();
453  for (int iat2 = 0; iat2 < N; iat2++)
454  {
455  PosType rp(P.R[iat2]);
456  for (int iG = 0; iG < nTwo; iG++)
457  TwoBodyPhase[iG] = dot(TwoBodyGvecs[iG], rp);
459  for (int iG = 0; iG < nTwo; iG++)
460  TwoBody_rhoG[iG] += TwoBody_e2iGr_new[iG];
461  }
462  // std::cerr << "TwoBody_rhoG = ";
463  // for (int i=0; i<nTwo; i++)
464  // std::cerr << TwoBody_rhoG[i] << " ";
465  // std::cerr << std::endl;
466  // for (int i=0; i<nTwo; i++)
467  // J2 += Prefactor*TwoBodyCoefs[i]*norm(TwoBody_rhoG[i]);
468  // for (int iat=0; iat<N; iat++) {
469  // PosType r(P.R[iat]);
470  for (int i = 0; i < nTwo; i++)
471  TwoBodyPhase[i] = dot(TwoBodyGvecs[i], r);
473  for (int i = 0; i < nTwo; i++)
474  {
475  PosType Gvec(TwoBodyGvecs[i]);
477  G += -Prefactor * 2.0 * Gvec * TwoBodyCoefs[i] * imag(qmcplusplus::conj(TwoBody_rhoG[i]) * z);
478  // L[iat] += Prefactor*2.0*TwoBodyCoefs[i]*dot(Gvec,Gvec)*(-real(z*qmcplusplus::conj(TwoBody_rhoG[i])) + 1.0);
479  }
480  // }
481  return G;
482 }
std::vector< ComplexType > OneBody_e2iGr
QTBase::GradType GradType
Definition: Configuration.h:62
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
std::vector< ComplexType > TwoBody_e2iGr_new
QMCTraits::PosType PosType
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
std::vector< PosType > OneBodyGvecs
Definition: kSpaceJastrow.h:90
std::vector< RealType > TwoBodyPhase
std::vector< RealType > TwoBodyCoefs
std::complex< RealType > ComplexType
Definition: kSpaceJastrow.h:79
float conj(const float &c)
Workaround to allow conj on scalar to return real instead of complex.
std::vector< ComplexType > OneBodyCoefs
std::vector< ComplexType > TwoBody_rhoG
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
std::vector< RealType > OneBodyPhase
void eval_e2iphi(int n, const T *restrict phi, T *restrict phase_r, T *restrict phase_i)
Definition: e2iphi.h:61
std::vector< PosType > TwoBodyGvecs
Definition: kSpaceJastrow.h:91

◆ evaluateDerivatives()

void evaluateDerivatives ( ParticleSet P,
const opt_variables_type active,
Vector< ValueType > &  dlogpsi,
Vector< ValueType > &  dhpsioverpsi 
)
override

Definition at line 829 of file kSpaceJastrow.cpp.

References qmcplusplus::conj(), qmcplusplus::convertToReal(), qmcplusplus::dot(), eval_e2iphi(), ParticleSet::G, ParticleSet::getTotalNum(), qmcplusplus::imag(), WaveFunctionComponent::myVars, qmcplusplus::Units::force::N, norm(), kSpaceJastrow::OneBody_e2iGr, kSpaceJastrow::OneBodyGvecs, kSpaceJastrow::OneBodyPhase, kSpaceJastrow::OneBodyVarMap, kSpaceJastrow::Prefactor, ParticleSet::R, qmcplusplus::real(), VariableSet::recompute(), VariableSet::size(), kSpaceJastrow::TwoBody_e2iGr_new, kSpaceJastrow::TwoBody_rhoG, kSpaceJastrow::TwoBodyGvecs, kSpaceJastrow::TwoBodyPhase, kSpaceJastrow::TwoBodyVarMap, and VariableSet::where().

833 {
834  bool recalculate(false);
835  for (int k = 0; k < myVars.size(); ++k)
836  {
837  int kk = myVars.where(k);
838  if (kk < 0)
839  continue;
840  if (active.recompute(kk))
841  recalculate = true;
842  }
843  if (recalculate)
844  {
845  int N = P.getTotalNum();
846  ComplexType eye(0.0, 1.0);
847  RealType tmp_dot;
848  int nOne = OneBodyGvecs.size();
849  if (nOne)
850  {
851  for (int iat = 0; iat < N; iat++)
852  {
853  PosType r(P.R[iat]);
854  for (int i = 0; i < nOne; i++)
855  OneBodyPhase[i] = dot(OneBodyGvecs[i], r);
857  for (int i = 0; i < nOne; i++)
858  {
860  int kk = myVars.where(OneBodyVarMap[i]);
861  if (kk >= 0)
862  {
863  //real part of coeff
864  dlogpsi[kk] += ValueType(Prefactor * real(z));
865  //convertToReal(dot(OneBodyGvecs[i],P.G[iat]),tmp_dot);
866  convertToReal(dot(P.G[iat], OneBodyGvecs[i]), tmp_dot);
867  dhpsioverpsi[kk] += ValueType(0.5 * Prefactor * dot(OneBodyGvecs[i], OneBodyGvecs[i]) * real(z) +
868  Prefactor * real(z * eye) * tmp_dot);
869  // + Prefactor*real(z*eye)*real(dot(OneBodyGvecs[i],P.G[iat]));
870  //imaginary part of coeff,
871  dlogpsi[kk + 1] += ValueType(Prefactor * real(eye * z));
872  //mius here due to i*i term
873  //dhpsioverpsi[kk+1] += 0.5*Prefactor*dot(OneBodyGvecs[i],OneBodyGvecs[i])*real(eye*z) - Prefactor*real(z)*real(dot(OneBodyGvecs[i],P.G[iat]));
874  dhpsioverpsi[kk + 1] += ValueType(0.5 * Prefactor * dot(OneBodyGvecs[i], OneBodyGvecs[i]) * real(eye * z) -
875  Prefactor * real(z) * tmp_dot);
876  }
877  }
878  }
879  }
880  // Do two-body part
881  int nTwo = TwoBodyGvecs.size();
882  for (int i = 0; i < nTwo; i++)
883  TwoBody_rhoG[i] = ComplexType();
884  for (int iat = 0; iat < N; iat++)
885  {
886  PosType r(P.R[iat]);
887  for (int iG = 0; iG < nTwo; iG++)
888  TwoBodyPhase[iG] = dot(TwoBodyGvecs[iG], r);
890  for (int iG = 0; iG < nTwo; iG++)
891  TwoBody_rhoG[iG] += TwoBody_e2iGr_new[iG];
892  }
893  for (int i = 0; i < nTwo; i++)
894  {
895  int kk = myVars.where(TwoBodyVarMap[i]);
896  if (kk >= 0)
897  {
898  dlogpsi[kk] += ValueType(Prefactor * norm(TwoBody_rhoG[i]));
899  }
900  }
901  for (int iat = 0; iat < N; iat++)
902  {
903  PosType r(P.R[iat]);
904  for (int i = 0; i < nTwo; i++)
905  TwoBodyPhase[i] = dot(TwoBodyGvecs[i], r);
907  for (int i = 0; i < nTwo; i++)
908  {
909  PosType Gvec(TwoBodyGvecs[i]);
911  int kk = myVars.where(TwoBodyVarMap[i]);
912  if (kk > 0)
913  {
914  convertToReal(dot(P.G[iat], Gvec), tmp_dot);
915  //dhpsioverpsi[kk] -= Prefactor*dot(Gvec,Gvec)*(-real(z*qmcplusplus::conj(TwoBody_rhoG[i])) + 1.0) - Prefactor*2.0*real(dot(P.G[iat],Gvec))*imag(qmcplusplus::conj(TwoBody_rhoG[i])*z);
916  dhpsioverpsi[kk] -=
917  ValueType(Prefactor * dot(Gvec, Gvec) * (-real(z * qmcplusplus::conj(TwoBody_rhoG[i])) + 1.0) -
918  Prefactor * 2.0 * tmp_dot * imag(qmcplusplus::conj(TwoBody_rhoG[i]) * z));
919  }
920  }
921  }
922  }
923 }
std::vector< ComplexType > OneBody_e2iGr
void convertToReal(const T1 &in, T2 &out)
generic conversion from type T1 to type T2 using implicit conversion
Definition: ConvertToReal.h:32
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
std::vector< int > OneBodyVarMap
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
std::vector< ComplexType > TwoBody_e2iGr_new
QMCTraits::PosType PosType
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
double norm(const zVec &c)
Definition: VectorOps.h:118
std::vector< PosType > OneBodyGvecs
Definition: kSpaceJastrow.h:90
QTBase::ValueType ValueType
Definition: Configuration.h:60
int where(int i) const
return the locator of the i-th Index
Definition: VariableSet.h:90
std::vector< RealType > TwoBodyPhase
size_type size() const
return the size
Definition: VariableSet.h:88
std::complex< RealType > ComplexType
Definition: kSpaceJastrow.h:79
float conj(const float &c)
Workaround to allow conj on scalar to return real instead of complex.
QMCTraits::RealType RealType
std::vector< ComplexType > TwoBody_rhoG
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
std::vector< int > TwoBodyVarMap
std::vector< RealType > OneBodyPhase
void eval_e2iphi(int n, const T *restrict phi, T *restrict phase_r, T *restrict phase_i)
Definition: e2iphi.h:61
std::vector< PosType > TwoBodyGvecs
Definition: kSpaceJastrow.h:91

◆ evaluateLog()

kSpaceJastrow::LogValue evaluateLog ( const ParticleSet P,
ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L 
)
overridevirtual

evaluate the value of the WaveFunctionComponent from scratch

Parameters
[in]Pactive ParticleSet
[out]GGradients, $\nabla\ln\Psi$
[out]LLaplacians, $\nabla^2\ln\Psi$
Returns
the log value

Mainly for walker-by-walker move. The initial stage of particle-by-particle move also uses this. causes complete state update in WFC's

Implements WaveFunctionComponent.

Definition at line 369 of file kSpaceJastrow.cpp.

References qmcplusplus::conj(), qmcplusplus::dot(), eval_e2iphi(), ParticleSet::getTotalNum(), qmcplusplus::imag(), qmcplusplus::Units::force::N, norm(), kSpaceJastrow::OneBody_e2iGr, kSpaceJastrow::OneBodyCoefs, kSpaceJastrow::OneBodyGvecs, kSpaceJastrow::OneBodyPhase, kSpaceJastrow::Prefactor, ParticleSet::R, qmcplusplus::real(), kSpaceJastrow::TwoBody_e2iGr_new, kSpaceJastrow::TwoBody_rhoG, kSpaceJastrow::TwoBodyCoefs, kSpaceJastrow::TwoBodyGvecs, and kSpaceJastrow::TwoBodyPhase.

Referenced by kSpaceJastrow::registerData(), and kSpaceJastrow::updateBuffer().

372 {
373  RealType J1(0.0), J2(0.0);
374  int N = P.getTotalNum();
375  ComplexType eye(0.0, 1.0);
376  int nOne = OneBodyGvecs.size();
377  for (int iat = 0; iat < N; iat++)
378  {
379  PosType r(P.R[iat]);
380  for (int i = 0; i < nOne; i++)
381  OneBodyPhase[i] = dot(OneBodyGvecs[i], r);
383  for (int i = 0; i < nOne; i++)
384  {
386  J1 += Prefactor * real(z);
387  G[iat] += -Prefactor * real(z * eye) * OneBodyGvecs[i];
388  L[iat] += -Prefactor * dot(OneBodyGvecs[i], OneBodyGvecs[i]) * real(z);
389  }
390  }
391  // Do two-body part
392  int nTwo = TwoBodyGvecs.size();
393  for (int i = 0; i < nTwo; i++)
394  TwoBody_rhoG[i] = ComplexType();
395  for (int iat = 0; iat < N; iat++)
396  {
397  PosType r(P.R[iat]);
398  for (int iG = 0; iG < nTwo; iG++)
399  TwoBodyPhase[iG] = dot(TwoBodyGvecs[iG], r);
401  for (int iG = 0; iG < nTwo; iG++)
402  TwoBody_rhoG[iG] += TwoBody_e2iGr_new[iG];
403  }
404  // std::cerr << "TwoBody_rhoG = ";
405  // for (int i=0; i<nTwo; i++)
406  // std::cerr << TwoBody_rhoG[i] << " ";
407  // std::cerr << std::endl;
408  for (int i = 0; i < nTwo; i++)
409  J2 += Prefactor * TwoBodyCoefs[i] * norm(TwoBody_rhoG[i]);
410  for (int iat = 0; iat < N; iat++)
411  {
412  PosType r(P.R[iat]);
413  for (int i = 0; i < nTwo; i++)
414  TwoBodyPhase[i] = dot(TwoBodyGvecs[i], r);
416  for (int i = 0; i < nTwo; i++)
417  {
418  PosType Gvec(TwoBodyGvecs[i]);
420  G[iat] += -Prefactor * 2.0 * Gvec * TwoBodyCoefs[i] * imag(qmcplusplus::conj(TwoBody_rhoG[i]) * z);
421  L[iat] +=
422  Prefactor * 2.0 * TwoBodyCoefs[i] * dot(Gvec, Gvec) * (-real(z * qmcplusplus::conj(TwoBody_rhoG[i])) + 1.0);
423  }
424  }
425  return J1 + J2;
426 }
std::vector< ComplexType > OneBody_e2iGr
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
std::vector< ComplexType > TwoBody_e2iGr_new
QMCTraits::PosType PosType
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
double norm(const zVec &c)
Definition: VectorOps.h:118
std::vector< PosType > OneBodyGvecs
Definition: kSpaceJastrow.h:90
std::vector< RealType > TwoBodyPhase
std::vector< RealType > TwoBodyCoefs
std::complex< RealType > ComplexType
Definition: kSpaceJastrow.h:79
float conj(const float &c)
Workaround to allow conj on scalar to return real instead of complex.
std::vector< ComplexType > OneBodyCoefs
QMCTraits::RealType RealType
std::vector< ComplexType > TwoBody_rhoG
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
std::vector< RealType > OneBodyPhase
void eval_e2iphi(int n, const T *restrict phi, T *restrict phase_r, T *restrict phase_i)
Definition: e2iphi.h:61
std::vector< PosType > TwoBodyGvecs
Definition: kSpaceJastrow.h:91

◆ evaluateRatiosAlltoOne()

void evaluateRatiosAlltoOne ( ParticleSet P,
std::vector< ValueType > &  ratios 
)
override

evaluate the ratio

Definition at line 575 of file kSpaceJastrow.cpp.

References qmcplusplus::conj(), qmcplusplus::dot(), eval_e2iphi(), qmcplusplus::exp(), ParticleSet::getActivePos(), ParticleSet::getTotalNum(), qmcplusplus::Units::force::N, qmcplusplus::n, norm(), kSpaceJastrow::OneBody_e2iGr, kSpaceJastrow::OneBodyCoefs, kSpaceJastrow::OneBodyGvecs, kSpaceJastrow::OneBodyPhase, kSpaceJastrow::Prefactor, ParticleSet::R, qmcplusplus::real(), kSpaceJastrow::TwoBody_e2iGr_new, kSpaceJastrow::TwoBody_e2iGr_old, kSpaceJastrow::TwoBody_rhoG, kSpaceJastrow::TwoBodyCoefs, kSpaceJastrow::TwoBodyGvecs, and kSpaceJastrow::TwoBodyPhase.

576 {
577  RealType J1new(0.0);
578  const PosType& rnew(P.getActivePos());
579  // Compute one-body contribution
580  int nOne = OneBodyGvecs.size();
581  for (int i = 0; i < nOne; i++)
582  OneBodyPhase[i] = dot(OneBodyGvecs[i], rnew);
584  // //
585  for (int i = 0; i < nOne; i++)
587  // Now, do two-body part
588  int nTwo = TwoBodyGvecs.size();
589  for (int i = 0; i < nTwo; i++)
590  TwoBodyPhase[i] = dot(TwoBodyGvecs[i], rnew);
592  int N = P.getTotalNum();
593  for (int n = 0; n < N; n++)
594  {
595  RealType J1old(0.0), J2Rat(0.0);
596  const PosType& rold(P.R[n]);
597  for (int i = 0; i < nOne; i++)
598  OneBodyPhase[i] = dot(OneBodyGvecs[i], rold);
600  for (int i = 0; i < nOne; i++)
602  for (int i = 0; i < nTwo; i++)
603  TwoBodyPhase[i] = dot(TwoBodyGvecs[i], rold);
605  for (int i = 0; i < nTwo; i++)
606  {
608  ComplexType rho_G_old = TwoBody_rhoG[i];
609  J2Rat += Prefactor * TwoBodyCoefs[i] * (std::norm(rho_G_new) - std::norm(rho_G_old));
610  }
611  ratios[n] = std::exp(J1new - J1old + J2Rat);
612  }
613 }
std::vector< ComplexType > OneBody_e2iGr
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
std::vector< ComplexType > TwoBody_e2iGr_new
QMCTraits::PosType PosType
double norm(const zVec &c)
Definition: VectorOps.h:118
std::vector< PosType > OneBodyGvecs
Definition: kSpaceJastrow.h:90
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
std::complex< RealType > ComplexType
Definition: kSpaceJastrow.h:79
float conj(const float &c)
Workaround to allow conj on scalar to return real instead of complex.
std::vector< ComplexType > OneBodyCoefs
QMCTraits::RealType RealType
std::vector< ComplexType > TwoBody_rhoG
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
std::vector< ComplexType > TwoBody_e2iGr_old
std::vector< RealType > OneBodyPhase
void eval_e2iphi(int n, const T *restrict phi, T *restrict phase_r, T *restrict phase_i)
Definition: e2iphi.h:61
std::vector< PosType > TwoBodyGvecs
Definition: kSpaceJastrow.h:91

◆ extractOptimizableObjectRefs()

void extractOptimizableObjectRefs ( UniqueOptObjRefs opt_obj_refs)
inlineoverridevirtual

extract underlying OptimizableObject references

Parameters
opt_obj_refsaggregated list of optimizable object references

Reimplemented from WaveFunctionComponent.

Definition at line 163 of file kSpaceJastrow.h.

References UniqueOptObjRefs::push_back().

163 { opt_obj_refs.push_back(*this); }

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements WaveFunctionComponent.

Definition at line 158 of file kSpaceJastrow.h.

158 { return "kSpaceJastrow"; }

◆ isOptimizable()

bool isOptimizable ( ) const
inlineoverridevirtual

if true, this contains optimizable components

Reimplemented from WaveFunctionComponent.

Definition at line 160 of file kSpaceJastrow.h.

160 { return true; }

◆ makeClone()

std::unique_ptr< WaveFunctionComponent > makeClone ( ParticleSet tqp) const
overridevirtual

make clone

Parameters
tqptarget Quantum ParticleSet
deepcopyif true, make a decopy

If not true, return a proxy class

Reimplemented from WaveFunctionComponent.

Definition at line 756 of file kSpaceJastrow.cpp.

References kSpaceJastrow::Ions.

757 {
758  auto kj = std::make_unique<kSpaceJastrow>(Ions);
759  kj->copyFrom(*this);
760  // kSpaceJastrow *kj = new kSpaceJastrow(*this);
761  // kj->VarMap.clear();
762  // for (int i=0; i<OneBodySymmCoefs.size(); i++) {
763  // std::stringstream name_real, name_imag;
764  // name_real << OneBodyID << "_" << 2*i;
765  // name_imag << OneBodyID << "_" << 2*i+1;
766  // kj->VarMap[name_real.str()] = &(kj->OneBodySymmCoefs[i].cG.real());
767  // kj->VarMap[name_imag.str()] = &(kj->OneBodySymmCoefs[i].cG.imag());
768  // }
769  // for (int i=0; i<TwoBodySymmCoefs.size(); i++) {
770  // std::stringstream name;
771  // name << TwoBodyID << "_" << i;
772  // kj->VarMap[name.str()] = &(kj->TwoBodySymmCoefs[i].cG);
773  // }
774  return kj;
775 }
const ParticleSet & Ions

◆ operator()()

bool operator() ( PosType  G1,
PosType  G2 
)

Definition at line 124 of file kSpaceJastrow.cpp.

References qmcplusplus::abs(), qmcplusplus::conj(), qmcplusplus::dot(), qmcplusplus::Units::charge::e, kSpaceJastrow::NumIonSpecies, and kSpaceJastrow::StructureFactor().

125 {
126  if (std::abs(dot(G1, G1) - dot(G2, G2)) > 1.0e-8)
127  return dot(G1, G1) < dot(G2, G2);
128  // if (Equivalent(G1,G2)) return false;
129  std::vector<ComplexType> rho_G1(NumIonSpecies), rho_G2(NumIonSpecies);
130  StructureFactor(G1, rho_G1);
131  StructureFactor(G2, rho_G2);
132  for (int i = 0; i < NumIonSpecies; i++)
133  for (int j = i + 1; j < NumIonSpecies; j++)
134  {
135  ComplexType zG1 = rho_G1[i] * qmcplusplus::conj(rho_G1[j]);
136  ComplexType zG2 = rho_G2[i] * qmcplusplus::conj(rho_G2[j]);
137  RealType SG1 = std::real(zG1);
138  RealType SG2 = std::real(zG2);
139  if (std::abs(SG1 - SG2) > 1.0e-8)
140  return SG1 < SG2;
141  }
142  return false;
143 }
QMCTraits::RealType real
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
std::complex< RealType > ComplexType
Definition: kSpaceJastrow.h:79
float conj(const float &c)
Workaround to allow conj on scalar to return real instead of complex.
QMCTraits::RealType RealType
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
void StructureFactor(PosType G, std::vector< ComplexType > &rho_G)

◆ printOneBody()

void printOneBody ( std::ostream &  os)

output jastrow coefficients

Definition at line 925 of file kSpaceJastrow.cpp.

References kSpaceJastrow::OneBodyCoefs, and kSpaceJastrow::OneBodyGvecs.

Referenced by kSpaceJastrowBuilder::outputJastrow().

926 {
927  for (int i = 0; i < OneBodyCoefs.size(); i++)
928  {
929  PosType gvec = OneBodyGvecs[i];
930  ComplexType coeff = OneBodyCoefs[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;
933  }
934 }
QMCTraits::PosType PosType
std::vector< PosType > OneBodyGvecs
Definition: kSpaceJastrow.h:90
std::complex< RealType > ComplexType
Definition: kSpaceJastrow.h:79
std::vector< ComplexType > OneBodyCoefs

◆ printTwoBody()

void printTwoBody ( std::ostream &  os)

Definition at line 936 of file kSpaceJastrow.cpp.

References kSpaceJastrow::TwoBodyCoefs, and kSpaceJastrow::TwoBodyGvecs.

Referenced by kSpaceJastrowBuilder::outputJastrow().

937 {
938  for (int i = 0; i < TwoBodyCoefs.size(); i++)
939  {
940  PosType gvec = TwoBodyGvecs[i];
941  ComplexType coeff = TwoBodyCoefs[i];
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;
944  }
945 }
QMCTraits::PosType PosType
std::vector< RealType > TwoBodyCoefs
std::complex< RealType > ComplexType
Definition: kSpaceJastrow.h:79
std::vector< PosType > TwoBodyGvecs
Definition: kSpaceJastrow.h:91

◆ put()

bool put ( xmlNodePtr  cur)

process input file

Definition at line 754 of file kSpaceJastrow.cpp.

754 { return true; }

◆ ratio()

kSpaceJastrow::PsiValue ratio ( ParticleSet P,
int  iat 
)
overridevirtual

evaluate the ratio of the new to old WaveFunctionComponent value

Parameters
Pthe active ParticleSet
iatthe index of a particle
Returns
$ \psi( \{ {\bf R}^{'} \} )/ \psi( \{ {\bf R}\})$

Specialized for particle-by-particle move

Implements WaveFunctionComponent.

Definition at line 536 of file kSpaceJastrow.cpp.

References qmcplusplus::conj(), qmcplusplus::dot(), eval_e2iphi(), qmcplusplus::exp(), ParticleSet::getActivePos(), norm(), kSpaceJastrow::OneBody_e2iGr, kSpaceJastrow::OneBodyCoefs, kSpaceJastrow::OneBodyGvecs, kSpaceJastrow::OneBodyPhase, kSpaceJastrow::Prefactor, ParticleSet::R, qmcplusplus::real(), kSpaceJastrow::TwoBody_e2iGr_new, kSpaceJastrow::TwoBody_e2iGr_old, kSpaceJastrow::TwoBody_rhoG, kSpaceJastrow::TwoBodyCoefs, kSpaceJastrow::TwoBodyGvecs, and kSpaceJastrow::TwoBodyPhase.

537 {
538  RealType J1new(0.0), J1old(0.0), J2new(0.0), J2old(0.0);
539  const PosType &rnew(P.getActivePos()), &rold(P.R[iat]);
540  // Compute one-body contribution
541  int nOne = OneBodyGvecs.size();
542  for (int i = 0; i < nOne; i++)
543  OneBodyPhase[i] = dot(OneBodyGvecs[i], rnew);
545  for (int i = 0; i < nOne; i++)
547  for (int i = 0; i < nOne; i++)
548  OneBodyPhase[i] = dot(OneBodyGvecs[i], rold);
550  for (int i = 0; i < nOne; i++)
552  // Now, do two-body part
553  int nTwo = TwoBodyGvecs.size();
554  for (int i = 0; i < nTwo; i++)
555  TwoBodyPhase[i] = dot(TwoBodyGvecs[i], rold);
557  for (int i = 0; i < nTwo; i++)
558  TwoBodyPhase[i] = dot(TwoBodyGvecs[i], rnew);
560  for (int i = 0; i < nTwo; i++)
561  {
562  ComplexType rho_G = TwoBody_rhoG[i];
563  J2old += Prefactor * TwoBodyCoefs[i] * std::norm(rho_G);
564  }
565  for (int i = 0; i < nTwo; i++)
566  {
568  J2new += Prefactor * TwoBodyCoefs[i] * std::norm(rho_G);
569  }
570  return std::exp(static_cast<PsiValue>(J1new + J2new - (J1old + J2old)));
571 }
std::vector< ComplexType > OneBody_e2iGr
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
std::vector< ComplexType > TwoBody_e2iGr_new
QMCTraits::PosType PosType
double norm(const zVec &c)
Definition: VectorOps.h:118
std::vector< PosType > OneBodyGvecs
Definition: kSpaceJastrow.h:90
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
std::complex< RealType > ComplexType
Definition: kSpaceJastrow.h:79
float conj(const float &c)
Workaround to allow conj on scalar to return real instead of complex.
std::vector< ComplexType > OneBodyCoefs
QMCTraits::RealType RealType
std::vector< ComplexType > TwoBody_rhoG
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
std::vector< ComplexType > TwoBody_e2iGr_old
std::vector< RealType > OneBodyPhase
void eval_e2iphi(int n, const T *restrict phi, T *restrict phase_r, T *restrict phase_i)
Definition: e2iphi.h:61
std::vector< PosType > TwoBodyGvecs
Definition: kSpaceJastrow.h:91

◆ ratioGrad()

kSpaceJastrow::PsiValue ratioGrad ( ParticleSet P,
int  iat,
GradType grad_iat 
)
overridevirtual

evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient

Parameters
Pthe active ParticleSet
iatthe index of a particle
grad_iatGradient for the active particle

Reimplemented from WaveFunctionComponent.

Definition at line 484 of file kSpaceJastrow.cpp.

References qmcplusplus::conj(), qmcplusplus::dot(), eval_e2iphi(), qmcplusplus::exp(), ParticleSet::getActivePos(), qmcplusplus::imag(), norm(), kSpaceJastrow::OneBody_e2iGr, kSpaceJastrow::OneBodyCoefs, kSpaceJastrow::OneBodyGvecs, kSpaceJastrow::OneBodyPhase, kSpaceJastrow::Prefactor, ParticleSet::R, qmcplusplus::real(), kSpaceJastrow::TwoBody_e2iGr_new, kSpaceJastrow::TwoBody_e2iGr_old, kSpaceJastrow::TwoBody_rhoG, kSpaceJastrow::TwoBodyCoefs, kSpaceJastrow::TwoBodyGvecs, and kSpaceJastrow::TwoBodyPhase.

485 {
486  ComplexType eye(0.0, 1.0);
487  RealType J1new(0.0), J1old(0.0), J2new(0.0), J2old(0.0);
488  const PosType &rnew(P.getActivePos()), &rold(P.R[iat]);
489  // Compute one-body contribution
490  int nOne = OneBodyGvecs.size();
491  for (int i = 0; i < nOne; i++)
492  OneBodyPhase[i] = dot(OneBodyGvecs[i], rnew);
494  for (int i = 0; i < nOne; i++)
495  {
497  J1new += Prefactor * real(z);
498  grad_iat += -Prefactor * real(z * eye) * OneBodyGvecs[i];
499  }
500  for (int i = 0; i < nOne; i++)
501  OneBodyPhase[i] = dot(OneBodyGvecs[i], rold);
503  for (int i = 0; i < nOne; i++)
505  // Now, do two-body part
506  int nTwo = TwoBodyGvecs.size();
507  for (int i = 0; i < nTwo; i++)
508  TwoBodyPhase[i] = dot(TwoBodyGvecs[i], rold);
510  for (int i = 0; i < nTwo; i++)
511  TwoBodyPhase[i] = dot(TwoBodyGvecs[i], rnew);
513  for (int i = 0; i < nTwo; i++)
514  {
515  ComplexType rho_G = TwoBody_rhoG[i];
516  J2old += Prefactor * TwoBodyCoefs[i] * std::norm(rho_G);
517  }
518  for (int i = 0; i < nTwo; i++)
519  {
521  J2new += Prefactor * TwoBodyCoefs[i] * std::norm(rho_G);
522  }
523  for (int i = 0; i < nTwo; i++)
524  {
525  PosType Gvec(TwoBodyGvecs[i]);
527  grad_iat += -Prefactor * 2.0 * TwoBodyGvecs[i] * TwoBodyCoefs[i] *
529  }
530  return std::exp(static_cast<PsiValue>(J1new + J2new - (J1old + J2old)));
531 }
std::vector< ComplexType > OneBody_e2iGr
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
std::vector< ComplexType > TwoBody_e2iGr_new
QMCTraits::PosType PosType
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
double norm(const zVec &c)
Definition: VectorOps.h:118
std::vector< PosType > OneBodyGvecs
Definition: kSpaceJastrow.h:90
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
std::complex< RealType > ComplexType
Definition: kSpaceJastrow.h:79
float conj(const float &c)
Workaround to allow conj on scalar to return real instead of complex.
std::vector< ComplexType > OneBodyCoefs
QMCTraits::RealType RealType
std::vector< ComplexType > TwoBody_rhoG
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
std::vector< ComplexType > TwoBody_e2iGr_old
std::vector< RealType > OneBodyPhase
void eval_e2iphi(int n, const T *restrict phi, T *restrict phase_r, T *restrict phase_i)
Definition: e2iphi.h:61
std::vector< PosType > TwoBodyGvecs
Definition: kSpaceJastrow.h:91

◆ registerData()

void registerData ( ParticleSet P,
WFBufferType buf 
)
overridevirtual

For particle-by-particle move.

Requests space in the buffer based on the data type sizes of the objects in this class.

Parameters
Pparticle set
bufAnonymous storage

Implements WaveFunctionComponent.

Definition at line 633 of file kSpaceJastrow.cpp.

References kSpaceJastrow::evaluateLog(), ParticleSet::G, ParticleSet::L, and WaveFunctionComponent::log_value_.

634 {
635  log_value_ = evaluateLog(P, P.G, P.L);
636  // eikr.resize(NumPtcls,MaxK);
637  // eikr_new.resize(MaxK);
638  // delta_eikr.resize(MaxK);
639  // for(int iat=0; iat<NumPtcls; iat++)
640  // copy(P.getSK().eikr[iat],P.getSK().eikr[iat]+MaxK,eikr[iat]);
641  // buf.add(Rhok.first_address(), Rhok.last_address());
642  // buf.add(U.first_address(), U.last_address());
643  // buf.add(d2U.first_address(), d2U.last_address());
644  // buf.add(FirstAddressOfdU,LastAddressOfdU);
645  // return LogValue;
646 }
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate the value of the WaveFunctionComponent from scratch

◆ resetParametersExclusive()

void resetParametersExclusive ( const opt_variables_type active)
finalvirtual

reset the parameters during optimizations.

Exclusive, see checkInVariablesExclusive

Implements OptimizableObject.

Definition at line 705 of file kSpaceJastrow.cpp.

References WaveFunctionComponent::myVars, kSpaceJastrow::OneBodyCoefs, kSpaceJastrow::OneBodySymmCoefs, kSpaceJastrow::TwoBodyCoefs, kSpaceJastrow::TwoBodySymmCoefs, and VariableSet::where().

706 {
707  int ii = 0;
708 
709  //Update the one body coefficients.
710  for (int i = 0; i < OneBodySymmCoefs.size(); i++)
711  {
712  //Reset and update the real part of one body term.
713 
714  int loc_r = myVars.where(ii);
715  if (loc_r >= 0)
716  {
717  myVars[ii] = active[loc_r]; //update the optimization parameter
718  //lvalue error with LLVM
719  OneBodySymmCoefs[i].cG = ComplexType(std::real(myVars[ii]), OneBodySymmCoefs[i].cG.imag());
720  //OneBodySymmCoefs[i].cG.real()=myVars[ii]; //update the coefficient from local opt parametr
721  ii++;
722  }
723  //The imaginary part...
724  int loc_i = myVars.where(ii);
725  if (loc_i >= 0)
726  {
727  myVars[ii] = active[loc_i];
728  //lvalue error with LLVM
729  OneBodySymmCoefs[i].cG = ComplexType(OneBodySymmCoefs[i].cG.real(), std::real(myVars[ii]));
730  //OneBodySymmCoefs[i].cG.imag()=myVars[ii];
731  ii++;
732  }
733  }
734 
735  //Update the two-body coefficients
736  for (int i = 0; i < TwoBodySymmCoefs.size(); i++)
737  {
738  int loc = myVars.where(ii);
739  if (loc >= 0)
740  {
741  myVars[ii] = active[loc];
742  TwoBodySymmCoefs[i].cG = std::real(myVars[ii]);
743  }
744  ii++;
745  }
746 
747 
748  for (int i = 0; i < OneBodySymmCoefs.size(); i++)
750  for (int i = 0; i < TwoBodySymmCoefs.size(); i++)
752 }
QMCTraits::RealType real
std::vector< kSpaceCoef< ComplexType > > OneBodySymmCoefs
Definition: kSpaceJastrow.h:95
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
int where(int i) const
return the locator of the i-th Index
Definition: VariableSet.h:90
std::vector< RealType > TwoBodyCoefs
std::complex< RealType > ComplexType
Definition: kSpaceJastrow.h:79
std::vector< ComplexType > OneBodyCoefs
std::vector< kSpaceCoef< RealType > > TwoBodySymmCoefs
Definition: kSpaceJastrow.h:96

◆ restore()

void restore ( int  iat)
overridevirtual

If a move for iat-th particle is rejected, restore to the content.

Parameters
iatindex of the particle whose new position was proposed

Ye: hopefully we can gradually move away from restore

Implements WaveFunctionComponent.

Definition at line 616 of file kSpaceJastrow.cpp.

617 {
618  //substract the addition in logRatio
619  //if(NeedToRestore) Rhok -= delta_eikr;
620 }

◆ setCoefficients()

void setCoefficients ( std::vector< RealType > &  oneBodyCoefs,
std::vector< RealType > &  twoBodyCoefs 
)

Definition at line 312 of file kSpaceJastrow.cpp.

References qmcplusplus::app_warning(), WaveFunctionComponent::myVars, kSpaceJastrow::OneBodyCoefs, kSpaceJastrow::OneBodySymmCoefs, kSpaceJastrow::TwoBodyCoefs, and kSpaceJastrow::TwoBodySymmCoefs.

Referenced by RPAJastrow::makeLongRange().

313 {
314  int kk(0);
315  // for (int i=0; i<oneBodyCoefs.size(); i++)
316  // std::cerr << "oneBodyCoefs[" << i << "] = " << oneBodyCoefs[i] << std::endl;
317  if (oneBodyCoefs.size() != 2 * OneBodySymmCoefs.size())
318  {
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()
322  << std::endl;
323  for (int i = 0; i < OneBodySymmCoefs.size(); i++)
324  {
325  OneBodySymmCoefs[i].cG = ComplexType();
326  myVars[kk++] = 0.0;
327  myVars[kk++] = 0.0;
329  }
330  }
331  else
332  {
333  for (int i = 0; i < OneBodySymmCoefs.size(); i++)
334  {
335  OneBodySymmCoefs[i].cG = ComplexType(oneBodyCoefs[2 * i + 0], oneBodyCoefs[2 * i + 1]);
336  myVars[kk++] = oneBodyCoefs[2 * i + 0];
337  myVars[kk++] = oneBodyCoefs[2 * i + 1];
339  }
340  }
341  if (twoBodyCoefs.size() != TwoBodySymmCoefs.size())
342  {
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()
346  << std::endl;
347  for (int i = 0; i < TwoBodySymmCoefs.size(); i++)
348  {
349  TwoBodySymmCoefs[i].cG = 0.0;
350  myVars[kk++] = 0.0;
352  }
353  }
354  else
355  {
356  for (int i = 0; i < TwoBodySymmCoefs.size(); i++)
357  {
358  TwoBodySymmCoefs[i].cG = twoBodyCoefs[i];
359  myVars[kk++] = twoBodyCoefs[i];
361  }
362  }
363 }
std::ostream & app_warning()
Definition: OutputManager.h:69
std::vector< kSpaceCoef< ComplexType > > OneBodySymmCoefs
Definition: kSpaceJastrow.h:95
opt_variables_type myVars
list of variables this WaveFunctionComponent handles
std::vector< RealType > TwoBodyCoefs
std::complex< RealType > ComplexType
Definition: kSpaceJastrow.h:79
std::vector< ComplexType > OneBodyCoefs
std::vector< kSpaceCoef< RealType > > TwoBodySymmCoefs
Definition: kSpaceJastrow.h:96

◆ setupCoefs()

void setupCoefs ( )
private

◆ setupGvecs()

void setupGvecs ( RealType  kcut,
std::vector< PosType > &  gvecs,
bool  useStructFact 
)
private

Definition at line 67 of file kSpaceJastrow.cpp.

References qmcplusplus::dot(), qmcplusplus::Units::charge::e, qmcplusplus::floor(), ParticleSet::getLattice(), qmcplusplus::Include(), kSpaceJastrow::Ions, norm(), kSpaceJastrow::NumIonSpecies, OHMMS_DIM, qmcplusplus::sqrt(), and kSpaceJastrow::StructureFactor().

Referenced by kSpaceJastrow::kSpaceJastrow().

68 {
69  gvecs.clear();
70  int maxIndex[OHMMS_DIM];
71  for (int i = 0; i < OHMMS_DIM; i++)
72  maxIndex[i] =
73  2 + (int)std::floor(std::sqrt(dot(Ions.getLattice().a(i), Ions.getLattice().a(i))) * kc / (2.0 * M_PI));
74  std::vector<ComplexType> rho_G(NumIonSpecies);
75 #if OHMMS_DIM == 3
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++)
79  {
80  // Omit half the G-vectors because of time-reversal symmetry
81  if (Include(i, j, k))
82  {
83  PosType G = 2.0 * M_PI *
84  ((RealType)i * Ions.getLattice().Gv[0] + (RealType)j * Ions.getLattice().Gv[1] +
85  (RealType)k * Ions.getLattice().Gv[2]);
86  if (dot(G, G) <= (kc * kc))
87  {
88  bool notZero(false);
89  StructureFactor(G, rho_G);
90  for (int sp = 0; sp < NumIonSpecies; sp++)
91  notZero = notZero || (norm(rho_G[sp]) > 1.0e-12);
92  if (notZero || !useStructFact)
93  gvecs.push_back(G);
94  }
95  }
96  }
97 #elif OHMMS_DIM == 2
98  for (int i = 0; i <= maxIndex[0]; i++)
99  for (int j = -maxIndex[1]; j <= maxIndex[1]; j++)
100  {
101  // Omit half the G-vectors because of time-reversal symmetry
102  if (Include(i, j))
103  {
104  PosType G = 2.0 * M_PI * ((RealType)i * Ions.getLattice().Gv[0] + (RealType)j * Ions.getLattice().Gv[1]);
105  if (dot(G, G) <= (kc * kc))
106  {
107  bool notZero(false);
108  StructureFactor(G, rho_G);
109  for (int sp = 0; sp < NumIonSpecies; sp++)
110  notZero = notZero || (norm(rho_G[sp]) > 1.0e-12);
111  if (notZero || !useStructFact)
112  gvecs.push_back(G);
113  }
114  }
115  }
116 #endif
117 }
QTBase::RealType RealType
Definition: Configuration.h:58
#define OHMMS_DIM
Definition: config.h:64
QMCTraits::PosType PosType
const ParticleSet & Ions
double norm(const zVec &c)
Definition: VectorOps.h:118
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
const auto & getLattice() const
Definition: ParticleSet.h:251
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
bool Include(int i, int j, int k)
void StructureFactor(PosType G, std::vector< ComplexType > &rho_G)
MakeReturn< UnaryNode< FnFloor, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t floor(const Vector< T1, C1 > &l)

◆ sortGvecs()

void sortGvecs ( std::vector< PosType > &  gvecs,
std::vector< kSpaceCoef< T >> &  coefs,
SymmetryType  symm 
)
private

Definition at line 167 of file kSpaceJastrow.cpp.

References kSpaceCoef< T >::cG, kSpaceJastrow::CRYSTAL, and kSpaceJastrow::Equivalent().

Referenced by kSpaceJastrow::kSpaceJastrow().

168 {
169  if (!gvecs.size())
170  return;
171  if (symm == CRYSTAL)
172  {
173  // First pass: sort all the G-vectors into equivalent groups
174  std::sort(gvecs.begin(), gvecs.end(), *this);
175  // Now, look through the sorted G-vectors and group them
176  kSpaceCoef<T> coef;
177  coef.cG = T();
178  coef.firstIndex = coef.lastIndex = 0;
179  for (int i = 1; i < gvecs.size(); i++)
180  if (Equivalent(gvecs[i], gvecs[i - 1]))
181  coef.lastIndex = i;
182  else
183  {
184  coefs.push_back(coef);
185  coef.firstIndex = coef.lastIndex = i;
186  }
187  coefs.push_back(coef);
188  }
189  else if (symm == ISOTROPIC)
190  {
191  magLess comparator;
192  std::sort(gvecs.begin(), gvecs.end(), comparator);
193  RealType curMag2 = dot(gvecs[0], gvecs[0]);
194  kSpaceCoef<T> coef;
195  coef.cG = T();
196  coef.firstIndex = coef.lastIndex = 0;
197  for (int i = 1; i < gvecs.size(); i++)
198  {
199  RealType mag2 = dot(gvecs[i], gvecs[i]);
200  if (std::abs(mag2 - curMag2) < 1.0e-10)
201  coef.lastIndex = i;
202  else
203  {
204  coefs.push_back(coef);
205  coef.firstIndex = coef.lastIndex = i;
206  curMag2 = mag2;
207  }
208  }
209  coefs.push_back(coef);
210  }
211  else if (symm == NOSYMM)
212  {
213  coefs.resize(gvecs.size());
214  for (int i = 0; i < gvecs.size(); i++)
215  {
216  coefs[i].cG = T();
217  coefs[i].firstIndex = coefs[i].lastIndex = i;
218  }
219  }
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++)
223  {
224  app_log() << " Group " << i << ":\n";
225  for (int j = coefs[i].firstIndex; j <= coefs[i].lastIndex; j++)
226  app_log() << " " << gvecs[j] << " " << std::sqrt(dot(gvecs[j], gvecs[j])) << std::endl;
227  }
228 }
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
std::ostream & app_log()
Definition: OutputManager.h:65
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
QMCTraits::RealType RealType
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
bool Equivalent(PosType G1, PosType G2)

◆ StructureFactor()

void StructureFactor ( PosType  G,
std::vector< ComplexType > &  rho_G 
)
private

Definition at line 28 of file kSpaceJastrow.cpp.

References qmcplusplus::cos(), qmcplusplus::dot(), ParticleSet::getTotalNum(), ParticleSet::GroupID, kSpaceJastrow::Ions, kSpaceJastrow::NumIonSpecies, ParticleSet::R, and qmcplusplus::sin().

Referenced by kSpaceJastrow::Equivalent(), kSpaceJastrow::operator()(), and kSpaceJastrow::setupGvecs().

29 {
30  for (int i = 0; i < NumIonSpecies; i++)
31  rho_G[i] = ComplexType();
32  for (int iat = 0; iat < Ions.getTotalNum(); iat++)
33  {
34  PosType r(Ions.R[iat]);
35  RealType phase = dot(r, G);
36  int id = Ions.GroupID[iat];
37  rho_G[id] += ComplexType(std::cos(phase), std::sin(phase));
38  }
39 }
size_t getTotalNum() const
Definition: ParticleSet.h:493
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
ParticleIndex GroupID
Species ID.
Definition: ParticleSet.h:77
QMCTraits::PosType PosType
const ParticleSet & Ions
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
ParticlePos R
Position.
Definition: ParticleSet.h:79
std::complex< RealType > ComplexType
Definition: kSpaceJastrow.h:79
QMCTraits::RealType RealType
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)

◆ updateBuffer()

kSpaceJastrow::LogValue updateBuffer ( ParticleSet P,
WFBufferType buf,
bool  fromscratch = false 
)
overridevirtual

For particle-by-particle move.

Put the objects of this class in the walker buffer or forward the memory cursor.

Parameters
Pparticle set
bufAnonymous storage
fromscratchrequest recomputing the precision critical pieces of wavefunction from scratch
Returns
log value of the wavefunction.

Implements WaveFunctionComponent.

Definition at line 648 of file kSpaceJastrow.cpp.

References kSpaceJastrow::evaluateLog(), ParticleSet::G, ParticleSet::L, and WaveFunctionComponent::log_value_.

649 {
650  log_value_ = evaluateLog(P, P.G, P.L);
651  // for(int iat=0; iat<NumPtcls; iat++)
652  // copy(P.getSK().eikr[iat],P.getSK().eikr[iat]+MaxK,eikr[iat]);
653  // buf.put(Rhok.first_address(), Rhok.last_address());
654  // buf.put(U.first_address(), U.last_address());
655  // buf.put(d2U.first_address(), d2U.last_address());
656  // buf.put(FirstAddressOfdU,LastAddressOfdU);
657  // return LogValue;
658  return log_value_;
659 }
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate the value of the WaveFunctionComponent from scratch

Member Data Documentation

◆ CellVolume

RealType CellVolume
private

Definition at line 83 of file kSpaceJastrow.h.

Referenced by kSpaceJastrow::copyFrom().

◆ Delta_e2iGr

Matrix<ComplexType> Delta_e2iGr
private

◆ Ion_rhoG

std::vector<ComplexType> Ion_rhoG
private

Definition at line 108 of file kSpaceJastrow.h.

Referenced by kSpaceJastrow::copyFrom(), and kSpaceJastrow::kSpaceJastrow().

◆ Ions

const ParticleSet& Ions
private

◆ NormConstant

RealType NormConstant
private

Definition at line 83 of file kSpaceJastrow.h.

Referenced by kSpaceJastrow::copyFrom().

◆ num_elecs

int num_elecs
private

◆ NumIons

int NumIons
private

Definition at line 86 of file kSpaceJastrow.h.

Referenced by kSpaceJastrow::copyFrom().

◆ NumIonSpecies

◆ NumSpins

int NumSpins
private

Definition at line 85 of file kSpaceJastrow.h.

Referenced by kSpaceJastrow::copyFrom().

◆ OneBody_e2iGr

◆ OneBody_rhoG

std::vector<ComplexType> OneBody_rhoG
private

Definition at line 110 of file kSpaceJastrow.h.

Referenced by kSpaceJastrow::copyFrom(), and kSpaceJastrow::kSpaceJastrow().

◆ OneBodyCoefs

◆ OneBodyGvecs

◆ OneBodyID

std::string OneBodyID
private

Definition at line 138 of file kSpaceJastrow.h.

Referenced by kSpaceJastrow::copyFrom(), and kSpaceJastrow::kSpaceJastrow().

◆ OneBodyPhase

◆ OneBodySymmCoefs

◆ OneBodySymmType

SymmetryType OneBodySymmType
private

Definition at line 104 of file kSpaceJastrow.h.

Referenced by kSpaceJastrow::copyFrom().

◆ OneBodyVarMap

std::vector<int> OneBodyVarMap
private

◆ Prefactor

◆ TwoBody_e2iGr_new

◆ TwoBody_e2iGr_old

◆ TwoBody_rhoG

◆ TwoBodyCoefs

◆ TwoBodyGvecs

◆ TwoBodyID

std::string TwoBodyID
private

Definition at line 139 of file kSpaceJastrow.h.

Referenced by kSpaceJastrow::copyFrom(), and kSpaceJastrow::kSpaceJastrow().

◆ TwoBodyPhase

◆ TwoBodySymmCoefs

◆ TwoBodySymmType

SymmetryType TwoBodySymmType
private

Definition at line 104 of file kSpaceJastrow.h.

Referenced by kSpaceJastrow::copyFrom().

◆ TwoBodyVarMap

std::vector<int> TwoBodyVarMap
private

The documentation for this class was generated from the following files: