21 #ifndef QMCPLUSPLUS_HAMILTONIAN_H 22 #define QMCPLUSPLUS_HAMILTONIAN_H 24 #include <string_view> 34 #if !defined(REMOVE_TRACEMANAGER) 41 class MCWalkerConfiguration;
42 class HamiltonianFactory;
43 class NonLocalECPotential;
77 void addOperator(std::unique_ptr<OperatorBase>&& h,
const std::string& aname,
bool physical =
true);
86 inline int size()
const {
return H.size(); }
107 #if !defined(REMOVE_TRACEMANAGER) 194 template<class IT, typename = std::enable_if_t<std::is_same<std::add_pointer<FullPrecRealType>::type, IT>::value>>
202 template<class IT, typename = std::enable_if_t<std::is_same<std::add_pointer<FullPrecRealType>::type, IT>::value>>
226 for (
int i = 0; i <
H.size(); i++)
251 static std::vector<QMCHamiltonian::FullPrecRealType>
mw_evaluate(
407 bool get(std::ostream& os)
const;
448 std::vector<std::unique_ptr<OperatorBase>>
H;
454 std::vector<std::unique_ptr<OperatorBase>>
auxH;
477 #if !defined(REMOVE_TRACEMANAGER) int addObservables(ParticleSet &P)
add each term to the PropertyList for averages
FullPrecRealType evaluateIonDerivsDeterministicFast(ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi_in, TWFFastDerivWrapper &psi_wrapper, ParticleSet::ParticlePos &dedr, ParticleSet::ParticlePos &wf_grad)
evaluate local energy and derivatives w.r.t ionic coordinates, but deterministically.
void registerCollectables(std::vector< ObservableHelper > &h5desc, hdf_archive &file) const
register collectables so that their averages can be dumped to hdf5
Array< TraceInt, 1 > * gen_sample
HamiltonianRef::FullPrecRealType FullPrecRealType
void informOperatorsOfListener()
Some Hamiltonian components need to be informed that they are in a per particle reporting situation s...
FullPrecRealType getLocalPotential()
Evaluate the L2 potentials around each ion.
std::string getObservableName(int i) const
return the name of the i-th observable
void setNonLocalMoves(xmlNodePtr cur)
set non local moves options
int sizeOfCollectables() const
return the size of collectables
NewTimer & ham_timer_
Total timer for H evaluation.
int startIndex() const
retrun the starting index
helper functions for EinsplineSetBuilder
Array< TraceInt, 1 > * step_sample
Array< TraceInt, 1 > * pid_sample
static std::vector< QMCHamiltonian::FullPrecRealType > mw_evaluateWithToperator(const RefVectorWithLeader< QMCHamiltonian > &ham_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list)
batched version of evaluate Local energy with Toperators updated.
RefVector< OperatorBase > getTWFDependentComponents()
return components, auxH not included, depending on TWF.
QTBase::RealType RealType
NewTimer & eval_vals_derivs_timer_
Total timer for H evaluation.
void addOperator(std::unique_ptr< OperatorBase > &&h, const std::string &aname, bool physical=true)
add an operator
OperatorBase * getHamiltonian(const std::string &aname)
return OperatorBase with the name aname
OperatorBase::Return_t Return_t
~QMCHamiltonian()
destructor
void addOperatorType(const std::string &name, const std::string &type)
record the name-type pair of an operator
QMCTraits::FullPrecRealType FullPrecRealType
void saveProperty(IT first)
save the values of Hamiltonian elements to the Properties
ResourceHandle manages the temporary resource referenced from a collection.
FullPrecRealType evaluateValueAndDerivatives(ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)
evaluate energy and derivatives wrt to the variables
SPOSet::ValueMatrix ValueMatrix
FullPrecRealType KineticEnergy
Current Kinetic Energy.
ResourceHandle< QMCHamiltonianMultiWalkerResource > mw_res_handle_
std::vector< std::reference_wrapper< NewTimer > > my_timers_
timers for H components
Declaration of OperatorBase.
RealType getObservable(int i) const
return the value of the i-th observable
Collection of Local Energy Operators.
OrbitalSetTraits< ValueType >::ValueMatrix ValueMatrix
An object of this type is a listener expecting a callback to the report function with a vector of val...
OperatorBase::RealType RealType
static void updateComponent(OperatorBase &op, QMCHamiltonian &ham, ParticleSet &pset)
accumulate local energy and update Observables and PropertyList
static void mw_registerLocalEnergyListener(QMCHamiltonian &ham_leader, ListenerVector< RealType > listener)
Timer accumulates time and call counts.
NonLocalECPotential * nlpp_ptr
pointer to NonLocalECP
Attaches a unit to a Vector for IO.
void resetObservables(int start, int ncollects)
reset Observables and counters
TWFFastDerivWrapper is a wrapper class for TrialWavefunction that provides separate and low level acc...
void createResource(ResourceCollection &collection) const
initialize a shared resource and hand it to a collection
void computeL2DK(ParticleSet &P, int iel, TensorType &D, PosType &K)
compute D matrix and K vector for L2 potential propagator
FullPrecRealType NewLocalEnergy
Current Local Energy for the proposed move.
static std::vector< QMCHamiltonian::FullPrecRealType > mw_evaluate(const RefVectorWithLeader< QMCHamiltonian > &ham_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list)
batched version of evaluate for LocalEnergy
OperatorBase::Walker_t Walker_t
static std::vector< QMCHamiltonian::FullPrecRealType > mw_evaluateValueAndDerivatives(const RefVectorWithLeader< QMCHamiltonian > &ham_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, const opt_variables_type &optvars, RecordArray< ValueType > &dlogpsi, RecordArray< ValueType > &dhpsioverpsi)
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
NewTimer & eval_ion_derivs_fast_timer_
Total timer for H ion deriv evaluation;.
static void mw_registerKineticListener(QMCHamiltonian &ham_leader, ListenerVector< RealType > listener)
Listener Registration This must be called on a QMCHamiltonian that has acquired multiwalker resources...
Array< TraceReal, 1 > * weight_sample
Specialized paritlce class for atomistic simulations.
void setProperty(IT first)
int myIndex
starting index
ParticleSet::Buffer_t BufferType
typedef for the serialized buffer
FullPrecRealType LocalEnergy
Current Local Energy.
int numCollectables
starting index
FullPrecRealType evaluateWithToperator(ParticleSet &P)
evaluate Local energy with Toperators updated.
QTBase::ValueType ValueType
TraceRequest request
traces variables
void collect_walker_traces(Walker_t &walker, int step)
collect walker trace data
int size() const
return the number of Hamiltonians
static void mw_registerLocalIonPotentialListener(QMCHamiltonian &ham_leader, ListenerVector< RealType > listener)
Factory class to build a many-body wavefunction.
class to handle a set of variables that can be modified during optimizations
void evaluateD(ParticleSet &P, int iel, TensorType &D)
int sizeOfObservables() const
return the size of observables
Array< TraceInt, 1 > * age_sample
FullPrecRealType evaluateIonDerivsDeterministic(ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_terms, ParticleSet::ParticlePos &pulay_terms, ParticleSet::ParticlePos &wf_grad)
evaluate local energy and derivatives w.r.t ionic coordinates, but deterministically.
FullPrecRealType evaluateDeterministic(ParticleSet &P)
evaluate Local Energy deterministically.
FullPrecRealType getEnsembleAverage()
return an average value of the LocalEnergy
L2Potential * l2_ptr
pointer to L2Potential
FullPrecRealType getLocalEnergy()
const std::string myName
getName is in the way
const std::string & getName() const
static void updateKinetic(QMCHamiltonian &ham, ParticleSet &pset)
extract kinetic and potential energies.
void evaluateElecGrad(ParticleSet &P, TrialWaveFunction &psi, ParticleSet::ParticlePos &EGrad, RealType delta=1e-5)
Evaluate the electron gradient of the local energy.
static std::vector< int > mw_makeNonLocalMoves(const RefVectorWithLeader< QMCHamiltonian > &ham_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list)
const std::string & getOperatorType(const std::string &name)
return type of named H element or fail
void initialize_traces(TraceManager &tm, ParticleSet &P)
initialize trace data
static constexpr std::array< std::string_view, 8 > available_quantities_
void auxHevaluate(ParticleSet &P)
An abstract class for Local Energy operators.
FullPrecRealType Return_t
type of return value of evaluate
Array< TraceReal, 2 > * position_sample
std::vector< std::reference_wrapper< T > > RefVector
void rejectedMove(ParticleSet &P, Walker_t &ThisWalker)
Looks like a hack see DMCBatched.cpp and DMC.cpp weight is used like temporary flag from DMC...
static void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< QMCHamiltonian > &ham_list)
acquire external resource Note: use RAII ResourceCollectionLock whenever possible ...
void registerObservables(std::vector< ObservableHelper > &h5desc, hdf_archive &file) const
register obsevables so that their averages can be dumped to hdf5
static void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< QMCHamiltonian > &ham_list)
release external resource Note: use RAII ResourceCollectionLock whenever possible ...
std::vector< std::unique_ptr< OperatorBase > > H
vector of Hamiltonians
bool has_L2()
determine if L2 potential is present
Evaluate the semi local potentials.
ParticleSet::Walker_t Walker_t
typedef for the walker
Class to represent a many-body trial wave function.
static void mw_registerLocalPotentialListener(QMCHamiltonian &ham_leader, ListenerVector< RealType > listener)
PropertySetType Observables
data
int getObservable(std::string Oname) const
return the value of the observable with a set name if it exists
Indexes
an enum denoting index of physical properties
FullPrecRealType evaluate(ParticleSet &P)
evaluate Local Energy
std::vector< std::unique_ptr< OperatorBase > > auxH
vector of Hamiltonians
void updateSource(ParticleSet &s)
remove a named Hamiltonian from the list
void finalize_traces()
finalize trace data
int makeNonLocalMoves(ParticleSet &P)
make non local moves
void resetTargetParticleSet(ParticleSet &P)
QTFull::RealType FullPrecRealType
Array< TraceInt, 1 > * mult_sample
std::map< std::string, std::string > operator_types
types of component operators
OperatorBase * getHamiltonian(int i)
return i-th OperatorBase
OperatorBase::ValueType ValueType
FullPrecRealType evaluateVariableEnergy(ParticleSet &P, bool free_nlpp)
evaluate energy
int total_size() const
return the total number of Hamiltonians (physical + aux)
Array< TraceInt, 1 > * id_sample
void setRandomGenerator(RandomBase< FullPrecRealType > *rng)
OperatorBase::PropertySetType PropertySetType
FullPrecRealType getKineticEnergy()
void setPrimary(bool primary)
set PRIMARY bit of all the components
static RefVectorWithLeader< OperatorBase > extract_HC_list(const RefVectorWithLeader< QMCHamiltonian > &ham_list, int id)
std::unique_ptr< QMCHamiltonian > makeClone(ParticleSet &qp, TrialWaveFunction &psi) const
return a clone
QTBase::TensorType TensorType
A container class to represent a walker.
void computeL2D(ParticleSet &P, int iel, TensorType &D)
compute D matrix for L2 potential propagator
void evaluateDK(ParticleSet &P, int iel, TensorType &D, PosType &K)
FullPrecRealType evaluateIonDerivs(ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_terms, ParticleSet::ParticlePos &pulay_terms, ParticleSet::ParticlePos &wf_grad)
evaluate local energy and derivatives w.r.t ionic coordinates.
QMCHamiltonian(const std::string &aname="psi0")
constructor
RecordNamedProperty< FullPrecRealType > PropertySetType
define PropertyList_t