QMCPACK
WaveFunctionTester Class Reference

Test the correctness of TrialWaveFunction for the values, gradients and laplacians. More...

+ Inheritance diagram for WaveFunctionTester:
+ Collaboration diagram for WaveFunctionTester:

Public Types

using LogValue = WaveFunctionComponent::LogValue
 type definition More...
 
- Public Types inherited from QMCDriver
enum  { QMC_UPDATE_MODE, QMC_MULTIPLE, QMC_OPTIMIZE, QMC_WARMUP }
 enumeration coupled with QMCMode More...
 
using Walker_t = MCWalkerConfiguration::Walker_t
 
using Buffer_t = Walker_t::Buffer_t
 
using FullPrecRealType = QMCTraits::FullPrecRealType
 
- Public Types inherited from QMCDriverInterface
using BranchEngineType = SimpleFixedNodeBranch
 
using FullPrecRealType = QMCTraits::FullPrecRealType
 
- 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 Types inherited from MPIObjectBase
using mpi_comm_type = Communicate::mpi_comm_type
 

Public Member Functions

 WaveFunctionTester (const ProjectData &project_data, MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, ParticleSetPool &ptclPool, Communicate *comm)
 Constructor. More...
 
 ~WaveFunctionTester () override
 
bool run () override
 Test the evaluation of the wavefunction, gradient and laplacian by comparing to the numerical evaluation. More...
 
bool put (xmlNodePtr q) override
 
- Public Member Functions inherited from QMCDriver
 QMCDriver (const ProjectData &project_data, MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, Communicate *comm, const std::string &QMC_driver_type, bool enable_profiling=false)
 Constructor. More...
 
 ~QMCDriver () override
 
int current () const
 return current step More...
 
void setUpdateMode (bool pbyp) override
 set the update mode More...
 
void setStatus (const std::string &aname, const std::string &h5name, bool append) override
 Set the status of the QMCDriver. More...
 
void add_H_and_Psi (QMCHamiltonian *h, TrialWaveFunction *psi) override
 add QMCHamiltonian/TrialWaveFunction pair for multiple More...
 
void process (xmlNodePtr cur) override
 initialize with xmlNode More...
 
xmlNodePtr getQMCNode ()
 return a xmlnode with update More...
 
void putWalkers (std::vector< xmlNodePtr > &wset) override
 Read walker configurations from *.config.h5 files. More...
 
void putTraces (xmlNodePtr txml) override
 
void requestTraces (bool traces) override
 
void putWalkerLogs (xmlNodePtr wlxml) override
 
void requestWalkerLogs (bool allow_walker_logs_) override
 
std::string getEngineName () override
 
template<class PDT >
void setValue (const std::string &aname, PDT x)
 
void setBranchEngine (std::unique_ptr< BranchEngineType > &&be) override
 set the BranchEngineType More...
 
std::unique_ptr< BranchEngineTypegetBranchEngine () override
 return BranchEngineType* More...
 
int addObservable (const std::string &aname)
 
RealType getObservable (int i)
 
void setTau (RealType i)
 
void setWalkerOffsets ()
 set global offsets of the walkers More...
 
RefVector< RandomBase< FullPrecRealType > > getRngRefs () const
 return the random generators More...
 
RandomBase< FullPrecRealType > & getRng (int i) override
 return the i-th random generator More...
 
unsigned long getDriverMode () override
 
- Public Member Functions inherited from QMCDriverInterface
virtual ~QMCDriverInterface ()
 
virtual void setBranchEngine (std::unique_ptr< BranchEngineType > &&be)
 
- Public Member Functions inherited from MPIObjectBase
 MPIObjectBase (Communicate *c)
 constructor with communicator More...
 
int rank () const
 return the rank of the communicator More...
 
int getGroupID () const
 return the group id of the communicator More...
 
CommunicategetCommunicator () const
 return myComm More...
 
CommunicategetCommRef () const
 return a TEMPORARY reference to Communicate More...
 
mpi_comm_type getMPI () const
 return MPI communicator if one wants to use MPI directly More...
 
bool is_manager () const
 return true if the rank == 0 More...
 
const std::string & getName () const
 return the name More...
 
void setName (const std::string &aname)
 

Private Member Functions

 WaveFunctionTester (const WaveFunctionTester &)=delete
 Copy Constructor (disabled) More...
 
WaveFunctionTesteroperator= (const WaveFunctionTester &)=delete
 Copy Operator (disabled) More...
 
void runBasicTest ()
 basic tests for G and L More...
 
void runRatioTest ()
 the basic ratios check More...
 
void runRatioTest2 ()
 
void runRatioV ()
 test ratios with virtual moves More...
 
void runCloneTest ()
 test clone implementations of new wavefunctions and operators More...
 
void runDerivTest ()
 
void runDerivNLPPTest ()
 
void runDerivCloneTest ()
 
void runGradSourceTest ()
 
void runZeroVarianceTest ()
 
void runNodePlot ()
 
void printEloc ()
 
void computeNumericalGrad (RealType delta, ParticleSet::ParticleGradient &G_fd, ParticleSet::ParticleLaplacian &L_fd)
 
bool checkGradients (int lower_iat, int upper_iat, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, ParticleSet::ParticleGradient &G_fd, ParticleSet::ParticleLaplacian &L_fd, std::stringstream &log, int indent=0)
 
bool checkGradientAtConfiguration (MCWalkerConfiguration::Walker_t *W1, std::stringstream &fail_log, bool &ignore)
 
QMCRunType getRunType () override
 

Private Attributes

ParticleSetPoolPtclPool
 
ParticleSet::ParticlePos deltaR
 
std::string checkRatio
 
std::string checkClone
 
std::string checkHamPbyP
 
std::string sourceName
 
std::string wftricks
 
std::string checkEloc
 
std::string checkBasic
 
std::string checkRatioV
 
xmlNodePtr myNode
 
double deltaParam
 
double toleranceParam
 
bool outputDeltaVsError
 
bool checkSlaterDet
 
std::string checkSlaterDetOption
 
FiniteDiffErrData DeltaVsError
 
std::ofstream fout
 
const size_t ndim
 

Additional Inherited Members

- Public Attributes inherited from QMCDriver
std::bitset< QMC_MODE_MAXqmc_driver_mode
 bits to classify QMCDriver More...
 
bool allow_traces
 whether to allow traces More...
 
xmlNodePtr traces_xml
 traces xml More...
 
bool allow_walker_logs
 whether to allow traces More...
 
xmlNodePtr walker_logs_xml
 traces xml More...
 
EstimatorManagerBaseEstimators
 Observables manager. More...
 
std::unique_ptr< TraceManagerTraces
 Traces manager. More...
 
std::unique_ptr< WalkerLogManagerwlog_manager_
 Traces manager. More...
 
- Protected Member Functions inherited from QMCDriver
bool putQMCInfo (xmlNodePtr cur)
 Parses the xml input file for parameter definitions for a single qmc simulation. More...
 
void addWalkers (int nwalkers)
 Add walkers to the end of the ensemble of walkers. More...
 
void recordBlock (int block) override
 record the state of the block More...
 
bool finalize (int block, bool dumpwalkers=true)
 finalize a qmc section More...
 
std::string getRotationName (std::string RootName)
 
std::string getLastRotationName (std::string RootName)
 
const std::string & get_root_name () const override
 
- Protected Attributes inherited from QMCDriver
const ProjectDataproject_data_
 top-level project data information More...
 
std::unique_ptr< BranchEngineTypebranchEngine
 branch engine More...
 
DriftModifierBaseDriftModifier
 drift modifer More...
 
bool ResetRandom
 randomize it More...
 
bool AppendRun
 flag to append or restart the run More...
 
bool DumpConfig
 flag to turn off dumping configurations More...
 
bool IsQMCDriver
 true, if it is a real QMC engine More...
 
int MyCounter
 the number of times this QMCDriver is executed More...
 
int kDelay
 the number to delay updates by More...
 
int Period4CheckPoint
 period of dumping walker configurations and everything else for restart More...
 
int Period4CheckProperties
 period of dumping walker positions and IDs for Forward Walking More...
 
int Period4WalkerDump
 period of recording walker configurations More...
 
int Period4ConfigDump
 period of recording walker positions and IDs for forward walking afterwards More...
 
IndexType CurrentStep
 current step More...
 
IndexType nBlocks
 maximum number of blocks More...
 
IndexType nSteps
 maximum number of steps More...
 
IndexType nSubSteps
 number of steps between a step: VMCs do not evaluate energies More...
 
IndexType nWarmupSteps
 number of warmup steps More...
 
IndexType nAccept
 counter for number of moves accepted More...
 
IndexType nReject
 counter for number of moves /rejected More...
 
IndexType nBlocksBetweenRecompute
 the number of blocks between recomptePsi More...
 
IndexType nTargetWalkers
 the number of walkers More...
 
IndexType nTargetSamples
 the number of saved samples More...
 
IndexType nStepsBetweenSamples
 alternate method of setting QMC run parameters More...
 
RealType nSamplesPerThread
 samples per thread More...
 
RealType nTargetPopulation
 target population More...
 
RealType Tau
 timestep More...
 
int MaxCPUSecs
 maximum cpu in secs More...
 
RealType m_oneover2tau
 Time-step factor $ 1/(2\tau)$. More...
 
RealType m_sqrttau
 Time-step factor $ \sqrt{\tau}$. More...
 
xmlNodePtr qmcNode
 pointer to qmc node in xml file More...
 
const std::string QMCType
 type of QMC driver More...
 
std::string h5FileRoot
 the root of h5File More...
 
std::string RootName
 root of all the output files More...
 
ParameterSet m_param
 store any parameter that has to be read from a file More...
 
MCWalkerConfigurationW
 walker ensemble More...
 
TrialWaveFunctionPsi
 trial function More...
 
QMCHamiltonianH
 Hamiltonian. More...
 
std::unique_ptr< HDFWalkerOutputwOut
 record engine for walkers More...
 
std::vector< TrialWaveFunction * > Psi1
 a list of TrialWaveFunctions for multiple method More...
 
std::vector< QMCHamiltonian * > H1
 a list of QMCHamiltonians for multiple method More...
 
UPtrVector< RandomBase< FullPrecRealType > > Rng
 Random number generators. More...
 
std::vector< xmlNodePtr > mcwalkerNodePtr
 a list of mcwalkerset element More...
 
ParticleSet::ParticlePos drift
 temporary storage for drift More...
 
ParticleSet::ParticlePos deltaR
 temporary storage for random displacement More...
 
RealType SpinMass
 spin mass for spinor calcs More...
 
int rotation
 
- Protected Attributes inherited from MPIObjectBase
CommunicatemyComm
 pointer to Communicate More...
 
std::string ClassName
 class Name More...
 
std::string myName
 name of the object More...
 

Detailed Description

Test the correctness of TrialWaveFunction for the values, gradients and laplacians.

Definition at line 42 of file WaveFunctionTester.h.

Member Typedef Documentation

◆ LogValue

type definition

Definition at line 46 of file WaveFunctionTester.h.

Constructor & Destructor Documentation

◆ WaveFunctionTester() [1/2]

WaveFunctionTester ( const ProjectData project_data,
MCWalkerConfiguration w,
TrialWaveFunction psi,
QMCHamiltonian h,
ParticleSetPool ptclPool,
Communicate comm 
)

Constructor.

Definition at line 39 of file WaveFunctionTester.cpp.

References ParameterSet::add(), qmcplusplus::app_log(), WaveFunctionTester::checkBasic, WaveFunctionTester::checkClone, WaveFunctionTester::checkEloc, WaveFunctionTester::checkHamPbyP, WaveFunctionTester::checkRatio, WaveFunctionTester::checkRatioV, WaveFunctionTester::checkSlaterDetOption, WaveFunctionTester::deltaParam, WaveFunctionTester::deltaR, ParticleSet::getTotalNum(), QMCDriver::m_param, qmcplusplus::makeGaussRandom(), WaveFunctionTester::ndim, WaveFunctionTester::sourceName, WaveFunctionTester::toleranceParam, and WaveFunctionTester::wftricks.

45  : QMCDriver(project_data, w, psi, h, comm, "WaveFunctionTester"),
46  PtclPool(ptclPool),
47  checkRatio("no"),
48  checkClone("no"),
49  checkHamPbyP("no"),
50  wftricks("no"),
51  checkEloc("no"),
52  checkBasic("yes"),
53  checkRatioV("no"),
54  deltaParam(0.0),
55  toleranceParam(0.0),
56  outputDeltaVsError(false),
57  checkSlaterDet(true),
58  ndim(w.getLattice().ndim)
59 {
60  m_param.add(checkRatio, "ratio");
61  m_param.add(checkClone, "clone");
62  m_param.add(checkHamPbyP, "hamiltonianpbyp");
63  m_param.add(sourceName, "source");
64  m_param.add(wftricks, "orbitalutility");
65  m_param.add(checkEloc, "printEloc");
66  m_param.add(checkBasic, "basic");
67  m_param.add(checkRatioV, "virtual_move");
68  m_param.add(deltaParam, "delta");
69  m_param.add(toleranceParam, "tolerance");
71 
72  deltaR.resize(w.getTotalNum());
74  if (ndim < 3)
75  {
76  app_log() << "WF test in " << ndim << "D" << std::endl;
77  for (int iat = 0; iat < deltaR.size(); ++iat)
78  deltaR[iat][2] = 0;
79  }
80 }
QMCDriver(const ProjectData &project_data, MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, Communicate *comm, const std::string &QMC_driver_type, bool enable_profiling=false)
Constructor.
Definition: QMCDriver.cpp:44
std::ostream & app_log()
Definition: OutputManager.h:65
ParameterSet m_param
store any parameter that has to be read from a file
Definition: QMCDriver.h:320
void makeGaussRandom(std::vector< TinyVector< T, D >> &a)
ParticleSet::ParticlePos deltaR
void add(PDT &aparam, const std::string &aname_in, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new parameter corresponding to an xmlNode <parameter>

◆ ~WaveFunctionTester()

~WaveFunctionTester ( )
override

Definition at line 82 of file WaveFunctionTester.cpp.

82 {}

◆ WaveFunctionTester() [2/2]

WaveFunctionTester ( const WaveFunctionTester )
privatedelete

Copy Constructor (disabled)

Member Function Documentation

◆ checkGradientAtConfiguration()

bool checkGradientAtConfiguration ( MCWalkerConfiguration::Walker_t W1,
std::stringstream &  fail_log,
bool &  ignore 
)
private

Definition at line 722 of file WaveFunctionTester.cpp.

References WaveFunctionTester::checkGradients(), WaveFunctionTester::checkSlaterDet, FiniteDifference::computeFiniteDiff(), WaveFunctionTester::deltaParam, qmcplusplus::det(), SlaterDet::Dets, TrialWaveFunction::evaluateLog(), FiniteDifference::FiniteDiff_LowOrder, FiniteDifference::finiteDifferencePoints(), WaveFunctionTester::fout, ParticleSet::G, TrialWaveFunction::getOrbitals(), TrialWaveFunction::getPhase(), ParticleSet::getTotalNum(), ParticleSet::L, ParticleSet::loadWalker(), ParticleSet::makeMove(), WaveFunctionTester::ndim, QMCDriver::Psi, ParticleSet::R, ParticleSet::rejectMove(), SPOSet::size(), ParticleSet::update(), and QMCDriver::W.

Referenced by WaveFunctionTester::runBasicTest().

725 {
726  int nat = W.getTotalNum();
727  ParticleSet::ParticleGradient G(nat), G1(nat);
728  ParticleSet::ParticleLaplacian L(nat), L1(nat);
729 
730  W.loadWalker(*W1, true);
731 
732  // compute analytic values
733  Psi.evaluateLog(W);
734  G = W.G;
735  L = W.L;
736 
737  // Use a single delta with a fairly large tolerance
738  //computeNumericalGrad(delta, G1, L1);
739 
740  RealType delta = 1.0e-4;
741  if (deltaParam > 0.0)
742  {
743  delta = deltaParam;
744  }
745  FiniteDifference fd(ndim, FiniteDifference::FiniteDiff_LowOrder);
746 
748 
749  fd.finiteDifferencePoints(delta, W, positions);
750 
751  FiniteDifference::ValueVector logpsi_vals;
752  FiniteDifference::PosChangeVector::iterator it;
753 
754  for (it = positions.begin(); it != positions.end(); it++)
755  {
756  PosType r0 = W.R[it->index];
757  W.R[it->index] = it->r;
758  W.update();
759  RealType logpsi0 = Psi.evaluateLog(W);
760  RealType phase0 = Psi.getPhase();
761 #if defined(QMC_COMPLEX)
762  ValueType logpsi = std::complex<OHMMS_PRECISION>(logpsi0, phase0);
763 #else
764  ValueType logpsi = logpsi0;
765 #endif
766  logpsi_vals.push_back(logpsi);
767 
768  W.R[it->index] = r0;
769  W.update();
770  Psi.evaluateLog(W);
771  }
772 
773  fd.computeFiniteDiff(delta, positions, logpsi_vals, G1, L1);
774 
775  fout << "delta = " << delta << std::endl;
776 
777  // TODO - better choice of tolerance
778  // TODO - adjust delta and tolerance based on precision of wavefunction
779 
780  bool all_okay = checkGradients(0, nat, G, L, G1, L1, fail_log);
781  // RealType tol = 1e-3;
782  // if (toleranceParam> 0.0)
783  // {
784  // tol = toleranceParam;
785  // }
786 
787  for (int iorb = 0; iorb < Psi.getOrbitals().size(); iorb++)
788  {
789  auto& orb = Psi.getOrbitals()[iorb];
790 
791  ParticleSet::ParticleGradient G(nat), tmpG(nat), G1(nat);
792  ParticleSet::ParticleLaplacian L(nat), tmpL(nat), L1(nat);
793 
794 
795  LogValue logpsi1 = orb->evaluateLog(W, G, L);
796 
797  fail_log << "WaveFunctionComponent " << iorb << " " << orb->getClassName() << " log psi = " << logpsi1 << std::endl;
798 
799  FiniteDifference::ValueVector logpsi_vals;
800  FiniteDifference::PosChangeVector::iterator it;
801  for (it = positions.begin(); it != positions.end(); it++)
802  {
803  PosType r0 = W.R[it->index];
804  W.R[it->index] = it->r;
805  W.update();
807  W.makeMove(it->index, zeroR);
808 
809  LogValue logpsi0 = orb->evaluateLog(W, tmpG, tmpL);
810 #if defined(QMC_COMPLEX)
811  ValueType logpsi(logpsi0.real(), logpsi0.imag());
812 #else
813  ValueType logpsi = std::real(logpsi0);
814 #endif
815  logpsi_vals.push_back(logpsi);
816  W.rejectMove(it->index);
817 
818  W.R[it->index] = r0;
819  W.update();
820  }
821  fd.computeFiniteDiff(delta, positions, logpsi_vals, G1, L1);
822 
823  fout << " WaveFunctionComponent " << iorb << " " << orb->getClassName() << std::endl;
824 
825  if (!checkGradients(0, nat, G, L, G1, L1, fail_log, 1))
826  {
827  all_okay = false;
828  }
829 
830  if (!checkSlaterDet)
831  continue; // skip SlaterDet check if <backflow> is present
832  // DiracDeterminantWithBackflow::evaluateLog requires a call to BackflowTransformation::evaluate in its owning SlaterDetWithBackflow to work correctly.
833  SlaterDet* sd = dynamic_cast<SlaterDet*>(orb.get());
834  if (sd)
835  {
836  for (int isd = 0; isd < sd->Dets.size(); isd++)
837  {
838  ParticleSet::ParticleGradient G(nat), tmpG(nat), G1(nat);
839  ParticleSet::ParticleLaplacian L(nat), tmpL(nat), L1(nat);
840  DiracDeterminantBase& det = *sd->Dets[isd];
841  LogValue logpsi2 = det.evaluateLog(W, G, L); // this won't work with backflow
842  fail_log << " Slater Determiant " << isd << " (for particles " << det.getFirstIndex() << " to "
843  << det.getLastIndex() << ") log psi = " << logpsi2 << std::endl;
844  // Should really check the condition number on the matrix determinant.
845  // For now, just ignore values that too small.
846  if (std::real(logpsi2) < -40.0)
847  {
848  ignore = true;
849  }
850  FiniteDifference::ValueVector logpsi_vals;
851  FiniteDifference::PosChangeVector::iterator it;
852  for (it = positions.begin(); it != positions.end(); it++)
853  {
854  PosType r0 = W.R[it->index];
855  W.R[it->index] = it->r;
856  W.update();
857 
858  LogValue logpsi0 = det.evaluateLog(W, tmpG, tmpL);
859 #if defined(QMC_COMPLEX)
860  ValueType logpsi(logpsi0.real(), logpsi0.imag());
861 #else
862  ValueType logpsi = std::real(logpsi0);
863 #endif
864  logpsi_vals.push_back(logpsi);
865 
866  W.R[it->index] = r0;
867  W.update();
868  }
869  fd.computeFiniteDiff(delta, positions, logpsi_vals, G1, L1);
870 
871  if (!checkGradients(det.getFirstIndex(), det.getLastIndex(), G, L, G1, L1, fail_log, 2))
872  {
873  all_okay = false;
874  }
875 
876 #if 0
877  // Testing single particle orbitals doesn't work yet - probably something
878  // with setup after setting the position.
879  std::map<std::string, SPOSetPtr>::iterator spo_it = sd->mySPOSet.begin();
880  for (; spo_it != sd->mySPOSet.end(); spo_it++)
881  {
882  SPOSetPtr spo = spo_it->second;
883  fail_log << " SPO set = " << spo_it->first << " name = " << spo->className;
884  fail_log << " orbital set size = " << spo->size();
885  fail_log << " basis set size = " << spo->getBasisSetSize() << std::endl;
886 
887  ParticleSet::ParticleGradient G(nat), tmpG(nat), G1(nat);
888  ParticleSet::ParticleLaplacian L(nat), tmpL(nat), L1(nat);
889  RealType logpsi3 = det.evaluateLog(W, G, L);
890  FiniteDifference::ValueVector logpsi_vals;
891  FiniteDifference::PosChangeVector::iterator it;
892  for (it = positions.begin(); it != positions.end(); it++)
893  {
894  PosType r0 = W.R[it->index];
895  W.R[it->index] = it->r;
896  W.update();
898  W.makeMove(it->index,zeroR);
899 
900  SPOSet::ValueVector psi(spo->size());
901 
902  spo->evaluate(W, it->index, psi);
903  ValueType logpsi = psi[0];
904  logpsi_vals.push_back(logpsi);
905 
906  W.rejectMove(it->index);
907  W.R[it->index] = r0;
908  W.update();
909  }
910  fd.computeFiniteDiff(delta, positions, logpsi_vals, G1, L1);
911 
912  if (!checkGradients(det.getFirstIndex(), det.getLastIndex(), G, L, G1, L1, fail_log, 3))
913  {
914  all_okay = false;
915  }
916  }
917 #endif
918  }
919  }
920  }
921  return all_okay;
922 }
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
SPOSet * SPOSetPtr
Definition: SPOSet.h:573
QMCTraits::RealType real
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
ParticleLayout::SingleParticlePos SingleParticlePos
Definition: Configuration.h:87
size_t getTotalNum() const
Definition: ParticleSet.h:493
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
int size() const
return the size of the orbital set Ye: this needs to be replaced by getOrbitalSetSize(); ...
Definition: SPOSet.h:75
void update(bool skipSK=false)
update the internal data
ParticleLaplacian L
laplacians of the particles
Definition: ParticleSet.h:85
QMCTraits::PosType PosType
WaveFunctionComponent::LogValue LogValue
type definition
std::vector< ValueType > ValueVector
QTBase::ValueType ValueType
Definition: Configuration.h:60
void rejectMove(Index_t iat)
reject a proposed move in regular mode
std::vector< PositionChange > PosChangeVector
ParticleGradient G
gradients of the particles
Definition: ParticleSet.h:83
OrbitalSetTraits< ValueType >::ValueVector ValueVector
Definition: SPOSet.h:49
std::vector< std::unique_ptr< WaveFunctionComponent > > const & getOrbitals()
ParticlePos R
Position.
Definition: ParticleSet.h:79
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
void loadWalker(Walker_t &awalker, bool pbyp)
load a Walker_t to the current ParticleSet
QMCTraits::RealType RealType
void makeMove(Index_t iat, const SingleParticlePos &displ, bool maybe_accept=true)
move the iat-th particle to active_pos_
TrialWaveFunction & Psi
trial function
Definition: QMCDriver.h:326
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95
bool checkGradients(int lower_iat, int upper_iat, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, ParticleSet::ParticleGradient &G_fd, ParticleSet::ParticleLaplacian &L_fd, std::stringstream &log, int indent=0)

◆ checkGradients()

bool checkGradients ( int  lower_iat,
int  upper_iat,
ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L,
ParticleSet::ParticleGradient G_fd,
ParticleSet::ParticleLaplacian L_fd,
std::stringstream &  log,
int  indent = 0 
)
private

Definition at line 632 of file WaveFunctionTester.cpp.

References qmcplusplus::abs(), qmcplusplus::Units::charge::e, WaveFunctionTester::fout, qmcplusplus::log(), OHMMS_DIM, ParticleSet::R, WaveFunctionTester::toleranceParam, and QMCDriver::W.

Referenced by WaveFunctionTester::checkGradientAtConfiguration().

640 {
641  ParticleSet::Scalar_t rel_tol = 1e-3;
642  ParticleSet::Scalar_t abs_tol = 1e-7;
643  if (toleranceParam > 0.0)
644  {
645  rel_tol = toleranceParam;
646  }
647 
648  bool all_okay = true;
649  std::string pad(4 * indent, ' ');
650 
651 
652  for (int iat = lower_iat; iat < upper_iat; iat++)
653  {
654  ParticleSet::Scalar_t L_err = std::abs(L[iat] - L_fd[iat]);
655  ParticleSet::Scalar_t L_rel_denom = std::max(std::abs(L[iat]), std::abs(L_fd[iat]));
656  ParticleSet::Scalar_t L_err_rel = std::abs(L_err / L_rel_denom);
657 
658  if (L_err_rel > rel_tol && L_err > abs_tol)
659  {
660  if (L_err_rel > rel_tol)
661  {
662  log << pad << "Finite difference Laplacian exceeds relative tolerance (" << rel_tol << ") for particle " << iat
663  << std::endl;
664  }
665  else
666  {
667  log << pad << "Finite difference Laplacian exceeds absolute tolerance (" << abs_tol << ") for particle " << iat
668  << std::endl;
669  }
670  log << pad << " Analytic = " << L[iat] << std::endl;
671  log << pad << " Finite diff = " << L_fd[iat] << std::endl;
672  log << pad << " Error = " << L_err << " Relative Error = " << L_err_rel << std::endl;
673  all_okay = false;
674  }
675 
676  ParticleSet::Scalar_t G_err_rel[OHMMS_DIM];
677  for (int idim = 0; idim < OHMMS_DIM; idim++)
678  {
679  ParticleSet::Scalar_t G_err = std::abs(G[iat][idim] - G_fd[iat][idim]);
680  ParticleSet::Scalar_t G_rel_denom = std::max(std::abs(G[iat][idim]), std::abs(G_fd[iat][idim]));
681  G_err_rel[idim] = std::abs(G_err / G[iat][idim]);
682 
683  if (G_err_rel[idim] > rel_tol && G_err > abs_tol)
684  {
685  if (G_err_rel[idim] > rel_tol)
686  {
687  log << pad << "Finite difference gradient exceeds relative tolerance (" << rel_tol << ") for particle "
688  << iat;
689  }
690  else
691  {
692  log << pad << "Finite difference gradient exceeds absolute tolerance (" << abs_tol << ") for particle "
693  << iat;
694  }
695  log << " component " << idim << std::endl;
696  log << pad << " Analytic = " << G[iat][idim] << std::endl;
697  log << pad << " Finite diff = " << G_fd[iat][idim] << std::endl;
698  log << pad << " Error = " << G_err << " Relative Error = " << G_err_rel[idim] << std::endl;
699  all_okay = false;
700  }
701  }
702 
703  fout << pad << "For particle #" << iat << " at " << W.R[iat] << std::endl;
704  fout << pad << "Gradient = " << std::setw(12) << G[iat] << std::endl;
705  fout << pad << " Finite diff = " << std::setw(12) << G_fd[iat] << std::endl;
706  fout << pad << " Error = " << std::setw(12) << G[iat] - G_fd[iat] << std::endl;
707  fout << pad << " Relative Error = ";
708  for (int idim = 0; idim < OHMMS_DIM; idim++)
709  {
710  fout << G_err_rel[idim] << " ";
711  }
712  fout << std::endl << std::endl;
713  fout << pad << "Laplacian = " << std::setw(12) << L[iat] << std::endl;
714  fout << pad << " Finite diff = " << std::setw(12) << L_fd[iat] << std::endl;
715  fout << pad << " Error = " << std::setw(12) << L[iat] - L_fd[iat] << " Relative Error = " << L_err_rel
716  << std::endl
717  << std::endl;
718  }
719  return all_okay;
720 }
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
#define OHMMS_DIM
Definition: config.h:64
ParticlePos R
Position.
Definition: ParticleSet.h:79
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
MakeReturn< UnaryNode< FnLog, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t log(const Vector< T1, C1 > &l)

◆ computeNumericalGrad()

void computeNumericalGrad ( RealType  delta,
ParticleSet::ParticleGradient G_fd,
ParticleSet::ParticleLaplacian L_fd 
)
private

Definition at line 595 of file WaveFunctionTester.cpp.

References FiniteDifference::computeFiniteDiff(), TrialWaveFunction::evaluateLog(), FiniteDifference::FiniteDiff_LowOrder, FiniteDifference::finiteDifferencePoints(), TrialWaveFunction::getPhase(), WaveFunctionTester::ndim, QMCDriver::Psi, ParticleSet::R, ParticleSet::update(), and QMCDriver::W.

Referenced by WaveFunctionTester::runBasicTest().

598 {
599  FiniteDifference fd(ndim, FiniteDifference::FiniteDiff_LowOrder);
601 
602  fd.finiteDifferencePoints(delta, W, positions);
603 
604  FiniteDifference::ValueVector logpsi_vals;
605  FiniteDifference::PosChangeVector::iterator it;
606 
607  for (it = positions.begin(); it != positions.end(); it++)
608  {
609  PosType r0 = W.R[it->index];
610  W.R[it->index] = it->r;
611  W.update();
612  RealType logpsi0 = Psi.evaluateLog(W);
613 #if defined(QMC_COMPLEX)
614  RealType phase0 = Psi.getPhase();
615  ValueType logpsi = std::complex<OHMMS_PRECISION>(logpsi0, phase0);
616 #else
617  ValueType logpsi = logpsi0;
618 #endif
619  logpsi_vals.push_back(logpsi);
620 
621  W.R[it->index] = r0;
622  W.update();
623  Psi.evaluateLog(W);
624  }
625 
626  fd.computeFiniteDiff(delta, positions, logpsi_vals, G_fd, L_fd);
627 }
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
void update(bool skipSK=false)
update the internal data
QMCTraits::PosType PosType
std::vector< ValueType > ValueVector
QTBase::ValueType ValueType
Definition: Configuration.h:60
std::vector< PositionChange > PosChangeVector
ParticlePos R
Position.
Definition: ParticleSet.h:79
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
QMCTraits::RealType RealType
TrialWaveFunction & Psi
trial function
Definition: QMCDriver.h:326

◆ getRunType()

QMCRunType getRunType ( )
inlineoverrideprivatevirtual

Implements QMCDriverInterface.

Definition at line 110 of file WaveFunctionTester.h.

References qmcplusplus::WF_TEST.

◆ operator=()

WaveFunctionTester& operator= ( const WaveFunctionTester )
privatedelete

Copy Operator (disabled)

◆ printEloc()

void printEloc ( )
private

Definition at line 216 of file WaveFunctionTester.cpp.

References APP_ABORT, qmcplusplus::app_log(), WalkerConfigurations::begin(), QMCHamiltonian::evaluate(), TrialWaveFunction::evaluateLog(), QMCHamiltonian::getObservable(), QMCHamiltonian::getObservableName(), ParticleSetPool::getPool(), ParticleSet::getTotalNum(), QMCDriver::H, Walker< t_traits, p_traits >::Properties, QMCDriver::Psi, WaveFunctionTester::PtclPool, ParticleSet::R, Walker< t_traits, p_traits >::R, QMCHamiltonian::sizeOfObservables(), WaveFunctionTester::sourceName, qmcplusplus::sqrt(), ParticleSet::update(), and QMCDriver::W.

Referenced by WaveFunctionTester::run().

217 {
218  app_log() << " ===== printEloc =====\n";
219  for (auto& [key, value] : PtclPool.getPool())
220  app_log() << "ParticelSet = " << key << std::endl;
221  // Find source ParticleSet
222  auto pit(PtclPool.getPool().find(sourceName));
223  if (pit == PtclPool.getPool().end())
224  APP_ABORT("Unknown source \"" + sourceName + "\" in printEloc in WaveFunctionTester.");
225  ParticleSet& source = *((*pit).second);
226  app_log() << "Source = " << sourceName << " " << (*pit).first << std::endl;
227  int nel = W.getTotalNum();
228  int ncenter = source.getTotalNum();
229  // int ncenter = 3;
230  // std::cout <<"number of centers: " <<source.getTotalNum() << std::endl;
231  // std::cout <<"0: " <<source.R[0] << std::endl;
232  // std::cout <<"1: " <<source.R[1] << std::endl;
233  // std::cout <<"2: " <<source.R[2] << std::endl;
234  MCWalkerConfiguration::PropertyContainer_t Properties(0, 0, 1, WP::MAXPROPERTIES);
235  ;
236  //pick the first walker
237  const MCWalkerConfiguration::Walker_t& awalker = **W.begin();
238  //copy the properties of the working walker
239  Properties = awalker.Properties;
240  W.R = awalker.R;
241  W.update();
242  //ValueType psi = Psi.evaluate(W);
243  ValueType logpsi = Psi.evaluateLog(W);
244  RealType eloc = H.evaluate(W);
245  app_log() << " Logpsi: " << logpsi << std::endl;
246  app_log() << " HamTest "
247  << " Total " << eloc << std::endl;
248  for (int i = 0; i < H.sizeOfObservables(); i++)
249  app_log() << " HamTest " << H.getObservableName(i) << " " << H.getObservable(i) << std::endl;
250  //RealType psi = Psi.evaluateLog(W);
251  //int iat=0;
252  double maxR = 1000000.0;
253  std::vector<int> closestElectron(ncenter);
254  for (int iat = 0; iat < ncenter; iat++)
255  {
256  maxR = 10000000;
257  for (int k = 0; k < nel; k++)
258  {
259  double dx = std::sqrt((W.R[k][0] - source.R[iat][0]) * (W.R[k][0] - source.R[iat][0]) +
260  (W.R[k][1] - source.R[iat][1]) * (W.R[k][1] - source.R[iat][1]) +
261  (W.R[k][2] - source.R[iat][2]) * (W.R[k][2] - source.R[iat][2]));
262  if (dx < maxR)
263  {
264  maxR = dx;
265  closestElectron[iat] = k;
266  }
267  }
268  }
269  // closestElectron[iat]=1;
270  std::ofstream out("eloc.dat");
271  double x, dx = 1.0 / 499.0;
272  for (int k = 0; k < 500; k++)
273  {
274  x = -0.5 + k * dx;
275  out << x << " ";
276  for (int iat = 0; iat < ncenter; iat++)
277  {
278  PosType tempR = W.R[closestElectron[iat]];
279  W.R[closestElectron[iat]] = source.R[iat];
280  // W.R[closestElectron[iat]]=0.0;
281  W.R[closestElectron[iat]][0] += x;
282  W.update();
283  Psi.evaluateLog(W);
284  ValueType ene = H.evaluate(W);
285  out << ene << " ";
286  W.R[closestElectron[iat]] = source.R[iat];
287  // W.R[closestElectron[iat]]=0.0;
288  W.R[closestElectron[iat]][1] += x;
289  W.update();
290  Psi.evaluateLog(W);
291  ene = H.evaluate(W);
292  out << ene << " ";
293  W.R[closestElectron[iat]] = source.R[iat];
294  // W.R[closestElectron[iat]]=0.0;
295  W.R[closestElectron[iat]][2] += x;
296  W.update();
297  Psi.evaluateLog(W);
298  ene = H.evaluate(W);
299  out << ene << " ";
300  W.R[closestElectron[iat]] = tempR;
301  }
302  out << std::endl;
303  }
304  out.close();
305 }
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
std::string getObservableName(int i) const
return the name of the i-th observable
size_t getTotalNum() const
Definition: ParticleSet.h:493
std::ostream & app_log()
Definition: OutputManager.h:65
RealType getObservable(int i) const
return the value of the i-th observable
void update(bool skipSK=false)
update the internal data
QMCTraits::PosType PosType
QTBase::ValueType ValueType
Definition: Configuration.h:60
QMCHamiltonian & H
Hamiltonian.
Definition: QMCDriver.h:329
int sizeOfObservables() const
return the size of observables
ParticlePos R
Position.
Definition: ParticleSet.h:79
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
WalkerConfigurations::Walker_t Walker_t
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
QMCTraits::RealType RealType
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
TrialWaveFunction & Psi
trial function
Definition: QMCDriver.h:326
const PoolType & getPool() const
get the Pool object
Walker_t::PropertyContainer_t PropertyContainer_t
container type of the Properties of a Walker
iterator begin()
return the first iterator

◆ put()

bool put ( xmlNodePtr  q)
overridevirtual

Implements QMCDriverInterface.

Definition at line 1687 of file WaveFunctionTester.cpp.

References WaveFunctionTester::DeltaVsError, WaveFunctionTester::myNode, WaveFunctionTester::outputDeltaVsError, FiniteDiffErrData::put(), and QMCDriver::putQMCInfo().

Referenced by WaveFunctionTester::run().

1688 {
1689  myNode = q;
1690  xmlNodePtr tcur = q->children;
1691  while (tcur != NULL)
1692  {
1693  std::string cname((const char*)(tcur->name));
1694  if (cname == "delta_output")
1695  {
1696  outputDeltaVsError = true;
1697  DeltaVsError.put(tcur);
1698  }
1699  tcur = tcur->next;
1700  }
1701 
1702  bool success = putQMCInfo(q);
1703 
1704  return success;
1705 }
bool putQMCInfo(xmlNodePtr cur)
Parses the xml input file for parameter definitions for a single qmc simulation.
Definition: QMCDriver.cpp:399

◆ run()

bool run ( )
overridevirtual

Test the evaluation of the wavefunction, gradient and laplacian by comparing to the numerical evaluation.

Use the finite difference formulas formulas

\[ \nabla_i f({\bf R}) = \frac{f({\bf R+\Delta r_i}) - f({\bf R})}{2\Delta r_i} \]

and

\[ \nabla_i^2 f({\bf R}) = \sum_{x,y,z} \frac{f({\bf R}+\Delta x_i) - 2 f({\bf R}) + f({\bf R}-\Delta x_i)}{2\Delta x_i^2}, \]

where $ f = \ln \Psi $ and $ \Delta r_i $ is a small displacement for the ith particle.

Implements QMCDriverInterface.

Definition at line 101 of file WaveFunctionTester.cpp.

References qmcplusplus::app_log(), WaveFunctionTester::checkBasic, WaveFunctionTester::checkClone, WaveFunctionTester::checkEloc, WaveFunctionTester::checkRatio, WaveFunctionTester::checkRatioV, WaveFunctionTester::checkSlaterDet, WaveFunctionTester::checkSlaterDetOption, OHMMS::Controller, WaveFunctionTester::deltaR, WaveFunctionTester::fout, QMCDriver::H, qmcplusplus::makeGaussRandom(), WaveFunctionTester::ndim, WaveFunctionTester::printEloc(), WaveFunctionTester::put(), QMCDriver::qmcNode, Communicate::rank(), QMCDriver::Rng, WaveFunctionTester::runBasicTest(), WaveFunctionTester::runCloneTest(), WaveFunctionTester::runDerivCloneTest(), WaveFunctionTester::runDerivNLPPTest(), WaveFunctionTester::runDerivTest(), WaveFunctionTester::runGradSourceTest(), WaveFunctionTester::runNodePlot(), WaveFunctionTester::runRatioTest2(), WaveFunctionTester::runRatioV(), QMCHamiltonian::setRandomGenerator(), WaveFunctionTester::sourceName, and WaveFunctionTester::wftricks.

102 {
103  std::array<char, 16> fname;
104  if (std::snprintf(fname.data(), fname.size(), "wftest.%03d", OHMMS::Controller->rank()) < 0)
105  throw std::runtime_error("Error generating filename");
106  fout.open(fname.data());
107  fout.precision(15);
108 
109  app_log() << "Starting a Wavefunction tester. Additional information in " << fname.data() << std::endl;
110 
111  put(qmcNode);
112 
113  auto Rng1 = std::make_unique<RandomGenerator>();
114  H.setRandomGenerator(Rng1.get());
115  // Add to Rng so the object is eventually deleted
116  Rng.emplace_back(std::move(Rng1));
117 
118  if (checkSlaterDetOption == "no")
119  checkSlaterDet = false;
120  if (checkRatio == "yes")
121  {
122  //runRatioTest();
123  runRatioTest2();
124  }
125  else if (checkClone == "yes")
126  runCloneTest();
127  else if (checkEloc != "no")
128  printEloc();
129  else if (sourceName.size() != 0)
130  {
132  // runZeroVarianceTest();
133  }
134  else if (checkRatio == "deriv")
135  {
137  if (ndim < 3)
138  {
139  for (int iat = 0; iat < deltaR.size(); ++iat)
140  deltaR[iat][2] = 0;
141  }
142  deltaR *= 0.2;
143  runDerivTest();
145  }
146  else if (checkRatio == "derivclone")
148  else if (wftricks == "rotate")
149  throw std::runtime_error("orbitalutility \"rotation\" has been removed.");
150  else if (wftricks == "plot")
151  runNodePlot();
152  else if (checkBasic == "yes")
153  runBasicTest();
154  else if (checkRatioV == "yes")
155  runRatioV();
156  else
157  app_log() << "No wavefunction test specified" << std::endl;
158 
159  //RealType ene = H.evaluate(W);
160  //app_log() << " Energy " << ene << std::endl;
161  return true;
162 }
int rank() const
return the rank
Definition: Communicate.h:116
std::ostream & app_log()
Definition: OutputManager.h:65
xmlNodePtr qmcNode
pointer to qmc node in xml file
Definition: QMCDriver.h:310
void runRatioV()
test ratios with virtual moves
Communicate * Controller
Global Communicator for a process.
Definition: Communicate.cpp:35
void makeGaussRandom(std::vector< TinyVector< T, D >> &a)
QMCHamiltonian & H
Hamiltonian.
Definition: QMCDriver.h:329
void runBasicTest()
basic tests for G and L
ParticleSet::ParticlePos deltaR
bool put(xmlNodePtr q) override
UPtrVector< RandomBase< FullPrecRealType > > Rng
Random number generators.
Definition: QMCDriver.h:341
void setRandomGenerator(RandomBase< FullPrecRealType > *rng)
void runCloneTest()
test clone implementations of new wavefunctions and operators

◆ runBasicTest()

void runBasicTest ( )
private

basic tests for G and L

Definition at line 924 of file WaveFunctionTester.cpp.

References qmcplusplus::abs(), qmcplusplus::app_log(), WalkerConfigurations::begin(), TrialWaveFunction::calcRatio(), WaveFunctionTester::checkGradientAtConfiguration(), WaveFunctionTester::computeNumericalGrad(), qmcplusplus::cos(), WaveFunctionTester::deltaR, WaveFunctionTester::DeltaVsError, qmcplusplus::Units::charge::e, WalkerConfigurations::end(), TrialWaveFunction::evaluateLog(), qmcplusplus::exp(), WaveFunctionTester::fout, ParticleSet::G, TrialWaveFunction::getPhase(), TrialWaveFunction::getPhaseDiff(), ParticleSet::getTotalNum(), FiniteDiffErrData::gradientComponentIndex, ParticleSet::L, qmcplusplus::makeGaussRandom(), ParticleSet::makeMove(), WaveFunctionTester::ndim, OHMMS_DIM, WaveFunctionTester::outputDeltaVsError, FiniteDiffErrData::outputFile, FiniteDiffErrData::particleIndex, QMCDriver::Psi, ParticleSet::R, ParticleSet::rejectMove(), TrialWaveFunction::rejectMove(), qmcplusplus::sin(), qmcplusplus::sqrt(), ParticleSet::update(), and QMCDriver::W.

Referenced by WaveFunctionTester::run().

925 {
926  int nat = W.getTotalNum();
927  fout << "Numerical gradient and Laplacian test" << std::endl;
928 
929  std::stringstream fail_log;
930  bool all_okay = true;
931  int fails = 0;
932  int nconfig = 0;
933  int nignore = 0;
934 
936  for (; Wit != W.end(); Wit++)
937  {
938  fout << "Walker # " << nconfig << std::endl;
939  std::stringstream fail_log1;
940  bool ignore = false;
941  bool this_okay = checkGradientAtConfiguration(Wit->get(), fail_log1, ignore);
942  if (ignore)
943  {
944  nignore++;
945  }
946  if (!this_okay && !ignore)
947  {
948  fail_log << "Walker # " << nconfig << std::endl;
949  fail_log << fail_log1.str();
950  fail_log << std::endl;
951  fails++;
952  all_okay = false;
953  }
954  nconfig++;
955  }
956 
957  app_log() << "Number of samples = " << nconfig << std::endl;
958  app_log() << "Number ignored (bad positions) = " << nignore << std::endl << std::endl;
959  app_log() << "Number of fails = " << fails << std::endl << std::endl;
960 
961  if (!all_okay)
962  {
963  std::string fail_name("wf_fails.dat");
964  app_log() << "More detail on finite difference failures in " << fail_name << std::endl;
965  std::ofstream eout(fail_name.c_str());
966  eout << fail_log.str();
967  eout.close();
968  }
969 
970  app_log() << "Finite difference test: " << (all_okay ? "PASS" : "FAIL") << std::endl;
971 
972  // Compute approximation error vs. delta.
973  if (outputDeltaVsError)
974  {
975  double delta = 1.0;
976  bool inputOkay = true;
977 
978  std::ofstream dout(DeltaVsError.outputFile.c_str());
979 
980  int iat = DeltaVsError.particleIndex;
982 
983  if (iat < 0 || iat >= nat)
984  {
985  dout << "# Particle index (" << iat << ") is out of range (0 - " << nat - 1 << ")" << std::endl;
986  inputOkay = false;
987  }
988 
989  if (ig < 0 || ig >= OHMMS_DIM)
990  {
991  dout << "# Gradient component index (" << ig << ") is out of range (0 - " << OHMMS_DIM - 1 << ")" << std::endl;
992  inputOkay = false;
993  }
994 
995  if (inputOkay)
996  {
997  dout << "# Particle = " << iat << " Gradient component = " << ig << std::endl;
998  dout << "#" << std::setw(11) << "delta" << std::setw(14) << "G_err_rel" << std::setw(14) << "L_err_rel"
999  << std::endl;
1000  ParticleSet::ParticleGradient G(nat), G1(nat);
1001  ParticleSet::ParticleLaplacian L(nat), L1(nat);
1002  for (int i = 0; i < 20; i++)
1003  {
1004  // compute analytic values
1005  G = W.G;
1006  L = W.L;
1007  Psi.evaluateLog(W);
1008 
1009  computeNumericalGrad(delta, G1, L1);
1010  ParticleSet::Scalar_t L_err = std::abs(L[iat] - L1[iat]);
1011  ParticleSet::Scalar_t L_err_rel = std::abs(L_err / L[iat]);
1012  ParticleSet::Scalar_t G_err = std::abs(G[iat][ig] - G1[iat][ig]);
1013  ParticleSet::Scalar_t G_err_rel = std::abs(G_err / G[iat][ig]);
1014  dout << std::setw(12) << delta;
1015  dout << std::setw(14) << std::abs(G_err_rel) << std::setw(14) << std::abs(L_err_rel);
1016  dout << std::endl;
1017  delta *= std::sqrt(0.1);
1018  }
1019  }
1020  dout.close();
1021  }
1022 
1023  fout << "Ratio test" << std::endl;
1024 
1025  RealType tol = 1e-3;
1026  RealType ratio_tol = 1e-9;
1027  bool any_ratio_fail = false;
1029  if (ndim < 3)
1030  {
1031  for (int iat = 0; iat < deltaR.size(); ++iat)
1032  deltaR[iat][2] = 0;
1033  }
1034  fout << "deltaR:" << std::endl;
1035  fout << deltaR << std::endl;
1036  fout << "Particle Ratio of Ratios Computed Ratio Internal Ratio" << std::endl;
1037  //testing ratio alone
1038  for (int iat = 0; iat < nat; iat++)
1039  {
1040  W.update();
1041  //ValueType psi_p = log(std::abs(Psi.evaluate(W)));
1042  RealType psi_p = Psi.evaluateLog(W);
1043  RealType phase_p = Psi.getPhase();
1044  W.makeMove(iat, deltaR[iat]);
1045  //W.update();
1046  ValueType aratio = Psi.calcRatio(W, iat);
1047  RealType phaseDiff = Psi.getPhaseDiff();
1048  W.rejectMove(iat);
1049  Psi.rejectMove(iat);
1050  W.R[iat] += deltaR[iat];
1051  W.update();
1052  //ValueType psi_m = log(std::abs(Psi.evaluate(W)));
1053  RealType psi_m = Psi.evaluateLog(W);
1054  RealType phase_m = Psi.getPhase();
1055 
1056 #if defined(QMC_COMPLEX)
1057  RealType ratioMag = std::exp(psi_m - psi_p);
1058  RealType dphase = phase_m - phase_p;
1059  if (phaseDiff < 0.0)
1060  phaseDiff += 2.0 * M_PI;
1061  if (phaseDiff > 2.0 * M_PI)
1062  phaseDiff -= 2.0 * M_PI;
1063  if (dphase < 0.0)
1064  dphase += 2.0 * M_PI;
1065  if (dphase > 2.0 * M_PI)
1066  dphase -= 2.0 * M_PI;
1067  ValueType ratDiff = std::complex<OHMMS_PRECISION>(ratioMag * std::cos(dphase), ratioMag * std::sin(dphase));
1068  // TODO - test complex ratio against a tolerance
1069  fout << iat << " " << aratio / ratDiff << " " << ratDiff << " " << aratio << std::endl;
1070  fout << " ratioMag " << std::abs(aratio) / ratioMag << " " << ratioMag << std::endl;
1071  fout << " PhaseDiff " << phaseDiff / dphase << " " << phaseDiff << " " << dphase << std::endl;
1072 #else
1073  RealType ratDiff = std::exp(psi_m - psi_p) * std::cos(phase_m - phase_p);
1074  fout << iat << " " << aratio / ratDiff << " " << ratDiff << " " << aratio << std::endl;
1075  if (std::abs(aratio / ratDiff - 1.0) > ratio_tol)
1076  {
1077  app_log() << "Wavefunction ratio exceeds tolerance " << tol << ") for particle " << iat << std::endl;
1078  app_log() << " Internally computed ratio = " << aratio << std::endl;
1079  app_log() << " Separately computed ratio = " << ratDiff << std::endl;
1080  any_ratio_fail = true;
1081  }
1082 #endif
1083  }
1084  app_log() << "Ratio test: " << (any_ratio_fail ? "FAIL" : "PASS") << std::endl;
1085 }
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
void rejectMove(int iat)
restore to the original state
ValueType calcRatio(ParticleSet &P, int iat, ComputeType ct=ComputeType::ALL)
compute psi(R_new) / psi(R_current) ratio It returns a complex value if the wavefunction is complex...
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
size_t getTotalNum() const
Definition: ParticleSet.h:493
std::ostream & app_log()
Definition: OutputManager.h:65
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
void update(bool skipSK=false)
update the internal data
ParticleLaplacian L
laplacians of the particles
Definition: ParticleSet.h:85
#define OHMMS_DIM
Definition: config.h:64
WalkerList_t::iterator iterator
FIX: a type alias of iterator for an object should not be for just one of many objects it holds...
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
QTBase::ValueType ValueType
Definition: Configuration.h:60
void makeGaussRandom(std::vector< TinyVector< T, D >> &a)
void rejectMove(Index_t iat)
reject a proposed move in regular mode
ParticleGradient G
gradients of the particles
Definition: ParticleSet.h:83
ParticlePos R
Position.
Definition: ParticleSet.h:79
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
ParticleSet::ParticlePos deltaR
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
QMCTraits::RealType RealType
void makeMove(Index_t iat, const SingleParticlePos &displ, bool maybe_accept=true)
move the iat-th particle to active_pos_
TrialWaveFunction & Psi
trial function
Definition: QMCDriver.h:326
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95
iterator end()
return the last iterator, [begin(), end())
void computeNumericalGrad(RealType delta, ParticleSet::ParticleGradient &G_fd, ParticleSet::ParticleLaplacian &L_fd)
bool checkGradientAtConfiguration(MCWalkerConfiguration::Walker_t *W1, std::stringstream &fail_log, bool &ignore)
iterator begin()
return the first iterator

◆ runCloneTest()

void runCloneTest ( )
private

test clone implementations of new wavefunctions and operators

Definition at line 164 of file WaveFunctionTester.cpp.

References PooledMemory< T_scalar, Alloc >::allocate(), qmcplusplus::app_log(), WalkerConfigurations::begin(), PooledMemory< T_scalar, Alloc >::clear(), TrialWaveFunction::copyFromBuffer(), PooledMemory< T_scalar, Alloc >::current(), Walker< t_traits, p_traits >::DataSet, QMCHamiltonian::evaluate(), TrialWaveFunction::evaluateLog(), ParticleSet::getTotalNum(), QMCDriver::H, QMCHamiltonian::makeClone(), TrialWaveFunction::makeClone(), Walker< t_traits, p_traits >::Properties, QMCDriver::Psi, ParticleSet::R, Walker< t_traits, p_traits >::R, TrialWaveFunction::registerData(), PooledMemory< T_scalar, Alloc >::size(), ParticleSet::update(), TrialWaveFunction::updateBuffer(), and QMCDriver::W.

Referenced by WaveFunctionTester::run().

165 {
166  app_log() << " ===== runCloneTest =====\n";
167  for (int iter = 0; iter < 4; ++iter)
168  {
169  app_log() << "Clone" << iter << std::endl;
170  auto w_clone = std::make_unique<MCWalkerConfiguration>(W);
171  auto psi_clone = Psi.makeClone(*w_clone);
172  auto h_clone = H.makeClone(*w_clone, *psi_clone);
173  h_clone->setPrimary(false);
174  int nat = W.getTotalNum();
175  MCWalkerConfiguration::PropertyContainer_t Properties(0, 0, 1, WP::MAXPROPERTIES);
176  //pick the first walker
177  MCWalkerConfiguration::Walker_t& awalker = **W.begin();
178  //copy the properties of the working walker
179  Properties = awalker.Properties;
180  W.R = awalker.R;
181  W.update();
182  ValueType logpsi1 = Psi.evaluateLog(W);
183  RealType eloc1 = H.evaluate(W);
184  w_clone->R = awalker.R;
185  w_clone->update();
186  ValueType logpsi2 = psi_clone->evaluateLog(*w_clone);
187  RealType eloc2 = h_clone->evaluate(*w_clone);
188  app_log() << "Testing walker-by-walker functions " << std::endl;
189  app_log() << "log (original) = " << logpsi1 << " energy = " << eloc1 << std::endl;
190  app_log() << "log (clone) = " << logpsi2 << " energy = " << eloc2 << std::endl;
191  app_log() << "Testing pbyp functions " << std::endl;
192  Walker_t::WFBuffer_t& wbuffer(awalker.DataSet);
193  wbuffer.clear();
194  app_log() << " Walker Buffer State current=" << wbuffer.current() << " size=" << wbuffer.size() << std::endl;
195  Psi.registerData(W, wbuffer);
196  wbuffer.allocate();
197  Psi.copyFromBuffer(W, wbuffer);
198  Psi.evaluateLog(W);
199  logpsi1 = Psi.updateBuffer(W, wbuffer, false);
200  eloc1 = H.evaluate(W);
201  app_log() << " Walker Buffer State current=" << wbuffer.current() << " size=" << wbuffer.size() << std::endl;
202  wbuffer.clear();
203  app_log() << " Walker Buffer State current=" << wbuffer.current() << " size=" << wbuffer.size() << std::endl;
204  psi_clone->registerData(W, wbuffer);
205  wbuffer.allocate();
206  Psi.copyFromBuffer(W, wbuffer);
207  Psi.evaluateLog(W);
208  logpsi2 = Psi.updateBuffer(W, wbuffer, false);
209  eloc2 = H.evaluate(*w_clone);
210  app_log() << " Walker Buffer State current=" << wbuffer.current() << " size=" << wbuffer.size() << std::endl;
211  app_log() << "log (original) = " << logpsi1 << " energy = " << eloc1 << std::endl;
212  app_log() << "log (clone) = " << logpsi2 << " energy = " << eloc2 << std::endl;
213  }
214 }
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
void copyFromBuffer(ParticleSet &P, WFBufferType &buf)
copy all the wavefunction components from buffer.
size_t getTotalNum() const
Definition: ParticleSet.h:493
std::ostream & app_log()
Definition: OutputManager.h:65
void update(bool skipSK=false)
update the internal data
RealType updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false)
update all the wavefunction components in buffer.
std::unique_ptr< TrialWaveFunction > makeClone(ParticleSet &tqp) const
PooledMemory< FullPrecRealType > WFBuffer_t
Definition: Walker.h:80
QTBase::ValueType ValueType
Definition: Configuration.h:60
void registerData(ParticleSet &P, WFBufferType &buf)
register all the wavefunction components in buffer.
QMCHamiltonian & H
Hamiltonian.
Definition: QMCDriver.h:329
ParticlePos R
Position.
Definition: ParticleSet.h:79
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
WalkerConfigurations::Walker_t Walker_t
QMCTraits::RealType RealType
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
TrialWaveFunction & Psi
trial function
Definition: QMCDriver.h:326
std::unique_ptr< QMCHamiltonian > makeClone(ParticleSet &qp, TrialWaveFunction &psi) const
return a clone
Walker_t::PropertyContainer_t PropertyContainer_t
container type of the Properties of a Walker
iterator begin()
return the first iterator

◆ runDerivCloneTest()

void runDerivCloneTest ( )
private

Definition at line 1925 of file WaveFunctionTester.cpp.

References qmcplusplus::app_log(), WalkerConfigurations::begin(), TrialWaveFunction::checkInVariables(), TrialWaveFunction::checkOutVariables(), WaveFunctionTester::deltaR, qmcplusplus::Units::charge::e, QMCHamiltonian::evaluate(), TrialWaveFunction::evaluateDerivatives(), TrialWaveFunction::evaluateLog(), WaveFunctionTester::fout, ParticleSet::G, QMCHamiltonian::getLocalEnergy(), QMCHamiltonian::getLocalPotential(), QMCHamiltonian::getObservable(), QMCHamiltonian::getObservableName(), ParticleSet::getTotalNum(), QMCDriver::H, ParticleSet::L, QMCHamiltonian::makeClone(), TrialWaveFunction::makeClone(), VariableSet::print(), QMCDriver::Psi, ParticleSet::R, Walker< t_traits, p_traits >::R, VariableSet::resetIndex(), TrialWaveFunction::resetParameters(), QMCDriver::Rng, QMCHamiltonian::setRandomGenerator(), VariableSet::size(), QMCHamiltonian::sizeOfObservables(), ParticleSet::update(), and QMCDriver::W.

Referenced by WaveFunctionTester::run().

1926 {
1927  app_log() << " ===== runDerivCloneTest =====\n";
1928  app_log() << " Testing derivatives clone" << std::endl;
1929  auto Rng1 = std::make_unique<RandomGenerator>();
1930  auto Rng2 = std::make_unique<RandomGenerator>();
1931  (*Rng1) = (*Rng2);
1932  auto w_clone = std::make_unique<MCWalkerConfiguration>(W);
1933  auto psi_clone = Psi.makeClone(*w_clone);
1934  auto h_clone = H.makeClone(*w_clone, *psi_clone);
1935  h_clone->setRandomGenerator(Rng2.get());
1936  H.setRandomGenerator(Rng1.get());
1937  // Add to Rng so the object is eventually deleted
1938  Rng.emplace_back(std::move(Rng1));
1939  h_clone->setPrimary(true);
1940  int nat = W.getTotalNum();
1942  //pick the first walker
1943  const MCWalkerConfiguration::Walker_t& awalker = **W.begin();
1944  // MCWalkerConfiguration::Walker_t* bwalker = *(w_clone->begin());
1945  // bwalker->R = awalker->R;
1946  W.R = awalker.R;
1947  W.update();
1948  w_clone->R = awalker.R;
1949  w_clone->update();
1950  opt_variables_type wfVars;
1951  //build optimizables from the wavefunction
1952  // wfVars.clear();
1953  Psi.checkInVariables(wfVars);
1954  wfVars.resetIndex();
1955  Psi.checkOutVariables(wfVars);
1956  wfVars.print(fout);
1957  int Nvars = wfVars.size();
1958  opt_variables_type wfvar_prime;
1959  // wfvar_prime.insertFrom(wfVars);
1960  // wfvar_prime.clear();
1961  psi_clone->checkInVariables(wfvar_prime);
1962  wfvar_prime.resetIndex();
1963  for (int j = 0; j < Nvars; j++)
1964  wfvar_prime[j] = wfVars[j];
1965  psi_clone->checkOutVariables(wfvar_prime);
1966  wfvar_prime.print(fout);
1967  psi_clone->resetParameters(wfvar_prime);
1968  Psi.resetParameters(wfVars);
1969  Vector<ValueType> Dsaved(Nvars, 0), og_Dsaved(Nvars, 0);
1970  Vector<ValueType> HDsaved(Nvars, 0), og_HDsaved(Nvars, 0);
1971  std::vector<RealType> PGradient(Nvars, 0), og_PGradient(Nvars, 0);
1972  std::vector<RealType> HGradient(Nvars, 0), og_HGradient(Nvars, 0);
1973  ValueType logpsi2 = psi_clone->evaluateLog(*w_clone);
1974  RealType eloc2 = h_clone->evaluate(*w_clone);
1975  psi_clone->evaluateDerivatives(*w_clone, wfvar_prime, Dsaved, HDsaved);
1976  ValueType logpsi1 = Psi.evaluateLog(W);
1977  RealType eloc1 = H.evaluate(W);
1978  Psi.evaluateDerivatives(W, wfVars, og_Dsaved, og_HDsaved);
1979  app_log() << "log (original) = " << logpsi1 << " energy = " << eloc1 << std::endl;
1980  for (int i = 0; i < H.sizeOfObservables(); i++)
1981  app_log() << " HamTest " << H.getObservableName(i) << " " << H.getObservable(i) << std::endl;
1982  app_log() << "log (clone) = " << logpsi2 << " energy = " << eloc2 << std::endl;
1983  for (int i = 0; i < h_clone->sizeOfObservables(); i++)
1984  app_log() << " HamTest " << h_clone->getObservableName(i) << " " << h_clone->getObservable(i) << std::endl;
1985  // app_log()<<" Saved quantities:"<< std::endl;
1986  // for(int i=0;i<Nvars;i++) app_log()<<Dsaved[i]<<" "<<og_Dsaved[i]<<" "<<HDsaved[i]<<" "<<og_HDsaved[i]<< std::endl;
1987  RealType FiniteDiff = 1e-6;
1988  QMCTraits::RealType dh = 1.0 / (2.0 * FiniteDiff);
1989  for (int i = 0; i < Nvars; i++)
1990  {
1991  for (int j = 0; j < Nvars; j++)
1992  wfvar_prime[j] = wfVars[j];
1993  wfvar_prime[i] = wfVars[i] + FiniteDiff;
1994  psi_clone->resetParameters(wfvar_prime);
1995  w_clone->update();
1996  w_clone->G = 0;
1997  w_clone->L = 0;
1998  RealType logpsiPlus = psi_clone->evaluateLog(*w_clone);
1999  h_clone->evaluate(*w_clone);
2000  RealType elocPlus = h_clone->getLocalEnergy() - h_clone->getLocalPotential();
2001  wfvar_prime[i] = wfVars[i] - FiniteDiff;
2002  psi_clone->resetParameters(wfvar_prime);
2003  w_clone->update();
2004  w_clone->G = 0;
2005  w_clone->L = 0;
2006  RealType logpsiMinus = psi_clone->evaluateLog(*w_clone);
2007  h_clone->evaluate(*w_clone);
2008  RealType elocMinus = h_clone->getLocalEnergy() - h_clone->getLocalPotential();
2009  PGradient[i] = (logpsiPlus - logpsiMinus) * dh;
2010  HGradient[i] = (elocPlus - elocMinus) * dh;
2011  }
2012  fout << "CLONE" << std::endl;
2013  fout << std::endl << " Deriv Numeric Analytic" << std::endl;
2014  for (int i = 0; i < Nvars; i++)
2015  fout << i << " " << PGradient[i] << " " << std::real(Dsaved[i]) << " "
2016  << (PGradient[i] - std::real(Dsaved[i])) / PGradient[i] << std::endl;
2017  fout << std::endl << " Hderiv Numeric Analytic" << std::endl;
2018  for (int i = 0; i < Nvars; i++)
2019  fout << i << " " << HGradient[i] << " " << std::real(HDsaved[i]) << " "
2020  << (HGradient[i] - std::real(HDsaved[i])) / HGradient[i] << std::endl;
2021  for (int i = 0; i < Nvars; i++)
2022  {
2023  for (int j = 0; j < Nvars; j++)
2024  wfvar_prime[j] = wfVars[j];
2025  wfvar_prime[i] = wfVars[i] + FiniteDiff;
2026  Psi.resetParameters(wfvar_prime);
2027  W.update();
2028  W.G = 0;
2029  W.L = 0;
2030  RealType logpsiPlus = Psi.evaluateLog(W);
2031  H.evaluate(W);
2032  RealType elocPlus = H.getLocalEnergy() - H.getLocalPotential();
2033  wfvar_prime[i] = wfVars[i] - FiniteDiff;
2034  Psi.resetParameters(wfvar_prime);
2035  W.update();
2036  W.G = 0;
2037  W.L = 0;
2038  RealType logpsiMinus = Psi.evaluateLog(W);
2039  H.evaluate(W);
2040  RealType elocMinus = H.getLocalEnergy() - H.getLocalPotential();
2041  PGradient[i] = (logpsiPlus - logpsiMinus) * dh;
2042  HGradient[i] = (elocPlus - elocMinus) * dh;
2043  }
2044  fout << "ORIGINAL" << std::endl;
2045  fout << std::endl << " Deriv Numeric Analytic" << std::endl;
2046  for (int i = 0; i < Nvars; i++)
2047  fout << i << " " << PGradient[i] << " " << std::real(Dsaved[i]) << " "
2048  << (PGradient[i] - std::real(Dsaved[i])) / PGradient[i] << std::endl;
2049  fout << std::endl << " Hderiv Numeric Analytic" << std::endl;
2050  for (int i = 0; i < Nvars; i++)
2051  fout << i << " " << HGradient[i] << " " << std::real(HDsaved[i]) << " "
2052  << (HGradient[i] - std::real(HDsaved[i])) / HGradient[i] << std::endl;
2053 }
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
FullPrecRealType getLocalPotential()
std::string getObservableName(int i) const
return the name of the i-th observable
QMCTraits::RealType real
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)
evaluate derivatives of KE wrt optimizable varibles
QTBase::RealType RealType
Definition: Configuration.h:58
size_t getTotalNum() const
Definition: ParticleSet.h:493
std::ostream & app_log()
Definition: OutputManager.h:65
void resetParameters(const opt_variables_type &active)
Set values of parameters in each component from the global list.
RealType getObservable(int i) const
return the value of the i-th observable
void resetIndex()
reset Index
void update(bool skipSK=false)
update the internal data
ParticleLaplacian L
laplacians of the particles
Definition: ParticleSet.h:85
std::unique_ptr< TrialWaveFunction > makeClone(ParticleSet &tqp) const
QTBase::ValueType ValueType
Definition: Configuration.h:60
ParticleGradient G
gradients of the particles
Definition: ParticleSet.h:83
QMCHamiltonian & H
Hamiltonian.
Definition: QMCDriver.h:329
int sizeOfObservables() const
return the size of observables
ParticlePos R
Position.
Definition: ParticleSet.h:79
FullPrecRealType getLocalEnergy()
ParticleSet::ParticlePos deltaR
void checkOutVariables(const opt_variables_type &o)
Check out optimizable variables Assign index mappings from global list (o) to local values in each co...
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
optimize::VariableSet opt_variables_type
WalkerConfigurations::Walker_t Walker_t
QMCTraits::RealType RealType
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
ParticleAttrib< SingleParticlePos > ParticlePos
Definition: Configuration.h:92
TrialWaveFunction & Psi
trial function
Definition: QMCDriver.h:326
UPtrVector< RandomBase< FullPrecRealType > > Rng
Random number generators.
Definition: QMCDriver.h:341
void setRandomGenerator(RandomBase< FullPrecRealType > *rng)
std::unique_ptr< QMCHamiltonian > makeClone(ParticleSet &qp, TrialWaveFunction &psi) const
return a clone
void checkInVariables(opt_variables_type &o)
Check in an optimizable parameter.
iterator begin()
return the first iterator

◆ runDerivNLPPTest()

void runDerivNLPPTest ( )
private

Definition at line 1809 of file WaveFunctionTester.cpp.

References qmcplusplus::app_log(), WalkerConfigurations::begin(), TrialWaveFunction::checkInVariables(), TrialWaveFunction::checkOutVariables(), VariableSet::clear(), OHMMS::Controller, WaveFunctionTester::deltaR, qmcplusplus::Units::charge::e, QMCHamiltonian::evaluate(), TrialWaveFunction::evaluateDerivatives(), TrialWaveFunction::evaluateLog(), QMCHamiltonian::evaluateValueAndDerivatives(), QMCHamiltonian::evaluateVariableEnergy(), ParticleSet::G, QMCHamiltonian::getLocalEnergy(), QMCHamiltonian::getObservable(), QMCHamiltonian::getObservableName(), ParticleSet::getTotalNum(), QMCDriver::H, ParticleSet::L, VariableSet::print(), Walker< t_traits, p_traits >::Properties, QMCDriver::Psi, ParticleSet::R, Walker< t_traits, p_traits >::R, Communicate::rank(), VariableSet::resetIndex(), TrialWaveFunction::resetParameters(), QMCHamiltonian::setPrimary(), VariableSet::size(), QMCHamiltonian::sizeOfObservables(), ParticleSet::update(), and QMCDriver::W.

Referenced by WaveFunctionTester::run().

1810 {
1811  app_log() << " ===== runDerivNLPPTest =====\n";
1812  std::array<char, 16> fname;
1813  if (std::snprintf(fname.data(), fname.size(), "nlpp.%03d", OHMMS::Controller->rank()) < 0)
1814  throw std::runtime_error("Error generating name");
1815 
1816  std::ofstream nlout(fname.data());
1817  nlout.precision(15);
1818 
1819  app_log() << " Testing derivatives" << std::endl;
1820  int nat = W.getTotalNum();
1821  MCWalkerConfiguration::PropertyContainer_t Properties(0, 0, 1, WP::MAXPROPERTIES);
1822  //pick the first walker
1823  const MCWalkerConfiguration::Walker_t& awalker = **W.begin();
1824  //copy the properties of the working walker
1825  Properties = awalker.Properties;
1826  //sample a new walker configuration and copy to ParticleSet::R
1827  W.R = awalker.R + deltaR;
1828 
1829  //W.R += deltaR;
1830  W.update();
1831  //ValueType psi = Psi.evaluate(W);
1832  Psi.evaluateLog(W);
1833  RealType eloc = H.evaluate(W);
1834 
1835  app_log() << " HamTest "
1836  << " Total " << eloc << std::endl;
1837  for (int i = 0; i < H.sizeOfObservables(); i++)
1838  app_log() << " HamTest " << H.getObservableName(i) << " " << H.getObservable(i) << std::endl;
1839 
1840  //RealType psi = Psi.evaluateLog(W);
1841  ParticleSet::ParticleGradient G(nat), G1(nat);
1842  ParticleSet::ParticleLaplacian L(nat), L1(nat);
1843  G = W.G;
1844  L = W.L;
1845  nlout << "Gradients" << std::endl;
1846  for (int iat = 0; iat < W.R.size(); iat++)
1847  {
1848  for (int i = 0; i < 3; i++)
1849  nlout << W.G[iat][i] << " ";
1850  nlout << std::endl;
1851  }
1852  nlout << "Laplaians" << std::endl;
1853  for (int iat = 0; iat < W.R.size(); iat++)
1854  {
1855  nlout << W.L[iat] << " ";
1856  nlout << std::endl;
1857  }
1858  opt_variables_type wfVars, wfvar_prime;
1859  //build optimizables from the wavefunction
1860  wfVars.clear();
1861  Psi.checkInVariables(wfVars);
1862  wfVars.resetIndex();
1863  Psi.checkOutVariables(wfVars);
1864  wfvar_prime = wfVars;
1865  wfVars.print(nlout);
1866  int Nvars = wfVars.size();
1867  Vector<ValueType> Dsaved(Nvars);
1868  Vector<ValueType> HDsaved(Nvars);
1869  std::vector<RealType> PGradient(Nvars);
1870  std::vector<RealType> HGradient(Nvars);
1871  Psi.resetParameters(wfVars);
1872 
1873  Psi.evaluateLog(W);
1874 
1875  //reuse the sphere for non-local pp
1876  H.setPrimary(false);
1877 
1878  std::vector<RealType> ene(4), ene_p(4), ene_m(4);
1879  Psi.evaluateDerivatives(W, wfVars, Dsaved, HDsaved);
1880 
1881  ene[0] = H.evaluateValueAndDerivatives(W, wfVars, Dsaved, HDsaved);
1882  app_log() << "Check the energy " << eloc << " " << H.getLocalEnergy() << " " << ene[0] << std::endl;
1883 
1884  RealType FiniteDiff = 1e-6;
1885  QMCTraits::RealType dh = 1.0 / (2.0 * FiniteDiff);
1886  for (int i = 0; i < Nvars; i++)
1887  {
1888  for (int j = 0; j < Nvars; j++)
1889  wfvar_prime[j] = wfVars[j];
1890  wfvar_prime[i] = wfVars[i] + FiniteDiff;
1891  Psi.resetParameters(wfvar_prime);
1892  W.update();
1893  W.G = 0;
1894  W.L = 0;
1895  RealType logpsiPlus = Psi.evaluateLog(W);
1896  RealType elocPlus = H.evaluateVariableEnergy(W, true);
1897 
1898  //H.evaluate(W);
1899  //RealType elocPlus=H.getLocalEnergy()-H.getLocalPotential();
1900 
1901  wfvar_prime[i] = wfVars[i] - FiniteDiff;
1902  Psi.resetParameters(wfvar_prime);
1903  W.update();
1904  W.G = 0;
1905  W.L = 0;
1906  RealType logpsiMinus = Psi.evaluateLog(W);
1907  RealType elocMinus = H.evaluateVariableEnergy(W, true);
1908 
1909  //H.evaluate(W);
1910  //RealType elocMinus = H.getLocalEnergy()-H.getLocalPotential();
1911 
1912  PGradient[i] = (logpsiPlus - logpsiMinus) * dh;
1913  HGradient[i] = (elocPlus - elocMinus) * dh;
1914  }
1915 
1916  nlout << std::endl << "Deriv Numeric Analytic" << std::endl;
1917  for (int i = 0; i < Nvars; i++)
1918  nlout << i << " " << PGradient[i] << " " << Dsaved[i] << " " << (PGradient[i] - Dsaved[i]) << std::endl;
1919  nlout << std::endl << "Hderiv Numeric Analytic" << std::endl;
1920  for (int i = 0; i < Nvars; i++)
1921  nlout << i << " " << HGradient[i] << " " << HDsaved[i] << " " << (HGradient[i] - HDsaved[i]) << std::endl;
1922 }
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
std::string getObservableName(int i) const
return the name of the i-th observable
int rank() const
return the rank
Definition: Communicate.h:116
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)
evaluate derivatives of KE wrt optimizable varibles
QTBase::RealType RealType
Definition: Configuration.h:58
size_t getTotalNum() const
Definition: ParticleSet.h:493
std::ostream & app_log()
Definition: OutputManager.h:65
FullPrecRealType evaluateValueAndDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)
evaluate energy and derivatives wrt to the variables
void resetParameters(const opt_variables_type &active)
Set values of parameters in each component from the global list.
RealType getObservable(int i) const
return the value of the i-th observable
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
void update(bool skipSK=false)
update the internal data
Communicate * Controller
Global Communicator for a process.
Definition: Communicate.cpp:35
ParticleLaplacian L
laplacians of the particles
Definition: ParticleSet.h:85
ParticleGradient G
gradients of the particles
Definition: ParticleSet.h:83
QMCHamiltonian & H
Hamiltonian.
Definition: QMCDriver.h:329
int sizeOfObservables() const
return the size of observables
ParticlePos R
Position.
Definition: ParticleSet.h:79
FullPrecRealType getLocalEnergy()
ParticleSet::ParticlePos deltaR
void checkOutVariables(const opt_variables_type &o)
Check out optimizable variables Assign index mappings from global list (o) to local values in each co...
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
optimize::VariableSet opt_variables_type
void clear()
clear the variable set
Definition: VariableSet.cpp:28
WalkerConfigurations::Walker_t Walker_t
QMCTraits::RealType RealType
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
TrialWaveFunction & Psi
trial function
Definition: QMCDriver.h:326
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95
FullPrecRealType evaluateVariableEnergy(ParticleSet &P, bool free_nlpp)
evaluate energy
void setPrimary(bool primary)
set PRIMARY bit of all the components
Walker_t::PropertyContainer_t PropertyContainer_t
container type of the Properties of a Walker
void checkInVariables(opt_variables_type &o)
Check in an optimizable parameter.
iterator begin()
return the first iterator

◆ runDerivTest()

void runDerivTest ( )
private

Definition at line 1707 of file WaveFunctionTester.cpp.

References qmcplusplus::app_log(), WalkerConfigurations::begin(), TrialWaveFunction::checkInVariables(), TrialWaveFunction::checkOutVariables(), VariableSet::clear(), WaveFunctionTester::deltaR, qmcplusplus::Units::charge::e, QMCHamiltonian::evaluate(), TrialWaveFunction::evaluateDerivatives(), TrialWaveFunction::evaluateLog(), WaveFunctionTester::fout, ParticleSet::G, QMCHamiltonian::getLocalEnergy(), QMCHamiltonian::getLocalPotential(), QMCHamiltonian::getObservable(), QMCHamiltonian::getObservableName(), ParticleSet::getTotalNum(), QMCDriver::H, ParticleSet::L, VariableSet::print(), Walker< t_traits, p_traits >::Properties, QMCDriver::Psi, ParticleSet::R, Walker< t_traits, p_traits >::R, VariableSet::resetIndex(), TrialWaveFunction::resetParameters(), QMCHamiltonian::setPrimary(), VariableSet::size(), QMCHamiltonian::sizeOfObservables(), ParticleSet::update(), and QMCDriver::W.

Referenced by WaveFunctionTester::run().

1708 {
1709  app_log() << " ===== runDerivTest =====\n";
1710  app_log() << " Testing derivatives" << std::endl;
1711  int nat = W.getTotalNum();
1712  MCWalkerConfiguration::PropertyContainer_t Properties(0, 0, 1, WP::MAXPROPERTIES);
1713  //pick the first walker
1714  const MCWalkerConfiguration::Walker_t& awalker = **W.begin();
1715  //copy the properties of the working walker
1716  Properties = awalker.Properties;
1717  //sample a new walker configuration and copy to ParticleSet::R
1718  W.R = awalker.R + deltaR;
1719 
1720  fout << "Position " << std::endl << W.R << std::endl;
1721 
1722  //W.R += deltaR;
1723  W.update();
1724  //ValueType psi = Psi.evaluate(W);
1725  Psi.evaluateLog(W);
1726  RealType eloc = H.evaluate(W);
1727  app_log() << " HamTest "
1728  << " Total " << eloc << std::endl;
1729  for (int i = 0; i < H.sizeOfObservables(); i++)
1730  app_log() << " HamTest " << H.getObservableName(i) << " " << H.getObservable(i) << std::endl;
1731  //RealType psi = Psi.evaluateLog(W);
1732  ParticleSet::ParticleGradient G(nat), G1(nat);
1733  ParticleSet::ParticleLaplacian L(nat), L1(nat);
1734  G = W.G;
1735  L = W.L;
1736  fout << "Gradients" << std::endl;
1737  for (int iat = 0; iat < W.R.size(); iat++)
1738  {
1739  for (int i = 0; i < 3; i++)
1740  fout << W.G[iat][i] << " ";
1741  fout << std::endl;
1742  }
1743  fout << "Laplaians" << std::endl;
1744  for (int iat = 0; iat < W.R.size(); iat++)
1745  {
1746  fout << W.L[iat] << " ";
1747  fout << std::endl;
1748  }
1749  opt_variables_type wfVars, wfvar_prime;
1750  //build optimizables from the wavefunction
1751  wfVars.clear();
1752  Psi.checkInVariables(wfVars);
1753  wfVars.resetIndex();
1754  Psi.checkOutVariables(wfVars);
1755  wfvar_prime = wfVars;
1756  wfVars.print(fout);
1757  int Nvars = wfVars.size();
1758  Vector<ValueType> Dsaved(Nvars);
1759  Vector<ValueType> HDsaved(Nvars);
1760  std::vector<RealType> PGradient(Nvars);
1761  std::vector<RealType> HGradient(Nvars);
1762  Psi.resetParameters(wfVars);
1763  Psi.evaluateLog(W);
1764 
1765  //reuse the sphere
1766  H.setPrimary(false);
1767 
1768  eloc = H.evaluate(W);
1769  Psi.evaluateDerivatives(W, wfVars, Dsaved, HDsaved);
1770  RealType FiniteDiff = 1e-6;
1771  QMCTraits::RealType dh = 1.0 / (2.0 * FiniteDiff);
1772  for (int i = 0; i < Nvars; i++)
1773  {
1774  for (int j = 0; j < Nvars; j++)
1775  wfvar_prime[j] = wfVars[j];
1776  wfvar_prime[i] = wfVars[i] + FiniteDiff;
1777  // Psi.checkOutVariables(wfvar_prime);
1778  Psi.resetParameters(wfvar_prime);
1779  W.update();
1780  W.G = 0;
1781  W.L = 0;
1782  RealType logpsiPlus = Psi.evaluateLog(W);
1783  H.evaluate(W);
1784  RealType elocPlus = H.getLocalEnergy() - H.getLocalPotential();
1785  wfvar_prime[i] = wfVars[i] - FiniteDiff;
1786  // Psi.checkOutVariables(wfvar_prime);
1787  Psi.resetParameters(wfvar_prime);
1788  W.update();
1789  W.G = 0;
1790  W.L = 0;
1791  RealType logpsiMinus = Psi.evaluateLog(W);
1792  H.evaluate(W);
1793  RealType elocMinus = H.getLocalEnergy() - H.getLocalPotential();
1794  PGradient[i] = (logpsiPlus - logpsiMinus) * dh;
1795  HGradient[i] = (elocPlus - elocMinus) * dh;
1796  }
1797  Psi.resetParameters(wfVars);
1798  fout << std::endl << "Deriv Numeric Analytic" << std::endl;
1799  for (int i = 0; i < Nvars; i++)
1800  fout << i << " " << PGradient[i] << " " << std::real(Dsaved[i]) << " " << (PGradient[i] - std::real(Dsaved[i]))
1801  << std::endl;
1802  fout << std::endl << "Hderiv Numeric Analytic" << std::endl;
1803  for (int i = 0; i < Nvars; i++)
1804  fout << i << " " << HGradient[i] << " " << std::real(HDsaved[i]) << " " << (HGradient[i] - std::real(HDsaved[i]))
1805  << std::endl;
1806 }
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
FullPrecRealType getLocalPotential()
std::string getObservableName(int i) const
return the name of the i-th observable
QMCTraits::RealType real
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)
evaluate derivatives of KE wrt optimizable varibles
QTBase::RealType RealType
Definition: Configuration.h:58
size_t getTotalNum() const
Definition: ParticleSet.h:493
std::ostream & app_log()
Definition: OutputManager.h:65
void resetParameters(const opt_variables_type &active)
Set values of parameters in each component from the global list.
RealType getObservable(int i) const
return the value of the i-th observable
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
void update(bool skipSK=false)
update the internal data
ParticleLaplacian L
laplacians of the particles
Definition: ParticleSet.h:85
ParticleGradient G
gradients of the particles
Definition: ParticleSet.h:83
QMCHamiltonian & H
Hamiltonian.
Definition: QMCDriver.h:329
int sizeOfObservables() const
return the size of observables
ParticlePos R
Position.
Definition: ParticleSet.h:79
FullPrecRealType getLocalEnergy()
ParticleSet::ParticlePos deltaR
void checkOutVariables(const opt_variables_type &o)
Check out optimizable variables Assign index mappings from global list (o) to local values in each co...
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
optimize::VariableSet opt_variables_type
void clear()
clear the variable set
Definition: VariableSet.cpp:28
WalkerConfigurations::Walker_t Walker_t
QMCTraits::RealType RealType
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
TrialWaveFunction & Psi
trial function
Definition: QMCDriver.h:326
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95
void setPrimary(bool primary)
set PRIMARY bit of all the components
Walker_t::PropertyContainer_t PropertyContainer_t
container type of the Properties of a Walker
void checkInVariables(opt_variables_type &o)
Check in an optimizable parameter.
iterator begin()
return the first iterator

◆ runGradSourceTest()

void runGradSourceTest ( )
private

Definition at line 1440 of file WaveFunctionTester.cpp.

References qmcplusplus::app_log(), QMCHamiltonian::auxHevaluate(), WalkerConfigurations::begin(), WaveFunctionTester::deltaR, TrialWaveFunction::evalGradSource(), QMCHamiltonian::evaluate(), TrialWaveFunction::evaluateLog(), WaveFunctionTester::fout, ParticleSet::G, QMCHamiltonian::getObservable(), QMCHamiltonian::getObservableName(), ParticleSetPool::getPool(), ParticleSet::getTotalNum(), QMCDriver::H, ParticleSet::L, qmcplusplus::log(), OHMMS_DIM, Walker< t_traits, p_traits >::Properties, QMCDriver::Psi, WaveFunctionTester::PtclPool, ParticleSet::R, Walker< t_traits, p_traits >::R, QMCHamiltonian::sizeOfObservables(), WaveFunctionTester::sourceName, ParticleSet::update(), and QMCDriver::W.

Referenced by WaveFunctionTester::run().

1441 {
1442  app_log() << " ===== runGradSourceTest =====\n";
1443  for (auto& [key, value] : PtclPool.getPool())
1444  app_log() << "ParticelSet = " << key << std::endl;
1445  // Find source ParticleSet
1446  auto pit(PtclPool.getPool().find(sourceName));
1447  app_log() << pit->first << std::endl;
1448  // if(pit == PtclPool.getPool().end())
1449  // APP_ABORT("Unknown source \"" + sourceName + "\" WaveFunctionTester.");
1450  ParticleSet& source = *((*pit).second);
1451  RealType delta = 0.00001;
1452  ValueType c1 = 1.0 / delta / 2.0;
1453  ValueType c2 = 1.0 / delta / delta;
1454  int nat = W.getTotalNum();
1456  MCWalkerConfiguration::PropertyContainer_t Properties(0, 0, 1, WP::MAXPROPERTIES);
1457  //pick the first walker
1458  const MCWalkerConfiguration::Walker_t& awalker = **W.begin();
1459  //copy the properties of the working walker
1460  Properties = awalker.Properties;
1461  //sample a new walker configuration and copy to ParticleSet::R
1462  //makeGaussRandom(deltaR);
1463  W.R = awalker.R;
1464  //W.R += deltaR;
1465  W.update();
1466  //ValueType psi = Psi.evaluate(W);
1467  ValueType logpsi = Psi.evaluateLog(W);
1468  RealType eloc = H.evaluate(W);
1469  H.auxHevaluate(W);
1470  app_log() << " HamTest "
1471  << " Total " << eloc << std::endl;
1472  for (int i = 0; i < H.sizeOfObservables(); i++)
1473  app_log() << " HamTest " << H.getObservableName(i) << " " << H.getObservable(i) << std::endl;
1474  //RealType psi = Psi.evaluateLog(W);
1475  ParticleSet::ParticleGradient G(nat), G1(nat);
1476  ParticleSet::ParticleLaplacian L(nat), L1(nat);
1477  G = W.G;
1478  L = W.L;
1479 
1480  //This code computes d/dR \ln \Psi_T using the evalGradSource method, and
1481  // by finite difference. Results are saved in grad_ion and grad_ion_FD respectively.
1482  // GRAD TEST COMPUTATION
1483  int nions = source.getTotalNum();
1484  ParticleSet::ParticleGradient grad_ion(nions), grad_ion_FD(nions);
1485  for (int iat = 0; iat < nions; iat++)
1486  {
1487  grad_ion[iat] = Psi.evalGradSource(W, source, iat);
1488  PosType rI = source.R[iat];
1489  for (int iondim = 0; iondim < 3; iondim++)
1490  {
1491  source.R[iat][iondim] = rI[iondim] + delta;
1492  source.update();
1493  W.update();
1494 
1495  ValueType log_p = Psi.evaluateLog(W);
1496 
1497  source.R[iat][iondim] = rI[iondim] - delta;
1498  source.update();
1499  W.update();
1500  ValueType log_m = Psi.evaluateLog(W);
1501 
1502  //symmetric finite difference formula for gradient.
1503  grad_ion_FD[iat][iondim] = c1 * (log_p - log_m);
1504 
1505  //reset everything to how it was.
1506  source.R[iat][iondim] = rI[iondim];
1507  source.update();
1508  W.update();
1509  }
1510  //this lastone makes sure the distance tables correspond to unperturbed source.
1511  }
1512  //END GRAD TEST COMPUTATION
1513 
1514  for (int isrc = 0; isrc < 1 /*source.getTotalNum()*/; isrc++)
1515  {
1520  for (int dim = 0; dim < OHMMS_DIM; dim++)
1521  {
1522  grad_grad[dim].resize(nat);
1523  lapl_grad[dim].resize(nat);
1524  grad_grad_FD[dim].resize(nat);
1525  lapl_grad_FD[dim].resize(nat);
1526  }
1527  Psi.evaluateLog(W);
1528  GradType grad_log = Psi.evalGradSource(W, source, isrc, grad_grad, lapl_grad);
1530  //grad_log = Psi.evalGradSource (W, source, isrc);
1531  for (int iat = 0; iat < nat; iat++)
1532  {
1533  PosType r0 = W.R[iat];
1534  GradType gFD[OHMMS_DIM];
1535  GradType lapFD = ValueType();
1536  for (int eldim = 0; eldim < 3; eldim++)
1537  {
1538  W.R[iat][eldim] = r0[eldim] + delta;
1539  W.update();
1540  ValueType log_p = Psi.evaluateLog(W);
1541  GradType gradlogpsi_p = Psi.evalGradSource(W, source, isrc);
1542  W.R[iat][eldim] = r0[eldim] - delta;
1543  W.update();
1544  ValueType log_m = Psi.evaluateLog(W);
1545  GradType gradlogpsi_m = Psi.evalGradSource(W, source, isrc);
1546  lapFD += gradlogpsi_m + gradlogpsi_p;
1547  gFD[eldim] = gradlogpsi_p - gradlogpsi_m;
1548  W.R[iat] = r0;
1549  W.update();
1550  //Psi.evaluateLog(W);
1551  }
1552  const ValueType six(6);
1553  for (int iondim = 0; iondim < OHMMS_DIM; iondim++)
1554  {
1555  for (int eldim = 0; eldim < OHMMS_DIM; eldim++)
1556  grad_grad_FD[iondim][iat][eldim] = c1 * gFD[eldim][iondim];
1557  lapl_grad_FD[iondim][iat] = c2 * (lapFD[iondim] - six * grad_log[iondim]);
1558  }
1559  }
1560  for (int dimsrc = 0; dimsrc < OHMMS_DIM; dimsrc++)
1561  {
1562  for (int iat = 0; iat < nat; iat++)
1563  {
1564  fout << "For particle #" << iat << " at " << W.R[iat] << std::endl;
1565  fout << "Grad Gradient = " << std::setw(12) << grad_grad[dimsrc][iat] << std::endl
1566  << " Finite diff = " << std::setw(12) << grad_grad_FD[dimsrc][iat] << std::endl
1567  << " Error = " << std::setw(12) << grad_grad_FD[dimsrc][iat] - grad_grad[dimsrc][iat] << std::endl
1568  << std::endl;
1569  fout << "Grad Laplacian = " << std::setw(12) << lapl_grad[dimsrc][iat] << std::endl
1570  << " Finite diff = " << std::setw(12) << lapl_grad_FD[dimsrc][iat] << std::endl
1571  << " Error = " << std::setw(12) << lapl_grad_FD[dimsrc][iat] - lapl_grad[dimsrc][iat] << std::endl
1572  << std::endl;
1573  }
1574  }
1575  fout << "==== BEGIN Ion Gradient Check ====\n";
1576  for (int iat = 0; iat < nions; iat++)
1577  {
1578  fout << "For ion #" << iat << " at " << source.R[iat] << std::endl;
1579  fout << "Gradient = " << std::setw(12) << grad_ion[iat] << std::endl
1580  << " Finite diff = " << std::setw(12) << grad_ion_FD[iat] << std::endl
1581  << " Error = " << std::setw(12) << grad_ion_FD[iat] - grad_ion[iat] << std::endl
1582  << std::endl;
1583  }
1584  fout << "==== END Ion Gradient Check ====\n";
1585  fout.flush();
1586  }
1587 }
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
std::string getObservableName(int i) const
return the name of the i-th observable
QTBase::GradType GradType
Definition: Configuration.h:62
size_t getTotalNum() const
Definition: ParticleSet.h:493
std::ostream & app_log()
Definition: OutputManager.h:65
RealType getObservable(int i) const
return the value of the i-th observable
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
void update(bool skipSK=false)
update the internal data
ParticleLaplacian L
laplacians of the particles
Definition: ParticleSet.h:85
#define OHMMS_DIM
Definition: config.h:64
QMCTraits::PosType PosType
QTBase::ValueType ValueType
Definition: Configuration.h:60
ParticleGradient G
gradients of the particles
Definition: ParticleSet.h:83
GradType evalGradSource(ParticleSet &P, ParticleSet &source, int iat)
Returns the logarithmic gradient of the trial wave function with respect to the iat^th atom of the so...
QMCHamiltonian & H
Hamiltonian.
Definition: QMCDriver.h:329
int sizeOfObservables() const
return the size of observables
ParticlePos R
Position.
Definition: ParticleSet.h:79
ParticleSet::ParticlePos deltaR
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
WalkerConfigurations::Walker_t Walker_t
MakeReturn< UnaryNode< FnLog, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t log(const Vector< T1, C1 > &l)
void auxHevaluate(ParticleSet &P)
QMCTraits::RealType RealType
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
ParticleAttrib< SingleParticlePos > ParticlePos
Definition: Configuration.h:92
TrialWaveFunction & Psi
trial function
Definition: QMCDriver.h:326
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95
const PoolType & getPool() const
get the Pool object
Walker_t::PropertyContainer_t PropertyContainer_t
container type of the Properties of a Walker
iterator begin()
return the first iterator

◆ runNodePlot()

void runNodePlot ( )
private

Definition at line 2055 of file WaveFunctionTester.cpp.

References ParameterSet::add(), qmcplusplus::app_log(), WalkerConfigurations::begin(), TrialWaveFunction::calcRatio(), qmcplusplus::Cartesian, ParticleSet::convert2Cart(), TrialWaveFunction::copyFromBuffer(), Walker< t_traits, p_traits >::DataSet, ParticleSet::getTotalNum(), qmcplusplus::Lattice, ParticleSet::loadWalker(), ParticleSet::makeMove(), WaveFunctionTester::myNode, QMCDriver::Psi, ParameterSet::put(), putContent(), ParticleSet::R, ParticleSet::rejectMove(), TrialWaveFunction::rejectMove(), QMCDriver::RootName, ParticleSet::update(), and QMCDriver::W.

Referenced by WaveFunctionTester::run().

2056 {
2057  app_log() << " ===== runNodePlot =====\n";
2058  xmlNodePtr kids = myNode->children;
2059  std::string doEnergy("no");
2060  ParameterSet aAttrib;
2061  aAttrib.add(doEnergy, "energy");
2062  aAttrib.put(myNode);
2063  std::vector<int> Grid;
2064  while (kids != NULL)
2065  {
2066  std::string cname((const char*)(kids->name));
2067  if (cname == "grid")
2068  putContent(Grid, kids);
2069  kids = kids->next;
2070  }
2071  ParticleSet::ParticlePos R_cart(1);
2072  R_cart.setUnit(PosUnit::Cartesian);
2073  ParticleSet::ParticlePos R_unit(1);
2074  R_unit.setUnit(PosUnit::Lattice);
2075  Walker_t& thisWalker(**(W.begin()));
2076  W.loadWalker(thisWalker, true);
2077  Walker_t::WFBuffer_t& w_buffer(thisWalker.DataSet);
2078  Psi.copyFromBuffer(W, w_buffer);
2079 #if OHMMS_DIM == 2
2080  assert(Grid.size() == 2);
2081  int nat = W.getTotalNum();
2082  int nup = W.getTotalNum() / 2; //std::max(W.getSpeciesSet().findSpecies("u"),W.getSpeciesSet().findSpecies("d"));
2083  // for(int iat(0);iat<nat;iat++)
2084  // e_out<<iat<<" "<<W[0]->R[iat][0]<<" "<<W[0]->R[iat][1]<< std::endl;
2085  RealType overG0(1.0 / Grid[0]);
2086  RealType overG1(1.0 / Grid[1]);
2087  for (int iat(0); iat < nat; iat++)
2088  {
2089  W.update();
2090  std::stringstream fn;
2091  fn << RootName.c_str() << ".ratios." << iat << ".py";
2092  std::ofstream plot_out(fn.str().c_str());
2093  plot_out.precision(6);
2094  // plot_out<<"#e x y ratio"<< std::endl;
2095  R_unit[0][0] = 1.0;
2096  R_unit[0][1] = 1.0;
2097  W.convert2Cart(R_unit, R_cart);
2098  RealType xmax = R_cart[0][0];
2099  RealType ymax = R_cart[0][1];
2100  plot_out << "import matplotlib\n";
2101  plot_out << "import numpy as np\n";
2102  plot_out << "import matplotlib.cm as cm\n";
2103  plot_out << "import matplotlib.mlab as mlab\n";
2104  plot_out << "import matplotlib.pyplot as plt\n";
2105  plot_out << std::endl;
2106  plot_out << "matplotlib.rcParams['xtick.direction'] = 'out'\n";
2107  plot_out << "matplotlib.rcParams['ytick.direction'] = 'out'\n";
2108  plot_out << std::endl;
2109  plot_out << "x = np.arange(0, " << xmax << ", " << xmax * overG0 << ")\n";
2110  plot_out << "y = np.arange(0, " << ymax << ", " << ymax * overG1 << ")\n";
2111  plot_out << "X, Y = np.meshgrid(x, y)\n";
2112  plot_out << "Z = [";
2113  for (int i = 0; i < Grid[0]; i++)
2114  {
2115  plot_out << "[ ";
2116  for (int j = 0; j < Grid[1]; j++)
2117  {
2118  R_unit[0][0] = overG0 * RealType(i);
2119  R_unit[0][1] = overG1 * RealType(j);
2120  W.convert2Cart(R_unit, R_cart);
2121  PosType dr(R_cart[0] - W.R[iat]);
2122  W.makeMove(iat, dr);
2123  ValueType aratio = Psi.calcRatio(W, iat);
2124  W.rejectMove(iat);
2125  Psi.rejectMove(iat);
2126  plot_out << aratio << ", ";
2127  }
2128  plot_out << "], ";
2129  }
2130  plot_out << "]\n";
2131  plot_out << "up_y=[";
2132  for (int ix(0); ix < nup; ix++)
2133  {
2134  RealType yy(W[0]->R[ix][0]);
2135  while (yy > xmax)
2136  yy -= xmax;
2137  while (yy < 0)
2138  yy += xmax;
2139  plot_out << yy << ", ";
2140  }
2141  plot_out << "]\n";
2142  plot_out << "up_x=[";
2143  for (int ix(0); ix < nup; ix++)
2144  {
2145  RealType yy(W[0]->R[ix][1]);
2146  while (yy > ymax)
2147  yy -= ymax;
2148  while (yy < 0)
2149  yy += ymax;
2150  plot_out << yy << ", ";
2151  }
2152  plot_out << "]\n";
2153  plot_out << "dn_y=[";
2154  for (int ix(nup); ix < nat; ix++)
2155  {
2156  RealType yy(W[0]->R[ix][0]);
2157  while (yy > xmax)
2158  yy -= xmax;
2159  while (yy < 0)
2160  yy += xmax;
2161  plot_out << yy << ", ";
2162  }
2163  plot_out << "]\n";
2164  plot_out << "dn_x=[";
2165  for (int ix(nup); ix < nat; ix++)
2166  {
2167  RealType yy(W[0]->R[ix][1]);
2168  while (yy > ymax)
2169  yy -= ymax;
2170  while (yy < 0)
2171  yy += ymax;
2172  plot_out << yy << ", ";
2173  }
2174  plot_out << "]\n";
2175  plot_out << "matplotlib.rcParams['contour.negative_linestyle'] = 'solid'\n";
2176  plot_out << "plt.figure()\n";
2177  plot_out << "CS = plt.contourf(X, Y, Z, 5, cmap=cm.gray)\n";
2178  plot_out << "CS2 = plt.contour(X, Y, Z, colors='k',levels=[0])\n";
2179  plot_out << "PTu = plt.scatter(up_x,up_y, c='r', marker='o')\n";
2180  plot_out << "PTd = plt.scatter(dn_x,dn_y, c='b', marker='d')\n";
2181  plot_out << "plt.clabel(CS2, fontsize=9, inline=1)\n";
2182  plot_out << "plt.title('2D Nodal Structure')\n";
2183  plot_out << "plt.xlim(0," << ymax * (1.0 - overG1) << ")\n";
2184  plot_out << "plt.ylim(0," << xmax * (1.0 - overG0) << ")\n";
2185  fn.str("");
2186  fn << RootName.c_str() << ".ratios." << iat << ".png";
2187  plot_out << "plt.savefig('" << fn.str().c_str() << "', bbox_inches='tight', pad_inches=0.01 )\n";
2188  }
2189 #elif OHMMS_DIM == 3
2190 // assert(Grid.size()==3);
2191 //
2192 // RealType overG0(1.0/Grid[0]);
2193 // RealType overG1(1.0/Grid[1]);
2194 // RealType overG2(1.0/Grid[2]);
2195 // int iat(0);
2196 // W.update();
2197 // plot_out<<"#e x y z ratio"<< std::endl;
2198 //
2199 // for(int i=0;i<Grid[0];i++)
2200 // for(int j=0;j<Grid[1];j++)
2201 // for(int k=0;k<Grid[2];k++)
2202 // {
2203 // R_unit[iat][0]=overG0*RealType(i);
2204 // R_unit[iat][1]=overG1*RealType(j);
2205 // R_unit[iat][2]=overG2*RealType(k);
2206 // W.convert2Cart(R_unit,R_cart);
2207 // PosType dr(R_cart[iat]-W.R[iat]);
2208 //
2209 // W.makeMove(iat,dr);
2210 // RealType aratio = Psi.ratio(W,iat);
2211 // W.rejectMove(iat);
2212 // Psi.rejectMove(iat);
2213 // plot_out<<iat<<" "<<R_cart[iat][0]<<" "<<R_cart[iat][1]<<" "<<R_cart[iat][2]<<" "<<aratio<<" "<< std::endl;
2214 // }
2215 #endif
2216 }
void rejectMove(int iat)
restore to the original state
ValueType calcRatio(ParticleSet &P, int iat, ComputeType ct=ComputeType::ALL)
compute psi(R_new) / psi(R_current) ratio It returns a complex value if the wavefunction is complex...
void copyFromBuffer(ParticleSet &P, WFBufferType &buf)
copy all the wavefunction components from buffer.
QTBase::RealType RealType
Definition: Configuration.h:58
std::string RootName
root of all the output files
Definition: QMCDriver.h:317
Parent class for all grids.
Definition: Grid.h:43
size_t getTotalNum() const
Definition: ParticleSet.h:493
std::ostream & app_log()
Definition: OutputManager.h:65
MCWalkerConfiguration::Walker_t Walker_t
Definition: QMCDriver.h:83
void update(bool skipSK=false)
update the internal data
bool put(std::istream &is) override
read from std::istream
Definition: ParameterSet.h:42
QMCTraits::PosType PosType
PooledMemory< FullPrecRealType > WFBuffer_t
Definition: Walker.h:80
class to handle a set of parameters
Definition: ParameterSet.h:27
QTBase::ValueType ValueType
Definition: Configuration.h:60
void rejectMove(Index_t iat)
reject a proposed move in regular mode
void convert2Cart(const ParticlePos &pin, ParticlePos &pout)
ParticlePos R
Position.
Definition: ParticleSet.h:79
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
void loadWalker(Walker_t &awalker, bool pbyp)
load a Walker_t to the current ParticleSet
bool putContent(T &a, xmlNodePtr cur)
replaces a&#39;s value with the first "element" in the "string" returned by XMLNodeString{cur}.
Definition: libxmldefs.h:88
void add(PDT &aparam, const std::string &aname_in, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new parameter corresponding to an xmlNode <parameter>
QMCTraits::RealType RealType
void makeMove(Index_t iat, const SingleParticlePos &displ, bool maybe_accept=true)
move the iat-th particle to active_pos_
ParticleAttrib< SingleParticlePos > ParticlePos
Definition: Configuration.h:92
TrialWaveFunction & Psi
trial function
Definition: QMCDriver.h:326
iterator begin()
return the first iterator

◆ runRatioTest()

void runRatioTest ( )
private

the basic ratios check

Definition at line 1087 of file WaveFunctionTester.cpp.

References ParticleSet::acceptMove(), TrialWaveFunction::acceptMove(), qmcplusplus::app_log(), WalkerConfigurations::begin(), WaveFunctionTester::checkHamPbyP, TrialWaveFunction::copyFromBuffer(), Walker< t_traits, p_traits >::DataSet, WaveFunctionTester::deltaR, WalkerConfigurations::end(), QMCHamiltonian::evaluate(), TrialWaveFunction::evaluateLog(), qmcplusplus::exp(), qmcplusplus::for(), WaveFunctionTester::fout, ParticleSet::G, QMCHamiltonian::getLocalEnergy(), QMCHamiltonian::getObservable(), QMCHamiltonian::getObservableName(), TrialWaveFunction::getPhase(), ParticleSet::getTotalNum(), QMCDriver::H, ParticleSet::L, ParticleSet::loadWalker(), qmcplusplus::makeGaussRandom(), ParticleSet::makeMove(), Walker< t_traits, p_traits >::Properties, QMCDriver::Psi, ParticleSet::R, Walker< t_traits, p_traits >::R, Random, TrialWaveFunction::registerData(), ParticleSet::rejectMove(), TrialWaveFunction::rejectMove(), Walker< t_traits, p_traits >::resetProperty(), QMCHamiltonian::saveProperty(), ParticleSet::saveWalker(), QMCHamiltonian::sizeOfObservables(), QMCDriver::Tau, ParticleSet::update(), TrialWaveFunction::updateBuffer(), and QMCDriver::W.

1088 {
1089 #if 0
1090  int nat = W.getTotalNum();
1091  ParticleSet::ParticleGradient Gp(nat), dGp(nat);
1092  ParticleSet::ParticleLaplacian Lp(nat), dLp(nat);
1093  bool checkHam=(checkHamPbyP == "yes");
1094  Tau=0.025;
1095  MCWalkerConfiguration::iterator it(W.begin()), it_end(W.end());
1096  while (it != it_end)
1097  {
1099  Walker_t::WFBuffer_t tbuffer;
1100  W.R = (**it).R+Tau*deltaR;
1101  (**it).R=W.R;
1102  W.update();
1103  RealType logpsi=Psi.registerData(W,tbuffer);
1104  RealType ene;
1105  if (checkHam)
1106  ene = H.registerData(W,tbuffer);
1107  else
1108  ene = H.evaluate(W);
1109  (*it)->DataSet=tbuffer;
1110  //RealType ene = H.evaluate(W);
1111  (*it)->resetProperty(logpsi,Psi.getPhase(),ene,0.0,0.0,1.0);
1112  H.saveProperty((*it)->getPropertyBase());
1113  ++it;
1114  app_log() << " HamTest " << " Total " << ene << std::endl;
1115  for (int i=0; i<H.sizeOfObservables(); i++)
1116  app_log() << " HamTest " << H.getObservableName(i) << " " << H.getObservable(i) << std::endl;
1117  }
1118  fout << " Update using drift " << std::endl;
1119  bool pbyp_mode=true;
1120  for (int iter=0; iter<4; ++iter)
1121  {
1122  int iw=0;
1123  it=W.begin();
1124  while (it != it_end)
1125  {
1126  fout << "\nStart Walker " << iw++ << std::endl;
1127  Walker_t& thisWalker(**it);
1128  W.loadWalker(thisWalker,pbyp_mode);
1129  Walker_t::WFBuffer_t& w_buffer(thisWalker.DataSet);
1130  Psi.copyFromBuffer(W,w_buffer);
1131  H.copyFromBuffer(W,w_buffer);
1132 // Psi.evaluateLog(W);
1133  RealType eold(thisWalker.Properties(WP::LOCALENERGY));
1134  RealType logpsi(thisWalker.Properties(LOGPSI));
1135  RealType emixed(eold), enew(eold);
1137  //mave a move
1138  RealType ratio_accum(1.0);
1139  for (int iat=0; iat<nat; iat++)
1140  {
1141  PosType dr(Tau*deltaR[iat]);
1142  PosType newpos(W.makeMove(iat,dr));
1143  //RealType ratio=Psi.ratio(W,iat,dGp,dLp);
1144  W.dG=0;
1145  W.dL=0;
1146  RealType ratio=Psi.ratio(W,iat,W.dG,W.dL);
1147  Gp = W.G + W.dG;
1148  //RealType enew = H.evaluatePbyP(W,iat);
1149  if (checkHam)
1150  enew = H.evaluatePbyP(W,iat);
1151  if (ratio > Random())
1152  {
1153  fout << " Accepting a move for " << iat << std::endl;
1154  fout << " Energy after a move " << enew << std::endl;
1155  W.G += W.dG;
1156  W.L += W.dL;
1157  W.acceptMove(iat);
1158  Psi.acceptMove(W,iat);
1159  if (checkHam)
1160  H.acceptMove(iat);
1161  ratio_accum *= ratio;
1162  }
1163  else
1164  {
1165  fout << " Rejecting a move for " << iat << std::endl;
1166  W.rejectMove(iat);
1167  Psi.rejectMove(iat);
1168  //H.rejectMove(iat);
1169  }
1170  }
1171  fout << " Energy after pbyp = " << H.getLocalEnergy() << std::endl;
1172  RealType newlogpsi_up = Psi.evaluateLog(W,w_buffer);
1173  W.saveWalker(thisWalker);
1174  RealType ene_up;
1175  if (checkHam)
1176  ene_up= H.evaluate(W,w_buffer);
1177  else
1178  ene_up = H.evaluate(W);
1179  Gp=W.G;
1180  Lp=W.L;
1181  W.R=thisWalker.R;
1182  W.update();
1183  RealType newlogpsi=Psi.updateBuffer(W,w_buffer,false);
1184  RealType ene = H.evaluate(W);
1185  thisWalker.resetProperty(newlogpsi,Psi.getPhase(),ene);
1186  //thisWalker.resetProperty(std::log(psi),Psi.getPhase(),ene);
1187  fout << iter << " Energy by update = "<< ene_up << " " << ene << " " << ene_up-ene << std::endl;
1188  fout << iter << " Ratio " << ratio_accum*ratio_accum
1189  << " | " << std::exp(2.0*(newlogpsi-logpsi)) << " "
1190  << ratio_accum*ratio_accum/std::exp(2.0*(newlogpsi-logpsi)) << std::endl
1191  << " new log(psi) updated " << newlogpsi_up
1192  << " new log(psi) calculated " << newlogpsi
1193  << " old log(psi) " << logpsi << std::endl;
1194  fout << " Gradients " << std::endl;
1195  for (int iat=0; iat<nat; iat++)
1196  fout << W.G[iat]-Gp[iat] << W.G[iat] << std::endl; //W.G[iat] << G[iat] << std::endl;
1197  fout << " Laplacians " << std::endl;
1198  for (int iat=0; iat<nat; iat++)
1199  fout << W.L[iat]-Lp[iat] << " " << W.L[iat] << std::endl;
1200  ++it;
1201  }
1202  }
1203  fout << " Update without drift : for VMC useDrift=\"no\"" << std::endl;
1204  for (int iter=0; iter<4; ++iter)
1205  {
1206  it=W.begin();
1207  int iw=0;
1208  while (it != it_end)
1209  {
1210  fout << "\nStart Walker " << iw++ << std::endl;
1211  Walker_t& thisWalker(**it);
1212  W.loadWalker(thisWalker,pbyp_mode);
1213  Walker_t::WFBuffer_t& w_buffer(thisWalker.DataSet);
1214  //Psi.updateBuffer(W,w_buffer,true);
1215  Psi.copyFromBuffer(W,w_buffer);
1216  RealType eold(thisWalker.Properties(WP::LOCALENERGY));
1217  RealType logpsi(thisWalker.Properties(LOGPSI));
1218  RealType emixed(eold), enew(eold);
1219  //mave a move
1220  RealType ratio_accum(1.0);
1221  for (int substep=0; substep<3; ++substep)
1222  {
1224  for (int iat=0; iat<nat; iat++)
1225  {
1226  PosType dr(Tau*deltaR[iat]);
1227  PosType newpos(W.makeMove(iat,dr));
1228  RealType ratio=Psi.ratio(W,iat);
1229  RealType prob = ratio*ratio;
1230  if (prob > Random())
1231  {
1232  fout << " Accepting a move for " << iat << std::endl;
1233  W.acceptMove(iat);
1234  Psi.acceptMove(W,iat);
1235  ratio_accum *= ratio;
1236  }
1237  else
1238  {
1239  fout << " Rejecting a move for " << iat << std::endl;
1240  W.rejectMove(iat);
1241  Psi.rejectMove(iat);
1242  }
1243  }
1244  RealType logpsi_up = Psi.updateBuffer(W,w_buffer,false);
1245  W.saveWalker(thisWalker);
1246  RealType ene = H.evaluate(W);
1247  thisWalker.resetProperty(logpsi_up,Psi.getPhase(),ene);
1248  }
1249  Gp=W.G;
1250  Lp=W.L;
1251  W.update();
1252  RealType newlogpsi=Psi.evaluateLog(W);
1253  fout << iter << " Ratio " << ratio_accum*ratio_accum
1254  << " | " << std::exp(2.0*(newlogpsi-logpsi)) << " "
1255  << ratio_accum*ratio_accum/std::exp(2.0*(newlogpsi-logpsi)) << std::endl
1256  << " new log(psi) " << newlogpsi
1257  << " old log(psi) " << logpsi << std::endl;
1258  fout << " Gradients " << std::endl;
1259  for (int iat=0; iat<nat; iat++)
1260  {
1261  fout << W.G[iat]-Gp[iat] << W.G[iat] << std::endl; //W.G[iat] << G[iat] << std::endl;
1262  }
1263  fout << " Laplacians " << std::endl;
1264  for (int iat=0; iat<nat; iat++)
1265  {
1266  fout << W.L[iat]-Lp[iat] << " " << W.L[iat] << std::endl;
1267  }
1268  ++it;
1269  }
1270  }
1271  //for(it=W.begin();it != it_end; ++it)
1272  //{
1273  // Walker_t& thisWalker(**it);
1274  // Walker_t::WFBuffer_t& w_buffer((*it)->DataSet);
1275  // w_buffer.rewind();
1276  // W.updateBuffer(**it,w_buffer);
1277  // RealType logpsi=Psi.updateBuffer(W,w_buffer,true);
1278  //}
1279 #endif
1280 }
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
std::string getObservableName(int i) const
return the name of the i-th observable
void rejectMove(int iat)
restore to the original state
void copyFromBuffer(ParticleSet &P, WFBufferType &buf)
copy all the wavefunction components from buffer.
size_t getTotalNum() const
Definition: ParticleSet.h:493
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false)
update the state with the new data
std::ostream & app_log()
Definition: OutputManager.h:65
void saveProperty(IT first)
save the values of Hamiltonian elements to the Properties
RealType getObservable(int i) const
return the value of the i-th observable
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
#define Random
MCWalkerConfiguration::Walker_t Walker_t
Definition: QMCDriver.h:83
void update(bool skipSK=false)
update the internal data
ParticleLaplacian L
laplacians of the particles
Definition: ParticleSet.h:85
RealType updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false)
update all the wavefunction components in buffer.
for(int i=0;i< size_test;++i) CHECK(Approx(gauss_random_vals[offset_for_rs+i])
QMCTraits::PosType PosType
PooledMemory< FullPrecRealType > WFBuffer_t
Definition: Walker.h:80
WalkerList_t::iterator iterator
FIX: a type alias of iterator for an object should not be for just one of many objects it holds...
void makeGaussRandom(std::vector< TinyVector< T, D >> &a)
void rejectMove(Index_t iat)
reject a proposed move in regular mode
ParticleGradient G
gradients of the particles
Definition: ParticleSet.h:83
void saveWalker(Walker_t &awalker)
save this to awalker
void registerData(ParticleSet &P, WFBufferType &buf)
register all the wavefunction components in buffer.
QMCHamiltonian & H
Hamiltonian.
Definition: QMCDriver.h:329
int sizeOfObservables() const
return the size of observables
ParticlePos R
Position.
Definition: ParticleSet.h:79
FullPrecRealType getLocalEnergy()
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
ParticleSet::ParticlePos deltaR
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
void loadWalker(Walker_t &awalker, bool pbyp)
load a Walker_t to the current ParticleSet
QMCTraits::RealType RealType
void makeMove(Index_t iat, const SingleParticlePos &displ, bool maybe_accept=true)
move the iat-th particle to active_pos_
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
TrialWaveFunction & Psi
trial function
Definition: QMCDriver.h:326
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95
RealType Tau
timestep
Definition: QMCDriver.h:299
iterator end()
return the last iterator, [begin(), end())
void acceptMove(Index_t iat)
accept the move and update the particle attribute by the proposed move in regular mode ...
iterator begin()
return the first iterator

◆ runRatioTest2()

void runRatioTest2 ( )
private

Definition at line 1282 of file WaveFunctionTester.cpp.

References PooledMemory< T_scalar, Alloc >::allocate(), qmcplusplus::app_log(), WalkerConfigurations::begin(), TrialWaveFunction::calcRatio(), TrialWaveFunction::calcRatioGrad(), TrialWaveFunction::copyFromBuffer(), Walker< t_traits, p_traits >::DataSet, WaveFunctionTester::deltaR, WalkerConfigurations::end(), TrialWaveFunction::evalGrad(), QMCHamiltonian::evaluate(), TrialWaveFunction::evaluateLog(), WaveFunctionTester::fout, ParticleSet::G, QMCHamiltonian::getObservable(), QMCHamiltonian::getObservableName(), TrialWaveFunction::getPhase(), ParticleSet::getTotalNum(), QMCDriver::H, ParticleSet::loadWalker(), qmcplusplus::makeGaussRandom(), ParticleSet::makeMove(), WaveFunctionTester::ndim, Walker< t_traits, p_traits >::Properties, QMCDriver::Psi, TrialWaveFunction::registerData(), ParticleSet::rejectMove(), TrialWaveFunction::rejectMove(), QMCHamiltonian::saveProperty(), QMCHamiltonian::sizeOfObservables(), QMCDriver::Tau, TrialWaveFunction::updateBuffer(), and QMCDriver::W.

Referenced by WaveFunctionTester::run().

1283 {
1284  app_log() << " ===== runRatioTest2 =====\n";
1285  int nat = W.getTotalNum();
1286  ParticleSet::ParticleGradient Gp(nat), dGp(nat);
1287  ParticleSet::ParticleLaplacian Lp(nat), dLp(nat);
1288  Tau = 0.025;
1289  MCWalkerConfiguration::iterator it(W.begin()), it_end(W.end());
1290  for (; it != it_end; ++it)
1291  {
1293  if (ndim < 3)
1294  {
1295  for (int iat = 0; iat < deltaR.size(); ++iat)
1296  deltaR[iat][2] = 0;
1297  }
1298  Walker_t::WFBuffer_t tbuffer;
1299  (**it).R += Tau * deltaR;
1300  W.loadWalker(**it, true);
1301  Psi.registerData(W, tbuffer);
1302  tbuffer.allocate();
1303  Psi.copyFromBuffer(W, tbuffer);
1304  Psi.evaluateLog(W);
1305  RealType logpsi = Psi.updateBuffer(W, tbuffer, false);
1306  RealType ene = H.evaluate(W);
1307  (*it)->DataSet = tbuffer;
1308  //RealType ene = H.evaluate(W);
1309  (*it)->resetProperty(logpsi, Psi.getPhase(), ene, 0.0, 0.0, 1.0);
1310  H.saveProperty((*it)->getPropertyBase());
1311  app_log() << " HamTest "
1312  << " Total " << ene << std::endl;
1313  for (int i = 0; i < H.sizeOfObservables(); i++)
1314  app_log() << " HamTest " << H.getObservableName(i) << " " << H.getObservable(i) << std::endl;
1315  }
1316  for (int iter = 0; iter < 20; ++iter)
1317  {
1318  int iw = 0;
1319  it = W.begin();
1320  //while(it != it_end)
1321  for (; it != it_end; ++it)
1322  {
1323  fout << "\nStart Walker " << iw++ << std::endl;
1324  Walker_t& thisWalker(**it);
1325  W.loadWalker(thisWalker, true);
1326  Walker_t::WFBuffer_t& w_buffer(thisWalker.DataSet);
1327  Psi.copyFromBuffer(W, w_buffer);
1328  RealType eold(thisWalker.Properties(WP::LOCALENERGY));
1329  RealType logpsi(thisWalker.Properties(WP::LOGPSI));
1330  Psi.evaluateLog(W);
1331  ParticleSet::ParticleGradient realGrad(W.G);
1333  if (ndim < 3)
1334  {
1335  for (int iat = 0; iat < deltaR.size(); ++iat)
1336  deltaR[iat][2] = 0;
1337  }
1338  //mave a move
1339  for (int iat = 0; iat < nat; iat++)
1340  {
1342  GradType grad_new;
1343  for (int sds = 0; sds < 3; sds++)
1344  fout << realGrad[iat][sds] - grad_now[sds] << " ";
1345  PosType dr(Tau * deltaR[iat]);
1346  W.makeMove(iat, dr);
1347  ValueType ratio2 = Psi.calcRatioGrad(W, iat, grad_new);
1348  W.rejectMove(iat);
1349  Psi.rejectMove(iat);
1350  W.makeMove(iat, dr);
1351  ValueType ratio1 = Psi.calcRatio(W, iat);
1352  //Psi.rejectMove(iat);
1353  W.rejectMove(iat);
1354  fout << " ratio1 = " << ratio1 << " ration2 = " << ratio2 << std::endl;
1355  }
1356  }
1357  }
1358  //for(it=W.begin();it != it_end; ++it)
1359  //{
1360  // Walker_t& thisWalker(**it);
1361  // Walker_t::WFBuffer_t& w_buffer((*it)->DataSet);
1362  // w_buffer.rewind();
1363  // W.updateBuffer(**it,w_buffer);
1364  // RealType logpsi=Psi.updateBuffer(W,w_buffer,true);
1365  //}
1366 }
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
std::string getObservableName(int i) const
return the name of the i-th observable
void rejectMove(int iat)
restore to the original state
ValueType calcRatio(ParticleSet &P, int iat, ComputeType ct=ComputeType::ALL)
compute psi(R_new) / psi(R_current) ratio It returns a complex value if the wavefunction is complex...
void copyFromBuffer(ParticleSet &P, WFBufferType &buf)
copy all the wavefunction components from buffer.
QTBase::GradType GradType
Definition: Configuration.h:62
size_t getTotalNum() const
Definition: ParticleSet.h:493
std::ostream & app_log()
Definition: OutputManager.h:65
void saveProperty(IT first)
save the values of Hamiltonian elements to the Properties
RealType getObservable(int i) const
return the value of the i-th observable
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
MCWalkerConfiguration::Walker_t Walker_t
Definition: QMCDriver.h:83
RealType updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false)
update all the wavefunction components in buffer.
QMCTraits::PosType PosType
PooledMemory< FullPrecRealType > WFBuffer_t
Definition: Walker.h:80
WalkerList_t::iterator iterator
FIX: a type alias of iterator for an object should not be for just one of many objects it holds...
QTBase::ValueType ValueType
Definition: Configuration.h:60
void makeGaussRandom(std::vector< TinyVector< T, D >> &a)
void rejectMove(Index_t iat)
reject a proposed move in regular mode
ParticleGradient G
gradients of the particles
Definition: ParticleSet.h:83
void registerData(ParticleSet &P, WFBufferType &buf)
register all the wavefunction components in buffer.
QMCHamiltonian & H
Hamiltonian.
Definition: QMCDriver.h:329
int sizeOfObservables() const
return the size of observables
ParticleSet::ParticlePos deltaR
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
void loadWalker(Walker_t &awalker, bool pbyp)
load a Walker_t to the current ParticleSet
QMCTraits::RealType RealType
void makeMove(Index_t iat, const SingleParticlePos &displ, bool maybe_accept=true)
move the iat-th particle to active_pos_
GradType evalGrad(ParticleSet &P, int iat)
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
TrialWaveFunction & Psi
trial function
Definition: QMCDriver.h:326
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95
RealType Tau
timestep
Definition: QMCDriver.h:299
iterator end()
return the last iterator, [begin(), end())
ValueType calcRatioGrad(ParticleSet &P, int iat, GradType &grad_iat)
compute psi(R_new) / psi(R_current) ratio and ln(psi(R_new)) gradients It returns a complex value if...
iterator begin()
return the first iterator

◆ runRatioV()

void runRatioV ( )
private

test ratios with virtual moves

Definition at line 1377 of file WaveFunctionTester.cpp.

References qmcplusplus::app_log(), WalkerConfigurations::begin(), WaveFunctionTester::deltaR, ParticleSet::DistTables, WalkerConfigurations::end(), TrialWaveFunction::evaluateRatios(), ParticleSet::getTotalNum(), qmcplusplus::makeGaussRandom(), VirtualParticleSet::makeMoves(), QMCDriver::Psi, ParticleSet::R, qmcplusplus::randomize(), TrialWaveFunction::registerData(), ParticleSet::rejectMove(), TrialWaveFunction::resetPhaseDiff(), QMCDriver::Tau, ParticleSet::update(), and QMCDriver::W.

Referenced by WaveFunctionTester::run().

1378 {
1379 #if 0
1380  app_log() << "WaveFunctionTester::runRatioV " << std::endl;
1381  int nat = W.getTotalNum();
1382  Tau=0.025;
1383 
1384  //create a VP with 8 virtual moves
1385  VirtualParticleSet vp(&W,8);
1386  W.enableVirtualMoves();
1387 
1388  //cheating
1389  const ParticleSet& ions=W.DistTables[1]->origin();
1390  DistanceTable* dt_ie=W.DistTables[1];
1391  double Rmax=2.0;
1392 
1393  ParticleSet::ParticlePos sphere(8);
1394  std::vector<RealType> ratio_1(8), ratio_v(8);
1395  MCWalkerConfiguration::iterator it(W.begin()), it_end(W.end());
1396  while (it != it_end)
1397  {
1399  Walker_t::WFBuffer_t tbuffer;
1400  W.R = (**it).R+Tau*deltaR;
1401  (**it).R=W.R;
1402  W.update();
1403  RealType logpsi=Psi.registerData(W,tbuffer);
1404 
1405  W.initVirtualMoves();
1406 
1407  for(int iat=0; iat<ions.getTotalNum(); ++iat)
1408  {
1409  for(int nn=dt_ie->M[iat],iel=0; nn<dt_ie->M[iat+1]; nn++,iel++)
1410  {
1411  RealType r(dt_ie->r(nn));
1412  if(r>Rmax) continue;
1413  randomize(sphere,(RealType)0.5);
1414 
1415  for(int k=0; k<sphere.size(); ++k)
1416  {
1417  W.makeMoveOnSphere(iel,sphere[k]);
1418  ratio_1[k]=Psi.ratio(W,iel);
1419  W.rejectMove(iel);
1420  Psi.resetPhaseDiff();
1421  }
1422 
1423  vp.makeMoves(iel,sphere);
1424 
1425  Psi.evaluateRatios(vp,ratio_v);
1426 
1427  app_log() << "IAT = " << iat << " " << iel << std::endl;
1428  for(int k=0; k<sphere.size(); ++k)
1429  {
1430  app_log() << ratio_1[k]/ratio_v[k] << " " << ratio_1[k] << std::endl;
1431  }
1432  app_log() << std::endl;
1433  }
1434  }
1435  ++it;
1436  }
1437 #endif
1438 }
size_t getTotalNum() const
Definition: ParticleSet.h:493
std::ostream & app_log()
Definition: OutputManager.h:65
void update(bool skipSK=false)
update the internal data
PooledMemory< FullPrecRealType > WFBuffer_t
Definition: Walker.h:80
WalkerList_t::iterator iterator
FIX: a type alias of iterator for an object should not be for just one of many objects it holds...
void makeGaussRandom(std::vector< TinyVector< T, D >> &a)
void rejectMove(Index_t iat)
reject a proposed move in regular mode
void registerData(ParticleSet &P, WFBufferType &buf)
register all the wavefunction components in buffer.
ParticlePos R
Position.
Definition: ParticleSet.h:79
ParticleSet::ParticlePos deltaR
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
QMCTraits::RealType RealType
ParticleAttrib< SingleParticlePos > ParticlePos
Definition: Configuration.h:92
TrialWaveFunction & Psi
trial function
Definition: QMCDriver.h:326
RealType Tau
timestep
Definition: QMCDriver.h:299
std::vector< std::unique_ptr< DistanceTable > > DistTables
distance tables that need to be updated by moving this ParticleSet
Definition: ParticleSet.h:630
iterator end()
return the last iterator, [begin(), end())
void evaluateRatios(const VirtualParticleSet &VP, std::vector< ValueType > &ratios, ComputeType ct=ComputeType::ALL)
compulte multiple ratios to handle non-local moves and other virtual moves
void randomize(ParticleAttrib< TinyVector< T, D >> &displ, T fac)
iterator begin()
return the first iterator

◆ runZeroVarianceTest()

void runZeroVarianceTest ( )
private

Definition at line 1590 of file WaveFunctionTester.cpp.

References qmcplusplus::app_log(), WalkerConfigurations::begin(), OHMMS::Controller, qmcplusplus::cos(), WaveFunctionTester::deltaR, qmcplusplus::Dot(), TrialWaveFunction::evalGradSource(), QMCHamiltonian::evaluate(), TrialWaveFunction::evaluateLog(), qmcplusplus::exp(), ParticleSet::G, TrialWaveFunction::getPhase(), ParticleSetPool::getPool(), ParticleSet::getTotalNum(), QMCDriver::H, qmcplusplus::imag(), ParticleSet::L, qmcplusplus::log(), OHMMS_DIM, Walker< t_traits, p_traits >::Properties, QMCDriver::Psi, WaveFunctionTester::PtclPool, ParticleSet::R, Walker< t_traits, p_traits >::R, Communicate::rank(), qmcplusplus::real(), qmcplusplus::sin(), WaveFunctionTester::sourceName, qmcplusplus::Sum(), ParticleSet::update(), and QMCDriver::W.

1591 {
1592  app_log() << " ===== runZeroVarianceTest =====\n";
1593  for (auto& [key, value] : PtclPool.getPool())
1594  app_log() << "ParticelSet = " << key << std::endl;
1595  // Find source ParticleSet
1596  auto pit(PtclPool.getPool().find(sourceName));
1597  app_log() << pit->first << std::endl;
1598  // if(pit == PtclPool.getPool().end())
1599  // APP_ABORT("Unknown source \"" + sourceName + "\" WaveFunctionTester.");
1600  ParticleSet& source = *((*pit).second);
1601  int nat = W.getTotalNum();
1603  MCWalkerConfiguration::PropertyContainer_t Properties(0, 0, 1, WP::MAXPROPERTIES);
1604  ;
1605  //pick the first walker
1606  const MCWalkerConfiguration::Walker_t& awalker = **W.begin();
1607  //copy the properties of the working walker
1608  Properties = awalker.Properties;
1609  //sample a new walker configuration and copy to ParticleSet::R
1610  //makeGaussRandom(deltaR);
1611  W.R = awalker.R;
1612  //W.R += deltaR;
1613  W.update();
1614  //ValueType psi = Psi.evaluate(W);
1615  ValueType logpsi = Psi.evaluateLog(W);
1616  RealType eloc = H.evaluate(W);
1617  //RealType psi = Psi.evaluateLog(W);
1618  ParticleSet::ParticleGradient G(nat), G1(nat);
1619  ParticleSet::ParticleLaplacian L(nat), L1(nat);
1620  G = W.G;
1621  L = W.L;
1622  PosType r1(5.0, 2.62, 2.55);
1623  W.R[1] = PosType(4.313, 5.989, 4.699);
1624  W.R[2] = PosType(5.813, 4.321, 4.893);
1625  W.R[3] = PosType(4.002, 5.502, 5.381);
1626  W.R[4] = PosType(5.901, 5.121, 5.311);
1627  W.R[5] = PosType(5.808, 4.083, 5.021);
1628  W.R[6] = PosType(4.750, 5.810, 4.732);
1629  W.R[7] = PosType(4.690, 5.901, 4.989);
1630  for (int i = 1; i < 8; i++)
1631  W.R[i] -= PosType(2.5, 2.5, 2.5);
1632  std::array<char, 32> fname;
1633  if (std::snprintf(fname.data(), fname.size(), "ZVtest.%03d.dat", OHMMS::Controller->rank()) < 0)
1634  throw std::runtime_error("Error generating filename");
1635  FILE* fzout = fopen(fname.data(), "w");
1640  for (int dim = 0; dim < OHMMS_DIM; dim++)
1641  {
1642  grad_grad[dim].resize(nat);
1643  lapl_grad[dim].resize(nat);
1644  grad_grad_FD[dim].resize(nat);
1645  lapl_grad_FD[dim].resize(nat);
1646  }
1647  for (r1[0] = 0.0; r1[0] < 5.0; r1[0] += 1.0e-4)
1648  {
1649  W.R[0] = r1;
1650  fprintf(fzout, "%1.8e %1.8e %1.8e ", r1[0], r1[1], r1[2]);
1652 // ValueType psi = std::cos(Psi.getPhase())*std::exp(log);//*W.PropertyList[SIGN];
1653 #if defined(QMC_COMPLEX)
1654  RealType ratioMag = std::exp(log);
1655  ValueType psi =
1656  std::complex<OHMMS_PRECISION>(ratioMag * std::cos(Psi.getPhase()), ratioMag * std::sin(Psi.getPhase()));
1657 #else
1658  ValueType psi = std::cos(Psi.getPhase()) * std::exp(log); //*W.PropertyList[SIGN];
1659 #endif
1660  double E = H.evaluate(W);
1661  //double KE = E - W.PropertyList[LOCALPOTENTIAL];
1662  double KE = -0.5 * (Sum(W.L) + Dot(W.G, W.G));
1663 #if defined(QMC_COMPLEX)
1664  fprintf(fzout, "%16.12e %16.12e %16.12e ", psi.real(), psi.imag(), KE);
1665 #else
1666  fprintf(fzout, "%16.12e %16.12e ", psi, KE);
1667 #endif
1668  for (int isrc = 0; isrc < source.getTotalNum(); isrc++)
1669  {
1670  GradType grad_log = Psi.evalGradSource(W, source, isrc, grad_grad, lapl_grad);
1671  for (int dim = 0; dim < OHMMS_DIM; dim++)
1672  {
1673  double ZV = 0.5 * Sum(lapl_grad[dim]) + Dot(grad_grad[dim], W.G);
1674 #if defined(QMC_COMPLEX)
1675  fprintf(fzout, "%16.12e %16.12e %16.12e ", ZV, grad_log[dim].real(), grad_log[dim].imag());
1676 #else
1677  fprintf(fzout, "%16.12e %16.12e ", ZV, grad_log[dim]);
1678 #endif
1679  }
1680  }
1681  fprintf(fzout, "\n");
1682  }
1683  fclose(fzout);
1684 }
RealType evaluateLog(ParticleSet &P)
evalaute the log (internally gradients and laplacian) of the trial wavefunction.
T Sum(const ParticleAttrib< T > &pa)
QTBase::GradType GradType
Definition: Configuration.h:62
int rank() const
return the rank
Definition: Communicate.h:116
size_t getTotalNum() const
Definition: ParticleSet.h:493
std::ostream & app_log()
Definition: OutputManager.h:65
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
Definition: Configuration.h:96
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
void update(bool skipSK=false)
update the internal data
Communicate * Controller
Global Communicator for a process.
Definition: Communicate.cpp:35
ParticleLaplacian L
laplacians of the particles
Definition: ParticleSet.h:85
#define OHMMS_DIM
Definition: config.h:64
T Dot(const ParticleAttrib< TinyVector< T, D >> &pa, const ParticleAttrib< TinyVector< T, D >> &pb)
QMCTraits::PosType PosType
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
QTBase::ValueType ValueType
Definition: Configuration.h:60
ParticleGradient G
gradients of the particles
Definition: ParticleSet.h:83
GradType evalGradSource(ParticleSet &P, ParticleSet &source, int iat)
Returns the logarithmic gradient of the trial wave function with respect to the iat^th atom of the so...
QMCHamiltonian & H
Hamiltonian.
Definition: QMCDriver.h:329
ParticlePos R
Position.
Definition: ParticleSet.h:79
QTBase::PosType PosType
Definition: Configuration.h:61
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
ParticleSet::ParticlePos deltaR
MCWalkerConfiguration & W
walker ensemble
Definition: QMCDriver.h:323
WalkerConfigurations::Walker_t Walker_t
MakeReturn< UnaryNode< FnLog, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t log(const Vector< T1, C1 > &l)
QMCTraits::RealType RealType
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
ParticleAttrib< SingleParticlePos > ParticlePos
Definition: Configuration.h:92
TrialWaveFunction & Psi
trial function
Definition: QMCDriver.h:326
ParticleAttrib< QTFull::GradType > ParticleGradient
Definition: Configuration.h:95
const PoolType & getPool() const
get the Pool object
Walker_t::PropertyContainer_t PropertyContainer_t
container type of the Properties of a Walker
iterator begin()
return the first iterator

Member Data Documentation

◆ checkBasic

std::string checkBasic
private

◆ checkClone

std::string checkClone
private

◆ checkEloc

std::string checkEloc
private

◆ checkHamPbyP

std::string checkHamPbyP
private

◆ checkRatio

std::string checkRatio
private

◆ checkRatioV

std::string checkRatioV
private

◆ checkSlaterDet

bool checkSlaterDet
private

◆ checkSlaterDetOption

std::string checkSlaterDetOption
private

◆ deltaParam

double deltaParam
private

◆ deltaR

◆ DeltaVsError

FiniteDiffErrData DeltaVsError
private

◆ fout

◆ myNode

xmlNodePtr myNode
private

◆ ndim

◆ outputDeltaVsError

bool outputDeltaVsError
private

◆ PtclPool

◆ sourceName

◆ toleranceParam

double toleranceParam
private

◆ wftricks

std::string wftricks
private

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