00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "QMCMikesJackedWalkerInitialization.h"
00014
00015 #define PI 3.14159265359
00016 #define a0 0.529177257507
00017
00018 QMCMikesJackedWalkerInitialization::
00019 QMCMikesJackedWalkerInitialization( QMCInput *INPUT )
00020 {
00021 Input = INPUT;
00022 }
00023
00024 Array2D<double> QMCMikesJackedWalkerInitialization::initializeWalkerPosition()
00025 {
00026 int natoms = Input->flags.Natoms;
00027 Array2D<double> atom_centers(natoms,3);
00028 atom_centers = Input->Molecule.Atom_Positions;
00029
00030 int nelectrons = Input->WF.getNumberElectrons();
00031 int nelectrons_left = nelectrons;
00032 int nbeta = Input->WF.getNumberElectrons(false);
00033 int nalpha = Input->WF.getNumberElectrons(true);
00034 int nbeta_left = nbeta;
00035 int nalpha_left = nalpha;
00036
00037 Array2D <double> atom_e_count(natoms,2);
00038
00039 atom_e_count = electrons_and_radii();
00040
00041
00042
00043
00044 Array2D <double> atom_ab_count(natoms,3);
00045
00046
00047
00048 int n_e_pairs = nalpha;
00049 if(nalpha>nbeta)
00050 {
00051 n_e_pairs = nbeta;
00052 }
00053 int n_e_pairs_left = n_e_pairs;
00054
00055 int n_lone_e = nelectrons-2*n_e_pairs;
00056 int n_lone_e_left = n_lone_e;
00057
00058 for(int np=0; np<natoms;np++)
00059 {
00060 atom_ab_count(np,0) = atom_e_count(np,0);
00061
00062
00063 atom_ab_count(np,1) = 0;
00064 atom_ab_count(np,2) = 0;
00065 }
00066
00067
00068
00069
00070 int flag1, flag2;
00071 for(int np=0;np<natoms;np++)
00072 {
00073 flag1 = 0;
00074 flag2 = 0;
00075 if( ( (int) (0.1+atom_ab_count(np,0)) ) %2 == 1)
00076 {
00077
00078 if(nalpha_left>nbeta_left) flag1 = 1;
00079 else if(nalpha_left<nbeta_left) flag1 = -1;
00080 else flag2 = 1;
00081
00082
00083 if(flag1==1)
00084 {
00085 nalpha_left--;
00086 nelectrons_left--;
00087 n_lone_e_left--;
00088 atom_ab_count(np,0)--;
00089 atom_ab_count(np,1)++;
00090 }
00091 else if(flag1==-1)
00092 {
00093 nbeta_left--;
00094 nelectrons_left--;
00095 n_lone_e_left--;
00096 atom_ab_count(np,0)--;
00097 atom_ab_count(np,2)++;
00098 }
00099 else if(flag2==1)
00100
00101 {
00102
00103 nalpha_left--;
00104 nelectrons_left--;
00105 n_lone_e_left++;
00106 n_e_pairs_left--;
00107 atom_ab_count(np,0)--;
00108 atom_ab_count(np,1)++;
00109 }
00110 else
00111 {
00112 cerr<< "ERROR: Incorrect number of electrons left A" << endl;
00113 exit(1);
00114 }
00115 }
00116 }
00117
00118
00119
00120
00121
00122 while(n_e_pairs_left!=0)
00123 {
00124 for(int np=0;np<natoms;np++)
00125 {
00126 if(atom_ab_count(np,0) >= 2)
00127
00128 {
00129 atom_ab_count(np,0) -= 2;
00130
00131 atom_ab_count(np,1)++;
00132 atom_ab_count(np,2)++;
00133 nelectrons_left -= 2;
00134 n_e_pairs_left--;
00135 nalpha_left--;
00136 nbeta_left--;
00137 }
00138 }
00139 }
00140
00141
00142 while(n_lone_e_left!=0)
00143 {
00144 for(int np=0;np<natoms;np++)
00145 {
00146 if(atom_ab_count(np,0)>0)
00147
00148 {
00149 if(nalpha_left>0)
00150 {
00151 nalpha_left--;
00152 nelectrons_left--;
00153 n_lone_e_left--;
00154 atom_ab_count(np,0)--;
00155 atom_ab_count(np,1)++;
00156 }
00157 else if(nbeta_left>0)
00158 {
00159 nbeta_left--;
00160 nelectrons_left--;
00161 n_lone_e_left--;
00162 atom_ab_count(np,0)--;
00163 atom_ab_count(np,2)++;
00164 }
00165 else
00166 {
00167 cerr << "Error: Alpha and beta counting has gone bad!"
00168 << endl;
00169 exit(1);
00170 }
00171 }
00172 }
00173 }
00174
00175
00176
00177
00178 if(nalpha_left!=0)
00179 {
00180 cerr<<"Error: In nalpha_left!=0" << endl;
00181 exit(1);
00182 }
00183 if(nbeta_left!=0)
00184 {
00185 cerr << "Error: In nbeta_left!=0" << endl;
00186 exit(1);
00187 }
00188 if(n_e_pairs_left!=0)
00189 {
00190 cerr << "Error: In n_e_pairs_left!=0" << endl;
00191 exit(1);
00192 }
00193 if(n_lone_e_left!=0)
00194 {
00195 cerr << "Error: In n_lone_e_left!=0" << endl;
00196 exit(1);
00197 }
00198 if(nelectrons_left!=0)
00199 {
00200 cerr << "Error: In nelectrons_left!=0" << endl;
00201 exit(1);
00202 }
00203
00204
00205
00206
00207 double x,y,z,xx,yy,zz,SD,atom_size,AA;
00208
00209
00210 int alpha_index = 0;
00211 int beta_index = nalpha;
00212
00213 Array2D<double> R(nelectrons,3);
00214 for(int np=0;np<natoms;np++)
00215 {
00216 x = atom_centers(np,0);
00217 y = atom_centers(np,1);
00218 z = atom_centers(np,2);
00219 nalpha_left = (int)(0.1+atom_ab_count(np,1));
00220 nbeta_left = (int)(0.1+atom_ab_count(np,2));
00221 atom_size = atom_e_count(np,1);
00222 while(nalpha_left!=0)
00223 {
00224 SD = atom_size;
00225 AA = SD*sqrt(2*PI/(3*PI-8.0));
00226
00227
00228
00229 xx = AA*ran.gasdev();
00230 yy = AA*ran.gasdev();
00231 zz = AA*ran.gasdev();
00232
00233 R(alpha_index,0) = xx+x;
00234 R(alpha_index,1) = yy+y;
00235 R(alpha_index,2) = zz+z;
00236 alpha_index++;
00237 nalpha_left--;
00238 }
00239 while(nbeta_left!=0)
00240 {
00241 SD = atom_size;
00242 AA = SD*sqrt(2*PI/(3*PI-8.0));
00243
00244
00245
00246 xx = AA*ran.gasdev();
00247 yy = AA*ran.gasdev();
00248 zz = AA*ran.gasdev();
00249
00250 R(beta_index,0) = xx+x;
00251 R(beta_index,1) = yy+y;
00252 R(beta_index,2) = zz+z;
00253 beta_index++;
00254 nbeta_left--;
00255 }
00256 }
00257
00258 return R;
00259 }
00260
00261 Array2D <double> QMCMikesJackedWalkerInitialization::electrons_and_radii()
00262 {
00263 int Norbitals = Input->WF.getNumberOrbitals();
00264 int Nbasisfunc = Input->WF.getNumberBasisFunctions();
00265
00266 Array2D<qmcfloat> OrbitalScratch(Input->WF.OrbitalCoeffs);
00267
00268
00269 for(int i=0; i<Norbitals; i++)
00270 for(int j=0; j<Nbasisfunc; j++)
00271 {
00272 OrbitalScratch(i,j) = OrbitalScratch(i,j)*OrbitalScratch(i,j);
00273 }
00274
00275
00276
00277 double OrbitalSum;
00278
00279 for(int i=0; i<Norbitals; i++)
00280 {
00281 OrbitalSum = 0;
00282 for(int j=0; j<Nbasisfunc; j++)
00283 {
00284 OrbitalSum += OrbitalScratch(i,j);
00285 }
00286
00287 for(int j=0; j<Nbasisfunc; j++)
00288 {
00289 OrbitalScratch(i,j) = OrbitalScratch(i,j)/OrbitalSum;
00290 }
00291 }
00292
00293
00294
00295 Array1D <int> OrbPos(Input->WF.getNumberBasisFunctions());
00296
00297 int Natoms = Input->flags.Natoms;
00298
00299 int i=0;
00300 for(int j=0; j<Natoms; j++)
00301 for(int k=0; k<Input->BF.getNumberBasisFunctions(j); k++)
00302 {
00303 OrbPos(i) = j;
00304 i++;
00305 }
00306
00307
00308
00309
00310
00311 Array2D <double> EandR(Natoms,2);
00312 for(int i=0; i<Natoms; i++)
00313 for(int j=0; j<2; j++)
00314 EandR(i,j) = 0.0;
00315
00316 double rv;
00317 double sum;
00318 for(int i=0; i<Norbitals; i++)
00319 {
00320 if (Input->WF.AlphaOccupation(0,i) != Input->WF.getUnusedIndicator())
00321 {
00322 sum = 0.0;
00323 rv = ran.unidev();
00324
00325 for(int j=0; j<Nbasisfunc; j++)
00326 {
00327 sum += OrbitalScratch(i,j);
00328 if (sum >= rv)
00329 {
00330 EandR(OrbPos(j),0) += 1;
00331 break;
00332 }
00333 }
00334 }
00335
00336 if (Input->WF.BetaOccupation(0,i) != Input->WF.getUnusedIndicator())
00337 {
00338 sum = 0.0;
00339 rv = ran.unidev();
00340
00341 for (int k=0; k<Nbasisfunc; k++)
00342 {
00343 sum += OrbitalScratch(i,k);
00344 if (sum >= rv)
00345 {
00346 EandR(OrbPos(k),0) += 1;
00347 break;
00348 }
00349 }
00350 }
00351 }
00352
00353 for(int i=0; i<Natoms; i++)
00354 {
00355 EandR(i,1) = covalent_radi(Input->Molecule.Z(i));
00356 }
00357
00358 return EandR;
00359 }
00360
00361
00362 double QMCMikesJackedWalkerInitialization::covalent_radi(int ZZ)
00363 {
00364
00365 double value = 0;
00366
00367 if(ZZ < 1)
00368 {
00369 cerr << "ERROR: Z < 1" << endl;
00370 cerr << "Z = " << ZZ << endl;
00371 exit(1);
00372 }
00373
00374
00375 switch(ZZ)
00376 {
00377 case 1: value = 0.15; break;
00378 case 2: value = 0.25; break;
00379 case 3: value = 0.40; break;
00380 case 4: value = 0.30; break;
00381 case 5: value = 0.30; break;
00382 case 6: value = 0.30; break;
00383 case 7: value = 0.50; break;
00384 case 8: value = 0.73; break;
00385 case 9: value = 0.72; break;
00386 case 10: value = 0.71; break;
00387 case 11: value = 1.54; break;
00388 case 12: value = 1.36; break;
00389 case 13: value = 1.18; break;
00390 case 14: value = 1.11; break;
00391 case 15: value = 1.06; break;
00392 case 16: value = 1.02; break;
00393 case 17: value = 0.99; break;
00394 case 18: value = 0.98; break;
00395 case 19: value = 2.03; break;
00396 case 20: value = 1.74; break;
00397 case 21: value = 1.44; break;
00398 case 22: value = 1.32; break;
00399 case 23: value = 1.22; break;
00400 case 24: value = 1.18; break;
00401 case 25: value = 1.17; break;
00402 case 26: value = 1.17; break;
00403 case 27: value = 1.16; break;
00404 case 28: value = 1.15; break;
00405 case 29: value = 1.17; break;
00406 case 30: value = 1.25; break;
00407 case 31: value = 1.26; break;
00408 case 32: value = 1.22; break;
00409 case 33: value = 1.20; break;
00410 case 34: value = 1.16; break;
00411 case 35: value = 1.14; break;
00412 case 36: value = 1.89; break;
00413 case 37: value = 2.16; break;
00414 case 38: value = 1.91; break;
00415 case 39: value = 1.62; break;
00416 case 40: value = 1.45; break;
00417 case 41: value = 1.34; break;
00418 case 42: value = 1.30; break;
00419 case 43: value = 1.27; break;
00420 case 44: value = 1.25; break;
00421 case 45: value = 1.25; break;
00422 case 46: value = 1.28; break;
00423 case 47: value = 1.34; break;
00424 case 48: value = 1.41; break;
00425 case 49: value = 1.44; break;
00426 case 50: value = 1.41; break;
00427 case 51: value = 1.40; break;
00428 case 52: value = 1.36; break;
00429 case 53: value = 1.33; break;
00430 case 54: value = 1.31; break;
00431 case 55: value = 2.35; break;
00432 case 56: value = 1.98; break;
00433 case 57: value = 1.25; break;
00434 case 58: value = 1.65; break;
00435 case 59: value = 1.65; break;
00436 case 60: value = 1.64; break;
00437 case 61: value = 1.63; break;
00438 case 62: value = 1.62; break;
00439 case 63: value = 1.85; break;
00440 case 64: value = 1.61; break;
00441 case 65: value = 1.59; break;
00442 case 66: value = 1.59; break;
00443 case 67: value = 1.58; break;
00444 case 68: value = 1.57; break;
00445 case 69: value = 1.56; break;
00446 case 70: value = 1.70; break;
00447 case 71: value = 1.56; break;
00448 case 72: value = 1.44; break;
00449 case 73: value = 1.34; break;
00450 case 74: value = 1.30; break;
00451 case 75: value = 1.28; break;
00452 case 76: value = 1.26; break;
00453 case 77: value = 1.27; break;
00454 case 78: value = 1.30; break;
00455 case 79: value = 1.34; break;
00456 case 80: value = 1.49; break;
00457 case 81: value = 1.48; break;
00458 case 82: value = 1.47; break;
00459 case 83: value = 1.46; break;
00460 case 84: value = 1.53; break;
00461 case 85: value = 1.47; break;
00462 case 90: value = 1.65; break;
00463 case 92: value = 1.42; break;
00464 }
00465
00466 if(value == 0)
00467 {
00468 cerr << "ERROR: Do not have a covalent radi for Z = " << ZZ << endl;
00469 exit(1);
00470 }
00471
00472 return value/a0;
00473 }
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489