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

Public Member Functions

 QMCCostFunctionTest (MCWalkerConfiguration &w, TrialWaveFunction &psi, QMCHamiltonian &h, Communicate *c)
 
void resetPsi (bool final_reset=false) override
 reset the wavefunction More...
 
Return_rt fillOverlapHamiltonianMatrices (Matrix< Return_rt > &Left, Matrix< Return_rt > &Right) override
 
void getConfigurations (const std::string &aroot) override
 
void checkConfigurations (EngineHandle &handle) override
 
EffectiveWeight correlatedSampling (bool needGrad=true) override
 run correlated sampling return effective walkers ( w_i)^2/(Nw * w^2_i) More...
 
void callUpdateXmlNodes ()
 
void printXml ()
 
xmlDocPtr getDoc ()
 
- Public Member Functions inherited from QMCCostFunctionBase
 QMCCostFunctionBase (ParticleSet &w, TrialWaveFunction &psi, QMCHamiltonian &h, Communicate *comm)
 Constructor. More...
 
 ~QMCCostFunctionBase () override
 Destructor. More...
 
bool put (xmlNodePtr cur)
 process xml node More...
 
void resetCostFunction (std::vector< xmlNodePtr > &cset)
 
Return_rt & Params (int i) override
 assign optimization parameter i More...
 
Return_t Params (int i) const override
 return optimization parameter i More...
 
int getType (int i) const
 
Return_rt Cost (bool needGrad=true) override
 return the cost value for CGMinimization More...
 
Return_rt computedCost ()
 return the cost value for CGMinimization More...
 
void printEstimates ()
 
void GradCost (std::vector< Return_rt > &PGradient, const std::vector< Return_rt > &PM, Return_rt FiniteDiff=0) override
 return the gradient of cost value for CGMinimization More...
 
int getNumParams () const override
 return the number of optimizable parameters More...
 
int getNumSamples () const
 return the global number of samples More...
 
void setNumSamples (int newNumSamples)
 
void getParameterTypes (std::vector< int > &types) const
 
void Report () override
 dump the current parameters and other report More...
 
void reportParameters ()
 report parameters at the end More...
 
void reportParametersH5 ()
 report parameters in HDF5 at the end More...
 
int getReportCounter () const
 return the counter which keeps track of optimization steps More...
 
void setWaveFunctionNode (xmlNodePtr cur)
 
void setTargetEnergy (Return_rt et)
 
void setRootName (const std::string &aroot)
 
void setStream (std::ostream *os)
 
void addCoefficients (xmlXPathContextPtr acontext, const char *cname)
 add coefficient or coefficients More...
 
void printCJParams (xmlNodePtr cur, std::string &rname)
 
void addCJParams (xmlXPathContextPtr acontext, const char *cname)
 
void setRng (RefVector< RandomBase< FullPrecRealType >> r)
 
bool getneedGrads () const
 
void setneedGrads (bool tf)
 
void setDMC ()
 
std::string getParamName (int i) const override
 
const opt_variables_typegetOptVariables () const
 
Return_rt getVariance () const
 return variance after checkConfigurations More...
 
- 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)
 

Additional Inherited Members

- Public Types inherited from QMCCostFunctionBase
enum  FieldIndex_OPT {
  LOGPSI_FIXED = 0, LOGPSI_FREE = 1, ENERGY_TOT = 2, ENERGY_FIXED = 3,
  ENERGY_NEW = 4, REWEIGHT = 5
}
 
enum  SumIndex_OPT {
  SUM_E_BARE = 0, SUM_ESQ_BARE, SUM_ABSE_BARE, SUM_E_WGT,
  SUM_ESQ_WGT, SUM_ABSE_WGT, SUM_WGT, SUM_WGTSQ,
  SUM_INDEX_SIZE
}
 
using EffectiveWeight = QMCTraits::QTFull::RealType
 
using FullPrecRealType = QMCTraits::FullPrecRealType
 
- Public Types inherited from MPIObjectBase
using mpi_comm_type = Communicate::mpi_comm_type
 
- Public Attributes inherited from QMCCostFunctionBase
bool reportH5
 Save opt parameters to HDF5. More...
 
bool CI_Opt
 
std::string newh5
 Path and name of the HDF5 prefix where CI coeffs are saved. More...
 
- Protected Types inherited from QMCCostFunctionBase
using ParticleGradient = ParticleSet::ParticleGradient
 Saved derivative properties and Hderivative properties of all the walkers. More...
 
using ParticleLaplacian = ParticleSet::ParticleLaplacian
 
- Protected Member Functions inherited from QMCCostFunctionBase
bool checkParameters ()
 Apply constraints on the optimizables. More...
 
void updateXmlNodes ()
 
bool isEffectiveWeightValid (EffectiveWeight effective_weight) const
 check the validity of the effective weight calculated by correlatedSampling More...
 
UniqueOptObjRefs extractOptimizableObjects (TrialWaveFunction &psi) const
 survey all the optimizable objects More...
 
void resetOptimizableObjects (TrialWaveFunction &psi, const opt_variables_type &opt_variables) const
 
- Protected Attributes inherited from QMCCostFunctionBase
ParticleSetW
 Particle set. More...
 
TrialWaveFunctionPsi
 Trial function. More...
 
QMCHamiltonianH
 Hamiltonian. More...
 
bool Write2OneXml
 if true, do not write the *.opt.#.xml More...
 
int PowerE
 |E-E_T|^PowerE is used for the cost function More...
 
int NumCostCalls
 number of times cost function evaluated More...
 
int NumSamples
 global number of samples to use in correlated sampling More...
 
int NumOptimizables
 total number of optimizable variables More...
 
int ReportCounter
 counter for output More...
 
Return_rt w_en
 weights for energy and variance in the cost function More...
 
Return_rt w_var
 
Return_rt w_abs
 
Return_rt w_w
 
Return_rt CostValue
 value of the cost function More...
 
Return_rt Etarget
 target energy More...
 
Return_rt EtargetEff
 real target energy with the Correlation Factor More...
 
Return_rt MinNumWalkers
 fraction of the number of walkers below which the costfunction becomes invalid More...
 
Return_rt MaxWeight
 maximum weight beyond which the weight is set to 1 More...
 
Return_rt curAvg
 current Average More...
 
Return_rt curVar
 current Variance More...
 
Return_rt curAvg_w
 current weighted average (correlated sampling) More...
 
Return_rt curVar_w
 current weighted variance (correlated sampling) More...
 
Return_rt curVar_abs
 current variance of SUM_ABSE_WGT/SUM_WGT More...
 
Return_rt w_beta
 
Return_rt vmc_or_dmc
 
bool needGrads
 
std::string targetExcitedStr
 whether we are targeting an excited state More...
 
bool targetExcited
 whether we are targeting an excited state More...
 
double omega_shift
 the shift to use when targeting an excited state More...
 
opt_variables_type OptVariables
 list of optimizables More...
 
opt_variables_type OptVariablesForPsi
 full list of optimizables More...
 
opt_variables_type InitVariables
 
std::vector< TinyVector< int, 2 > > equalVarMap
 index mapping for <equal> constraints More...
 
std::vector< TinyVector< int, 2 > > negateVarMap
 index mapping for <negate> constraints More...
 
std::ostream * msg_stream
 stream to which progress is sent More...
 
xmlNodePtr m_wfPtr
 xml node to be dumped More...
 
xmlDocPtr m_doc_out
 document node to be dumped More...
 
std::map< std::string, xmlNodePtr > paramNodes
 parameters to be updated` More...
 
std::map< std::string, xmlNodePtr > coeffNodes
 coefficients to be updated More...
 
std::map< std::string, std::pair< xmlNodePtr, std::string > > attribNodes
 attributes to be updated More...
 
std::string RootName
 string for the file root More...
 
UPtrVector< RandomBase< FullPrecRealType > > RngSaved
 Random number generators. More...
 
std::vector< RandomBase< FullPrecRealType > * > MoverRng
 
std::vector< std::string > variational_subset_names
 optimized parameter names More...
 
std::vector< Return_rt > SumValue
 Sum of energies and weights for averages. More...
 
Matrix< Return_rt > Records
 Saved properties of all the walkers. More...
 
std::vector< ParticleGradient * > dLogPsi
 Fixed Gradients , $\nabla\ln\Psi$, components. More...
 
std::vector< ParticleLaplacian * > d2LogPsi
 Fixed Laplacian , $\nabla^2\ln\Psi$, components. More...
 
std::unique_ptr< std::ostream > debug_stream
 stream for debug More...
 
bool do_override_output
 Flag on whether the variational parameter override is output to the new wavefunction. More...
 
- 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

Definition at line 20 of file test_QMCCostFunctionBase.cpp.

Constructor & Destructor Documentation

◆ QMCCostFunctionTest()

Definition at line 23 of file test_QMCCostFunctionBase.cpp.

24  : QMCCostFunctionBase(w, psi, h, c)
25  {}
QMCCostFunctionBase(ParticleSet &w, TrialWaveFunction &psi, QMCHamiltonian &h, Communicate *comm)
Constructor.

Member Function Documentation

◆ callUpdateXmlNodes()

void callUpdateXmlNodes ( )
inline

Definition at line 33 of file test_QMCCostFunctionBase.cpp.

References QMCCostFunctionBase::do_override_output, and QMCCostFunctionBase::updateXmlNodes().

Referenced by qmcplusplus::TEST_CASE().

34  {
35  do_override_output = true;
37  }
bool do_override_output
Flag on whether the variational parameter override is output to the new wavefunction.

◆ checkConfigurations()

void checkConfigurations ( EngineHandle handle)
inlineoverridevirtual

Implements QMCCostFunctionBase.

Definition at line 30 of file test_QMCCostFunctionBase.cpp.

30 {}

◆ correlatedSampling()

EffectiveWeight correlatedSampling ( bool  needGrad = true)
inlineoverridevirtual

run correlated sampling return effective walkers ( w_i)^2/(Nw * w^2_i)

Implements QMCCostFunctionBase.

Definition at line 31 of file test_QMCCostFunctionBase.cpp.

31 { return 0; }

◆ fillOverlapHamiltonianMatrices()

Return_rt fillOverlapHamiltonianMatrices ( Matrix< Return_rt > &  Left,
Matrix< Return_rt > &  Right 
)
inlineoverridevirtual

Implements QMCCostFunctionBase.

Definition at line 28 of file test_QMCCostFunctionBase.cpp.

28 { return 0; }

◆ getConfigurations()

void getConfigurations ( const std::string &  aroot)
inlineoverridevirtual

Implements QMCCostFunctionBase.

Definition at line 29 of file test_QMCCostFunctionBase.cpp.

29 {}

◆ getDoc()

xmlDocPtr getDoc ( )
inline

Definition at line 50 of file test_QMCCostFunctionBase.cpp.

References QMCCostFunctionBase::m_doc_out.

Referenced by qmcplusplus::TEST_CASE().

50 { return m_doc_out; }
xmlDocPtr m_doc_out
document node to be dumped

◆ printXml()

void printXml ( )
inline

Definition at line 40 of file test_QMCCostFunctionBase.cpp.

References QMCCostFunctionBase::m_doc_out.

41  {
42  char* buf;
43  int out_buflen;
44  xmlDocDumpFormatMemory(m_doc_out, (xmlChar**)&buf, &out_buflen, 1);
45  std::cout << "XML buffer length = " << out_buflen << std::endl;
46  std::cout << "XML: " << std::endl << buf << std::endl;
47  xmlFree(buf);
48  }
xmlDocPtr m_doc_out
document node to be dumped

◆ resetPsi()

void resetPsi ( bool  final_reset = false)
inlineoverridevirtual

reset the wavefunction

Implements QMCCostFunctionBase.

Definition at line 27 of file test_QMCCostFunctionBase.cpp.

27 {}

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