void Md_method::read(vector <string> words, unsigned int & pos, Program_options & options) { pos=0; vector <string> vmcsec; if(!readsection(words, pos=0, vmcsec, "EMBED")) { error("Need EMBED section"); } allocate(vmcsec,options, qmc_avg); if(!readvalue(words, pos=0, nstep, "NSTEP")) { error("Need NSTEP"); } if(!readvalue(words, pos=0, tstep, "TIMESTEP")) { error("Need TIMESTEP in MD method"); } readvalue(words, pos=0, readcheckfile, "READCHECK"); readvalue(words, pos=0, writecheckfile, "STORECHECK"); if(!readvalue(words, pos=0, log_label, "LABEL")) log_label="md"; if(readvalue(words, pos=0, damp, "DAMP")) { if(damp > 1 || damp < 0) error("DAMP must be in [0,1]"); } else damp=0.0; string resdim; pos=0; restrict_dimension.Resize(3); restrict_dimension=0; if(readvalue(words, pos, resdim, "RESTRICT")) { if(caseless_eq(resdim, "X")) restrict_dimension(0)=1; else if(caseless_eq(resdim, "Y")) restrict_dimension(1)=1; else if(caseless_eq(resdim, "Z")) restrict_dimension(2)=1; else error("Unknown argument to RESTRICT:", resdim); } vector <string> weighttxt; if(!readsection(words, pos=0, weighttxt, "ATOMIC_WEIGHTS") ) { error("Need ATOMIC_WEIGHTS in MD method"); } atomic_weights.Resize(weighttxt.size()); for(int i=0; i< atomic_weights.GetDim(0); i++) { atomic_weights(i)=atof(weighttxt[i].c_str()); } }
int allocate(vector <string> & wftext, System * sys, Wavefunction_data * & wfptr) { assert(wfptr == NULL); if(wftext.size() < 1) error("Empty wavefunction section"); if(caseless_eq(wftext[0],"SLATER")) wfptr=new Slat_wf_data; else if(caseless_eq(wftext[0],"JASTROW2") || caseless_eq(wftext[0], "JASTROW")) wfptr=new Jastrow2_wf_data; else if(caseless_eq(wftext[0],"SLATER-JASTROW")) wfptr=new Slat_Jastrow_data; else if(caseless_eq(wftext[0],"BACKFLOW")) wfptr=new Backflow_wf_data; else if(caseless_eq(wftext[0],"BACKFLOW-PFAFFIAN")) wfptr=new Backflow_pf_wf_data; else if(caseless_eq(wftext[0],"PFAFFIAN")) wfptr=new Pfaff_wf_data; else if(caseless_eq(wftext[0],"BCS")) wfptr=new BCS_wf_data; else error("Error parsing the trial wavefunction section; unknown keyword ", wftext[0]); unsigned int pos=1; wfptr->read(wftext,pos,sys); return 1; }
int haskeyword(vector <string> & input, unsigned int & pos, const char * valuename) { int level=0; //how many brackets we've descended into. for(; pos< input.size(); pos++) { if(input[pos]==startsec) { level++; } else if(input[pos]==endsec) { level--; } if(level < 0) { pos++; return 0; } if(level==0 && caseless_eq(input[pos], valuename))//input[pos]==valuename) { return 1; } } //if we get here, we didn't find a value return 0; }
void Dmc_point::read(istream & is) { config_pos.read(is); int filepos=is.tellg(); string dum; is >> dum; if(!caseless_eq(dum, "DMC")) { is.seekg(filepos); return; } is >> dum; //the { //prop.read(is); is >> dum >> weight; is >> dum >> sign; //ignoring the past stuff for the moment.. }
void Average_ekt::read(System * sys, Wavefunction_data * wfdata, vector <string> & words) { unsigned int pos=0; vector <string> orbs; vector <string> mosec; if(readsection(words,pos=0, mosec,"ORBITALS")) { //error("Need ORBITALS section in ekt"); complex_orbitals=false; allocate(mosec,sys,momat); nmo=momat->getNmo(); } else if(readsection(words,pos=0,mosec,"CORBITALS")) { complex_orbitals=true; allocate(mosec,sys,cmomat); nmo=cmomat->getNmo(); } else { error("Need ORBITALS or CORBITALS in EKT"); } occupations.Resize(1); if(readsection(words,pos=0,orbs,"STATES")) { nmo=orbs.size(); occupations[0].Resize(nmo); for(int i=0; i< nmo; i++) occupations[0][i]=atoi(orbs[i].c_str())-1; } else if(readsection(words,pos=0,orbs,"EVAL_ORBS")) { nmo=orbs.size(); occupations[0].Resize(nmo); for(int i=0; i< nmo; i++) occupations[0][i]=atoi(orbs[i].c_str()); } else { occupations[0].Resize(nmo); for(int i=0; i< nmo; i++) { occupations[0][i]=i; } } deterministic_psp=0; if(haskeyword(words,pos=0,"DETERMINISTIC_PSP")) deterministic_psp=1; dump_data=false; if(haskeyword(words,pos=0,"DUMP_DATA")) dump_data=true; if(!readvalue(words, pos=0,ekt_cutoff,"EKT_CUTOFF")) ekt_cutoff=1e3; if(complex_orbitals) cmomat->buildLists(occupations); else momat->buildLists(occupations); if(!readvalue(words, pos=0,nstep_sample,"NSTEP_SAMPLE")) nstep_sample=10; if(!readvalue(words,pos=0,npoints_eval,"NPOINTS")) npoints_eval=4; string mode; eval_obdm=false; eval_conduction=false; eval_valence=false; if(readvalue(words,pos=0,mode,"MODE")) { if(caseless_eq(mode,"ALL") or caseless_eq(mode, "CONDUCTION")) { eval_obdm=true; eval_conduction=true; eval_valence=true; } else if (caseless_eq(mode, "VALENCE")) { eval_obdm=true; eval_conduction=true; } else if (caseless_eq(mode, "OBDM")) { eval_obdm=true; } } eval_obdm=true; eval_conduction=true; eval_valence=true; int ndim=3; saved_r.Resize(npoints_eval*2); //r1 and r2; for(int i=0; i< npoints_eval*2; i++) saved_r(i).Resize(ndim); rk.Resize(npoints_eval*2); int warmup_steps=1000; Sample_point * sample=NULL; sys->generateSample(sample); sample->randomGuess(); Array2 <dcomplex> movals(nmo,1); for(int i=0; i< npoints_eval*2; i++) { gen_sample(warmup_steps,1.0,0,movals,sample); sample->getElectronPos(0,saved_r(i)); } delete sample; }
Cubic_spline::symmetry_type Cubic_spline::symmetry_lookup(string & s) { if(caseless_eq(s, "S")) return sym_S; if(caseless_eq(s, "P")) return sym_P; if(caseless_eq(s, "D")|| caseless_eq(s,"6D")) return sym_6D; if(caseless_eq(s,"F") || caseless_eq(s,"10F")) return sym_10F; if(caseless_eq(s, "G")|| caseless_eq(s,"15G")) return sym_15G; if(caseless_eq(s,"5D")) return sym_5D; if(caseless_eq(s,"7F")) return sym_7F; if(caseless_eq(s,"9G")) return sym_9G; if (caseless_eq(s, "7F_crystal"))//CRYSTAL F orbital return sym_7F_crystal; //CRYSTAL F orbital if(caseless_eq(s,"P_siesta")) return sym_P_siesta; if(caseless_eq(s,"5D_siesta")) return sym_D_siesta; if(caseless_eq(s,"7F_siesta")) return sym_F_siesta; error("I don't understand symmetry type ", s, "\nShould be S,P,D,etc."); return sym_S; }
/*! \bug When you have a section completely in one block in characters (ie {1}), it does not realize that the start and end are there, and chaos ensues. */ void parsefile(ifstream & inputfile, vector <string> & words) { string temp; vector <string> tempwords; while(inputfile >> temp) { string temp2, temp3; unsigned int pos; //Ignore comments pos=temp.find(comment); if( pos < temp.size() ) { temp.erase(pos,temp.size()-pos); inputfile.ignore(800, '\n'); } //Put start section markers in their own word pos = temp.find(startsec); if( pos < temp.size() ) { temp.erase(pos,startsec.size()); temp2=startsec; temp3.append(temp, pos, temp.size()); temp.erase(pos, temp.size()-pos); } //Put any end section markers in their //own word pos = temp.find(endsec); if( pos < temp.size() ) { temp.erase(pos,endsec.size()); temp2=endsec; temp3.append(temp, pos, temp.size()); temp.erase(pos, temp.size()-pos); } if( ! temp.empty() ) tempwords.push_back(temp); if( ! temp2.empty() ) tempwords.push_back(temp2); if( ! temp3.empty() ) tempwords.push_back(temp3); } // Include any include files(It's recursive here..) for(unsigned int i=0; i < tempwords.size(); i++) { if(caseless_eq(tempwords[i],"INCLUDE")) { ifstream includefile(tempwords[i+1].c_str()); vector <string> includewords; if(!includefile) { error("couldn't open ", tempwords[i+1]); } parsefile(includefile, includewords); for(unsigned int j=0; j< includewords.size(); j++) { words.push_back(includewords[j]); } includefile.close(); i++; } else { words.push_back(tempwords[i]); } } }
/*! Puts the next section after pos with name sectionname into section. Stays within the same level that we started; if the section is ended before finding anything, we return 0. */ int readsection(vector <string> & input, unsigned int & pos, vector <string> & section, const char * sectionname) { string temp; section.erase(section.begin(), section.end()); int level=0; string name(sectionname); //cout << "searching for " << name << endl; //for(int i=0; i< input.size(); i++) // cout << input[i] << endl; //cout << "____________________________________" << endl; for(; pos< input.size(); pos++) { if(input[pos]==startsec) { level++; } else if(input[pos]==endsec) { level--; } if(level < 0) { pos++; return 0; } //if(input[pos]==sectionname && level == 0) //if(level==0) cout << "looking at " << input[pos] // << " : " << caseless_eq(input[pos], name) // << endl; if(level==0 && caseless_eq(input[pos], name)) { int nsec=0; pos++; //check for a section start if(pos >= input.size()) error("Section starter ", sectionname, " but nothing following it."); if(input[pos] != startsec) error("You must follow ", sectionname, "with a ", startsec); pos++; int begin=pos; for(; pos < input.size(); pos++) { if(input[pos]==startsec) nsec++; if(input[pos]==endsec) nsec--; if(nsec < 0) { break;} //section.push_back(input[pos]); } pos++; //step past the end int end=pos; section.insert(section.end(), input.begin()+begin, input.begin()+end-1); //input.erase(input.begin()+begin-2, input.begin()+end); //for(int i=0; i< section.size(); i++) // cout << section[i] << " "; //cout << endl; //cout << "---------------input left " << endl; //for(int i=0; i< input.size(); i++) // cout << input[i] << " "; //cout << endl; /* readnext(input, pos, temp); if(temp != startsec) { error("You must follow ", sectionname, "with a ", startsec); } while(pos < input.size() ) { readnext(input, pos, temp); if(temp == startsec) { nsec++; } if(temp == endsec) { nsec--; } if(nsec<0) { pos++; break; } section.insert(section.end(), temp); } */ return 1; } } //if we get here, we didn't find a section. return 0; }