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

Public Types

using k2_t = std::vector< RealType >
 
using dens_t = std::vector< RealType >
 
using pts_t = std::vector< PosType >
 
- Public Types inherited from OperatorBase
enum  EnergyDomains { KINETIC = 0, POTENTIAL, NO_ENERGY_DOMAIN }
 enum to denote energy domain of operators More...
 
enum  QuantumDomains {
  NO_QUANTUM_DOMAIN = 0, CLASSICAL, QUANTUM, CLASSICAL_CLASSICAL,
  QUANTUM_CLASSICAL, QUANTUM_QUANTUM
}
 
enum  {
  PRIMARY = 0, OPTIMIZABLE = 1, RATIOUPDATE = 2, PHYSICAL = 3,
  COLLECTABLE = 4, NONLOCAL = 5
}
 enum for update_mode More...
 
using Return_t = FullPrecRealType
 type of return value of evaluate More...
 
using ValueMatrix = SPOSet::ValueMatrix
 For fast derivative evaluation. More...
 
using GradMatrix = SPOSet::GradMatrix
 
using BufferType = ParticleSet::Buffer_t
 typedef for the serialized buffer More...
 
using Walker_t = ParticleSet::Walker_t
 typedef for the walker More...
 
using ParticleScalar = ParticleSet::Scalar_t
 typedef for the ParticleScalar More...
 
using SPOMap = SPOSet::SPOMap
 typedef for SPOMap More...
 
- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 

Public Member Functions

 StaticStructureFactor (ParticleSet &P)
 
 ~StaticStructureFactor () override
 
std::string getClassName () const override
 return class name More...
 
std::unique_ptr< OperatorBasemakeClone (ParticleSet &P, TrialWaveFunction &psi) final
 
bool put (xmlNodePtr cur) override
 Read the input parameter. More...
 
Return_t evaluate (ParticleSet &P) override
 Evaluate the local energy contribution of this component. More...
 
void addObservables (PropertySetType &plist, BufferType &olist) override
 named values to the property list Default implementaton uses addValue(plist_) More...
 
void registerCollectables (std::vector< ObservableHelper > &h5desc, hdf_archive &file) const override
 
void resetTargetParticleSet (ParticleSet &P) override
 Reset the data with the target ParticleSet. More...
 
void setObservables (PropertySetType &plist) override
 Set the values evaluated by this object to plist Default implementation is to assign Value which is updated by evaluate function using my_index_. More...
 
void setParticlePropertyList (PropertySetType &plist, int offset) override
 
void checkout_scalar_arrays (TraceManager &tm)
 
void collect_scalar_samples ()
 
void delete_scalar_arrays ()
 
bool get (std::ostream &os) const override
 write about the class More...
 
void reset ()
 
void report (const std::string &pad)
 
- Public Member Functions inherited from OperatorBase
 OperatorBase ()
 Construct a new Operator Base object Default and unique empty constructor. More...
 
virtual ~OperatorBase ()=default
 
virtual bool dependsOnWaveFunction () const
 return true if this operator depends on a wavefunction More...
 
std::bitset< 8 > & getUpdateMode () noexcept
 get update_mode_ reference More...
 
Return_t getValue () const noexcept
 get a copy of value_ More...
 
std::string getName () const noexcept
 getter a copy of my_name_, rvalue small string optimization More...
 
void setName (const std::string name) noexcept
 Set my_name member, uses small string optimization (pass by value) More...
 
TraceRequestgetRequest () noexcept
 Get request_ member. More...
 
virtual void registerObservables (std::vector< ObservableHelper > &h5desc, hdf_archive &file) const
 add to observable descriptor for hdf5 The default implementation is to register a scalar for this->value_ More...
 
virtual void setHistories (Walker_t &ThisWalker)
 
virtual Return_t evaluateDeterministic (ParticleSet &P)
 Evaluate the local energy contribution of this component, deterministically based on current state. More...
 
virtual void mw_evaluate (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list) const
 Evaluate the contribution of this component of multiple walkers. More...
 
virtual void mw_evaluatePerParticle (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< ListenerVector< RealType >> &listeners, const std::vector< ListenerVector< RealType >> &listeners_ions) const
 Evaluate the contribution of this component of multiple walkers per particle and report to registerd listeners from objects in Estimators. More...
 
virtual void mw_evaluateWithParameterDerivatives (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< ParticleSet > &p_list, const opt_variables_type &optvars, const RecordArray< ValueType > &dlogpsi, RecordArray< ValueType > &dhpsioverpsi) const
 TODO: add docs. More...
 
virtual Return_t rejectedMove (ParticleSet &P)
 TODO: add docs. More...
 
virtual Return_t evaluateWithToperator (ParticleSet &P)
 Evaluate the local energy contribution of this component with Toperators updated if requested. More...
 
virtual void mw_evaluateWithToperator (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list) const
 Evaluate the contribution of this component of multiple walkers. More...
 
virtual void mw_evaluatePerParticleWithToperator (const RefVectorWithLeader< OperatorBase > &o_list, const RefVectorWithLeader< TrialWaveFunction > &wf_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< ListenerVector< RealType >> &listeners, const std::vector< ListenerVector< RealType >> &listeners_ions) const
 Evaluate the contribution of this component of multiple walkers per particle and report to registerd listeners from objects in Estimators. More...
 
virtual Return_t evaluateValueAndDerivatives (ParticleSet &P, const opt_variables_type &optvars, const Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)
 Evaluate value and derivatives wrt the optimizables. More...
 
virtual Return_t evaluateWithIonDerivs (ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_term, ParticleSet::ParticlePos &pulay_term)
 Evaluate contribution to local energy and derivatives w.r.t ionic coordinates from OperatorBase. More...
 
virtual Return_t evaluateWithIonDerivsDeterministic (ParticleSet &P, ParticleSet &ions, TrialWaveFunction &psi, ParticleSet::ParticlePos &hf_term, ParticleSet::ParticlePos &pulay_term)
 Evaluate contribution to local energy and derivatives w.r.t ionic coordinates from OperatorBase. More...
 
virtual void evaluateOneBodyOpMatrix (ParticleSet &P, const TWFFastDerivWrapper &psi, std::vector< ValueMatrix > &B)
 Evaluate "B" matrix for observable. More...
 
virtual void evaluateOneBodyOpMatrixForceDeriv (ParticleSet &P, ParticleSet &source, const TWFFastDerivWrapper &psi, const int iat, std::vector< std::vector< ValueMatrix >> &Bforce)
 Evaluate "dB/dR" matrices for observable. More...
 
virtual void updateSource (ParticleSet &s)
 Update data associated with a particleset. More...
 
virtual Return_t getEnsembleAverage ()
 Return an average value by collective operation. More...
 
virtual void createResource (ResourceCollection &collection) const
 Initialize a shared resource and hand it to a collection. More...
 
virtual void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const
 Acquire a shared resource from a collection. More...
 
virtual void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< OperatorBase > &o_list) const
 Return a shared resource to a collection. More...
 
virtual void setRandomGenerator (RandomBase< FullPrecRealType > *rng)
 Set the Random Generator object TODO: add docs. More...
 
virtual void add2Hamiltonian (ParticleSet &qp, TrialWaveFunction &psi, QMCHamiltonian &targetH)
 TODO: add docs. More...
 
virtual void getRequiredTraces (TraceManager &tm)
 TODO: add docs. More...
 
virtual void informOfPerParticleListener ()
 
bool isClassical () const noexcept
 
bool isQuantum () const noexcept
 
bool isClassicalClassical () const noexcept
 
bool isQuantumClassical () const noexcept
 
bool isQuantumQuantum () const noexcept
 
bool getMode (const int i) const noexcept
 Return the mode i. More...
 
bool isNonLocal () const noexcept
 TODO: add docs. More...
 
bool hasListener () const noexcept
 
void contributeTraceQuantities ()
 Make trace quantities available. More...
 
void checkoutTraceQuantities (TraceManager &tm)
 Checkout trace arrays Derived classes must guard individual checkouts using request info. More...
 
void collectScalarTraces ()
 Collect scalar trace data. More...
 
void deleteTraceQuantities ()
 delete trace arrays More...
 

Public Attributes

int nspecies
 
std::vector< std::string > species_name
 
RealType ecut
 
int nkpoints
 
const ParticleSetPinit
 

Additional Inherited Members

- Protected Member Functions inherited from OperatorBase
virtual void contributeScalarQuantities ()
 
virtual void checkoutScalarQuantities (TraceManager &tm)
 
virtual void collectScalarQuantities ()
 
virtual void deleteScalarQuantities ()
 
virtual void contributeParticleQuantities ()
 
virtual void checkoutParticleQuantities (TraceManager &tm)
 
virtual void deleteParticleQuantities ()
 
virtual void setComputeForces (bool compute)
 
void setEnergyDomain (EnergyDomains edomain)
 Set the Energy Domain. More...
 
void setQuantumDomain (QuantumDomains qdomain)
 set quantum domain More...
 
void oneBodyQuantumDomain (const ParticleSet &P)
 set quantum domain for one-body operator More...
 
void twoBodyQuantumDomain (const ParticleSet &P)
 set quantum domain for two-body operator More...
 
void twoBodyQuantumDomain (const ParticleSet &P1, const ParticleSet &P2)
 set quantum domain for two-body operator More...
 
void addValue (PropertySetType &plist)
 named values to the property list More...
 
- Protected Attributes inherited from OperatorBase
std::bitset< 8 > update_mode_
 set the current update mode More...
 
Return_t value_
 current value More...
 
std::string name_
 name of this object More...
 
TraceRequest request_
 whether traces are being collected More...
 
int my_index_
 starting index of this object More...
 
Return_t new_value_
 a new value for a proposed move More...
 
Walker_tt_walker_
 reference to the current walker More...
 
bool streaming_particles_
 
bool have_required_traces_
 

Detailed Description

Definition at line 21 of file StaticStructureFactor.h.

Member Typedef Documentation

◆ dens_t

using dens_t = std::vector<RealType>

Definition at line 25 of file StaticStructureFactor.h.

◆ k2_t

using k2_t = std::vector<RealType>

Definition at line 24 of file StaticStructureFactor.h.

◆ pts_t

using pts_t = std::vector<PosType>

Definition at line 26 of file StaticStructureFactor.h.

Constructor & Destructor Documentation

◆ StaticStructureFactor()

Definition at line 21 of file StaticStructureFactor.cpp.

References APP_ABORT, ParticleSet::getLattice(), ParticleSet::getSpeciesSet(), StaticStructureFactor::nspecies, StaticStructureFactor::reset(), qmcplusplus::Units::time::s, SpeciesSet::size(), StaticStructureFactor::species_name, SpeciesSet::speciesName, and qmcplusplus::SUPERCELL_OPEN.

21  : Pinit(P)
22 {
23  if (P.getLattice().SuperCellEnum == SUPERCELL_OPEN)
24  APP_ABORT("StaticStructureFactor is incompatible with open boundary conditions");
25 
26  // get particle information
27  SpeciesSet& species = P.getSpeciesSet();
28  nspecies = species.size();
29  for (int s = 0; s < nspecies; ++s)
30  species_name.push_back(species.speciesName[s]);
31  reset();
32 }
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
std::vector< std::string > species_name

◆ ~StaticStructureFactor()

~StaticStructureFactor ( )
inlineoverride

Definition at line 37 of file StaticStructureFactor.h.

37 {}

Member Function Documentation

◆ addObservables()

void addObservables ( PropertySetType plist,
BufferType collectables 
)
overridevirtual

named values to the property list Default implementaton uses addValue(plist_)

Parameters
plistRecordNameProperty
collectablesObservables that are accumulated by evaluate

Reimplemented from OperatorBase.

Definition at line 99 of file StaticStructureFactor.cpp.

References PooledData< T >::add(), PooledData< T >::current(), OperatorBase::my_index_, StaticStructureFactor::nkpoints, and StaticStructureFactor::nspecies.

100 {
101  my_index_ = collectables.current();
102  std::vector<RealType> tmp(nspecies * 2 * nkpoints); // real & imag parts
103  collectables.add(tmp.begin(), tmp.end());
104 }
int my_index_
starting index of this object
Definition: OperatorBase.h:535

◆ checkout_scalar_arrays()

void checkout_scalar_arrays ( TraceManager tm)
inline

Definition at line 55 of file StaticStructureFactor.h.

55 {}

◆ collect_scalar_samples()

void collect_scalar_samples ( )
inline

Definition at line 56 of file StaticStructureFactor.h.

56 {}

◆ delete_scalar_arrays()

void delete_scalar_arrays ( )
inline

Definition at line 57 of file StaticStructureFactor.h.

57 {}

◆ evaluate()

StaticStructureFactor::Return_t evaluate ( ParticleSet P)
overridevirtual

Evaluate the local energy contribution of this component.

Parameters
Pinput configuration containing N particles
Returns
the value of the Hamiltonian component

Implements OperatorBase.

Definition at line 125 of file StaticStructureFactor.cpp.

References ParticleSet::Collectables, Matrix< T, Alloc >::cols(), ParticleSet::getSK(), OperatorBase::my_index_, StaticStructureFactor::nkpoints, StaticStructureFactor::nspecies, StructFact::rhok_i, StructFact::rhok_r, qmcplusplus::Units::time::s, OperatorBase::t_walker_, and Walker< t_traits, p_traits >::Weight.

126 {
128  const Matrix<RealType>& rhok_r = P.getSK().rhok_r;
129  const Matrix<RealType>& rhok_i = P.getSK().rhok_i;
130  int nkptot = rhok_r.cols();
131  for (int s = 0; s < nspecies; ++s)
132  {
133  int kc = my_index_ + s * 2 * nkpoints;
134  //int kstart = s*nkptot;
135  //for(int k=kstart;k<kstart+nkpoints;++k,++kc)
136  // P.Collectables[kc] += w*rhok_r(k);
137  //for(int k=kstart;k<kstart+nkpoints;++k,++kc)
138  // P.Collectables[kc] += w*rhok_i(k);
139  for (int k = 0; k < nkpoints; ++k, ++kc)
140  P.Collectables[kc] += w * rhok_r(s, k);
141  for (int k = 0; k < nkpoints; ++k, ++kc)
142  P.Collectables[kc] += w * rhok_i(s, k);
143  }
144  return 0.0;
145 }
int my_index_
starting index of this object
Definition: OperatorBase.h:535
Walker_t * t_walker_
reference to the current walker
Definition: OperatorBase.h:541
QMCTraits::RealType RealType
FullPrecRealType Weight
Weight of the walker.
Definition: Walker.h:102

◆ get()

bool get ( std::ostream &  os) const
inlineoverridevirtual

write about the class

Implements OperatorBase.

Definition at line 61 of file StaticStructureFactor.h.

61 { return false; }

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements OperatorBase.

Definition at line 40 of file StaticStructureFactor.h.

40 { return "StaticStructureFactor"; }

◆ makeClone()

std::unique_ptr< OperatorBase > makeClone ( ParticleSet P,
TrialWaveFunction psi 
)
finalvirtual

Implements OperatorBase.

Definition at line 44 of file StaticStructureFactor.cpp.

45 {
46  return std::make_unique<StaticStructureFactor>(*this);
47 }

◆ put()

bool put ( xmlNodePtr  cur)
overridevirtual

Read the input parameter.

Parameters
curxml node for a OperatorBase object

Implements OperatorBase.

Definition at line 50 of file StaticStructureFactor.cpp.

References OhmmsAttributeSet::add(), APP_ABORT, StaticStructureFactor::ecut, ParticleSet::getSimulationCell(), OperatorBase::name_, StaticStructureFactor::nkpoints, StaticStructureFactor::Pinit, OhmmsAttributeSet::put(), StaticStructureFactor::report(), StaticStructureFactor::reset(), and qmcplusplus::sqrt().

51 {
52  using std::sqrt;
53  reset();
54  const k2_t& k2_init = Pinit.getSimulationCell().getKLists().ksq;
55 
56  std::string write_report = "no";
57  OhmmsAttributeSet attrib;
58  attrib.add(name_, "name");
59  //attrib.add(ecut,"ecut");
60  attrib.add(write_report, "report");
61  attrib.put(cur);
62 
63  if (ecut < 0.0)
64  nkpoints = k2_init.size();
65  else
66  {
67  RealType k2cut = 2.0 * ecut;
68  nkpoints = 0;
69  for (int i = 0; i < k2_init.size(); ++i)
70  if (k2_init[i] < k2cut)
71  nkpoints++;
72  }
73 
74  if (nkpoints == 0)
75  APP_ABORT("StaticStructureFactor::put could not find any kpoints");
76 
77  ecut = .5 * k2_init[nkpoints - 1];
78 
79  if (write_report == "yes")
80  report(" ");
81 
82  return true;
83 }
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
const auto & getSimulationCell() const
Definition: ParticleSet.h:250
std::string name_
name of this object
Definition: OperatorBase.h:527
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
QMCTraits::RealType RealType
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
Definition: AttributeSet.h:42
void report(const std::string &pad)

◆ registerCollectables()

void registerCollectables ( std::vector< ObservableHelper > &  h5desc,
hdf_archive file 
) const
overridevirtual

Reimplemented from OperatorBase.

Definition at line 107 of file StaticStructureFactor.cpp.

References ObservableHelper::addProperty(), ParticleSet::getSimulationCell(), OperatorBase::my_index_, OperatorBase::name_, StaticStructureFactor::nkpoints, StaticStructureFactor::nspecies, qmcplusplus::oh, StaticStructureFactor::Pinit, qmcplusplus::Units::time::s, and StaticStructureFactor::species_name.

108 {
109  h5desc.emplace_back(hdf_path(name_) / "kpoints");
110  auto& oh = h5desc.back();
111  oh.addProperty(const_cast<std::vector<PosType>&>(Pinit.getSimulationCell().getKLists().kpts_cart), "value", file);
112 
113  std::vector<int> ng(2);
114  ng[0] = 2;
115  ng[1] = nkpoints;
116  for (int s = 0; s < nspecies; ++s)
117  {
118  h5desc.emplace_back(hdf_path{species_name[s]});
119  auto& ohSpeciesName = h5desc.back();
120  ohSpeciesName.set_dimensions(ng, my_index_ + s * 2 * nkpoints);
121  }
122 }
int my_index_
starting index of this object
Definition: OperatorBase.h:535
void addProperty(T &p, const std::string &pname, hdf_archive &file)
add named property to describe the collectable this helper class handles
const auto & getSimulationCell() const
Definition: ParticleSet.h:250
std::string name_
name of this object
Definition: OperatorBase.h:527
std::vector< std::string > species_name
ObservableHelper oh

◆ report()

void report ( const std::string &  pad)

Definition at line 86 of file StaticStructureFactor.cpp.

References qmcplusplus::app_log(), StaticStructureFactor::ecut, OperatorBase::name_, StaticStructureFactor::nkpoints, StaticStructureFactor::nspecies, qmcplusplus::Units::time::s, and StaticStructureFactor::species_name.

Referenced by StaticStructureFactor::put().

87 {
88  app_log() << pad << "StaticStructureFactor report" << std::endl;
89  app_log() << pad << " name = " << name_ << std::endl;
90  app_log() << pad << " ecut = " << ecut << std::endl;
91  app_log() << pad << " nkpoints = " << nkpoints << std::endl;
92  app_log() << pad << " nspecies = " << nspecies << std::endl;
93  for (int s = 0; s < nspecies; ++s)
94  app_log() << pad << " species[" << s << "] = " << species_name[s] << std::endl;
95  app_log() << pad << "end StaticStructureFactor report" << std::endl;
96 }
std::ostream & app_log()
Definition: OutputManager.h:65
std::string name_
name of this object
Definition: OperatorBase.h:527
std::vector< std::string > species_name

◆ reset()

◆ resetTargetParticleSet()

void resetTargetParticleSet ( ParticleSet P)
inlineoverridevirtual

Reset the data with the target ParticleSet.

Parameters
Pnew target ParticleSet

Implements OperatorBase.

Definition at line 50 of file StaticStructureFactor.h.

50 {}

◆ setObservables()

void setObservables ( PropertySetType plist)
inlineoverridevirtual

Set the values evaluated by this object to plist Default implementation is to assign Value which is updated by evaluate function using my_index_.

Parameters
plistRecordNameProperty

Reimplemented from OperatorBase.

Definition at line 51 of file StaticStructureFactor.h.

51 {}

◆ setParticlePropertyList()

void setParticlePropertyList ( PropertySetType plist,
int  offset 
)
inlineoverridevirtual

Reimplemented from OperatorBase.

Definition at line 52 of file StaticStructureFactor.h.

52 {}

Member Data Documentation

◆ ecut

◆ nkpoints

◆ nspecies

◆ Pinit

◆ species_name


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