From 4ba73a0eb1e2ef1980df41bb169a4779e998a2f0 Mon Sep 17 00:00:00 2001 From: Cody Melton Date: Thu, 9 Mar 2023 13:08:50 -0700 Subject: [PATCH] change variables in SOECPotential to follow convention --- src/QMCHamiltonians/SOECPotential.cpp | 120 +++++++++--------- src/QMCHamiltonians/SOECPotential.h | 24 ++-- .../tests/test_SOECPotential.cpp | 6 +- 3 files changed, 75 insertions(+), 75 deletions(-) diff --git a/src/QMCHamiltonians/SOECPotential.cpp b/src/QMCHamiltonians/SOECPotential.cpp index 6a4fc6e3b3..3adaf2c60c 100644 --- a/src/QMCHamiltonians/SOECPotential.cpp +++ b/src/QMCHamiltonians/SOECPotential.cpp @@ -38,14 +38,14 @@ struct SOECPotential::SOECPotentialMultiWalkerResource : public Resource *\param psi Trial wave function */ SOECPotential::SOECPotential(ParticleSet& ions, ParticleSet& els, TrialWaveFunction& psi) - : myRNG_(nullptr), IonConfig_(ions), Psi_(psi), Peln_(els), ElecNeighborIons_(els), IonNeighborElecs_(ions) + : my_rng_(nullptr), ion_config_(ions), psi_(psi), peln_(els), elec_neighbor_ions_(els), ion_neighbor_elecs_(ions) { setEnergyDomain(POTENTIAL); twoBodyQuantumDomain(ions, els); - myTableIndex_ = els.addTable(ions); - NumIons_ = ions.getTotalNum(); - PP_.resize(NumIons_, nullptr); - PPset_.resize(IonConfig_.getSpeciesSet().getTotalNum()); + my_table_index_ = els.addTable(ions); + num_ions_ = ions.getTotalNum(); + pp_.resize(num_ions_, nullptr); + ppset_.resize(ion_config_.getSpeciesSet().getTotalNum()); sopp_jobs_.resize(els.groups()); for (size_t ig = 0; ig < els.groups(); ig++) sopp_jobs_[ig].reserve(2 * els.groupsize(ig)); @@ -71,28 +71,28 @@ void SOECPotential::evaluateImpl(ParticleSet& P, bool keep_grid) { value_ = 0.0; if (!keep_grid) - for (int ipp = 0; ipp < PPset_.size(); ipp++) - if (PPset_[ipp]) - PPset_[ipp]->rotateQuadratureGrid(generateRandomRotationMatrix(*myRNG_)); + for (int ipp = 0; ipp < ppset_.size(); ipp++) + if (ppset_[ipp]) + ppset_[ipp]->rotateQuadratureGrid(generateRandomRotationMatrix(*my_rng_)); - const auto& myTable = P.getDistTableAB(myTableIndex_); - for (int iat = 0; iat < NumIons_; iat++) - IonNeighborElecs_.getNeighborList(iat).clear(); + const auto& ble = P.getDistTableAB(my_table_index_); + for (int iat = 0; iat < num_ions_; iat++) + ion_neighbor_elecs_.getNeighborList(iat).clear(); for (int jel = 0; jel < P.getTotalNum(); jel++) - ElecNeighborIons_.getNeighborList(jel).clear(); + elec_neighbor_ions_.getNeighborList(jel).clear(); for (int jel = 0; jel < P.getTotalNum(); jel++) { - const auto& dist = myTable.getDistRow(jel); - const auto& displ = myTable.getDisplRow(jel); - std::vector& NeighborIons = ElecNeighborIons_.getNeighborList(jel); - for (int iat = 0; iat < NumIons_; iat++) - if (PP_[iat] != nullptr && dist[iat] < PP_[iat]->getRmax()) + const auto& dist = ble.getDistRow(jel); + const auto& displ = ble.getDisplRow(jel); + std::vector& NeighborIons = elec_neighbor_ions_.getNeighborList(jel); + for (int iat = 0; iat < num_ions_; iat++) + if (pp_[iat] != nullptr && dist[iat] < pp_[iat]->getRmax()) { - RealType pairpot = PP_[iat]->evaluateOne(P, iat, Psi_, jel, dist[iat], -displ[iat]); + RealType pairpot = pp_[iat]->evaluateOne(P, iat, psi_, jel, dist[iat], -displ[iat]); value_ += pairpot; NeighborIons.push_back(iat); - IonNeighborElecs_.getNeighborList(iat).push_back(jel); + ion_neighbor_elecs_.getNeighborList(iat).push_back(jel); } } } @@ -103,18 +103,18 @@ SOECPotential::Return_t SOECPotential::evaluateValueAndDerivatives(ParticleSet& Vector& dhpsioverpsi) { value_ = 0.0; - for (int ipp = 0; ipp < PPset_.size(); ipp++) - if (PPset_[ipp]) - PPset_[ipp]->rotateQuadratureGrid(generateRandomRotationMatrix(*myRNG_)); + for (int ipp = 0; ipp < ppset_.size(); ipp++) + if (ppset_[ipp]) + ppset_[ipp]->rotateQuadratureGrid(generateRandomRotationMatrix(*my_rng_)); - const auto& myTable = P.getDistTableAB(myTableIndex_); + const auto& ble = P.getDistTableAB(my_table_index_); for (int jel = 0; jel < P.getTotalNum(); jel++) { - const auto& dist = myTable.getDistRow(jel); - const auto& displ = myTable.getDisplRow(jel); - for (int iat = 0; iat < NumIons_; iat++) - if (PP_[iat] != nullptr && dist[iat] < PP_[iat]->getRmax()) - value_ += PP_[iat]->evaluateValueAndDerivatives(P, iat, Psi_, jel, dist[iat], -displ[iat], optvars, dlogpsi, + const auto& dist = ble.getDistRow(jel); + const auto& displ = ble.getDisplRow(jel); + for (int iat = 0; iat < num_ions_; iat++) + if (pp_[iat] != nullptr && dist[iat] < pp_[iat]->getRmax()) + value_ += pp_[iat]->evaluateValueAndDerivatives(P, iat, psi_, jel, dist[iat], -displ[iat], optvars, dlogpsi, dhpsioverpsi); } return value_; @@ -153,17 +153,17 @@ void SOECPotential::mw_evaluateImpl(const RefVectorWithLeader& o_l const ParticleSet& P(p_list[iw]); if (!keep_grid) - for (size_t ipp = 0; ipp < O.PPset_.size(); ipp++) - if (O.PPset_[ipp]) - O.PPset_[ipp]->rotateQuadratureGrid(generateRandomRotationMatrix(*O.myRNG_)); + for (size_t ipp = 0; ipp < O.ppset_.size(); ipp++) + if (O.ppset_[ipp]) + O.ppset_[ipp]->rotateQuadratureGrid(generateRandomRotationMatrix(*O.my_rng_)); //loop over all the ions - const auto& myTable = P.getDistTableAB(O.myTableIndex_); + const auto& ble = P.getDistTableAB(O.my_table_index_); //clear elec and ion neighbor lists - for (size_t iat = 0; iat < O.NumIons_; iat++) - O.IonNeighborElecs_.getNeighborList(iat).clear(); + for (size_t iat = 0; iat < O.num_ions_; iat++) + O.ion_neighbor_elecs_.getNeighborList(iat).clear(); for (size_t jel = 0; jel < P.getTotalNum(); jel++) - O.ElecNeighborIons_.getNeighborList(jel).clear(); + O.elec_neighbor_ions_.getNeighborList(jel).clear(); for (size_t ig = 0; ig < P.groups(); ig++) // loop over species { @@ -172,14 +172,14 @@ void SOECPotential::mw_evaluateImpl(const RefVectorWithLeader& o_l for (size_t jel = P.first(ig); jel < P.last(ig); jel++) { - const auto& dist = myTable.getDistRow(jel); - const auto& displ = myTable.getDisplRow(jel); - std::vector& NeighborIons = O.ElecNeighborIons_.getNeighborList(jel); - for (size_t iat = 0; iat < O.NumIons_; iat++) - if (O.PP_[iat] != nullptr && dist[iat] < O.PP_[iat]->getRmax()) + const auto& dist = ble.getDistRow(jel); + const auto& displ = ble.getDisplRow(jel); + std::vector& NeighborIons = O.elec_neighbor_ions_.getNeighborList(jel); + for (size_t iat = 0; iat < O.num_ions_; iat++) + if (O.pp_[iat] != nullptr && dist[iat] < O.pp_[iat]->getRmax()) { NeighborIons.push_back(iat); - O.IonNeighborElecs_.getNeighborList(iat).push_back(jel); + O.ion_neighbor_elecs_.getNeighborList(iat).push_back(jel); joblist.emplace_back(iat, jel, dist[iat], -displ[iat]); } } @@ -192,19 +192,19 @@ void SOECPotential::mw_evaluateImpl(const RefVectorWithLeader& o_l auto& ve_samples = O_leader.mw_res_->ve_samples; auto& vi_samples = O_leader.mw_res_->vi_samples; ve_samples.resize(nw, pset_leader.getTotalNum()); - vi_samples.resize(nw, O_leader.IonConfig_.getTotalNum()); + vi_samples.resize(nw, O_leader.ion_config_.getTotalNum()); } - auto pp_component = std::find_if(O_leader.PPset_.begin(), O_leader.PPset_.end(), [](auto& ptr) { return bool(ptr); }); - assert(pp_component != std::end(O_leader.PPset_)); + auto pp_component = std::find_if(O_leader.ppset_.begin(), O_leader.ppset_.end(), [](auto& ptr) { return bool(ptr); }); + assert(pp_component != std::end(O_leader.ppset_)); RefVector soecp_potential_list; RefVectorWithLeader soecp_component_list(**pp_component); RefVectorWithLeader pset_list(pset_leader); - RefVectorWithLeader psi_list(O_leader.Psi_); - assert(&O_leader.Psi_ == &wf_list.getLeader()); + RefVectorWithLeader psi_list(O_leader.psi_); + assert(&O_leader.psi_ == &wf_list.getLeader()); for (size_t iw = 0; iw < nw; iw++) - assert(&o_list.getCastedElement(iw).Psi_ == &wf_list[iw]); + assert(&o_list.getCastedElement(iw).psi_ == &wf_list[iw]); RefVector> batch_list; std::vector pairpots(nw); @@ -240,7 +240,7 @@ void SOECPotential::mw_evaluateImpl(const RefVectorWithLeader& o_l { const auto& job = O.sopp_jobs_[ig][jobid]; soecp_potential_list.push_back(O); - soecp_component_list.push_back(*O.PP_[job.ion_id]); + soecp_component_list.push_back(*O.pp_[job.ion_id]); pset_list.push_back(p_list[iw]); psi_list.push_back(wf_list[iw]); batch_list.push_back(job); @@ -274,7 +274,7 @@ void SOECPotential::mw_evaluateImpl(const RefVectorWithLeader& o_l for (int iw = 0; iw < nw; iw++) { Vector ve_sample(ve_samples.begin(iw), num_electrons); - Vector vi_sample(vi_samples.begin(iw), O_leader.NumIons_); + Vector vi_sample(vi_samples.begin(iw), O_leader.num_ions_); for (const ListenerVector& listener : listeners->electron_values) listener.report(iw, O_leader.getName(), ve_sample); for (const ListenerVector& listener : listeners->ion_values) @@ -287,28 +287,28 @@ void SOECPotential::mw_evaluateImpl(const RefVectorWithLeader& o_l std::unique_ptr SOECPotential::makeClone(ParticleSet& qp, TrialWaveFunction& psi) { - std::unique_ptr myclone = std::make_unique(IonConfig_, qp, psi); - for (int ig = 0; ig < PPset_.size(); ++ig) - if (PPset_[ig]) - myclone->addComponent(ig, std::unique_ptr(PPset_[ig]->makeClone(qp))); + std::unique_ptr myclone = std::make_unique(ion_config_, qp, psi); + for (int ig = 0; ig < ppset_.size(); ++ig) + if (ppset_[ig]) + myclone->addComponent(ig, std::unique_ptr(ppset_[ig]->makeClone(qp))); return myclone; } void SOECPotential::addComponent(int groupID, std::unique_ptr&& ppot) { - for (int iat = 0; iat < PP_.size(); iat++) - if (IonConfig_.GroupID[iat] == groupID) - PP_[iat] = ppot.get(); - PPset_[groupID] = std::move(ppot); + for (int iat = 0; iat < pp_.size(); iat++) + if (ion_config_.GroupID[iat] == groupID) + pp_[iat] = ppot.get(); + ppset_[groupID] = std::move(ppot); } void SOECPotential::createResource(ResourceCollection& collection) const { auto new_res = std::make_unique(); - for (int ig = 0; ig < PPset_.size(); ig++) - if (PPset_[ig]->getVP()) + for (int ig = 0; ig < ppset_.size(); ig++) + if (ppset_[ig]->getVP()) { - PPset_[ig]->getVP()->createResource(new_res->collection); + ppset_[ig]->getVP()->createResource(new_res->collection); break; } auto resource_index = collection.addResource(std::move(new_res)); diff --git a/src/QMCHamiltonians/SOECPotential.h b/src/QMCHamiltonians/SOECPotential.h index 7992c229bc..60471cf246 100644 --- a/src/QMCHamiltonians/SOECPotential.h +++ b/src/QMCHamiltonians/SOECPotential.h @@ -60,7 +60,7 @@ class SOECPotential : public OperatorBase bool get(std::ostream& os) const override { - os << "SOECPotential: " << IonConfig_.getName(); + os << "SOECPotential: " << ion_config_.getName(); return true; } @@ -68,7 +68,7 @@ class SOECPotential : public OperatorBase void addComponent(int groupID, std::unique_ptr&& pp); - void setRandomGenerator(RandomGenerator* rng) override { myRNG_ = rng; } + void setRandomGenerator(RandomGenerator* rng) override { my_rng_ = rng; } //initialize shared resource and hand to collection void createResource(ResourceCollection& collection) const override; @@ -80,11 +80,11 @@ class SOECPotential : public OperatorBase void releaseResource(ResourceCollection& collection, const RefVectorWithLeader& o_list) const override; protected: - RandomGenerator* myRNG_; - std::vector PP_; - std::vector> PPset_; - ParticleSet& IonConfig_; - TrialWaveFunction& Psi_; + RandomGenerator* my_rng_; + std::vector pp_; + std::vector> ppset_; + ParticleSet& ion_config_; + TrialWaveFunction& psi_; static void mw_evaluateImpl(const RefVectorWithLeader& o_list, const RefVectorWithLeader& wf_list, const RefVectorWithLeader& p_list, @@ -93,15 +93,15 @@ class SOECPotential : public OperatorBase private: ///number of ions - int NumIons_; + int num_ions_; ///index of distance table for ion-el pair - int myTableIndex_; + int my_table_index_; ///reference to the electrons - ParticleSet& Peln_; + ParticleSet& peln_; ///neighborlist of electrons - NeighborLists ElecNeighborIons_; + NeighborLists elec_neighbor_ions_; ///neighborlist of ions - NeighborLists IonNeighborElecs_; + NeighborLists ion_neighbor_elecs_; //job list for evaluation std::vector>> sopp_jobs_; //multi walker resource diff --git a/src/QMCHamiltonians/tests/test_SOECPotential.cpp b/src/QMCHamiltonians/tests/test_SOECPotential.cpp index 714dcd3bcc..69359eccb8 100644 --- a/src/QMCHamiltonians/tests/test_SOECPotential.cpp +++ b/src/QMCHamiltonians/tests/test_SOECPotential.cpp @@ -33,11 +33,11 @@ class TestSOECPotential public: static void copyGridUnrotatedForTest(SOECPotential& so_ecp) { - so_ecp.PPset_[0]->rrotsgrid_m_ = so_ecp.PPset_[0]->sgridxyz_m_; + so_ecp.ppset_[0]->rrotsgrid_m_ = so_ecp.ppset_[0]->sgridxyz_m_; } static bool didGridChange(SOECPotential& so_ecp) { - return so_ecp.PPset_[0]->rrotsgrid_m_ != so_ecp.PPset_[0]->sgridxyz_m_; + return so_ecp.ppset_[0]->rrotsgrid_m_ != so_ecp.ppset_[0]->sgridxyz_m_; } static void addVPs(const RefVectorWithLeader& o_list, const RefVectorWithLeader& p_list) { @@ -45,7 +45,7 @@ class TestSOECPotential { auto& sopp = o_list.getCastedElement(iw); auto& pset = p_list[iw]; - for (auto& uptr_comp : sopp.PPset_) + for (auto& uptr_comp : sopp.ppset_) uptr_comp.get()->initVirtualParticle(pset); } }