mirror of https://github.com/QMCPACK/qmcpack.git
Add update_source function to update internal data after a particleset is
updated, e.g., when ions are moved. git-svn-id: https://subversion.assembla.com/svn/qmcdev/trunk@5915 e5b18d87-469d-4833-9cc0-8cdfa06e9491
This commit is contained in:
parent
9026181c2f
commit
43dd0a5720
|
@ -28,6 +28,10 @@ CoulombPBCAA::CoulombPBCAA(ParticleSet& ref, bool active,
|
|||
ComputeForces(computeForces), ForceBase(ref,ref)
|
||||
{
|
||||
ReportEngine PRE("CoulombPBCAA","CoulombPBCAA");
|
||||
|
||||
//save source tag
|
||||
SourceID=ref.tag();
|
||||
|
||||
//create a distance table: just to get the table name
|
||||
DistanceTableData *d_aa = DistanceTable::add(ref);
|
||||
PtclRefName=d_aa->Name;
|
||||
|
@ -38,21 +42,22 @@ CoulombPBCAA::CoulombPBCAA(ParticleSet& ref, bool active,
|
|||
if(!is_active)
|
||||
{
|
||||
d_aa->evaluate(ref);
|
||||
RealType eL(0.0), eS(0.0);
|
||||
if (computeForces)
|
||||
{
|
||||
forces = 0.0;
|
||||
eS=evalSRwithForces(ref);
|
||||
// 1.3978248322
|
||||
eL=evalLRwithForces(ref);
|
||||
// 2.130267378
|
||||
}
|
||||
else
|
||||
{
|
||||
eL=evalLR(ref);
|
||||
eS=evalSR(ref);
|
||||
}
|
||||
NewValue=Value = eL+eS+myConst;
|
||||
update_source(ref);
|
||||
//RealType eL(0.0), eS(0.0);
|
||||
//if (computeForces)
|
||||
//{
|
||||
// forces = 0.0;
|
||||
// eS=evalSRwithForces(ref);
|
||||
// // 1.3978248322
|
||||
// eL=evalLRwithForces(ref);
|
||||
// // 2.130267378
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// eL=evalLR(ref);
|
||||
// eS=evalSR(ref);
|
||||
//}
|
||||
//NewValue=Value = eL+eS+myConst;
|
||||
//app_log() << " Fixed Coulomb potential for " << ref.getName();
|
||||
//app_log() << "\n e-e Madelung Const. =" << MC0
|
||||
// << "\n Vtot =" << Value << endl;
|
||||
|
@ -71,6 +76,26 @@ void CoulombPBCAA::addObservables(PropertySetType& plist, BufferType& collectabl
|
|||
addObservablesF(plist);
|
||||
}
|
||||
|
||||
void CoulombPBCAA::update_source(ParticleSet& s)
|
||||
{
|
||||
if(s.tag() == SourceID || s.parent() == SourceID)
|
||||
{
|
||||
RealType eL(0.0), eS(0.0);
|
||||
if (ComputeForces)
|
||||
{
|
||||
forces = 0.0;
|
||||
eS=evalSRwithForces(s);
|
||||
eL=evalLRwithForces(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
eL=evalLR(s);
|
||||
eS=evalSR(s);
|
||||
}
|
||||
NewValue=Value = eL+eS+myConst;
|
||||
}
|
||||
}
|
||||
|
||||
void CoulombPBCAA::resetTargetParticleSet(ParticleSet& P)
|
||||
{
|
||||
if(is_active)
|
||||
|
|
|
@ -40,6 +40,7 @@ struct CoulombPBCAA: public QMCHamiltonianBase, public ForceBase
|
|||
|
||||
bool is_active;
|
||||
bool FirstTime;
|
||||
int SourceID;
|
||||
int NumSpecies;
|
||||
int ChargeAttribIndx;
|
||||
int MemberAttribIndx;
|
||||
|
@ -70,6 +71,8 @@ struct CoulombPBCAA: public QMCHamiltonianBase, public ForceBase
|
|||
|
||||
Return_t evaluate(ParticleSet& P);
|
||||
|
||||
void update_source(ParticleSet& s);
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P, vector<NonLocalData>& Txy)
|
||||
{
|
||||
return evaluate(P);
|
||||
|
|
|
@ -89,6 +89,14 @@ struct CoulombPotential: public QMCHamiltonianBase
|
|||
|
||||
~CoulombPotential() { }
|
||||
|
||||
void update_source(ParticleSet& s)
|
||||
{
|
||||
if(myTableIndex == 0 && (s.tag() == PtclA->tag() || s.parent() == PtclA->tag()))
|
||||
{
|
||||
Value=evaluateAA(s.DistTables[myTableIndex],s.Z.first_address());
|
||||
}
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P)
|
||||
{
|
||||
if(is_active)
|
||||
|
|
|
@ -108,6 +108,13 @@ QMCHamiltonian::addOperator(QMCHamiltonianBase* h, const string& aname, bool phy
|
|||
//{
|
||||
// return false;
|
||||
//}
|
||||
void QMCHamiltonian::update_source(ParticleSet& s)
|
||||
{
|
||||
for(int i=0; i<H.size(); ++i)
|
||||
H[i]->update_source(s);
|
||||
for(int i=0; i<auxH.size(); ++i)
|
||||
auxH[i]->update_source(s);
|
||||
}
|
||||
|
||||
/** add a number of properties to the ParticleSet
|
||||
* @param P ParticleSet to which multiple columns to be added
|
||||
|
|
|
@ -151,6 +151,7 @@ public:
|
|||
// KineticEnergy=LocalEnergy-first[LOCALPOTENTIAL];
|
||||
std::copy(first+myIndex,first+myIndex+Observables.size(),Observables.begin());
|
||||
}
|
||||
void update_source(ParticleSet& s);
|
||||
|
||||
////return the LocalEnergy \f$=\sum_i H^{qmc}_{i}\f$
|
||||
inline Return_t getLocalEnergy()
|
||||
|
|
|
@ -188,6 +188,13 @@ struct QMCHamiltonianBase: public QMCTraits
|
|||
}
|
||||
virtual Return_t evaluate(ParticleSet& P, vector<NonLocalData>& Txy) = 0;
|
||||
|
||||
/** update data associated with a particleset
|
||||
* @param s source particle set
|
||||
*
|
||||
* Default implementation does nothing. Only A-A interactions for s needs to implement its own method.
|
||||
*/
|
||||
virtual void update_source(ParticleSet& s) { }
|
||||
|
||||
/*@{
|
||||
* @brief Functions to handle particle-by-particle move
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue