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) 2022 QMCPACK developers.
5+ // Copyright (c) 2025 QMCPACK developers.
66//
77// File developed by: Ken Esler, kpesler@gmail.com, University of Illinois at Urbana-Champaign
88// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
@@ -32,8 +32,6 @@ class OneDimCubicSplineLinearGrid;
3232/* * @ingroup hamiltonian
3333 *\brief Calculates the AA Coulomb potential using PBCs
3434 *
35- * Functionally identical to CoulombPBCAA but uses a templated version of
36- * LRHandler.
3735 */
3836struct CoulombPBCAA : public OperatorBase , public ForceBase
3937{
@@ -44,7 +42,7 @@ struct CoulombPBCAA : public OperatorBase, public ForceBase
4442 using OffloadSpline = OneDimCubicSplineLinearGrid<LRCoulombSingleton::pRealType>;
4543
4644 // / energy-optimized long range handle. Should be const LRHandlerType eventually
47- std::shared_ptr<LRHandlerType> AA ;
45+ std::shared_ptr<LRHandlerType> lr_aa_ ;
4846 // / energy-optimized short range pair potential
4947 std::shared_ptr<const RadFunctorType> rVs;
5048 // / the same as rVs but can be used inside OpenMP offload regions
@@ -85,10 +83,31 @@ struct CoulombPBCAA : public OperatorBase, public ForceBase
8583 Array<TraceReal, 1 >* V_sample;
8684 Array<TraceReal, 1 > V_const;
8785#endif
88- ParticleSet& Ps;
8986
87+ /* * Needs to be a mutable reference and not a copy since ParticleSet
88+ * copy misses important state which causes later access
89+ * violations.
90+ * This is a bad bad smell.
91+ */
92+ ParticleSet& Ps;
9093
91- /* * constructor */
94+ /* * constructor
95+ * Sadly there is significant conditional behavior here
96+ * the constructor does the operator calculation for the static
97+ * and only for active==true are most of the methods other than
98+ * nops.
99+ *
100+ * Consistent side effects
101+ * * local copies of most of of pset refs basic properties
102+ * input psets will not be checked for consistency later!
103+ * *
104+ * Conditional side effects include
105+ * When ComputeForces == true
106+ * * turnOnPerParticleSK for ref
107+ * * updateSource(ref)
108+ * When is_activate == false
109+ *
110+ */
92111 CoulombPBCAA (ParticleSet& ref, bool active, bool computeForces, bool use_offload);
93112
94113 ~CoulombPBCAA () override ;
@@ -97,6 +116,13 @@ struct CoulombPBCAA : public OperatorBase, public ForceBase
97116
98117 void resetTargetParticleSet (ParticleSet& P) override ;
99118
119+ /* * evaluate just one walker
120+ *
121+ * This is still called for batch AA IonIon
122+ * we later need to make sure for Ions that we assign from value_
123+ * to the v_samples in multi walker reference.
124+ * AA IonIon evaluation.
125+ */
100126 Return_t evaluate (ParticleSet& P) override ;
101127
102128 void mw_evaluate (const RefVectorWithLeader<OperatorBase>& o_list,
@@ -124,6 +150,11 @@ struct CoulombPBCAA : public OperatorBase, public ForceBase
124150 TrialWaveFunction& psi,
125151 ParticleSet::ParticlePos& hf_terms,
126152 ParticleSet::ParticlePos& pulay_terms) override ;
153+
154+ /* *
155+ * calls eval(LR|SR){withForces} and updates eS and eL updates new_value_
156+ * new_value_ doesn't seem to ever be used anywhere
157+ */
127158 void updateSource (ParticleSet& s) override ;
128159
129160 /* * Do nothing */
@@ -209,7 +240,13 @@ struct CoulombPBCAA : public OperatorBase, public ForceBase
209240
210241 /* * constructor code factored out
211242 */
212- void initBreakup (ParticleSet& P);
243+ void initBreakup (ParticleSet& ref_pset);
244+
245+ /* * initialize everything for a static particle set
246+ * for static particle set hamiltonians no significant calculation
247+ * is done after this.
248+ */
249+ void inactiveInitialization (ParticleSet& ref);
213250
214251 /* * Compute the const part of the per particle coulomb self interaction potential.
215252 * \param[out] pp_consts constant values for the particles self interaction
0 commit comments