int Cutoff_cusp::read( vector <string> & words, unsigned int & pos) { //cout << "gauss read " << endl; unsigned int startpos=pos; centername=words[0]; vector <string> alphatxt; if(!readvalue(words, pos, cusp, "CUSP")) { error("Need CUSP section in Cutoff_cusp"); } pos=startpos; if(!readvalue(words, pos, gamma, "GAMMA") ) { error("Need GAMMA in Cutoff_cusp"); } pos=startpos; if(!readvalue(words, pos, rcut, "CUTOFF") ) { error("Need CUTOFF in Cutoff_cusp"); } rcutinv=1.0/rcut; if(rcut < 0) { error("Cutoff must be greater than zero in Cutoff_cusp. I read ", rcut); } pade0=1./(3.+gamma); return 0; }
/*! */ void Postprocess_method::read(vector <string> words, unsigned int & pos, Program_options & options) { if(!readvalue(words, pos=0, configfile, "READCONFIG")) error("Need READCONFIG in Postprocess"); if(!readvalue(words, pos=0, nskip, "NSKIP")) nskip=0; evaluate_energy=true; if(haskeyword(words,pos=0,"NOENERGY")) evaluate_energy=false; vector <vector < string> > dens_words; vector<string> tmp_dens; pos=0; while(readsection(words, pos, tmp_dens, "DENSITY")) { dens_words.push_back(tmp_dens); } vector <vector < string> > avg_words; pos=0; while(readsection(words, pos, tmp_dens, "AVERAGE")) { avg_words.push_back(tmp_dens); } sys=NULL; allocate(options.systemtext[0], sys); sys->generatePseudo(options.pseudotext, pseudo); debug_write(cout, "wfdata allocate\n"); wfdata=NULL; if(options.twftext.size() < 1) error("Need TRIALFUNC section for POSTPROCESS"); allocate(options.twftext[0], sys, wfdata); average_var.Resize(avg_words.size()); average_var=NULL; for(int i=0; i< average_var.GetDim(0); i++) { allocate(avg_words[i], sys, wfdata, average_var(i)); } densplt.Resize(dens_words.size()); for(int i=0; i< densplt.GetDim(0); i++) { allocate(dens_words[i], sys, options.runid,densplt(i)); } }
/*! Read the "words" from the method section in the input file via doinput() parsing, and store section information in private variables orbs, resolution, and minmax. Set up MO_matrix and Sample_point objects for wavefunction from input */ void Wannier_method::read(vector <string> words, unsigned int & pos, Program_options & options) { sys=NULL; allocate(options.systemtext[0], sys); if(! readvalue(words,pos=0,resolution,"RESOLUTION")) resolution=.1; if(! readvalue(words,pos=0,max_opt_steps,"MAX_OPT_STEPS")) max_opt_steps=80000; if(!readvalue(words,pos=0, out_orbs, "OUT_ORB")) out_orbs=options.runid+".orb"; if(!readvalue(words,pos=0, shake,"SHAKE")) shake=1./10.; vector <vector < string> > orbgroup_txt; pos=0; vector < string> dummy; while( readsection(words,pos,dummy,"ORB_GROUP")) { orbgroup_txt.push_back(dummy); } orbital_groups.Resize(orbgroup_txt.size()); for(int i=0; i< orbital_groups.GetDim(0); i++) { int norb_this=orbgroup_txt[i].size(); orbital_groups[i].Resize(norb_this); for(int j=0; j< norb_this; j++) { orbital_groups[i][j]=atoi(orbgroup_txt[i][j].c_str())-1; } } vector <string> orbtext; if(!readsection(words, pos=0, orbtext, "ORBITALS")) { error("Need ORBITALS"); } allocate(orbtext, sys, mymomat); mywalker=NULL; sys->generateSample(mywalker); origin.Resize(3); origin=0; LatticeVec.Resize(3,3); if(!sys->getBounds(LatticeVec,origin)) error("need getBounds"); }
void xml::readattr() { int otherchars = 0; char *begin = NULL; readspace(); begin = m_current; while(m_current != NULL) { switch(m_current[0]) { case '>': return; break; case '/': m_slash = m_current; m_current++; break; case '=': case ' ': if(begin) m_attr = strndup(begin, m_current-begin); m_current++; readvalue(); readspace(); begin = m_current; break; default: otherchars++; m_current++; break; } } }
bool readrecord() { if(!skip('#')) return false; // Read data base name if(!readidentifier()) { error(ErrorExpectedIdentifier); return true; } skipws(); const bsreq* fields = 0; auto pd = bsdata::find(buffer); if(pd) fields = pd->fields; else warning(ErrorNotFoundBase1p, buffer); // Read key value parent_object = value_object; if(iskey(p)) readvalue(fields, true); else if(pd) value_object = pd->add(); else value_object = 0; readfields(value_object, fields); parent_type = fields; return true; }
/*! \todo Allow center specification inline in the input file, rather than having to read an external file. */ void Center_set::read(vector <string> & words, unsigned int pos, System * sys) { usingsampcenters=usingatoms=0; int nelectrons=sys->nelectrons(0)+sys->nelectrons(1); unsigned int startpos=pos; if(readvalue(words,pos, centerfile, "READ")) { readcenterfile(centerfile); } else { pos=startpos; if(haskeyword(words, pos,"USEATOMS")) { //cout << "using atoms " << endl; usingatoms=1; sys->getAtomicLabels(labels); ncenters=labels.size(); //cout << "ncenters " << ncenters << endl; } else if(haskeyword(words, pos=0, "USEGLOBAL")) { usingsampcenters=1; sys->getCenterLabels(labels); ncenters=labels.size(); //cout << ncenters << " centers from system " << endl; } else { error("Couldn't find anything in center section"); } } if(usingsampcenters) { sys->getEquivalentCenters(equiv_centers, ncenters_atom, centers_displacement); } else { equiv_centers.Resize(ncenters,1); ncenters_atom.Resize(ncenters); centers_displacement.Resize(ncenters,3); centers_displacement=0; for(int cen=0; cen< ncenters; cen++) { equiv_centers(cen,0)=cen; ncenters_atom(cen)=1; } } edist.Resize(nelectrons,ncenters, 5); nbasis.Resize(ncenters); nbasis=0; }
//---------------------------------------------------------------------- void Average_ekt::read(vector <string> & words) { unsigned int pos=0; readvalue(words, pos=0,nmo,"NMO"); readvalue(words,pos=0,npoints_eval,"NPOINTS"); if(haskeyword(words, pos=0,"OBDM")) eval_obdm=true; else eval_obdm=false; if(haskeyword(words, pos=0,"CONDUCTION")) eval_conduction=true; else eval_conduction=false; if(haskeyword(words,pos=0,"VALENCE")) eval_valence=true; else eval_valence=false; if(haskeyword(words,pos=0,"CORBITALS")) complex_orbitals=true; else complex_orbitals=false; eval_obdm=true; eval_valence=true; eval_conduction=true; occupations.Resize(1); occupations(0).Resize(nmo); vector <string> orbs; if(!readsection(words,pos=0,orbs,"STATES")) { cout << "WARNING: init section does not contain states. Numbering of the density matrix may be incorrect." << endl; for(int i=0; i < nmo; i++) occupations[0][i]=i; } else { nmo=orbs.size(); occupations[0].Resize(nmo); for(int i=0; i< nmo; i++) occupations[0][i]=atoi(orbs[i].c_str())-1; } }
/*! Read the "words" from the method section in the input file via doinput() parsing, and store section information in private variables orbs, resolution, and minmax. Set up MO_matrix and Sample_point objects for wavefunction from input */ void Rotate_orbs_method::read(vector <string> words, unsigned int & pos, Program_options & options) { sys=NULL; allocate(options.systemtext[0], sys); vector <vector < string> > orbgroup_txt; pos=0; vector < string> dummy; while( readsection(words,pos,dummy,"ORB_GROUP")) { orbgroup_txt.push_back(dummy); } if(orbgroup_txt.size() != 1) { error("Need one ORB_GROUP in rotate"); } orbital_groups.Resize(orbgroup_txt.size()); for(int i=0; i< orbital_groups.GetDim(0); i++) { int norb_this=orbgroup_txt[i].size(); orbital_groups[i].Resize(norb_this); for(int j=0; j< norb_this; j++) { orbital_groups[i][j]=atoi(orbgroup_txt[i][j].c_str())-1; } } vector <string> orbtext; if(!readsection(words, pos=0, orbtext, "ORBITALS")){ error("Need ORBITALS"); } allocate(orbtext, sys, mymomat); rotation_file="rotation"; output_orb=options.runid+".orb"; readvalue(words, pos=0, rotation_file,"ROTATION"); readvalue(words, pos=0, output_orb,"OUTPUT"); mywalker=NULL; sys->generateSample(mywalker); }
bool readreq(void* object, const bsreq* req, unsigned index) { if(!skip('(')) return false; while(*p) { if(skip(')')) break; readvalue(req ? req->type : 0, false); storevalue(object, req, index); if(skip(',')) index++; } skipws(); return true; }
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 Step_function::read( vector <string> & words, unsigned int & pos) { centername=words[0]; if(!readvalue(words, pos=0, rcut, "CUTOFF") ) { error("Need CUTOFF in step_function"); } return 1; }
afs_int32 ReadDumpHeader(struct DumpHeader *dh) { int i, done; char tag, c; afs_int32 magic AFS_UNUSED; /* memset(&dh, 0, sizeof(dh)); */ magic = ntohl(readvalue(4)); dh->version = ntohl(readvalue(4)); done = 0; while (!done) { tag = readchar(); switch (tag) { case 'v': dh->volumeId = ntohl(readvalue(4)); break; case 'n': for (i = 0, c = 'a'; c != '\0'; i++) { dh->volumeName[i] = c = readchar(); } dh->volumeName[i] = c; break; case 't': dh->nDumpTimes = ntohl(readvalue(2)) >> 1; if (dh->nDumpTimes > MAXDUMPTIMES) { fprintf(stderr, "Too many dump times in header (%d > %d)\n", dh->nDumpTimes, MAXDUMPTIMES); dh->nDumpTimes = MAXDUMPTIMES; } for (i = 0; i < dh->nDumpTimes; i++) { dh->dumpTimes[i].from = ntohl(readvalue(4)); dh->dumpTimes[i].to = ntohl(readvalue(4)); } break; default: done = 1; break; } } return ((afs_int32) tag); }
afs_int32 ReadDumpHeader(struct DumpHeader *dh) { int i, done; char tag, c; afs_int32 magic; /* memset(&dh, 0, sizeof(dh)); */ magic = ntohl(readvalue(4)); dh->version = ntohl(readvalue(4)); done = 0; while (!done) { tag = readchar(); switch (tag) { case 'v': dh->volumeId = ntohl(readvalue(4)); break; case 'n': for (i = 0, c = 'a'; c != '\0'; i++) { dh->volumeName[i] = c = readchar(); } dh->volumeName[i] = c; break; case 't': dh->nDumpTimes = ntohl(readvalue(2)) >> 1; for (i = 0; i < dh->nDumpTimes; i++) { dh->dumpTimes[i].from = ntohl(readvalue(4)); dh->dumpTimes[i].to = ntohl(readvalue(4)); } break; default: done = 1; break; } } return ((afs_int32) tag); }
afs_int32 ReadVolumeHeader(afs_int32 count) { struct volumeHeader vh; int i, done; char tag, c; /* memset(&vh, 0, sizeof(vh)); */ done = 0; while (!done) { tag = readchar(); switch (tag) { case 'i': vh.volumeId = ntohl(readvalue(4)); break; case 'v': (void)ntohl(readvalue(4)); /* version stamp - ignore */ break; case 'n': for (i = 0, c = 'a'; c != '\0'; i++) { vh.volumeName[i] = c = readchar(); } vh.volumeName[i] = c; break; case 's': vh.inService = ntohl(readvalue(1)); break; case 'b': vh.blessed = ntohl(readvalue(1)); break; case 'u': vh.uniquifier = ntohl(readvalue(4)); break; case 't': vh.volType = ntohl(readvalue(1)); break; case 'p': vh.parentVol = ntohl(readvalue(4)); break; case 'c': vh.cloneId = ntohl(readvalue(4)); break; case 'q': vh.maxQuota = ntohl(readvalue(4)); break; case 'm': vh.minQuota = ntohl(readvalue(4)); break; case 'd': vh.diskUsed = ntohl(readvalue(4)); break; case 'f': vh.fileCount = ntohl(readvalue(4)); break; case 'a': vh.accountNumber = ntohl(readvalue(4)); break; case 'o': vh.owner = ntohl(readvalue(4)); break; case 'C': vh.creationDate = ntohl(readvalue(4)); break; case 'A': vh.accessDate = ntohl(readvalue(4)); break; case 'U': vh.updateDate = ntohl(readvalue(4)); break; case 'E': vh.expirationDate = ntohl(readvalue(4)); break; case 'B': vh.backupDate = ntohl(readvalue(4)); break; case 'O': for (i = 0, c = 'a'; c != '\0'; i++) { vh.message[i] = c = readchar(); } vh.volumeName[i] = c; break; case 'W': vh.weekCount = ntohl(readvalue(2)); for (i = 0; i < vh.weekCount; i++) { vh.weekUse[i] = ntohl(readvalue(4)); } break; case 'M': for (i = 0, c = 'a'; c != '\0'; i++) { vh.motd[i] = c = readchar(); } break; case 'D': vh.dayUseDate = ntohl(readvalue(4)); break; case 'Z': vh.dayUse = ntohl(readvalue(4)); break; case 'V': readvalue(4); /*volUpCounter*/ break; default: done = 1; break; } } return ((afs_int32) tag); }
/*! 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()); } } }
void Dmc_method::read(vector <string> words, unsigned int & pos, Program_options & options) { ndim=3; have_read_options=1; //vector <string> offsetwords; //required options if(!readvalue(words, pos=0, timestep, "TIMESTEP")) error("Need TIMESTEP in METHOD section"); //optional options if(!readvalue(words, pos=0, nblock, "NBLOCK")) nblock=100; int target_config; if(!readvalue(words,pos=0,target_config,"TARGET_CONFIG")) target_config=2048; if(!readvalue(words, pos=0, nconfig, "NCONFIG")) nconfig=max(target_config/mpi_info.nprocs,1); if(!readvalue(words, pos=0, nstep, "NSTEP")) nstep=max(int(1.0/timestep+0.5),1); if(!readvalue(words, pos=0, readconfig, "READCONFIG")) readconfig=options.runid+".config"; if(!readvalue(words, pos=0, eref, "EREF")) eref=0.0; if(!readvalue(words,pos=0, max_poss_weight, "MAX_POSS_WEIGHT")) max_poss_weight=7.0; if(haskeyword(words, pos=0, "TMOVES")) tmoves=1; else tmoves=0; if(haskeyword(words, pos=0, "TMOVESSC")) tmoves_sizeconsistent=1; else tmoves_sizeconsistent=0; readvalue(words,pos=0,save_trace,"SAVE_TRACE"); if(!readvalue(words, pos=0, nhist, "CORR_HIST")) nhist=-1; if(haskeyword(words, pos=0, "PURE_DMC")) { pure_dmc=1; if( nhist < 1 ) error("CORR_HIST must be > 1 when PURE_DMC is on"); } else pure_dmc=0; if(!readvalue(words, pos=0, storeconfig, "STORECONFIG")) storeconfig=options.runid+".config"; if(!readvalue(words, pos=0, log_label, "LABEL")) log_label="dmc"; if(!readvalue(words, pos=0, start_feedback, "START_FEEDBACK")) start_feedback=1; if(readvalue(words, pos=0, feedback_interval, "FEEDBACK_INTERVAL")) { if(feedback_interval < 1) error("FEEDBACK_INTERVAL must be greater than or equal to 1"); } else feedback_interval=5; if(!readvalue(words, pos=0, feedback, "FEEDBACK")) feedback=1.0; if(!readvalue(words, pos=0, branch_start_cutoff, "BRANCH_START_CUTOFF")) branch_start_cutoff=10; branch_stop_cutoff=branch_start_cutoff*1.5; vector <string> proptxt; if(readsection(words, pos=0, proptxt, "PROPERTIES")) mygather.read(proptxt); vector<string> tmp_dens; pos=0; while(readsection(words, pos, tmp_dens, "DENSITY")) { dens_words.push_back(tmp_dens); } pos=0; while(readsection(words, pos, tmp_dens, "NONLOCAL_DENSITY")) { nldens_words.push_back(tmp_dens); } pos=0; while(readsection(words, pos, tmp_dens, "AVERAGE")) { avg_words.push_back(tmp_dens); } vector <string> dynamics_words; if(!readsection(words, pos=0, dynamics_words, "DYNAMICS") ) dynamics_words.push_back("SPLIT"); low_io=0; if(haskeyword(words, pos=0,"LOW_IO")) low_io=1; allocate(dynamics_words, dyngen); dyngen->enforceNodes(1); //MB: forwark walking lengths fw_length.Resize(0); fw_length=0; vector <string> fw_words; max_fw_length=0; if(readsection(words, pos=0, fw_words, "fw_length")){ fw_length.Resize(fw_words.size()); for(int i=0;i<fw_words.size();i++){ fw_length(i)=atoi(fw_words[i].c_str()); if(fw_length(i) > max_fw_length) max_fw_length=fw_length(i); } } //cout <<" Maximum forward walking history is "<<max_fw_length<<" steps"<<endl; }
// Convert Planar YUV 4:2:2 To 16-Bit DCT Quantization Block File (Y Channel) static void convert_dct_Y(FILE *source_file, FILE *target_file, long ofs, long ofs_end) { unsigned int i = 0; unsigned int u = 0; unsigned int v = 0; unsigned int x = 0; unsigned int y = 0; // Fill JPEG Standard Quantization 8x8 Matrix Set By Quality Level for(i=0; i < 64; i++) { if(quality > 50) q[i] = q50[i] * (100-quality)/50; if(quality < 50) q[i] = q50[i] * 50/quality; if(quality == 50) q[i] = q50[i]; if(q[i] > 255) q[i] = 255; if(q[i] < 1) q[i] = 1; } // Fill COS Look Up Table for(u=0; u < 8; u++) { for(x=0; x < 8; x++) coslut[u*8 + x] = cos((2*x + 1) * u * M_PI / 16); } // Loop Blocks ofs = 0; long wofs = 0; unsigned int block_row = 0; // Block Row Counter while(wofs < (width * height * 4) - 2048) { // Load Image Block (Y Channel) for(y=0; y < 8; y++) { for(x=0; x < 8; x++) { fseek(source_file, ofs, SEEK_SET); SourceCHR = readvalue(source_file); image[y*8 + x] = SourceCHR; ofs ++; } ofs += (width - 8); // Next Scanline In Block } block_row++; if(block_row == (width / 8)) { block_row = 0; // Next Block Row ofs -= (width - 8); } else ofs -= ((width * 8) - 8) ; // Next Block Column // Clear DCT Block for(i=0; i < 64; i++) dct[i] = 0.0; // Write DCT Block for(u=0; u < 8; u++) { for(v=0; v < 8; v++) { for(x=0; x < 8; x++) { for(y=0; y < 8; y++) { dct[v*8 + u] += ( image[y*8 + x] * clut[u] * clut[v] * coslut[u*8 + x] // cos((2*x + 1) * u * pi / 16) * coslut[v*8 + y] // cos((2*y + 1) * v * pi / 16) ); } } } } // Write DCTQ Block (Quantization) for(i=0; i < 64; i++) dctq[i] = dct[i] / q[i]; // Write Zig-Zag DCTQ Block dctqz[0] = dctq[0]; dctqz[1] = dctq[1]; dctqz[2] = dctq[8]; dctqz[3] = dctq[16]; dctqz[4] = dctq[9]; dctqz[5] = dctq[2]; dctqz[6] = dctq[3]; dctqz[7] = dctq[10]; dctqz[8] = dctq[17]; dctqz[9] = dctq[24]; dctqz[10] = dctq[32]; dctqz[11] = dctq[25]; dctqz[12] = dctq[18]; dctqz[13] = dctq[11]; dctqz[14] = dctq[4]; dctqz[15] = dctq[5]; dctqz[16] = dctq[12]; dctqz[17] = dctq[19]; dctqz[18] = dctq[26]; dctqz[19] = dctq[33]; dctqz[20] = dctq[40]; dctqz[21] = dctq[48]; dctqz[22] = dctq[41]; dctqz[23] = dctq[34]; dctqz[24] = dctq[27]; dctqz[25] = dctq[20]; dctqz[26] = dctq[13]; dctqz[27] = dctq[6]; dctqz[28] = dctq[7]; dctqz[29] = dctq[14]; dctqz[30] = dctq[21]; dctqz[31] = dctq[28]; dctqz[32] = dctq[35]; dctqz[33] = dctq[42]; dctqz[34] = dctq[49]; dctqz[35] = dctq[56]; dctqz[36] = dctq[57]; dctqz[37] = dctq[50]; dctqz[38] = dctq[43]; dctqz[39] = dctq[36]; dctqz[40] = dctq[29]; dctqz[41] = dctq[22]; dctqz[42] = dctq[15]; dctqz[43] = dctq[23]; dctqz[44] = dctq[30]; dctqz[45] = dctq[37]; dctqz[46] = dctq[44]; dctqz[47] = dctq[51]; dctqz[48] = dctq[58]; dctqz[49] = dctq[59]; dctqz[50] = dctq[52]; dctqz[51] = dctq[45]; dctqz[52] = dctq[38]; dctqz[53] = dctq[31]; dctqz[54] = dctq[39]; dctqz[55] = dctq[46]; dctqz[56] = dctq[53]; dctqz[57] = dctq[60]; dctqz[58] = dctq[61]; dctqz[59] = dctq[54]; dctqz[60] = dctq[47]; dctqz[61] = dctq[55]; dctqz[62] = dctq[62]; dctqz[63] = dctq[63]; // Write DCTQZ To Output File for(i=0; i < 64; i++) { SourceCHR = dctqz[i] >> 8; fseek(target_file, wofs, SEEK_SET); writevalue(SourceCHR, target_file); wofs++; SourceCHR = dctqz[i] & 0xFF; fseek(target_file, wofs, SEEK_SET); writevalue(SourceCHR, target_file); wofs++; } if((wofs & 0x7FF) == 0) wofs += 2048; } }
void get_onebody_parms_diffspin(vector<string> & words, vector<string> & atomnames, Array2 <doublevar> & unique_parameters, int s, Array1 <int> & nparms, vector <string> & parm_labels, Array2 <int> & linear_parms, int & counter, Array1 <int> & parm_centers) { vector < vector < string> > parmtxt; vector <string> parmtmp; unsigned int pos=0; if(s==0){ while(readsection(words, pos,parmtmp, "LIKE_COEFFICIENTS")) parmtxt.push_back(parmtmp); if(parmtxt.size()==0) error("Didn't find LIKE COEFFICIENTS in one of threebody spin Jastrow section"); } else{ while(readsection(words, pos,parmtmp, "UNLIKE_COEFFICIENTS")) parmtxt.push_back(parmtmp); if(parmtxt.size()==0) error("Didn't find UNLIKE COEFFICIENTS in one of threebody spin Jastrow section"); } int nsec=parmtxt.size(); int maxsize=0; nparms.Resize(nsec); for(int i=0; i< nsec; i++) nparms(i)=parmtxt[i].size()-1; for(int i=0; i< nsec; i++) if(maxsize < nparms(i)) maxsize=nparms(i); unique_parameters.Resize(nsec, maxsize); linear_parms.Resize(nsec, maxsize); //cout <<"spin "<<s<<" counter "<<counter<<endl; for(int i=0; i< nsec; i++) { for(int j=0; j< nparms(i); j++) { unique_parameters(i,j)=atof(parmtxt[i][j+1].c_str()); linear_parms(i,j)=counter++; } } parm_labels.resize(nsec); for(int i=0; i< nsec; i++) parm_labels[i]=parmtxt[i][0]; int natoms=atomnames.size(); parm_centers.Resize(natoms); parm_centers=-1; for(int i=0; i< nsec; i++) { int found=0; for(int j=0; j< natoms; j++) { if(atomnames[j]==parm_labels[i]) { parm_centers(j)=i; found=1; } } if(!found) error("Couldn't find a matching center for ", parm_labels[i]); } doublevar scale; if(readvalue(words, pos=0, scale, "SCALE")) { for(int i=0; i< unique_parameters.GetDim(0); i++) { for(int j=0; j< nparms(i); j++) { unique_parameters(i,j)*=scale; } } } }
// Convert 32-Bit/24-Bit BMP To 8-Bit DCT Quantization Block File static void convert_dct(FILE *source_file, FILE *target_file, long ofs, long ofs_end) { ofs = 0x12; fseek(source_file, ofs, SEEK_SET); width = readvalue(source_file); width += (readvalue(source_file))<<8; width += (readvalue(source_file))<<16; width += (readvalue(source_file))<<24; height = readvalue(source_file); height += (readvalue(source_file))<<8; height += (readvalue(source_file))<<16; height += (readvalue(source_file))<<24; ofs = 0x1C; fseek(source_file, ofs, SEEK_SET); depth = readvalue(source_file); depth += (readvalue(source_file))<<8; unsigned int i = 0; unsigned int u = 0; unsigned int v = 0; unsigned int x = 0; unsigned int y = 0; // Fill JPEG Standard Quantization 8x8 Matrix Set By Quality Level for(i=0; i < 64; i++) { if(quality > 50) q[i] = q50[i] * (100-quality)/50; if(quality < 50) q[i] = q50[i] * 50/quality; if(quality == 50) q[i] = q50[i]; if(q[i] > 255) q[i] = 255; if(q[i] < 1) q[i] = 1; } // Fill COS Look Up Table for(u=0; u < 8; u++) { for(x=0; x < 8; x++) coslut[u*8 + x] = cos((2*x + 1) * u * M_PI / 16); } // Loop Blocks ofs = ofs_end - ((depth / 8) * width); long wofs = 0; unsigned int block_row = 0; // Block Row Counter while(wofs < width * height) { // Load Image Block (Red Channel) for(y=0; y < 8; y++) { for(x=0; x < 8; x++) { fseek(source_file, ofs, SEEK_SET); SourceCHR = readvalue(source_file); image[y*8 + x] = SourceCHR; ofs += (depth / 8); } ofs -= ((depth / 8) * width) + ((depth / 8) * 8); // Next Scanline In Block } block_row++; if(block_row == (width / 8)) { block_row = 0; // Next Column Block ofs += (depth / 8) * 8; ofs -= ((depth / 8) * width); } else ofs += ((depth / 8) * (width * 8)) + ((depth / 8) * 8); // Next Block Row // Clear DCT Block for(i=0; i < 64; i++) dct[i] = 0.0; // Write DCT Block for(u=0; u < 8; u++) { for(v=0; v < 8; v++) { for(x=0; x < 8; x++) { for(y=0; y < 8; y++) { dct[v*8 + u] += ( image[y*8 + x] * clut[u] * clut[v] * coslut[u*8 + x] // cos((2*x + 1) * u * pi / 16) * coslut[v*8 + y] // cos((2*y + 1) * v * pi / 16) ); } } } } // Write DCTQ Block (Quantization) for(i=0; i < 64; i++) dctq[i] = dct[i] / q[i]; // Write DCTQ To Output File for(i=0; i < 64; i++) { SourceCHR = dctq[i]; fseek(target_file, wofs, SEEK_SET); writevalue(SourceCHR, target_file); wofs++; } } }
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; }
//------------------------------------------------------------------------- int Cubic_spline::read( vector <string> & words, unsigned int & pos ) { Array1 <double> basisparms(4); atomname=words[0]; basisparms(0)=.02; //spacing basisparms(1)=2500; //number of points basisparms(2)=1e31; basisparms(3)=1e31; if(!readvalue(words, pos=0, norm_type, "NORMTYPE")) { norm_type="GAMESSNORM"; } if(haskeyword(words, pos=0, "NORENORMALIZE")) { renormalize=false; } else { renormalize=true; } doublevar cutmax; if(readvalue(words, pos=0, cutmax, "CUTOFF")) { requested_cutoff=cutmax; } else { requested_cutoff=-1; } enforce_cusp=false; if(readvalue(words, pos=0, cusp, "CUSP")) enforce_cusp=true; match_sto=false; if(readvalue(words, pos=0, cusp_matching, "CUSP_MATCHING")) match_sto=true; zero_derivative=false; if(haskeyword(words, pos=0, "ZERO_DERIVATIVE")) zero_derivative=true; customspacing=basisparms(0); if(readvalue(words, pos=0, customspacing, "SPACING")) { basisparms(0)=customspacing; basisparms(1)=50.0/customspacing; } vector <string> basisspec; string read_file; //read positions from a file if(readsection(words,pos=0, basisspec, "GAMESS")) { unsigned int newpos=0; return readbasis(basisspec, newpos, basisparms); } else { pos=0; if(readspline(words)) { return 1; } else { error("couldn't find proper basis section in AOSPLINE. " "Try GAMESS { .. }."); return 0; } } //We assume that all splines use the same interval, //which saves a few floating divisions, so check to make //sure the assumption is good. for(int i=0; i< splines.GetDim(0); i++) { if(!splines(0).match(splines(i))) error("spline ", i, " doesn't match the first one "); } }
/*! */ int HEG_system::read(vector <string> & words, unsigned int & pos) { const int ndim=3; int startpos=pos; vector <string> latvectxt; vector <string> spintxt; if(!readsection(words, pos, spintxt, "NSPIN")) { error("Need NSPIN in HEG system"); } nspin.Resize(2); nspin(0)=atoi(spintxt[0].c_str()); nspin(1)=atoi(spintxt[1].c_str()); totnelectrons=nspin(0)+nspin(1); vector <string> ktxt; if(readsection(words, pos=0, ktxt, "KPOINT")) { if(ktxt.size()!=3) error("KPOINT must be a section of size 3"); kpt.Resize(3); for(int i=0; i< 3; i++) kpt(i)=atof(ktxt[i].c_str()); } else { kpt.Resize(3); kpt=0; } pos=startpos; if(!readsection(words, pos, latvectxt, "BOXSIZE")) error("BOXSIZE is required in HEG"); if(latvectxt.size() != ndim) error("BOXSIZE must have exactly ",ndim, " values"); vector< vector<string> > perturb_sec; vector <string> dumstring; pos=startpos; while(readsection(words, pos,dumstring, "PERTURB")) perturb_sec.push_back(dumstring); nperturb=perturb_sec.size(); perturb_pos.Resize(nperturb, ndim); perturb_strength.Resize(nperturb); perturb_alpha.Resize(nperturb); perturb_spin.Resize(nperturb); for(int i=0; i< nperturb; i++) { if(!readsection(perturb_sec[i], pos=0,dumstring,"POS")) error("Need POS in PERTURB"); if(dumstring.size()!=ndim) error("wrong dimension in POS in PERTURB"); for(int d=0; d< ndim; d++) perturb_pos(i,d)=atof(dumstring[d].c_str()); if(!readvalue(perturb_sec[i], pos=0,perturb_strength(i),"STRENGTH")) error("Need STRENGTH in PERTURB"); if(!readvalue(perturb_sec[i], pos=0,perturb_alpha(i),"SCALE")) error("Need SCALE in PERTURB"); if(!readvalue(perturb_sec[i], pos=0,perturb_spin(i),"SPIN")) error("Need SPIN in PERTURB"); } latVec.Resize(ndim, ndim); latVec=0.0; for(int i=0; i< ndim; i++) latVec(i,i)=atof(latvectxt[i].c_str()); /* for(int i=0; i< ndim; i++) { for(int j=0; j< ndim; j++) { latVec(i,j)=atof(latvectxt[i*ndim+j].c_str()); } } */ origin.Resize(3); vector <string> origintxt; if(readsection(words, pos=0, origintxt, "ORIGIN")) { if(origintxt.size() < 3) error("ORIGIN section must have at least 3 elements."); for(int i=0; i< 3; i++) origin(i)=atof(origintxt[i].c_str()); } else { origin=0; //defaulting the origin to zero } vector <string> interactiontxt; // default is truncated Coulomb calcLocChoice=&HEG_system::calcLocTrunc; eeModel=2; same_spin_int=true; diff_spin_int=true; if(readsection(words, pos=0, interactiontxt, "INTERACTION")) { if( haskeyword(interactiontxt, pos=0, "EWALD") ) { calcLocChoice=&HEG_system::calcLocEwald; eeModel=1; } if( haskeyword(interactiontxt, pos=0, "TRUNCCOUL") ) { calcLocChoice=&HEG_system::calcLocTrunc; eeModel=2; } if( haskeyword(interactiontxt, pos=0, "GAUSS") ) { calcLocChoice=&HEG_system::calcLocGauss; eeModel=3; if(!readvalue(interactiontxt,pos=0,Gauss_a, "AMP")) error("Gauss interaction model requested, but no AMP given."); if(!readvalue(interactiontxt,pos=0,Gauss_s, "STDEV")) error("Gauss interaction model requested, but no STDEV given."); Gauss_s2=Gauss_s*Gauss_s; } if( haskeyword(interactiontxt, pos=0, "NO_SAME_SPIN") ) same_spin_int=false; if( haskeyword(interactiontxt, pos=0, "NO_DIFF_SPIN") ) diff_spin_int=false; } if ( eeModel==1 && ( !same_spin_int || !diff_spin_int ) ) error("Spin-dependent Ewald interaction not supported."); //-------------cross products //cross product: 0->1x2, 1->2x0, 2->0x1 Array2 <doublevar> crossProduct(ndim, ndim); crossProduct(0,0)=(latVec(1,1)*latVec(2,2)-latVec(1,2)*latVec(2,1)); crossProduct(0,1)=(latVec(1,2)*latVec(2,0)-latVec(1,0)*latVec(2,2)); crossProduct(0,2)=(latVec(1,0)*latVec(2,1)-latVec(1,1)*latVec(2,0)); crossProduct(1,0)=(latVec(2,1)*latVec(0,2)-latVec(2,2)*latVec(0,1)); crossProduct(1,1)=(latVec(2,2)*latVec(0,0)-latVec(2,0)*latVec(0,2)); crossProduct(1,2)=(latVec(2,0)*latVec(0,1)-latVec(2,1)*latVec(0,0)); crossProduct(2,0)=(latVec(0,1)*latVec(1,2)-latVec(0,2)*latVec(1,1)); crossProduct(2,1)=(latVec(0,2)*latVec(1,0)-latVec(0,0)*latVec(1,2)); crossProduct(2,2)=(latVec(0,0)*latVec(1,1)-latVec(0,1)*latVec(1,0)); //------------ reciprocal cell (used in setupEwald and showinfo) recipLatVec.Resize(ndim, ndim); doublevar det=Determinant(latVec, ndim); debug_write(cout, "cell volume ", det,"\n"); cellVolume=det; for(int i=0; i< ndim; i++) { for(int j=0; j< ndim; j++) { recipLatVec(i,j)=crossProduct(i,j)/det; } } //------------ normal vectors (needed in enforcePbc) normVec.Resize(ndim, ndim); for(int i=0; i< ndim; i++) { for(int j=0; j < ndim; j++) { normVec(i,j)=crossProduct(i,j); } //Check to make sure the direction is facing out doublevar dotprod=0; for(int j=0; j < ndim; j++) { dotprod+=normVec(i,j)*latVec(i,j); } if(dotprod < 0) { for(int j=0; j< ndim; j++) { normVec(i,j)= -normVec(i,j); } } } corners.Resize(ndim, ndim); for(int i=0; i< ndim; i++) { for(int j=0; j< ndim; j++) { corners(i,j)=origin(j)+latVec(i,j); } } //------------ setup for interaction calculators (reciprocal part of Ewald sum etc.) if ( eeModel == 1 ) setupEwald(crossProduct); if ( eeModel == 2 ) setupTruncCoulomb(); return 1; }
void Reptation_method::read(vector <string> words, unsigned int & pos, Program_options & options) { have_read_options=1; if(!readvalue(words, pos=0, nblock, "NBLOCK")) error("Need NBLOCK in RETPTATION section"); if(!readvalue(words, pos=0, nstep, "NSTEP")) error("Need NSTEP in REPTATION section"); if(!readvalue(words, pos=0, timestep, "TIMESTEP")) error("Need TIMESTEP in REPTATION section"); if(!readvalue(words, pos=0, reptile_length, "LENGTH")) error("Need LENGTH in REPTATION"); //------------------optional stuff print_pdb=haskeyword(words, pos=0,"PRINT_PDB"); if(!readvalue(words, pos=0, readconfig, "READCONFIG")) readconfig=options.runid+".config"; vector <string> proptxt; if(readsection(words, pos=0, proptxt, "PROPERTIES")) mygather.read(proptxt); if(!readvalue(words, pos=0, log_label, "LABEL")) log_label="rmc"; if(!readvalue(words, pos=0, storeconfig, "STORECONFIG")) storeconfig=options.runid+".config"; if(readvalue(words, pos=0, center_trace, "CENTER_TRACE")) canonical_filename(center_trace); if(!readvalue(words, pos=0, trace_wait, "TRACE_WAIT")) trace_wait=int(.3/timestep)+1; vector <string> dynamics_words; if(!readsection(words, pos=0, dynamics_words, "DYNAMICS") ) dynamics_words.push_back("SPLIT"); allocate(dynamics_words, sampler); vector<string> tmp_dens; pos=0; while(readsection(words, pos, tmp_dens, "DENSITY")) { dens_words.push_back(tmp_dens); } pos=0; while(readsection(words, pos, tmp_dens, "AVERAGE")) { avg_words.push_back(tmp_dens); } sampler->enforceNodes(1); guidewf=new Primary; }