本文整理汇总了C++中OhmmsAttributeSet::add方法的典型用法代码示例。如果您正苦于以下问题:C++ OhmmsAttributeSet::add方法的具体用法?C++ OhmmsAttributeSet::add怎么用?C++ OhmmsAttributeSet::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OhmmsAttributeSet
的用法示例。
在下文中一共展示了OhmmsAttributeSet::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: put
bool singleRPAJastrowBuilder::put(xmlNodePtr cur, int addOrbital)
{
MyName="Jep";
string rpafunc="RPA";
OhmmsAttributeSet a;
a.add(MyName,"name");
a.add(rpafunc,"function");
a.put(cur);
ParameterSet params;
RealType Rs(-1.0);
RealType Kc(-1.0);
params.add(Rs,"rs","double");
params.add(Kc,"kc","double");
params.put(cur);
if(Rs<0) {
Rs=tlen;
}
if(Kc<0){
Kc = 1e-6 ;
};
if (rpafunc=="RPA"){
myHandler= new LRRPAHandlerTemp<EPRPABreakup<RealType>,LPQHIBasis>(targetPtcl,Kc);
app_log()<<" using e-p RPA"<<endl;
}
else if (rpafunc=="dRPA") {
myHandler= new LRRPAHandlerTemp<derivEPRPABreakup<RealType>,LPQHIBasis>(targetPtcl,Kc);
app_log()<<" using e-p derivRPA"<<endl;
}
myHandler->Breakup(targetPtcl,Rs);
// app_log() << " Maximum K shell " << myHandler->MaxKshell << endl;
// app_log() << " Number of k vectors " << myHandler->Fk.size() << endl;
//Add short range part
Rcut = myHandler->get_rc()-0.1;
GridType* myGrid = new GridType;
int npts=static_cast<int>(Rcut/0.01)+1;
myGrid->set(0,Rcut,npts);
//create the numerical functor
nfunc = new FuncType;
SRA = new ShortRangePartAdapter<RealType>(myHandler);
SRA->setRmax(Rcut);
nfunc->initialize(SRA, myGrid);
J1s = new JneType (*sourcePtcl,targetPtcl);
for(int ig=0; ig<ng; ig++) {
J1s->addFunc(ig,nfunc);
}
app_log()<<" Only Short range part of E-I RPA is implemented"<<endl;
if (addOrbital) targetPsi.addOrbital(J1s,MyName);
return true;
}
示例2: cname
WMConstraints::InFuncType*
WMConstraints::createCorrelation(xmlNodePtr cur,BasisSetType* basis) {
int nc=0;
InFuncType* acombo=new InFuncType;
cur=cur->children;
while(cur != NULL) {
string cname((const char*)(cur->name));
if(cname == "parameter") {
string id("0");
string ref("0");
RealType c=1.0;
OhmmsAttributeSet aAttrib;
aAttrib.add(id,"id");
aAttrib.add(ref,"ref");
aAttrib.put(cur);
putContent(c,cur);
if(nc <basis->size()) acombo->add((*basis)[nc++],c,id);
}
cur=cur->next;
}
if(nc)
return acombo;
else {
delete acombo;
return 0;
}
}
示例3: put
bool JastrowBuilder::put(xmlNodePtr cur) {
myNode=cur;
resetOptions();
OhmmsAttributeSet oAttrib;
oAttrib.add(typeOpt,"type");
oAttrib.add(nameOpt,"name");
oAttrib.add(funcOpt,"function");
oAttrib.add(transformOpt,"transform");
oAttrib.add(sourceOpt,"source");
oAttrib.add(spinOpt,"spin");
oAttrib.put(cur);
if(nameOpt[0] == '0')
{
app_warning() << " JastrowBuilder::put does not have name "<< endl;
return false;
}
if(typeOpt.find("One") < typeOpt.size())
return addOneBody(cur);
if(typeOpt.find("Two") < typeOpt.size())
return addTwoBody(cur);
if(typeOpt.find("Three") < typeOpt.size())
return addThreeBody(cur);
return false;
}
示例4: addBasisGroup
void WMConstraints::addBasisGroup(xmlNodePtr cur) {
string sourceOpt("e");
string elementType("e");
OhmmsAttributeSet aAttrib;
aAttrib.add(sourceOpt,"source");
aAttrib.add(elementType,"elementType");
aAttrib.put(cur);
RealType rcut(myGrid->rmax());
map<string,BasisSetType*>::iterator it(myBasisSet.find(elementType));
if(it == myBasisSet.end()) {
BasisSetType* newBasis=new BasisSetType;
cur=cur->children;
while(cur != NULL) {
string cname((const char*)(cur->name));
if(cname == "parameter") {
//BasisType* a=new BasisType(1.0,rcut);
WMFunctor<RealType>* a = new WMFunctor<RealType>(1.0,rcut);
a->put(cur);
newBasis->push_back(a);
}
cur=cur->next;
}
//add a new BasisSet
myBasisSet[elementType]=newBasis;
}
}
示例5: putDeterminant
int SlaterDetBuilder::putDeterminant(xmlNodePtr cur, int firstIndex) {
string basisName("invalid");
string detname("NONE"), refname("NONE");
OhmmsAttributeSet aAttrib;
aAttrib.add(basisName,basisset_tag);
aAttrib.add(detname,"id");
aAttrib.add(refname,"ref");
aAttrib.put(cur);
xmlNodePtr c_ptr = NULL, o_ptr=NULL;
Det_t* adet=0;
//index of the last SlaterDeterminant
int dIndex=DetSet.size();
if(refname == "NONE") { //create one and use detname
if(detname =="NONE") { //no id is given, assign one
char newname[8];
sprintf(newname,"det%d",dIndex);
detname=newname;
}
}
map<string,SPOSetBasePtr>::iterator lit(SPOSet.find(detname));
SPOSetBasePtr psi;
if(lit == SPOSet.end()) {
#if defined(ENABLE_SMARTPOINTER)
psi.reset(myBasisSetFactory->createSPOSet(cur));
#else
psi = myBasisSetFactory->createSPOSet(cur);
#endif
psi->put(cur);
psi->checkObject();
SPOSet[detname]=psi;
} else {
psi = (*lit).second;
}
if(psi->getOrbitalSetSize()) {
map<string,Det_t*>::iterator dit(DetSet.find(detname));
if(dit == DetSet.end()) {
adet = new Det_t(psi,firstIndex);
adet->set(firstIndex,psi->getOrbitalSetSize());
DetSet[detname]=adet;
} else {
adet = (*dit).second;
}
firstIndex += psi->getOrbitalSetSize();
}
//only if a determinant is not 0
if(adet) SlaterDetSet.back()->add(adet);
return firstIndex;
}
示例6: useXmlFormat
void ECPotentialBuilder::useXmlFormat(xmlNodePtr cur) {
cur=cur->children;
while(cur != NULL) {
string cname((const char*)cur->name);
if(cname == "pseudo") {
string href("none");
string ionName("none");
string format("xml");
//RealType rc(2.0);//use 2 Bohr
OhmmsAttributeSet hAttrib;
hAttrib.add(href,"href");
hAttrib.add(ionName,"elementType"); hAttrib.add(ionName,"symbol");
hAttrib.add(format,"format");
//hAttrib.add(rc,"cutoff");
hAttrib.put(cur);
int speciesIndex=IonConfig.getSpeciesSet().findSpecies(ionName);
if(speciesIndex < IonConfig.getSpeciesSet().getTotalNum()) {
app_log() << endl << " Adding pseudopotential for " << ionName << endl;
ECPComponentBuilder ecp(ionName);
bool success=false;
if(format == "xml") {
if(href == "none") {
success=ecp.put(cur);
} else {
success=ecp.parse(href,cur);
}
}
else if(format == "casino")
{
//success=ecp.parseCasino(href,rc);
success=ecp.parseCasino(href,cur);
}
if(success) {
#if !defined(HAVE_MPI)
ecp.printECPTable();
#endif
if(ecp.pp_loc) {
localPot[speciesIndex]=ecp.pp_loc;
localZeff[speciesIndex]=ecp.Zeff;
hasLocalPot=true;
}
if(ecp.pp_nonloc) {
nonLocalPot[speciesIndex]=ecp.pp_nonloc;
hasNonLocalPot=true;
}
}
} else {
app_error() << " Ion species " << ionName << " is not found." << endl;
}
}
cur=cur->next;
}
}
示例7: put
bool HDFWalkerInputManager::put(xmlNodePtr cur)
{
//reference revision number
HDFVersion start_version(0,4);
//current node
int pid=myComm->rank();
string froot("0"), cfile("0");
//string target("e"), collect("no");
int anode=-1, nblocks=1, nprocs=1;
HDFVersion in_version(0,1); //set to be old version
OhmmsAttributeSet pAttrib;
pAttrib.add(cfile,"href");
pAttrib.add(cfile,"file");
pAttrib.add(froot,"fileroot");
pAttrib.add(anode,"node");
pAttrib.add(nprocs,"nprocs");
//pAttrib.add(collect,"collected");
pAttrib.add(in_version,"version");
pAttrib.put(cur);
bool success=false;
if(in_version>=start_version)
{
HDFWalkerInput_0_4 win(targetW,myComm,in_version);
success= win.put(cur);
cfile=win.FileName;
}
else
{
//missing version or old file
if(froot[0] != '0')//use nprocs
{
anode=pid;
if(nprocs==1)
cfile=froot;
else
{
char *h5name=new char[froot.size()+10];
sprintf(h5name,"%s.p%03d",froot.c_str(),pid);
cfile=h5name;
delete [] h5name;
}
}
int pid_target= (anode<0)? pid:anode;
if(pid_target == pid && cfile[0] != '0')
{
HDFWalkerInput_0_0 win(targetW,cfile);
success= win.put(cur);
}
}
if(success)
CurrentFileRoot = cfile;
return success;
}
示例8: put
bool JAABuilder::put(xmlNodePtr cur) {
string spinOpt("no");
string typeOpt("Two-Body");
string jastfunction("pade");
OhmmsAttributeSet aAttrib;
aAttrib.add(spinOpt,"spin");
aAttrib.add(typeOpt,"type");
aAttrib.add(jastfunction,"function");
aAttrib.put(cur);
IgnoreSpin=(spinOpt=="no");
bool success=false;
//if(jastfunction == "pade") {
// app_log() << " Two-Body Jastrow Function = " << jastfunction << endl;
// PadeJastrow<RealType> *dummy = 0;
// success = createJAA(cur,dummy);
//} else
if(jastfunction == "short") {
app_log() << " Modified Jastrow function Two-Body Jastrow Function = " << jastfunction << endl;
IgnoreSpin=true;
//ModPadeFunctor<RealType> *dummy = 0;
success = createJAA<ModPadeFunctor<RealType> >(cur,jastfunction);
}else if(jastfunction == "modMcMillan")
{
app_log() << " Modified McMillan Jastrow function Two-Body Jastrow Function = " << jastfunction << endl;
IgnoreSpin=true;
success = createJAA<ModMcMillanJ2Functor<RealType> >(cur,jastfunction);
}else if(jastfunction == "McMillan")
{
app_log() << " McMillan Jastrow (LONG RANGE!) function Two-Body Jastrow Function = " << jastfunction << endl;
IgnoreSpin=true;
success = createJAA<McMillanJ2Functor<RealType> >(cur,jastfunction);
}else if(jastfunction == "Gaussian")
{
app_log() << " Gaussian function Two-Body Jastrow Function = " << jastfunction << endl;
IgnoreSpin=true;
success = createJAA<GaussianFunctor<RealType> >(cur,jastfunction);
} else if(jastfunction == "shiftedGaussian")
{
app_log() << " Gaussian function Two-Body Jastrow Function = " << jastfunction << endl;
IgnoreSpin=true;
success = createJAA<TruncatedShiftedGaussianFunctor<RealType> >(cur,jastfunction);
}
//} else if(jastfunction == "rpa") {
// app_log() << " Two-Body Jastrow Function = " << jastfunction << endl;
// RPAJastrow<RealType> *dummy = 0;
// success = createJAA(cur,dummy);
//}
return success;
}
示例9: putkids
bool eeI_JastrowBuilder::putkids (xmlNodePtr kids, J3type &J3)
{
SpeciesSet &iSet = sourcePtcl->getSpeciesSet();
SpeciesSet &eSet = targetPtcl.getSpeciesSet();
int numiSpecies = iSet.getTotalNum();
bool success=false;
while (kids != NULL) {
std::string kidsname = (char*)kids->name;
if (kidsname == "correlation") {
RealType ee_cusp=0.0;
RealType eI_cusp=0.0;
string iSpecies, eSpecies1("u"), eSpecies2("u");
OhmmsAttributeSet rAttrib;
rAttrib.add(iSpecies,"ispecies");
rAttrib.add(eSpecies1,"especies1");
rAttrib.add(eSpecies2,"especies2");
rAttrib.add(ee_cusp,"ecusp");
rAttrib.add(eI_cusp,"icusp");
rAttrib.put(kids);
typedef typename J3type::FuncType FT;
FT *functor = new FT(ee_cusp, eI_cusp);
functor->iSpecies = iSpecies;
functor->eSpecies1 = eSpecies1;
functor->eSpecies2 = eSpecies2;
int iNum = iSet.findSpecies (iSpecies);
int eNum1 = eSet.findSpecies (eSpecies1);
int eNum2 = eSet.findSpecies (eSpecies2);
functor->put (kids);
if (functor->cutoff_radius < 1.0e-6) {
app_log() << " eeI functor rcut is currently zero.\n"
<< " Setting to Wigner-Seitz radius = "
<< sourcePtcl->Lattice.WignerSeitzRadius << endl;
functor->cutoff_radius = sourcePtcl->Lattice.WignerSeitzRadius;
functor->reset();
}
strstream aname;
aname << iSpecies << "_" << eSpecies1 << "_" << eSpecies2;
J3.addFunc(aname.str(), iNum, eNum1, eNum2, functor);
}
kids = kids->next;
}
targetPsi.addOrbital(&J3,"eeI");
J3.setOptimizable(true);
return true;
}
示例10:
/** process xml node for each element
* @param cur xmlnode <element name="string" alpha="double" rb="double"/>
*/
bool LocalCorePolPotential::CPP_Param::put(xmlNodePtr cur)
{
OhmmsAttributeSet att;
att.add(alpha,"alpha");
att.add(r_b,"rb");
att.put(cur);
//const xmlChar* a_ptr = xmlGetProp(cur,(const xmlChar *)"alpha");
//const xmlChar* b_ptr = xmlGetProp(cur,(const xmlChar *)"rb");
//if(a_ptr) alpha = atof((const char*)a_ptr);
//if(b_ptr) r_b = atof((const char*)b_ptr);
C = -0.5*alpha;
one_over_rr = 1.0/r_b/r_b;
app_log() << "\talpha = " << alpha << " rb = " << r_b <<endl;
return true;
}
示例11: addSingleBasisPerSpecies
void PolyConstraints::addSingleBasisPerSpecies(xmlNodePtr cur)
{
RealType rcut=10.0;
int npts=101;
RealType step=-1.0;
if(myGrid) {
rcut=myGrid->rmax();
npts = myGrid->size();
}
OhmmsAttributeSet gAttrib;
gAttrib.add(rcut,"rf");
BasisGroupType* curBG=0;
cur=cur->children;
while(cur != NULL)
{
string cname((const char*)(cur->name));
string elementType("e");
OhmmsAttributeSet aAttrib;
aAttrib.add(elementType,"elementType");
aAttrib.put(cur);
if(cname == "atomicBasisSet")
{
xmlNodePtr cur1=cur->children;
while(cur1 != NULL)
{
string cname1((const char*)(cur1->name));
if(cname1 == "basisGroup")
{
createBasisGroup(cur1,elementType,rcut);
}
else if(cname1 == "grid")
{
gAttrib.put(cur1);
}
cur1=cur1->next;
}
}
else if(cname == "basisGroup")
{
createBasisGroup(cur,elementType,rcut);
}
else if(cname == "grid")
gAttrib.put(cur);
cur=cur->next;
}
}
示例12: put
/** process xml node for CPP
* @param cur xmlnode containing element+
*
* element/@name is used to find the index of the element of the
* IonConfig::SpeciesSet. The size of InpCPP is the number of species.
* The size of Centers is the number of ions.
*/
bool LocalCorePolPotential::put(xmlNodePtr cur)
{
bool success(true);
if(cur!= NULL)//input is provided
{
string ename;
cur= cur->children;
while(cur != NULL){
string cname((const char*)cur->name);
if(cname == "element")
{
string species_name;
OhmmsAttributeSet att;
att.add(species_name,"name");
att.put(cur);
if(species_name.size())
{
int itype = IonConfig.getSpeciesSet().addSpecies(species_name); //(const char*)e_ptr);
if(InpCPP[itype]==0) InpCPP[itype] = new CPP_Param;
app_log() << "CPP parameters for " << IonConfig.getSpeciesSet().speciesName[itype] << endl;
success = InpCPP[itype]->put(cur);
}
}
cur=cur->next;
}
}
for(int iat=0; iat<nCenters; iat++)
Centers[iat]=InpCPP[IonConfig.GroupID[iat]];
return success;
}
示例13: put
/** process an xml element
* @param cur current xmlNodePtr
* @return true, if successful.
*
* Creating MCWalkerConfiguration for all the ParticleSet
* objects.
*/
bool ParticleSetPool::put(xmlNodePtr cur)
{
ReportEngine PRE("ParticleSetPool","put");
//const ParticleSet::ParticleLayout_t* sc=DistanceTable::getSimulationCell();
//ParticleSet::ParticleLayout_t* sc=0;
string id("e"), role("none");
OhmmsAttributeSet pAttrib;
pAttrib.add(id,"id"); pAttrib.add(id,"name");
pAttrib.add(role,"role");
pAttrib.put(cur);
//backward compatibility
if(id == "e" && role=="none") role="MC";
ParticleSet* pTemp = getParticleSet(id);
if(pTemp == 0)
{
app_log() << " Creating " << id << " particleset" << endl;
pTemp = new MCWalkerConfiguration;
//if(role == "MC")
// pTemp = new MCWalkerConfiguration;
//else
// pTemp = new ParticleSet;
if(SimulationCell)
{
app_log() << " Initializing the lattice of " << id << " by the global supercell" << endl;
pTemp->Lattice.copy(*SimulationCell);
}
myPool[id] = pTemp;
XMLParticleParser pread(*pTemp,TileMatrix);
bool success = pread.put(cur);
pTemp->setName(id);
app_log() << pTemp->getName() <<endl;
return success;
} else {
app_warning() << "particleset " << id << " is already created. Ignore this" << endl;
}
return true;
}
示例14: gridType
/** main functio to optimize multiple contracted S orbitals
*/
void GTO2Slater::optimize() {
//construct one-dim grid
double ri = 1e-5;
double rf = 10.0;
int npts = 101;
string gridType("log");
if(gridPtr) {
OhmmsAttributeSet radAttrib;
radAttrib.add(gridType,"type");
radAttrib.add(npts,"npts");
radAttrib.add(ri,"ri"); radAttrib.add(rf,"rf");
radAttrib.put(gridPtr);
}
myGrid.set(ri,rf,npts);
//create a numerical grid funtor
typedef OneDimCubicSpline<double> RadialOrbitalType;
RadialOrbitalType radorb(&myGrid);
int L= 0;
//Loop over all the constracted S orbitals
map<string,xmlNodePtr>::iterator it(sPtr.begin()),it_end(sPtr.end());
while(it != it_end) {
//create contracted gaussian
GTOType gset(L,Normalized);
//read the radfunc's of basisGroup
gset.putBasisGroup((*it).second);
//convert to a radial functor
Transform2GridFunctor<GTOType,RadialOrbitalType> transform(gset, radorb);
transform.generate(myGrid.rmin(),myGrid.rmax(),myGrid.size());
//optimize it with the radial functor
Any2Slater gto2slater(radorb);
gto2slater.optimize();
++it;
}
sPtr.clear();
}
示例15: put
bool HamiltonianPool::put(xmlNodePtr cur)
{
ReportEngine PRE("HamiltonianPool","put");
string id("h0"), target("e"),role("extra");
OhmmsAttributeSet hAttrib;
hAttrib.add(id,"id"); hAttrib.add(id,"name");
hAttrib.add(role,"role");
hAttrib.add(target,"target");
hAttrib.put(cur);
ParticleSet* qp=ptclPool->getParticleSet(target);
if(qp == 0)
{//never a good thing
PRE.error("No target particle "+ target+ " exists.");
return false;
}
bool set2Primary=false;
//first Hamiltonian is set to the primary Hamiltonian
if(myPool.empty() || role == "primary" ) set2Primary=true;
HamiltonianFactory *curH=0;
PoolType::iterator hit(myPool.find(id));
if(hit == myPool.end())
{
curH= new HamiltonianFactory(qp, ptclPool->getPool(), psiPool->getPool(),myComm);
curH->setName(id);
myPool[id]=curH;
}
else
curH=(*hit).second;
bool success= curH->put(cur);
if(set2Primary) primaryH=curH->targetH;
return success;
}