22// This file is distributed under the University of Illinois/NCSA Open Source License.
33// See LICENSE file in top directory for details.
44//
5- // Copyright (c) 2024 QMCPACK developers.
5+ // Copyright (c) 2025 QMCPACK developers.
66//
77// File developed by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Laboratory
88//
1212#include " EstimatorManagerInput.h"
1313#include " EstimatorInputDelegates.h"
1414#include < algorithm>
15+ #include < variant>
16+ #include " MagnetizationDensityInput.h"
1517#include " ModernStringUtils.hpp"
1618
1719namespace qmcplusplus
@@ -76,19 +78,19 @@ void EstimatorManagerInput::readXML(xmlNodePtr cur)
7678 appendScalarEstimatorInput<RMCLocalEnergyInput>(child);
7779 app_warning () << " RMCLocalEnergyEstimator support is at best experimental with batch drivers" << std::endl;
7880 }
79- else if (atype == " onebodydensitymatrices " )
81+ else if (atype == lowerCase (OneBodyDensityMatricesInput::type_tag) )
8082 appendEstimatorInput<OneBodyDensityMatricesInput>(child);
81- else if (atype == " spindensity " )
83+ else if (atype == lowerCase (SpinDensityInput::type_tag) )
8284 appendEstimatorInput<SpinDensityInput>(child);
83- else if (atype == " momentumdistribution " )
85+ else if (atype == lowerCase (MomentumDistributionInput::type_tag) )
8486 appendEstimatorInput<MomentumDistributionInput>(child);
85- else if (atype == " selfhealingoverlap " )
87+ else if (atype == lowerCase (SelfHealingOverlapInput::type_tag) )
8688 appendEstimatorInput<SelfHealingOverlapInput>(child);
87- else if (atype == " perparticlehamiltonianlogger " )
89+ else if (atype == lowerCase (PerParticleHamiltonianLoggerInput::type_tag) )
8890 appendEstimatorInput<PerParticleHamiltonianLoggerInput>(child);
89- else if (atype == " magnetizationdensity " )
91+ else if (atype == lowerCase (MagnetizationDensityInput::type_tag) )
9092 appendEstimatorInput<MagnetizationDensityInput>(child);
91- else if (atype == " energydensity " )
93+ else if (atype == lowerCase (EnergyDensityInput::type_tag) )
9294 appendEstimatorInput<EnergyDensityInput>(child);
9395 else
9496 throw UniformCommunicateError (error_tag + " unparsable <estimator> node, name: " + aname + " type: " + atype +
@@ -112,8 +114,29 @@ void EstimatorManagerInput::readXML(xmlNodePtr cur)
112114 }
113115}
114116
117+ template <typename T>
118+ std::vector<int > EstimatorManagerInput::getEstimatorTypeIndexes () const
119+ {
120+ std::vector<int > type_indexes;
121+ for (int i = 0 ; i < estimator_inputs_.size (); ++i)
122+ {
123+ if (std::holds_alternative<T>(estimator_inputs_[i]))
124+ type_indexes.push_back (i);
125+ }
126+ return type_indexes;
127+ }
128+
129+
115130void EstimatorManagerInput::append (const EstimatorInput& ei) { estimator_inputs_.emplace_back (ei); }
116131void EstimatorManagerInput::append (const ScalarEstimatorInput& sei) { scalar_estimator_inputs_.emplace_back (sei); }
117132
133+ template std::vector<int > EstimatorManagerInput::getEstimatorTypeIndexes<EnergyDensityInput>() const ;
134+ template std::vector<int > EstimatorManagerInput::getEstimatorTypeIndexes<SpinDensityInput>() const ;
135+ template std::vector<int > EstimatorManagerInput::getEstimatorTypeIndexes<MomentumDistributionInput>() const ;
136+ template std::vector<int > EstimatorManagerInput::getEstimatorTypeIndexes<OneBodyDensityMatricesInput>() const ;
137+ template std::vector<int > EstimatorManagerInput::getEstimatorTypeIndexes<SelfHealingOverlapInput>() const ;
138+ template std::vector<int > EstimatorManagerInput::getEstimatorTypeIndexes<MagnetizationDensityInput>() const ;
139+ template std::vector<int > EstimatorManagerInput::getEstimatorTypeIndexes<PerParticleHamiltonianLoggerInput>() const ;
140+
118141
119142} // namespace qmcplusplus
0 commit comments