Skip to content

Commit 989d91c

Browse files
authored
Merge pull request QMCPACK#5603 from ye-luo/paircorr-remove-target
Remove target input entry from PairCorrelationEstimator.
2 parents f2728eb + 9dda047 commit 989d91c

9 files changed

Lines changed: 18 additions & 19 deletions

docs/hamiltonianobservable.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,8 +1081,6 @@ attributes:
10811081
+-------------------------------+--------------+----------------------+------------------------+-------------------------+
10821082
| ``debug``:math:`^o` | boolean | yes/no | no | *No current function* |
10831083
+-------------------------------+--------------+----------------------+------------------------+-------------------------+
1084-
| ``target``:math:`^o` | text | ``particleset.name`` | ``"e"`` | Quantum particles |
1085-
+-------------------------------+--------------+----------------------+------------------------+-------------------------+
10861084
| ``sources``:math:`^o` | text array | ``particleset.name`` | ``"e"`` | Classical particles |
10871085
+-------------------------------+--------------+----------------------+------------------------+-------------------------+
10881086

@@ -1107,9 +1105,6 @@ Additional information:
11071105
``sources="ion0"``), but there can be several in principle (e.g.,
11081106
``sources="ion0 ion1 ion2"``).
11091107

1110-
- ``target:`` The default value is the preferred usage (i.e.,
1111-
``target`` does not need to be provided).
1112-
11131108
- Data is output to the ``stat.h5`` for each QMC subrun. It appears in an hdf group
11141109
determined by the name attribute.
11151110
histograms are named according to the quantum particleset and index

src/Estimators/EstimatorManagerNew.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void EstimatorManagerNew::constructEstimators(EstimatorManagerInput&& emi,
101101
const ParticleSet& pset,
102102
const TrialWaveFunction& twf,
103103
const QMCHamiltonian& H,
104-
PSPool& pset_pool)
104+
const PSPool& pset_pool)
105105
{
106106
for (auto& est_input : emi.get_estimator_inputs())
107107
if (!(createEstimator<SpinDensityInput>(est_input, pset.getLattice(), pset.getSpeciesSet()) ||
@@ -114,7 +114,13 @@ void EstimatorManagerNew::constructEstimators(EstimatorManagerInput&& emi,
114114
createEstimator<PerParticleHamiltonianLoggerInput>(est_input, my_comm_->rank()) ||
115115
createEstimator<EnergyDensityInput>(est_input, pset_pool) ||
116116
createEstimator<StructureFactorInput>(est_input, pset_pool) ||
117-
createEstimator<PairCorrelationInput>(est_input, pset_pool)))
117+
// Estimators are preferred not modifying pset, twf, H during the constructor call
118+
// PairCorrelation ported from legacy adds a distance table (DT) in pset.
119+
// Thus, we remove const, namely altering pset.
120+
// A potential clean solution is to create the needed DT inside the estimator
121+
// if pset doesn't have one already. In this way, there will be no side effect
122+
// when PairCorrelation is not used in the next QMC driver section.
123+
createEstimator<PairCorrelationInput>(est_input, pset_pool, const_cast<ParticleSet&>(pset))))
118124
throw UniformCommunicateError(std::string(error_tag_) +
119125
"cannot construct an estimator from estimator input object.");
120126

src/Estimators/EstimatorManagerNew.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class EstimatorManagerNew
9090
const ParticleSet& pset_primary,
9191
const TrialWaveFunction& twf_primary,
9292
const QMCHamiltonian& H,
93-
PSPool& pset_pool);
93+
const PSPool& pset_pool);
9494

9595
/** Start the manager at the beginning of a driver run().
9696
* Open files. Setting zeros.

src/Estimators/PairCorrelationEstimator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ namespace qmcplusplus
1717
{
1818

1919
PairCorrelationEstimator::PairCorrelationEstimator(const PairCorrelationInput& pci,
20-
PSPool& pset_pool,
20+
const PSPool& pset_pool,
21+
ParticleSet& elecs,
2122
DataLocality data_locality)
2223
: OperatorEstBase(data_locality, pci.get_name(), pci.get_type()), input_(pci)
2324
{
24-
ParticleSet& elecs = getParticleSet(pset_pool, pci.get_target());
25-
num_species_ = elecs.groups();
25+
num_species_ = elecs.groups();
2626
n_vec_.resize(num_species_, 0);
2727
for (int i = 0; i < num_species_; i++)
2828
n_vec_[i] = elecs.last(i) - elecs.first(i);

src/Estimators/PairCorrelationEstimator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ class PairCorrelationEstimator : public OperatorEstBase
4343
*
4444
*/
4545
PairCorrelationEstimator(const PairCorrelationInput& pci,
46-
PSPool& psp,
46+
const PSPool& pset_pool,
47+
ParticleSet& elecs,
4748
DataLocality data_locality = DataLocality::crowd);
4849

4950
PairCorrelationEstimator(const PairCorrelationEstimator& pce, DataLocality dl);

src/Estimators/PairCorrelationInput.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ PairCorrelationInput::PairCorrelationInput(xmlNodePtr cur)
2626
explicit_set_delta_ = setIfInInput(delta_, "dr");
2727
setIfInInput(debug_, "debug");
2828
setIfInInput(sources_, "sources");
29-
setIfInInput(target_, "target");
3029
}
3130

3231
} // namespace qmcplusplus

src/Estimators/PairCorrelationInput.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class PairCorrelationInput
3232
{
3333
section_name = type_tag;
3434
section_name_alternates = {"gofr"};
35-
attributes = {"type", "name", "num_bin", "rmax", "dr", "debug", "sources", "target"};
36-
strings = {"type", "name", "target"};
35+
attributes = {"type", "name", "num_bin", "rmax", "dr", "debug", "sources"};
36+
strings = {"type", "name"};
3737
multi_strings = {"sources"};
3838
reals = {"dr", "rmax"};
3939
integers = {"num_bin"};
@@ -48,7 +48,6 @@ class PairCorrelationInput
4848

4949
std::string name_{type_tag};
5050
std::string type_{type_tag};
51-
std::string target_{"e"};
5251
std::vector<std::string> sources_{"e"};
5352
Real rmax_{10};
5453
bool explicit_set_rmax_{false};
@@ -62,7 +61,6 @@ class PairCorrelationInput
6261
std::string get_name() const { return name_; }
6362
std::string get_type() const { return type_; }
6463
const std::vector<std::string>& get_sources() const { return sources_; }
65-
const std::string& get_target() const { return target_; }
6664
Real get_rmax() const { return rmax_; }
6765
Real get_delta() const { return delta_; }
6866
int get_nbins() const { return nbins_; }

src/Particle/ParticleSetPool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class ParticleSetPool : public MPIObjectBase
8989

9090
/** get the Pool object
9191
*/
92-
inline PoolType& getPool() { return myPool; }
92+
inline const PoolType& getPool() const { return myPool; }
9393

9494
/// get simulation cell
9595
const auto& getSimulationCell() const { return *simulation_cell_; }

tests/heg/heg_14_gamma/batch/deter-heg-SJ-batch.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
</qmcsystem>
5353
<qmc method="vmc" move="pbyp">
5454
<estimators>
55-
<estimator name="gofr" type="PairCorrelation" sources="e" target="e"/>
55+
<estimator name="gofr" type="PairCorrelation" sources="e"/>
5656
</estimators>
5757
<parameter name="warmupsteps" > 2 </parameter>
5858
<parameter name="blocks" > 3 </parameter>

0 commit comments

Comments
 (0)