QMCPACK
PairCorrEstimator Class Reference

gofr estimator More...

+ Inheritance diagram for PairCorrEstimator:
+ Collaboration diagram for PairCorrEstimator:

Public Member Functions

 PairCorrEstimator (ParticleSet &elns, std::string &sources)
 constructor More...
 
std::string getClassName () const override
 return class name More...
 
void resetTargetParticleSet (ParticleSet &P) override
 Reset the data with the target ParticleSet. More...
 
Return_t evaluate (ParticleSet &P) override
 Evaluate the local energy contribution of this component. More...
 
void addObservables (PropertySetType &plist)
 
void addObservables (PropertySetType &plist, BufferType &collectables) override
 named values to the property list Default implementaton uses addValue(plist_) More...
 
void registerCollectables (std::vector< ObservableHelper > &h5list, hdf_archive &file) const override
 
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
 
bool put (xmlNodePtr cur) override
 Read the input parameter. More...
 
bool get (std::ostream &os) const override
 write about the class More...
 
std::unique_ptr< OperatorBasemakeClone (ParticleSet &qp, TrialWaveFunction &psi) final
 
void set_norm_factor ()
 
void report ()
 
- 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...
 

Static Public Member Functions

static int gen_pair_id (const int ig, const int jg, const int ns)
 generate the unique pair id from the group ids of particle i and j and the number of species More...
 

Private Member Functions

void resize (int nbins)
 resize the internal data More...
 

Private Attributes

int NumBins
 number of bins More...
 
RealType Dmax
 maximum distance More...
 
RealType Delta
 bin size More...
 
RealType DeltaInv
 one of bin size More...
 
RealType Volume
 volume of the cell More...
 
std::vector< int > pair_ids
 save pair indices More...
 
std::vector< int > other_ids
 table indexs for other type More...
 
std::vector< int > other_offsets
 offset of the gofr's associated with others_id More...
 
Matrix< RealTypenorm_factor
 normalization factor More...
 
int num_species
 
int N_e
 
std::vector< RealTypen_vec
 
const int d_aa_ID_
 
std::vector< std::string > gof_r_prefix
 prefix of each gof_r More...
 

Additional Inherited Members

- 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 > >
 
- 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

gofr estimator

Compute pair correlation function for the target particle set and optionally any source particles

Definition at line 27 of file PairCorrEstimator.h.

Constructor & Destructor Documentation

◆ PairCorrEstimator()

PairCorrEstimator ( ParticleSet elns,
std::string &  sources 
)

constructor

Parameters
elnstarget particle set
sourceslist of source particle sets

Use the elns.DistTables to evaluate the pair correlation functions.

Definition at line 25 of file PairCorrEstimator.cpp.

References qmcplusplus::app_log(), OperatorBase::COLLECTABLE, copy(), PairCorrEstimator::Delta, PairCorrEstimator::DeltaInv, PairCorrEstimator::Dmax, ParticleSet::first(), ParticleSet::getDistTable(), ParticleSet::getLattice(), OhmmsElementBase::getName(), ParticleSet::getNumDistTables(), ParticleSet::getTotalNum(), PairCorrEstimator::gof_r_prefix, ParticleSet::groups(), ParticleSet::last(), PairCorrEstimator::N_e, PairCorrEstimator::n_vec, qmcplusplus::NEED_FULL_TABLE_ON_HOST_AFTER_DONEPBYP, PairCorrEstimator::num_species, PairCorrEstimator::NumBins, PairCorrEstimator::other_ids, PairCorrEstimator::other_offsets, parsewords(), SpeciesSet::size(), OperatorBase::update_mode_, and PairCorrEstimator::Volume.

26  : Dmax(10.),
27  Delta(0.5),
28  num_species(2),
30 {
31  update_mode_.set(COLLECTABLE, 1);
32  num_species = elns.groups();
33  n_vec.resize(num_species, 0);
34  for (int i = 0; i < num_species; i++)
35  n_vec[i] = elns.last(i) - elns.first(i);
36  N_e = elns.getTotalNum();
37 
38  // use the simulation cell radius if any direction is periodic
39  if (elns.getLattice().SuperCellEnum)
40  {
41  Dmax = elns.getLattice().WignerSeitzRadius;
42  Volume = elns.getLattice().Volume;
43  }
44  else // Open BC's
45  Volume = 1.0;
46  NumBins = static_cast<int>(Dmax / Delta);
47  Delta = Dmax / static_cast<RealType>(NumBins);
48  DeltaInv = 1.0 / Delta;
49  //ostringstream h;
50  //h<<"gofr_" << elns.getName();
51  //gof_r_prefix.push_back(h.str());
52  std::map<int, int> pair_map;
53  int npairs = 0;
54  for (int i = 0; i < num_species; ++i)
55  for (int j = i; j < num_species; ++j)
56  {
57  std::ostringstream os;
58  os << "gofr_" << elns.getName() << "_" << i << "_" << j;
59  gof_r_prefix.push_back(os.str());
60  pair_map[i * num_species + j] = npairs;
61  ++npairs;
62  }
63 
64  // source-target tables
65  std::vector<std::string> slist, dlist;
66  const int ntables = elns.getNumDistTables();
67  for (int k = 0; k < ntables; ++k)
68  if (elns.getName() != elns.getDistTable(k).get_origin().getName())
69  dlist.push_back(elns.getDistTable(k).get_origin().getName());
70  parsewords(sources.c_str(), slist);
71  std::set<int> others_sorted;
72  for (int i = 0; i < slist.size(); ++i)
73  {
74  int k = 0;
75  while (k < dlist.size())
76  {
77  if (slist[i] == dlist[k])
78  {
79  others_sorted.insert(k + 1);
80  break;
81  }
82  ++k;
83  }
84  }
85  other_ids.resize(others_sorted.size());
86  other_offsets.resize(others_sorted.size());
87  copy(others_sorted.begin(), others_sorted.end(), other_ids.begin());
88  int toff = gof_r_prefix.size();
89  for (int k = 0; k < other_ids.size(); ++k)
90  {
91  const DistanceTable& t(elns.getDistTable(other_ids[k]));
92  app_log() << " GOFR for " << t.getName() << " starts at " << toff << std::endl;
93  other_offsets[k] = toff;
94  const SpeciesSet& species(t.get_origin().getSpeciesSet());
95  int ng = species.size();
96  for (int i = 0; i < ng; ++i)
97  {
98  std::ostringstream os;
99  os << "gofr_" << t.getName() << "_" << species.speciesName[i];
100  gof_r_prefix.push_back(os.str());
101  }
102  toff += ng;
103  }
104 }
std::ostream & app_log()
Definition: OutputManager.h:65
std::vector< int > other_offsets
offset of the gofr&#39;s associated with others_id
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
Definition: Blitz.h:639
unsigned parsewords(const char *inbuf, std::vector< std::string > &slist, const std::string &extra_tokens)
std::vector< std::string > gof_r_prefix
prefix of each gof_r
RealType DeltaInv
one of bin size
std::vector< int > other_ids
table indexs for other type
RealType Dmax
maximum distance
QMCTraits::RealType RealType
whether full table needs to be ready at anytime or not after donePbyP Optimization can be implemented...
std::vector< RealType > n_vec
std::bitset< 8 > update_mode_
set the current update mode
Definition: OperatorBase.h:521
RealType Volume
volume of the cell

Member Function Documentation

◆ addObservables() [1/2]

void addObservables ( PropertySetType plist)
inline

Definition at line 47 of file PairCorrEstimator.h.

Referenced by qmcplusplus::TEST_CASE().

47 {}

◆ addObservables() [2/2]

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 177 of file PairCorrEstimator.cpp.

References PooledData< T >::add(), PairCorrEstimator::gof_r_prefix, OperatorBase::my_index_, PairCorrEstimator::NumBins, and PooledData< T >::size().

178 {
179  my_index_ = collectables.size();
180  std::vector<RealType> g(gof_r_prefix.size() * NumBins, 0);
181  collectables.add(g.begin(), g.end());
182  ////only while debugging
183  //if(gof_r.size())
184  //{
185  // myDebugIndex=plist.size();
186  // for(int i=0; i<gof_r_prefix.size(); ++i)
187  // {
188  // for(int k=0; k<gof_r.cols(); ++k)
189  // {
190  // std::ostringstream h;
191  // h << gof_r_prefix[i]<< "_" << k;
192  // int dum=plist.add(h.str());
193  // }
194  // }
195  //}
196 }
int my_index_
starting index of this object
Definition: OperatorBase.h:535
std::vector< std::string > gof_r_prefix
prefix of each gof_r

◆ evaluate()

PairCorrEstimator::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 117 of file PairCorrEstimator.cpp.

References ParticleSet::Collectables, PairCorrEstimator::d_aa_ID_, PairCorrEstimator::DeltaInv, PairCorrEstimator::Dmax, PairCorrEstimator::gen_pair_id(), ParticleSet::getDistTableAA(), ParticleSet::getDistTableAB(), ParticleSet::GroupID, OperatorBase::my_index_, PairCorrEstimator::norm_factor, PairCorrEstimator::num_species, PairCorrEstimator::NumBins, PairCorrEstimator::other_ids, and PairCorrEstimator::other_offsets.

Referenced by qmcplusplus::TEST_CASE().

118 {
119  BufferType& collectables(P.Collectables);
120  const auto& dii(P.getDistTableAA(d_aa_ID_));
121  for (int iat = 1; iat < dii.centers(); ++iat)
122  {
123  const auto& dist = dii.getDistRow(iat);
124  const int ig = P.GroupID[iat];
125  for (int j = 0; j < iat; ++j)
126  {
127  const RealType r = dist[j];
128  if (r < Dmax)
129  {
130  const int loc = static_cast<int>(DeltaInv * r);
131  const int jg = P.GroupID[j];
132  const int pair_id = gen_pair_id(ig, jg, num_species);
133  collectables[pair_id * NumBins + loc + my_index_] += norm_factor(pair_id + 1, loc);
134  }
135  }
136  }
137  for (int k = 0; k < other_ids.size(); ++k)
138  {
139  const auto& d1(P.getDistTableAB(other_ids[k]));
140  const ParticleSet::ParticleIndex& gid(d1.get_origin().GroupID);
141  int koff = other_offsets[k];
142  RealType overNI = 1.0 / d1.centers();
143  for (int iat = 0; iat < d1.targets(); ++iat)
144  {
145  const auto& dist = d1.getDistRow(iat);
146  for (int j = 0; j < d1.centers(); ++j)
147  {
148  const RealType r = dist[j];
149  if (r < Dmax)
150  {
151  int toff = (gid[j] + koff) * NumBins;
152  int loc = static_cast<int>(DeltaInv * r);
153  collectables[toff + loc + my_index_] += norm_factor(0, loc) * overNI;
154  }
155  }
156  }
157  }
158  return 0.0;
159 }
int my_index_
starting index of this object
Definition: OperatorBase.h:535
std::vector< int > other_offsets
offset of the gofr&#39;s associated with others_id
Matrix< RealType > norm_factor
normalization factor
ParticleAttrib< Index_t > ParticleIndex
Definition: Configuration.h:90
ParticleSet::Buffer_t BufferType
typedef for the serialized buffer
Definition: OperatorBase.h:75
RealType DeltaInv
one of bin size
std::vector< int > other_ids
table indexs for other type
RealType Dmax
maximum distance
QMCTraits::RealType RealType
static int gen_pair_id(const int ig, const int jg, const int ns)
generate the unique pair id from the group ids of particle i and j and the number of species ...

◆ gen_pair_id()

int gen_pair_id ( const int  ig,
const int  jg,
const int  ns 
)
static

generate the unique pair id from the group ids of particle i and j and the number of species

Definition at line 109 of file PairCorrEstimator.cpp.

References qmcplusplus::Units::time::ns.

Referenced by PairCorrEstimator::evaluate(), and qmcplusplus::TEST_CASE().

110 {
111  if (jg < ig)
112  return ns * (ns - 1) / 2 - (ns - jg) * (ns - jg - 1) / 2 + ig;
113  else
114  return ns * (ns - 1) / 2 - (ns - ig) * (ns - ig - 1) / 2 + jg;
115 }

◆ get()

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

write about the class

Implements OperatorBase.

Definition at line 321 of file PairCorrEstimator.cpp.

References PairCorrEstimator::Dmax, and OperatorBase::name_.

322 {
323  os << name_ << " dmax=" << Dmax << std::endl;
324  return true;
325 }
std::string name_
name of this object
Definition: OperatorBase.h:527
RealType Dmax
maximum distance

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements OperatorBase.

Definition at line 38 of file PairCorrEstimator.h.

38 { return "PairCorrEstimator"; }

◆ makeClone()

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

Implements OperatorBase.

Definition at line 327 of file PairCorrEstimator.cpp.

328 {
329  //default constructor is sufficient
330  return std::make_unique<PairCorrEstimator>(*this);
331 }

◆ put()

bool put ( xmlNodePtr  cur)
overridevirtual

Read the input parameter.

Parameters
curxml node for a OperatorBase object

Implements OperatorBase.

Definition at line 209 of file PairCorrEstimator.cpp.

References OhmmsAttributeSet::add(), qmcplusplus::ceil(), PairCorrEstimator::Delta, PairCorrEstimator::DeltaInv, PairCorrEstimator::Dmax, PairCorrEstimator::NumBins, OhmmsAttributeSet::put(), PairCorrEstimator::report(), and PairCorrEstimator::set_norm_factor().

Referenced by qmcplusplus::TEST_CASE().

210 {
211  //set resolution
212  int nbins = (int)std::ceil(Dmax * DeltaInv);
213  std::string debug("no");
214  OhmmsAttributeSet attrib;
215  attrib.add(nbins, "num_bin");
216  attrib.add(Dmax, "rmax");
217  attrib.add(Delta, "dr");
218  attrib.add(debug, "debug");
219  attrib.put(cur);
220  Delta = Dmax / static_cast<RealType>(nbins);
221  DeltaInv = 1.0 / Delta;
222  NumBins = nbins;
223 
224  // Set normalization based on updated parameters & report status
225  set_norm_factor();
226  report();
227 
228  return true;
229 }
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
MakeReturn< UnaryNode< FnCeil, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t ceil(const Vector< T1, C1 > &l)
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
RealType DeltaInv
one of bin size
RealType Dmax
maximum distance
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

◆ registerCollectables()

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

Reimplemented from OperatorBase.

Definition at line 161 of file PairCorrEstimator.cpp.

References PairCorrEstimator::Delta, PairCorrEstimator::Dmax, PairCorrEstimator::gof_r_prefix, OperatorBase::my_index_, and PairCorrEstimator::NumBins.

162 {
163  std::vector<int> onedim(1, NumBins);
164  int offset = my_index_;
165  for (int i = 0; i < gof_r_prefix.size(); ++i)
166  {
167  h5list.emplace_back(hdf_path{gof_r_prefix[i]});
168  auto& h5o = h5list.back();
169  h5o.set_dimensions(onedim, offset);
170  h5o.addProperty(const_cast<RealType&>(Delta), "delta", file);
171  h5o.addProperty(const_cast<RealType&>(Dmax), "cutoff", file);
172  offset += NumBins;
173  }
174 }
int my_index_
starting index of this object
Definition: OperatorBase.h:535
std::vector< std::string > gof_r_prefix
prefix of each gof_r
RealType Dmax
maximum distance

◆ report()

void report ( )

Definition at line 308 of file PairCorrEstimator.cpp.

References qmcplusplus::app_log(), PairCorrEstimator::Delta, PairCorrEstimator::DeltaInv, PairCorrEstimator::Dmax, PairCorrEstimator::num_species, PairCorrEstimator::NumBins, and PairCorrEstimator::Volume.

Referenced by PairCorrEstimator::put().

309 {
310  app_log() << "PairCorrEstimator report" << std::endl;
311  app_log() << " num_species = " << num_species << std::endl;
312  app_log() << " Volume = " << Volume << std::endl;
313  app_log() << " Dmax = " << Dmax << std::endl;
314  app_log() << " NumBins = " << NumBins << std::endl;
315  app_log() << " Delta = " << Delta << std::endl;
316  app_log() << " DeltaInv = " << DeltaInv << std::endl;
317  //app_log()<<" x = "<< x << std::endl;
318  app_log() << "end PairCorrEstimator report" << std::endl;
319 }
std::ostream & app_log()
Definition: OutputManager.h:65
RealType DeltaInv
one of bin size
RealType Dmax
maximum distance
RealType Volume
volume of the cell

◆ resetTargetParticleSet()

void resetTargetParticleSet ( ParticleSet P)
overridevirtual

Reset the data with the target ParticleSet.

Parameters
Pnew target ParticleSet

Implements OperatorBase.

Definition at line 106 of file PairCorrEstimator.cpp.

106 {}

◆ resize()

void resize ( int  nbins)
private

resize the internal data

Parameters
nbinsnumber of bins for the historgram

Definition at line 333 of file PairCorrEstimator.cpp.

References PairCorrEstimator::Delta, PairCorrEstimator::DeltaInv, qmcplusplus::Units::distance::m, qmcplusplus::n, PairCorrEstimator::N_e, PairCorrEstimator::n_vec, PairCorrEstimator::norm_factor, PairCorrEstimator::num_species, PairCorrEstimator::NumBins, Matrix< T, Alloc >::resize(), and PairCorrEstimator::Volume.

334 {
335  NumBins = nbins;
337  RealType r = Delta * 0.5;
338  RealType pf = Volume * DeltaInv / (4 * M_PI);
339  for (int i = 0; i < NumBins; ++i, r += Delta)
340  {
341  RealType rm2 = pf / r / r;
342  norm_factor(0, i) = rm2 / N_e;
343  int indx(1);
344  for (int m(0); m < num_species; m++)
345  for (int n(m); n < num_species; n++, indx++)
346  norm_factor(indx, i) = rm2 * n_vec[n] * n_vec[m];
347  }
348  // norm_factor.resize(nbins);
349  // RealType r=Delta*0.5;
350  // for(int i=0; i<norm_factor.size(); ++i, r+=Delta)
351  // {
352  // norm_factor[i]=1.0/r/r;
353  // }
354 }
Matrix< RealType > norm_factor
normalization factor
void resize(size_type n, size_type m)
Resize the container.
Definition: OhmmsMatrix.h:99
RealType DeltaInv
one of bin size
QMCTraits::RealType RealType
std::vector< RealType > n_vec
RealType Volume
volume of the cell

◆ set_norm_factor()

void set_norm_factor ( )

Definition at line 234 of file PairCorrEstimator.cpp.

References PairCorrEstimator::Delta, qmcplusplus::Units::distance::m, qmcplusplus::n, PairCorrEstimator::N_e, PairCorrEstimator::n_vec, qmcplusplus::Units::distance::nm, PairCorrEstimator::norm_factor, PairCorrEstimator::num_species, PairCorrEstimator::NumBins, qmcplusplus::pow(), Matrix< T, Alloc >::resize(), and PairCorrEstimator::Volume.

Referenced by PairCorrEstimator::put().

235 {
236  /*
237  Number of species-pair-specific gofr's to compute
238  E.g. "uu", "dd", "ud", & etc.
239  Note the addition +1 bin, which is for the total gofr of the system
240  (which seems not to get saved to h5 file. Why compute it then?)
241  */
242  const RealType n_channels = num_species * (num_species - 1) / 2 + num_species + 1;
243  norm_factor.resize(n_channels, NumBins);
244 
245  /*
246  Compute the normalization V/Npairs/Nid, with
247  V the volume of the system
248  Npairs the number of (unique) pairs of particles of given types
249  Nid the number of particles expected for a uniformly random distribution
250  with the same number density
251  */
252  RealType r = 0.;
253  const RealType ftpi = 4. / 3 * M_PI;
254  const RealType N_tot_pairs = N_e * (N_e - 1) / 2;
255  for (int i = 0; i < NumBins; i++)
256  {
257  // Separation for current bin
258  r = static_cast<RealType>(i) * Delta;
259 
260  // Number density of pairs
261  RealType rho = N_tot_pairs / Volume;
262 
263  // Volume of spherical shell of thickness Delta
264  RealType bin_volume = ftpi * (std::pow(r + Delta, 3) - std::pow(r, 3));
265 
266  // Expected number of pairs of particles separated by distance r assuming
267  // they are uniformly randomly distributed (ideal gas-like)
268  RealType nid = rho * bin_volume;
269  norm_factor(0, i) = 1. / nid;
270  int indx(1);
271 
272  // Do same as above, but for each unique pair of species
273  // e.g. uu, ud, dd...
274  for (int m = 0; m < num_species; m++)
275  {
276  const RealType nm = n_vec[m];
277  for (int n = m; n < num_species; n++)
278  {
279  const RealType nn = n_vec[n];
280  const RealType npairs = (m == n ? (nn * (nn - 1) / 2.) : (nn * nm));
281  rho = npairs / Volume;
282  nid = rho * bin_volume;
283  norm_factor(indx, i) = 1. / nid;
284  indx++;
285  }
286  }
287  }
288 
289  // ***DEBUG*** print norm_factor
290  /*
291  std::cout << "norm_factor:\n";
292  std::cout << std::fixed;
293  for( int j=0; j<norm_factor.size2(); j++ )
294  {
295  std::cout << std::setw(4) << j;
296  std::cout << std::setw(8) << std::setprecision(4) << j*Delta;
297  for( int i=0; i<norm_factor.size1(); i++ )
298  {
299  std::cout << " " << std::setw(10) << std::setprecision(4) << norm_factor(i,j);
300  }
301  std::cout << std::endl;
302  }
303  std::cout << std::endl;
304  */
305 }
Matrix< RealType > norm_factor
normalization factor
void resize(size_type n, size_type m)
Resize the container.
Definition: OhmmsMatrix.h:99
MakeReturn< BinaryNode< FnPow, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t, typename CreateLeaf< Vector< T2, C2 > >::Leaf_t > >::Expression_t pow(const Vector< T1, C1 > &l, const Vector< T2, C2 > &r)
QMCTraits::RealType RealType
std::vector< RealType > n_vec
RealType Volume
volume of the cell

◆ setObservables()

void setObservables ( PropertySetType plist)
overridevirtual

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 199 of file PairCorrEstimator.cpp.

200 {
201  //std::copy(gof_r.first_address(),gof_r.last_address(),plist.begin()+myIndex);
202 }

◆ setParticlePropertyList()

void setParticlePropertyList ( PropertySetType plist,
int  offset 
)
overridevirtual

Reimplemented from OperatorBase.

Definition at line 204 of file PairCorrEstimator.cpp.

205 {
206  //std::copy(gof_r.first_address(),gof_r.last_address(),plist.begin()+myDebugIndex+offset);
207 }

Member Data Documentation

◆ d_aa_ID_

const int d_aa_ID_
private

Definition at line 83 of file PairCorrEstimator.h.

Referenced by PairCorrEstimator::evaluate().

◆ Delta

◆ DeltaInv

◆ Dmax

◆ gof_r_prefix

std::vector<std::string> gof_r_prefix
private

◆ N_e

◆ n_vec

◆ norm_factor

Matrix<RealType> norm_factor
private

normalization factor

Definition at line 79 of file PairCorrEstimator.h.

Referenced by PairCorrEstimator::evaluate(), PairCorrEstimator::resize(), and PairCorrEstimator::set_norm_factor().

◆ num_species

◆ NumBins

◆ other_ids

std::vector<int> other_ids
private

table indexs for other type

Definition at line 73 of file PairCorrEstimator.h.

Referenced by PairCorrEstimator::evaluate(), and PairCorrEstimator::PairCorrEstimator().

◆ other_offsets

std::vector<int> other_offsets
private

offset of the gofr's associated with others_id

Definition at line 75 of file PairCorrEstimator.h.

Referenced by PairCorrEstimator::evaluate(), and PairCorrEstimator::PairCorrEstimator().

◆ pair_ids

std::vector<int> pair_ids
private

save pair indices

Definition at line 71 of file PairCorrEstimator.h.

◆ Volume


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