void Maximize_method::run(Program_options & options, ostream & output) { Wavefunction * wf=NULL; Sample_point * sample=NULL; sys->generateSample(sample); wfdata->generateWavefunction(wf); sample->attachObserver(wf); int nconfig=100; Array1 <Config_save_point> config_pos(nconfig); Array1 <doublevar> epos(3); Primary guidewf; generate_sample(sample,wf,wfdata,&guidewf,nconfig,config_pos); int nelectrons=sample->electronSize(); Properties_gather mygather; string tablename=options.runid+".table"; ofstream tableout(tablename.c_str()); for(int e=0; e< nelectrons; e++) { sample->getElectronPos(e,epos); for(int d=0; d< 3; d++) { tableout << "e" << e << "_"<< d << " "; } } tableout << "elocal" << endl; for(int i=0; i < nconfig; i++) { maximize(sample,wf,config_pos(i)); for(int e=0; e< nelectrons; e++) { sample->getElectronPos(e,epos); for(int d=0; d< 3; d++) { tableout << epos(d) << " "; } } Properties_point pt; mygather.gatherData(pt, pseudo, sys, wfdata, wf, sample, &guidewf); tableout << pt.energy(0) << endl; config_pos(i).write(cout); } delete wf; delete sample; }
/*! Read the "words" from the method section in the input file via doinput() parsing, and store section information in private variables isoses, resolution, and minmax. Set up MO_matrix and Sample_point objects for wavefunction from input */ void Nodes_method::read(vector <string> words, unsigned int & pos, Program_options & options) { pos=0; //always start from first word doublevar Tres; vector <string> Torbs; vector <string> Tminmax; vector <string> orbtext; vector <string> Tdxyz; allocate(options.systemtext[0], sysprop); sysprop->generateSample(mywalker); allocate(options.twftext[0], sysprop, wfdata); wfdata->generateWavefunction(wf); mywalker->attachObserver(wf); pos=0; if(readsection(words,pos=0,Torbs,"CONTOURS")){ // error("Need CONTOURS in METHOD section"); plots.Resize(Torbs.size()); for(unsigned int i=0; i<Torbs.size(); i++){ plots(i)=atoi(Torbs[i].c_str()); } } else { cout <<"WARNING: All electrons are used for scanning!"<<endl; plots.Resize(mywalker->electronSize()); for(int i=0; i<plots.GetSize(); i++){ plots(i)=i+1; } } pos=0; if(! readvalue(words,pos,Tres,"RESOLUTION")) error("Need RESOLUTION in METHOD section"); resolution=Tres; pos=0; minmax.Resize(6); if(readsection(words,pos,Tminmax,"MINMAX")) { if(Tminmax.size() != 6) error("MINMAX needs 6 values"); for(unsigned int i=0; i<Tminmax.size(); i++) { minmax(i)=atof(Tminmax[i].c_str()); } } else { minmax=0.0; int nions=sysprop->nIons(); Array1 <doublevar> ionpos(3); for(int i=0; i< nions; i++) { sysprop->getIonPos(i,ionpos); for(int d=0; d< 3; d++) { if(ionpos(d) < minmax(2*d)) minmax(2*d) = ionpos(d); if(ionpos(d) > minmax(2*d+1)) minmax(2*d+1)=ionpos(d); } } for(int d=0; d< 3; d++) { minmax(2*d)-=4.0; minmax(2*d+1)+=4.0; cout << "minmax " << minmax(2*d) << " " << minmax(2*d+1) << endl; } } // Makes the Nodes methods use the current implementation of Nodes if(readvalue(words, pos=0, readconfig, "READCONFIG")){ Array1 <Config_save_point> config_pos; config_pos.Resize(0); if(readconfig!="") { read_configurations(readconfig, config_pos); } if(config_pos.GetDim(0)<1) error("Could not read a single walker from config file"); //take a first one config_pos(0).restorePos(mywalker); } else { mywalker->randomGuess(); debug_write(cout, 0, " configs read ", 1, " configs randomly generated \n"); } pos=0; doublemove=false; if( readsection(words,pos,Tdxyz,"DOUBLEMOVES")){ doublemove=true; if(plots.GetSize()%2) error("Needs pairs of countours for doublemoves"); unsigned int dummy=3*plots.GetSize()/2; if(Tdxyz.size()!=dummy) error("DOUBLEMOVES needs 3 x # of vectors values"); dxyz.Resize(plots.GetSize()/2,3); for(int i=0; i<plots.GetSize()/2; i++){ for (int j=0; j<3;j++) dxyz(i,j)=atof(Tdxyz[i*3+j].c_str()); } } }