mirror of https://github.com/QMCPACK/qmcpack.git
Use addFunctor instead of insert.
git-svn-id: https://subversion.assembla.com/svn/qmcdev/trunk@2569 e5b18d87-469d-4833-9cc0-8cdfa06e9491
This commit is contained in:
parent
684d138c51
commit
bf4bde729f
|
@ -19,6 +19,7 @@
|
|||
#include "QMCWaveFunctions/Jastrow/JAABuilder.h"
|
||||
#include "QMCWaveFunctions/Jastrow/ModPadeFunctor.h"
|
||||
#include "QMCWaveFunctions/Jastrow/TwoBodyJastrowOrbital.h"
|
||||
#include "OhmmsData/AttributeSet.h"
|
||||
|
||||
namespace qmcplusplus {
|
||||
|
||||
|
@ -35,110 +36,65 @@ namespace qmcplusplus {
|
|||
*spin-dependent Jastrow function,e.g., for electrons, two functions
|
||||
*are created for uu(dd) and ud(du).
|
||||
*/
|
||||
template<class FN>
|
||||
bool JAABuilder::createJAA(xmlNodePtr cur, FN* dummy) {
|
||||
template<class FN> bool JAABuilder::createJAA(xmlNodePtr cur, FN* dummy) {
|
||||
|
||||
string corr_tag("correlation");
|
||||
int ng = targetPtcl.groups();
|
||||
//temporary storage for counting only
|
||||
map<string,FN*> j2Unique;
|
||||
vector<FN*> jastrow(ng*ng);
|
||||
for(int i=0; i<ng*ng; i++) jastrow[i]=0;
|
||||
|
||||
int ia=0, ib=0, iab=0;
|
||||
int cur_var = targetPsi.VarList.size();
|
||||
xmlNodePtr gridPtr=NULL;
|
||||
cur = cur->children;
|
||||
const SpeciesSet& species(targetPtcl.getSpeciesSet());
|
||||
typedef TwoBodyJastrowOrbital<FN> JeeType;
|
||||
JeeType *J2 = new JeeType(targetPtcl);
|
||||
|
||||
int pairs=0;
|
||||
while(cur != NULL) {
|
||||
string cname((const char*)(cur->name));
|
||||
if(cname == corr_tag) {
|
||||
string spA((const char*)(xmlGetProp(cur,(const xmlChar *)"speciesA")));
|
||||
string spB((const char*)(xmlGetProp(cur,(const xmlChar *)"speciesB")));
|
||||
const xmlChar* refptr=xmlGetProp(cur,(const xmlChar *)"ref");
|
||||
const xmlChar* idptr=xmlGetProp(cur,(const xmlChar *)"id");
|
||||
|
||||
if(!IgnoreSpin) { //get the species
|
||||
ia = targetPtcl.getSpeciesSet().findSpecies(spA);
|
||||
ib = targetPtcl.getSpeciesSet().findSpecies(spB);
|
||||
iab = ia*ng+ib;
|
||||
if(cname == corr_tag)
|
||||
{
|
||||
string spA("u");
|
||||
string spB("u");
|
||||
OhmmsAttributeSet rAttrib;
|
||||
rAttrib.add(spA, "speciesA"); rAttrib.add(spA, "species1");
|
||||
rAttrib.add(spB, "speciesB"); rAttrib.add(spA, "species2");
|
||||
rAttrib.put(cur);
|
||||
if(spA==targetPsi.getName()) //could have used the particle name
|
||||
{
|
||||
spA=species.speciesName[0];
|
||||
spB=species.speciesName[0];
|
||||
}
|
||||
if(!(jastrow[iab])) {
|
||||
//create the new Jastrow function
|
||||
//FN *j2= new FN(ia==ib);
|
||||
FN *j2= new FN;
|
||||
if(targetPtcl.Lattice.BoxBConds[0])
|
||||
j2->setDensity(targetPtcl.getTotalNum()/targetPtcl.Lattice.Volume);
|
||||
if(idptr == NULL) {
|
||||
ostringstream idassigned; idassigned << "j2"<<iab;
|
||||
j2Unique[idassigned.str()] = j2;
|
||||
} else {
|
||||
j2Unique[(const char*)idptr]=j2;
|
||||
}
|
||||
//initialize
|
||||
j2->put(cur);
|
||||
j2->addOptimizables(targetPsi.VarList);
|
||||
//j2->put(cur,targetPsi.VarList);
|
||||
jastrow[iab]= j2;
|
||||
if(ia != ib) {//up-down-type pair, treat down-up the same way
|
||||
jastrow[ib*ng+ia] = j2;
|
||||
} else {
|
||||
for(int iaa=0; iaa<ng; iaa++) if(iaa != ia && jastrow[iaa*ng+iaa]==0) jastrow[iaa*ng+iaa] = j2;
|
||||
}
|
||||
XMLReport("Added Jastrow Correlation between "<<spA<<" and "<<spB)
|
||||
} else {
|
||||
ERRORMSG("Using an existing Jastrow Correlation "<<spA<<" and "<<spB)
|
||||
int ia = species.findSpecies(spA);
|
||||
int ib = species.findSpecies(spB);
|
||||
if(ia==species.size() || ia == species.size())
|
||||
{
|
||||
APP_ABORT("JAABuilder::createJAA is trying to use invalid species");
|
||||
}
|
||||
string pairID=spA+spB;
|
||||
FN *j= new FN;
|
||||
j->put(cur);
|
||||
j->addOptimizables(targetPsi.VarList);
|
||||
J2->addFunc(pairID,ia,ib,j);
|
||||
++pairs;
|
||||
}
|
||||
cur = cur->next;
|
||||
} // while cur
|
||||
|
||||
DistanceTableData* d_table = DistanceTable::add(targetPtcl);
|
||||
/*
|
||||
if(IgnoreSpin) {
|
||||
TwoBodyJastrow<FN,true>* J2 = new TwoBodyJastrow<FN,true>(targetPtcl,d_table);
|
||||
J2->F=(*jastrow[0]);
|
||||
J2->setOptimizable(true);
|
||||
targetPsi.add(J2);
|
||||
} else {
|
||||
TwoBodyJastrow<FN,false>* J2 = new TwoBodyJastrow<FN,false>(targetPtcl,d_table);
|
||||
int ij = 0;
|
||||
for(int i=0; i<ng; i++) {
|
||||
for(int j=0; j<ng; j++, ij++) {
|
||||
J2->F.push_back(jastrow[ij]);
|
||||
}
|
||||
if(pairs)
|
||||
{
|
||||
//set this jastrow function to be not optimizable
|
||||
if(targetPsi.VarList.size() == cur_var) {
|
||||
J2->setOptimizable(false);
|
||||
}
|
||||
J2->setOptimizable(true);
|
||||
targetPsi.add(J2);
|
||||
targetPsi.addOrbital(J2);
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
typedef TwoBodyJastrowOrbital<FN> JeeType;
|
||||
JeeType *J2 = new JeeType(targetPtcl,d_table);
|
||||
J2->insert(j2Unique);
|
||||
if(IgnoreSpin) {
|
||||
LOGMSG(" Spin-indepdenent two-body jastrow ")
|
||||
for(int i=0; i<ng; i++) {
|
||||
for(int j=0; j<ng; j++) {
|
||||
J2->addFunc(jastrow[0]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOGMSG(" Spin-depdenent two-body jastrow. Unique functors = "<< j2Unique.size())
|
||||
int ij = 0;
|
||||
for(int i=0; i<ng; i++) {
|
||||
for(int j=0; j<ng; j++, ij++) {
|
||||
J2->addFunc(jastrow[ij]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{//clean up and delete the twobody orbitals
|
||||
delete J2;
|
||||
return false;
|
||||
}
|
||||
|
||||
//set this jastrow function to be not optimizable
|
||||
if(targetPsi.VarList.size() == cur_var) {
|
||||
J2->setOptimizable(false);
|
||||
}
|
||||
|
||||
targetPsi.addOrbital(J2);
|
||||
XMLReport("Added a Two-Body Jastrow Function")
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JAABuilder::put(xmlNodePtr cur) {
|
||||
|
|
Loading…
Reference in New Issue