void Tarrec::Allocator(void) { // // Now populate lattice with homogeneous, isotropic composition. int curSize = nx * ny; ixyz.Dimension(curSize, 3); // minJx = minJy = minJz = 1; maxJx = nx; maxJy = ny; maxJz = nz; // nat0 = 0; for(int jx=0; jx<nx; ++jx) { for(int jy=0; jy<ny; ++jy) { for(int jz=0; jz<nz; ++jz) { if (nat0 >= curSize) { ixyz.Extend(nz); curSize = ixyz.GetSize(0); } ixyz.Fill3(nat0, jx+1, jy+1, jz+1); // Positions are expressed starting from one, not zero int index = GetLinearAddress(nat0); Composer(index, 0); iocc[index] = true; ++nat0; } } } ixyz.Close(nat0); }
void Tartet::Allocator(void) { if ((dx.data[0] != onex_) || (dx.data[1] != onex_)) Errmsg("Fatal", "Tartet", " tartet does not support noncubic lattice"); // // Determine list of occupied sites. int curSize = nx * ny; ixyz.Dimension(curSize, 3); nat0 = 0; for(int i=minJx; i<=maxJx; ++i) { real x = i + xoff; // YMAX=largest value of Y which can occur for this X value // YMIN=smallest value of Y which can occur for this X value // ZMAX0=largest value of Z which can occur for this X value real ymax = (real)( shpar[0] * Sqrt(3./16.) - x / Sqrt(twox_)); real ymin = (real)(-shpar[0] * Sqrt(3./64.) + x / Sqrt(8.)); real zmax0 = (real)(3. * shpar[0] / 8. - x * Sqrt(3./8.)); for(int j=minJy; j<=maxJy; ++j) { real y = j + yoff; if ((y >= ymin) && (y <= ymax)) { real fy = (y - ymin) / (ymax - ymin); real zmax = (onex_ - fy) * zmax0; // ! ZMAX=largest value of Z which can occur for this (X,Y) for(int k=minJz; k<=maxJz; ++k) { real z = k + zoff; if (Fabs(z) <= zmax) // ! Site is occupied: { if (nat0 >= curSize) { ixyz.Extend(nz); curSize = ixyz.GetSize(0); } ixyz.Fill3(nat0, i, j, k); int index = GetLinearAddress(nat0); Composer(index, 0); iocc[index] = true; ++nat0; } } } } } ixyz.Close(nat0); }
Randomizer::Randomizer(const char * _filename) : Base(_filename) { Composer(ZERO); srand(time(nullptr)); for(int i = 0; i < ENTRIES_NUM; i++) { Record Persona = CreatePersona(); if(((Search(Persona.uid)).compare(RECORD_FORM)) == 0) { Append(Persona); // islem sayaci artirma transaction++; } else if (((Search(Persona.uid)).compare(RECORD_FORM)) != 0) { i--; continue; } } }
void Target_Octahedron::Allocator(void) { // // Current version of TARPLATONIC is restricted to cubic lattices if ((dx.data[0] != onex_) || (dx.data[1] != onex_)) Errmsg("Fatal", shortDescr.c_str(), " TargetOctahedron does not support noncubic lattice"); // int nlong = (int)shpar[0]; real nlongHalf = nlong / (real)2.; // int curSize = nx * ny; ixyz.Dimension(curSize, 3); // nat0 = 0; for(int jx=minJx; jx<=maxJx; ++jx) { real x = (real)jx - nlongHalf; for(int jy=minJy; jy<=maxJy; ++jy) { real y = (real)jy - nlongHalf; for(int jz=minJz; jz<=maxJz; ++jz) { real z = (real)jz - nlongHalf; if (Check(x, y, z)) { if (nat0 >= curSize) { ixyz.Extend(nz); curSize = ixyz.GetSize(0); } ixyz.Fill3(nat0, jx, jy, jz); int index = GetLinearAddress(nat0); Composer(index, 0); iocc[index] = true; ++nat0; } } } } ixyz.Close(nat0); }
void Tarcyl::Allocator(void) // A=cylinder length/d, B=cylinder diameter/d { int jlo, jhi; int curSize = nx * ny; ixyz.Dimension(curSize, 3); real r2 = (real)0.25 * shpar[1] * shpar[1]; // switch((int)shpar[2]) { case 1: jlo = maxJx; jhi = minJx; nat0 = 0; for(int jx=minJx; jx<=maxJx; ++jx) { real rx2 = twox_ * Fabs(jx * dx.data[0] - xcm); if (rx2 <= shpar[0]) { for(int jy=minJy; jy<=maxJy; ++jy) { real ry2 = jy * dx.data[1] - ycm; ry2 = ry2 * ry2; for(int jz=minJz; jz<=maxJz; ++jz) { real rz2 = jz * dx.data[2] - zcm; rz2 = rz2 * rz2; if (ry2 + rz2 <= r2) { if (nat0 >= curSize) { ixyz.Extend(nz); curSize = ixyz.GetSize(0); } ixyz.Fill3(nat0, jx, jy, jz); int index = GetLinearAddress(nat0); Composer(index, 0); iocc[index] = true; if (jx < jlo) jlo = jx; if (jx > jhi) jhi = jx; ++nat0; } } } } } break; case 2: jlo = maxJy; jhi = minJy; nat0 = 0; for(int jx=minJx; jx<=maxJx; ++jx) { real rx2 = jx * dx.data[0] - xcm; rx2 = rx2 * rx2; for(int jy=minJy; jy<=maxJy; ++jy) { real ry2 = twox_ * Fabs(jy * dx.data[1] - ycm); if (ry2 <= shpar[0]) { for(int jz=minJz; jz<=maxJz; ++jz) { real rz2 = jz * dx.data[2] - zcm; rz2 = rz2 * rz2; if (rx2 + rz2 <= r2) { if (nat0 >= curSize) { ixyz.Extend(nz); curSize = ixyz.GetSize(0); } ixyz.Fill3(nat0, jx, jy, jz); int index = GetLinearAddress(nat0); Composer(index, 0); iocc[index] = true; if (jy < jlo) jlo = jy; if (jy > jhi) jhi = jy; ++nat0; } } } } } break; case 3: jlo = maxJz; jhi = minJz; nat0 = 0; for(int jx=minJx; jx<=maxJx; ++jx) { real rx2 = jx * dx.data[0] - xcm; rx2 = rx2 * rx2; for(int jy=minJy; jy<=maxJy; ++jy) { real ry2 = jy * dx.data[1] - ycm; ry2 = ry2 * ry2; if (rx2 + ry2 <= r2) { for(int jz=minJz; jz<=maxJz; ++jz) { real rz2 = twox_ * Fabs(jz * dx.data[2] - zcm); if (rz2 <= shpar[0]) { if (nat0 >= curSize) { ixyz.Extend(nz); curSize = ixyz.GetSize(0); } ixyz.Fill3(nat0, jx, jy, jz); int index = GetLinearAddress(nat0); Composer(index, 0); iocc[index] = true; if (jz < jlo) jlo = jz; if (jz > jhi) jhi = jz; ++nat0; } } } } } break; default: break; } int nlay = jhi - jlo + 1; ixyz.Close(nat0); // // NLAY = number of layers in cylinder // NFAC = number of atoms in slice int nfac = nat0 / nlay; // // REFF2=effective radius**2 of disk real reff2 = (real)nfac / Pi; // // ASPR=aspect ratio (length/diameter) real aspr = half_ * (real)nlay / Sqrt(reff2); // // Description sprintf(freeDescr, " Cyl.prism, NAT=%7d NFAC=%4d NLAY=%4d asp.ratio=%lf", nat0, nfac, nlay, aspr); }
MidSquareSO::MidSquareSO(const char * _filename, const char * linear_filename) : MidSquare(_filename) { endpoint = THOUSAND_MOD; ifstream linear_file; linear_file.open(linear_filename, ios::in); if( !linear_file.is_open() ) { cout << "MidSquareSO(): " << "ERROR: " << linear_filename << " Can't be opened" << endl; } else { string redLine; while(linear_file.good()) { getline(linear_file, redLine); if(redLine.compare("\0") != 0) { Record Persona = Parser(redLine); unsigned int hashline = HashFunction(Persona.uid); if(Collision(hashline) == 0) { Write(Persona, hashline); // islem sayisini artirma transaction++; } else if(Collision(hashline) != 0) { hashline = THOUSAND_MOD; Composer(ONE); endpoint++; while(Collision(hashline) != 0) { hashline++; // islem sayisini artirma transaction++; // dosyanin max. boyutuna ulasmasi if(!(hashline < (ENTRIES_NUM + THOUSAND_MOD))) { cout << "MidSquareSO(): " << "ERROR: " << filename << " Can't write UID: " << Persona.uid << " file is OVERFLOW" << endl; break; } } // Correction control if(Collision(hashline) == 0) { Write(Persona, hashline); // islem sayisini artirma transaction++; } } } } linear_file.clear(); linear_file.seekg(0, ios::beg); while(linear_file.good()) { getline(linear_file, redLine); if(redLine.compare("\0") != 0) { Record Persona = Parser(redLine); unsigned int hashline = HashFunction(Persona.uid); if((Search(Persona.uid, hashline)).compare(RECORD_FORM) != 0) { // islem sayisini artirma transaction++; } else { hashline = THOUSAND_MOD; while(((Search(Persona.uid, hashline)).compare(RECORD_FORM) == 0) && (hashline < endpoint)) { hashline++; // islem sayisini artirma transaction++; } // Correction control if((Search(Persona.uid, hashline)).compare(RECORD_FORM) != 0) { // islem sayisini artirma transaction++; } else { cout << "MidSquareSO(): " << "ERROR: " << " Can't find UID: " << Persona.uid << " in file " << filename << endl; } } } } linear_file.close(); } }
MidSquare::MidSquare(const char * _filename) : Base(_filename) { Composer(THOUSAND_MOD); }
Folding::Folding(const char * _filename) : Base(_filename) { Composer(THOUSAND_MOD); }
DivRemain::DivRemain(const char * _filename) : Base(_filename) { Composer(DIVREMAIN_MOD); }
Linear::Linear(const char * _filename, const char * random_filename) : Base(_filename) { ifstream random_file; random_file.open(random_filename, ios::in); if( !random_file.is_open() ) { cout << "Linear(): " << "ERROR: " << random_filename << " Can't be opened" << endl; } else { // dosyaya yazma islemi string redLine; while(random_file.good()) { getline(random_file, redLine); if(redLine.compare("\0") != 0) { Record Persona = Parser(redLine); Composer(ONE); unsigned int line = 0; while(Collision(line) != 0) { line++; // islem sayisini artirma transaction++; // dosya dolu ise if(line >= ENTRIES_NUM) { cout << "Linear(): " << "ERROR: " << filename << " Can't write UID: " << Persona.uid << " file is FULL" << endl; break; } } // Correction control if(Collision(line) == 0) { Write(Persona, line); // islem sayisini artirma transaction++; } } } // dosyada arama islemi random_file.clear(); random_file.seekg(0, ios::beg); while(random_file.good()) { getline(random_file, redLine); if(redLine.compare("\0") != 0) { Record Persona = Parser(redLine); unsigned int line = 0; // adres dolu ve kayit o adreste degil ise while((Search(Persona.uid, line)).compare(RECORD_FORM) == 0 && line < ENTRIES_NUM) { line++; // islem sayisini artirma transaction++; } // Correction control if((Search(Persona.uid, line)).compare(RECORD_FORM) != 0) { // islem sayisini artirma //transaction++; } else { cout << "Linear(): " << "ERROR: " << " Can't find UID: " << Persona.uid << " in file " << filename << endl; } } } random_file.close(); } }