00001
00002
00003
00004 #include "QMCDansWalkerInitialization.h"
00005
00006 #define PI 3.14159265359
00007
00008 QMCDansWalkerInitialization::QMCDansWalkerInitialization(QMCInput * INPUT)
00009 {
00010 Input = INPUT;
00011 if (!arraysInitialized)
00012 {
00013 arraysInitialized = true;
00014 initializeArrays();
00015 }
00016 }
00017
00018 QMCDansWalkerInitialization::~QMCDansWalkerInitialization()
00019 {
00020 arraysInitialized = false;
00021 phiSplines.deallocate();
00022 phiSplinesMade.deallocate();
00023 thetaSplines.deallocate();
00024 thetaSplinesMade.deallocate();
00025 radialSplines.deallocate();
00026 radialSplinesMade.deallocate();
00027 x_array.deallocate();
00028 }
00029
00030
00031 bool QMCDansWalkerInitialization::arraysInitialized = false;
00032
00033 Array1D<CubicSpline> QMCDansWalkerInitialization::phiSplines;
00034 Array1D<int> QMCDansWalkerInitialization::phiSplinesMade;
00035
00036 Array1D<CubicSpline> QMCDansWalkerInitialization::thetaSplines;
00037 Array1D<int> QMCDansWalkerInitialization::thetaSplinesMade;
00038
00039 Array2D<CubicSpline> QMCDansWalkerInitialization::radialSplines;
00040 Array2D<int> QMCDansWalkerInitialization::radialSplinesMade;
00041
00042 Array1D<double> QMCDansWalkerInitialization::x_array;
00043
00044 void QMCDansWalkerInitialization::initializeArrays()
00045 {
00046 phiSplines.allocate(19);
00047 phiSplinesMade.allocate(19);
00048 phiSplinesMade = 0;
00049
00050 thetaSplines.allocate(19);
00051 thetaSplinesMade.allocate(19);
00052 thetaSplinesMade = 0;
00053
00054 radialSplines.allocate(18,3);
00055 radialSplinesMade.allocate(18,3);
00056 radialSplinesMade = 0;
00057
00058 x_array.allocate(21);
00059 for (int i=0; i<21; i++) x_array(i) = i/20.0;
00060 }
00061
00062 Array2D<double> QMCDansWalkerInitialization::initializeWalkerPosition()
00063 {
00064 int natoms = Input->flags.Natoms;
00065 Array2D<double> atom_centers(natoms,3);
00066 atom_centers = Input->Molecule.Atom_Positions;
00067
00068 int nelectrons = Input->WF.getNumberElectrons();
00069 int nbeta = Input->WF.getNumberElectrons(false);
00070 int nalpha = Input->WF.getNumberElectrons(true);
00071
00072
00073
00074
00075 Array2D<int> ab_count(natoms,3);
00076 ab_count = assign_electrons_to_nuclei();
00077
00078
00079
00080 int icharge_init, icharge, kcharge, partner, partnercharge, give, get;
00081
00082 for (int i=0; i<natoms; i++)
00083 if (Input->Molecule.Z(i) != ab_count(i,0))
00084 {
00085 icharge_init = Input->Molecule.Z(i) - ab_count(i,0);
00086 for (int j=0; j<abs(icharge_init); j++)
00087 {
00088 icharge = Input->Molecule.Z(i) - ab_count(i,0);
00089 partner = -1;
00090 give = -1;
00091 get = -1;
00092 partnercharge = 0;
00093 for (int k=0; k<natoms; k++)
00094 {
00095 if (k != i)
00096 {
00097 kcharge = Input->Molecule.Z(k) - ab_count(k,0);
00098 if (icharge < 0 && kcharge >= icharge+2)
00099 {
00100 if (partner == -1)
00101 {
00102 partner = k;
00103 partnercharge = kcharge;
00104 }
00105 else if (kcharge > partnercharge)
00106 {
00107 partner = k;
00108 partnercharge = kcharge;
00109 }
00110 }
00111 else if (icharge > 0 && kcharge <= icharge-2)
00112 {
00113 if (partner == -1)
00114 {
00115 partner = k;
00116 partnercharge = kcharge;
00117 }
00118 else if (kcharge < partnercharge)
00119 {
00120 partner = k;
00121 partnercharge = kcharge;
00122 }
00123 }
00124 }
00125 }
00126 if (partner != -1)
00127 {
00128 if (icharge < partnercharge)
00129
00130 {
00131 give = i;
00132 get = partner;
00133 }
00134 else if (icharge > partnercharge)
00135
00136 {
00137 get = i;
00138 give = partner;
00139 }
00140 if (ab_count(give,1) == ab_count(give,2))
00141 {
00142 if (ab_count(get,1) <= ab_count(get,2))
00143 {
00144 ab_count(give,0) -= 1;
00145 ab_count(give,1) -= 1;
00146 ab_count(get,0) += 1;
00147 ab_count(get,1) += 1;
00148 }
00149 else if (ab_count(get,1) > ab_count(get,2))
00150 {
00151 ab_count(give,0) -= 1;
00152 ab_count(give,2) -= 1;
00153 ab_count(get,0) += 1;
00154 ab_count(get,2) += 1;
00155 }
00156 }
00157 else if (ab_count(give,1) > ab_count(give,2))
00158 {
00159 if (ab_count(get,1) <= ab_count(get,2))
00160 {
00161 ab_count(give,0) -= 1;
00162 ab_count(give,1) -= 1;
00163 ab_count(get,0) += 1;
00164 ab_count(get,1) += 1;
00165 }
00166 else if (ab_count(get,1) > ab_count(get,2))
00167
00168
00169 {
00170 for (int l=0; l<natoms; l++)
00171 if ( (l != give && l != get) &&
00172 (ab_count(l,1) <= ab_count(l,2)) )
00173 {
00174 ab_count(give,0) -= 1;
00175 ab_count(give,1) -= 1;
00176 ab_count(l,1) += 1;
00177 ab_count(l,2) -= 1;
00178 ab_count(get,0) += 1;
00179 ab_count(get,2) += 1;
00180 break;
00181 }
00182 }
00183 }
00184 else if (ab_count(give,1) < ab_count(give,2))
00185 {
00186 if (ab_count(get,1) >= ab_count(get,2))
00187 {
00188 ab_count(give,0) -= 1;
00189 ab_count(give,2) -= 1;
00190 ab_count(get,0) += 1;
00191 ab_count(get,2) += 1;
00192 }
00193 else if (ab_count(get,1) < ab_count(get,2))
00194
00195
00196 {
00197 for (int m=0; m<natoms; m++)
00198 if ( (m != give && m != get) &&
00199 (ab_count(m,1) >= ab_count(m,2)) )
00200 {
00201 ab_count(give,0) -= 1;
00202 ab_count(give,2) -= 1;
00203 ab_count(m,2) += 1;
00204 ab_count(m,1) -= 1;
00205 ab_count(get,0) += 1;
00206 ab_count(get,1) += 1;
00207 break;
00208 }
00209 }
00210 }
00211 }
00212 }
00213 }
00214
00215
00216
00217
00218
00219
00220
00221
00222 for (int i=0; i<natoms; i++)
00223 {
00224 if (Input->Molecule.Z(i) <= 2)
00225 {
00226
00227
00228
00229 if (ab_count(i,1) > 1)
00230 {
00231 int extra_alphas = ab_count(i,1)-1;
00232 for (int p=0; p<extra_alphas; p++)
00233 for (int q=0; q<natoms; q++)
00234 if (q != i && ab_count(q,1) <= ab_count(q,2))
00235 {
00236 ab_count(i,1) -= 1;
00237 ab_count(q,1) += 1;
00238 ab_count(i,2) += 1;
00239 ab_count(q,2) -= 1;
00240 break;
00241 }
00242 }
00243 if (ab_count(i,2) > 1)
00244 {
00245 int extra_betas = ab_count(i,2)-1;
00246 for (int r=0; r<extra_betas; r++)
00247 for (int s=0; s<natoms; s++)
00248 if (s != i && ab_count(s,1) >= ab_count(s,2))
00249 {
00250 ab_count(i,2) -= 1;
00251 ab_count(i,1) += 1;
00252 ab_count(s,2) += 1;
00253 ab_count(s,1) -= 1;
00254 break;
00255 }
00256 }
00257 }
00258 if (Input->Molecule.Z(i) <= 10 && Input->Molecule.Z(i) > 2)
00259 {
00260
00261
00262 if (ab_count(i,1) > 5)
00263 {
00264 int extra_alphas = ab_count(i,1)-5;
00265 for (int j=0; j<extra_alphas; j++)
00266 for (int k=0; k<natoms; k++)
00267 if (k != i && ab_count(k,1) <= ab_count(k,2))
00268 {
00269 ab_count(i,1) -= 1;
00270 ab_count(k,1) += 1;
00271 ab_count(i,2) += 1;
00272 ab_count(k,2) -= 1;
00273 break;
00274 }
00275 }
00276 if (ab_count(i,1) == 0)
00277 {
00278
00279
00280
00281 for (int j=0; j<natoms; j++)
00282 if (j != i && ab_count(j,1) >= ab_count(j,2))
00283 {
00284 ab_count(i,1) += 1;
00285 ab_count(j,1) -= 1;
00286 ab_count(i,2) -= 1;
00287 ab_count(j,2) += 1;
00288 break;
00289 }
00290 }
00291 if (ab_count(i,2) > 5)
00292 {
00293 int extra_betas = ab_count(i,2)-5;
00294 for (int m=0; m<extra_betas; m++)
00295 for (int n=0; n<natoms; n++)
00296 if (n != i && ab_count(n,1) >= ab_count(n,2))
00297 {
00298 ab_count(i,2) -= 1;
00299 ab_count(n,2) += 1;
00300 ab_count(i,1) += 1;
00301 ab_count(n,1) -= 1;
00302 break;
00303 }
00304 }
00305 if (ab_count(i,2) == 0)
00306 {
00307 for (int j=0; j<natoms; j++)
00308 if (j != i && ab_count(j,2) >= ab_count(j,1))
00309 {
00310 ab_count(i,2) += 1;
00311 ab_count(j,2) -= 1;
00312 ab_count(i,1) -= 1;
00313 ab_count(j,1) += 1;
00314 break;
00315 }
00316 }
00317 }
00318 if (Input->Molecule.Z(i) <= 18 && Input->Molecule.Z(i) > 10)
00319 {
00320
00321
00322 if (ab_count(i,1) > 9)
00323 {
00324 int extra_alphas = ab_count(i,1)-9;
00325 for (int j=0; j<extra_alphas; j++)
00326 for (int k=0; k<natoms; k++)
00327 if (k != i && ab_count(k,1) <= ab_count(k,2))
00328 {
00329 ab_count(i,1) -= 1;
00330 ab_count(k,1) += 1;
00331 ab_count(i,2) += 1;
00332 ab_count(k,2) -= 1;
00333 break;
00334 }
00335 }
00336 if (ab_count(i,1) < 5)
00337 {
00338 int alphas_needed = 5-ab_count(i,1);
00339 for (int j=0; j<alphas_needed; j++)
00340 for (int k=0; k<natoms; k++)
00341 if (k != i && ab_count(k,1) >= ab_count(k,2))
00342 {
00343 ab_count(i,1) += 1;
00344 ab_count(k,1) -= 1;
00345 ab_count(i,2) -= 1;
00346 ab_count(k,2) += 1;
00347 break;
00348 }
00349 }
00350 if (ab_count(i,2) > 9)
00351 {
00352 int extra_betas = ab_count(i,2)-9;
00353 for (int m=0; m<extra_betas; m++)
00354 for (int n=0; n<natoms; n++)
00355 if (n != i && ab_count(n,1) >= ab_count(n,2))
00356 {
00357 ab_count(i,2) -= 1;
00358 ab_count(n,2) += 1;
00359 ab_count(i,1) += 1;
00360 ab_count(n,1) -= 1;
00361 break;
00362 }
00363 }
00364 if (ab_count(i,2) < 5)
00365 {
00366 int betas_needed = 5-ab_count(i,2);
00367 for (int j=0; j<betas_needed; j++)
00368 for (int k=0; k<natoms; k++)
00369 if (k != i && ab_count(k,2) >= ab_count(k,1))
00370 {
00371 ab_count(i,2) += 1;
00372 ab_count(k,2) -= 1;
00373 ab_count(i,1) -= 1;
00374 ab_count(k,1) += 1;
00375 break;
00376 }
00377 }
00378 }
00379 }
00380
00381
00382
00383 int check_elec = 0;
00384 int check_alpha = 0;
00385 int check_beta = 0;
00386
00387 for (int i=0; i<natoms; i++)
00388 {
00389 if ( (ab_count(i,1)+ab_count(i,2)) != ab_count(i,0) )
00390 {
00391 cerr << "Alpha and beta electrons do not add up for atom " << i;
00392 cerr << endl;
00393 exit(1);
00394 }
00395 check_elec += ab_count(i,0);
00396 check_alpha += ab_count(i,1);
00397 check_beta += ab_count(i,2);
00398 }
00399
00400 if (check_elec != nelectrons)
00401 {
00402 cerr << "Electron counting has gone bad." << endl;
00403 exit(1);
00404 }
00405
00406 if (check_alpha != nalpha)
00407 {
00408 cerr << "Alpha counting has gone bad." << endl;
00409 exit(1);
00410 }
00411
00412 if (check_beta != nbeta)
00413 {
00414 cerr << "Beta counting has gone bad." << endl;
00415 exit(1);
00416 }
00417
00418 int alpha_index = 0;
00419 int beta_index = 0;
00420
00421 Array2D<double> temp_coords;
00422 int n_e,n_a,n_b;
00423
00424
00425
00426
00427 Array2D<double> R(nelectrons,3);
00428
00429 for (int i=0; i<natoms; i++)
00430 {
00431 n_e = ab_count(i,0);
00432 n_a = ab_count(i,1);
00433 n_b = ab_count(i,2);
00434
00435 if (n_e > 0)
00436 {
00437 temp_coords.allocate(n_e,3);
00438 temp_coords = dist_center(Input->Molecule.Z(i),n_e,n_a,n_b);
00439
00440 for (int j=0; j<n_a; j++)
00441 {
00442 for (int k=0; k<3; k++)
00443 R(alpha_index,k) = temp_coords(j,k) + atom_centers(i,k);
00444 alpha_index++;
00445 }
00446
00447 for (int m=0; m<n_b; m++)
00448 {
00449 for (int n=0; n<3; n++)
00450 R(nalpha+beta_index,n)=temp_coords(n_a+m,n)+atom_centers(i,n);
00451 beta_index++;
00452 }
00453 }
00454 }
00455 return R;
00456 }
00457
00458 Array2D<int> QMCDansWalkerInitialization::assign_electrons_to_nuclei()
00459 {
00460 int Norbitals = Input->WF.getNumberOrbitals();
00461 int Nbasisfunc = Input->WF.getNumberBasisFunctions();
00462
00463 Array2D<qmcfloat> OrbitalScratch(Input->WF.OrbitalCoeffs);
00464
00465
00466
00467 for (int i=0; i<Norbitals; i++)
00468 for (int j=0; j<Nbasisfunc; j++)
00469 {
00470 OrbitalScratch(i,j) = OrbitalScratch(i,j)*OrbitalScratch(i,j);
00471 }
00472
00473
00474 double OrbitalSum;
00475
00476 for (int i=0; i<Norbitals; i++)
00477 {
00478 OrbitalSum = 0.0;
00479 for(int j=0; j<Nbasisfunc; j++)
00480 {
00481 OrbitalSum += OrbitalScratch(i,j);
00482 }
00483 for(int j=0; j<Nbasisfunc; j++)
00484 {
00485 OrbitalScratch(i,j) = OrbitalScratch(i,j)/OrbitalSum;
00486 }
00487 }
00488
00489
00490
00491
00492 int Natoms = Input->flags.Natoms;
00493
00494 Array1D<int> OrbPos(Nbasisfunc);
00495
00496 int i = 0;
00497 for (int j=0; j<Natoms; j++)
00498 for(int k=0; k<(Input->BF.getNumberBasisFunctions(j)); k++)
00499 {
00500 OrbPos(i) = j;
00501 i++;
00502 }
00503
00504
00505
00506 Array2D <int> atom_occ(Natoms,3);
00507 atom_occ = 0;
00508
00509 double sum = 0.0;
00510 double rv;
00511
00512
00513 rv = ran.unidev();
00514
00515 int determinant_index = 0;
00516 for (int i=0; i<Input->WF.getNumberDeterminants(); i++)
00517 {
00518 sum += Input->WF.CI_coeffs(i)*Input->WF.CI_coeffs(i);
00519 if (sum >= rv)
00520 {
00521 determinant_index = i;
00522 break;
00523 }
00524 }
00525
00526 for (int i=0; i<Norbitals; i++)
00527 {
00528 if (Input->WF.AlphaOccupation(determinant_index,i) != Input->WF.getUnusedIndicator())
00529 {
00530 sum = 0.0;
00531 rv = ran.unidev();
00532
00533 for (int j=0; j<Nbasisfunc; j++)
00534 {
00535 sum += OrbitalScratch(i,j);
00536 if (sum >= rv)
00537 {
00538 atom_occ(OrbPos(j),0) += 1;
00539 atom_occ(OrbPos(j),1) += 1;
00540 break;
00541 }
00542 }
00543 }
00544
00545 if (Input->WF.BetaOccupation(determinant_index,i) != Input->WF.getUnusedIndicator())
00546 {
00547 sum = 0.0;
00548 rv = ran.unidev();
00549
00550 for (int k=0; k<Nbasisfunc; k++)
00551 {
00552 sum += OrbitalScratch(i,k);
00553 if (sum >= rv)
00554 {
00555 atom_occ(OrbPos(k),0) += 1;
00556 atom_occ(OrbPos(k),2) += 1;
00557 break;
00558 }
00559 }
00560 }
00561 }
00562 return atom_occ;
00563 }
00564
00565 Array2D<double> QMCDansWalkerInitialization::
00566 dist_center(int atomic_charge, int n_e, int n_a, int n_b)
00567 {
00568 Array2D<double> e_locs(n_e,3);
00569 e_locs = 1e20;
00570
00571 if (n_e <= 2)
00572 e_locs = dist_energy_level(atomic_charge,1,n_a,n_b);
00573
00574 else if (n_e > 2 && n_e <= 10)
00575 {
00576 Array2D<double> level_1_of_2(2,3);
00577 level_1_of_2 = dist_energy_level(atomic_charge,1,1,1);
00578 for (int i=0; i<3; i++)
00579 {
00580 e_locs(0,i) = level_1_of_2(0,i);
00581 e_locs(n_a,i) = level_1_of_2(1,i);
00582 }
00583
00584 Array2D<double> level_2_of_2(n_e-2,3);
00585 level_2_of_2 = dist_energy_level(atomic_charge,2,n_a-1,n_b-1);
00586
00587 for (int j=0; j<n_a-1; j++)
00588 for (int k=0; k<3; k++)
00589 e_locs(1+j,k) = level_2_of_2(j,k);
00590
00591 for (int m=0; m<n_b-1; m++)
00592 for (int n=0; n<3; n++)
00593 e_locs(1+n_a+m,n) = level_2_of_2(n_a-1+m,n);
00594 }
00595
00596 else if (n_e > 10 && n_e <=18)
00597 {
00598 Array2D<double> level_1_of_3(2,3);
00599 level_1_of_3 = dist_energy_level(atomic_charge,1,1,1);
00600
00601 for (int i=0; i<3; i++)
00602 {
00603 e_locs(0,i) = level_1_of_3(0,i);
00604 e_locs(n_a,i) = level_1_of_3(1,i);
00605 }
00606
00607 Array2D<double> level_2_of_3(8,3);
00608 level_2_of_3 = dist_energy_level(atomic_charge,2,4,4);
00609
00610 for (int j=0; j<4; j++)
00611 for (int k=0; k<3; k++)
00612 {
00613 e_locs(1+j,k) = level_2_of_3(j,k);
00614 e_locs(n_a+1+j,k) = level_2_of_3(4+j,k);
00615 }
00616
00617 Array2D<double> level_3_of_3(n_e-10,3);
00618 level_3_of_3 = dist_energy_level(atomic_charge,3,n_a-5,n_b-5);
00619
00620 for (int j=0; j<n_a-5; j++)
00621 for (int k=0; k<3; k++)
00622 e_locs(5+j,k) = level_3_of_3(j,k);
00623
00624 for (int m=0; m<n_b-5; m++)
00625 for (int n=0; n<3; n++)
00626 e_locs(n_a+5+m,n) = level_3_of_3(n_a-5+m,n);
00627 }
00628 return e_locs;
00629 }
00630
00631 Array2D<double> QMCDansWalkerInitialization::
00632 dist_energy_level(int Z, int n, int nalpha, int nbeta)
00633 {
00634
00635
00636 Array1D<double> r_locs;
00637 r_locs = generateRadialDistances(Z,n,nalpha+nbeta);
00638
00639
00640
00641
00642
00643 int a_interval = 0;
00644 int b_interval = 0;
00645
00646 if (nalpha == 1)
00647 {
00648 if (nbeta == 0) a_interval = 0;
00649 else a_interval = 1;
00650 }
00651 else if (nalpha == 2) a_interval = 1;
00652 else if (nalpha == 3) a_interval = 5;
00653 else if (nalpha == 4) a_interval = 11;
00654 if (nbeta == 1)
00655 {
00656 if (nalpha == 0) b_interval = 0;
00657 else if (nalpha == 1) b_interval = 2;
00658 else b_interval = 3;
00659 }
00660 else if (nbeta == 2) b_interval = 3;
00661 else if (nbeta == 3) b_interval = 8;
00662 else if (nbeta == 4) b_interval = 15;
00663
00664 if (a_interval > 11 || a_interval < 0)
00665 {
00666 cerr << "Error in alpha interval." << endl;
00667 exit (1);
00668 }
00669 if (b_interval > 15 || b_interval < 0)
00670 {
00671 cerr << "Error in beta interval." << endl;
00672 exit (1);
00673 }
00674
00675 Array1D<double> a_phi(nalpha);
00676 Array1D<double> b_phi(nbeta);
00677 Array1D<double> a_theta(nalpha);
00678 Array1D<double> b_theta(nbeta);
00679
00680
00681
00682 for (int i=0; i<nalpha; i++)
00683 {
00684 a_phi(i) = generatePhiCoordinate(a_interval+i);
00685 a_theta(i) = generateThetaCoordinate(a_interval+i);
00686 }
00687
00688 for (int j=0; j<nbeta; j++)
00689 {
00690 b_phi(j) = generatePhiCoordinate(b_interval+j);
00691 b_theta(j) = generateThetaCoordinate(b_interval+j);
00692 }
00693
00694
00695
00696 Array2D<double> crds(nalpha+nbeta,3);
00697
00698 for (int i=0; i<nalpha; i++)
00699 {
00700 crds(i,0)=r_locs(i)*sin(a_theta(i))*cos(a_phi(i));
00701 crds(i,1)=r_locs(i)*sin(a_theta(i))*sin(a_phi(i));
00702 crds(i,2)=r_locs(i)*cos(a_theta(i));
00703 }
00704
00705 for (int j=0; j<nbeta; j++)
00706 {
00707 crds(nalpha+j,0)=r_locs(nalpha+j)*sin(b_theta(j))*cos(b_phi(j));
00708 crds(nalpha+j,1)=r_locs(nalpha+j)*sin(b_theta(j))*sin(b_phi(j));
00709 crds(nalpha+j,2)=r_locs(nalpha+j)*cos(b_theta(j));
00710 }
00711
00712
00713
00714
00715 double phi = ran.unidev()*2*PI;
00716 double theta = ran.sindev();
00717 double angle = ran.unidev()*2*PI;
00718
00719 Array1D<double> axis(3);
00720 axis(0) = sin(theta)*cos(phi);
00721 axis(1) = sin(theta)*sin(phi);
00722 axis(2) = cos(theta);
00723
00724 for (int i=0; i<(nalpha+nbeta); i++)
00725 {
00726 Array1D<double> temp_coords(3);
00727 for (int j=0; j<3; j++) temp_coords(j) = crds(i,j);
00728 temp_coords.rotate(axis,angle);
00729 for (int k=0; k<3; k++) crds(i,k) = temp_coords(k);
00730 }
00731 return crds;
00732 }
00733
00734 double QMCDansWalkerInitialization::generatePhiCoordinate(int index)
00735 {
00736
00737 if (index == 0 || index == 1 || index == 2 || index == 5)
00738 {
00739 return ran.unidev()*2*PI;
00740 }
00741 else
00742 {
00743
00744
00745 if (phiSplinesMade(index) == 0)
00746 {
00747
00748
00749 if (index == 15 || index == 12)
00750 {
00751 Array1D<double> phi_array;
00752 phi_array = AngleDistributions::getPhiArray(12);
00753 double derivative=(phi_array(1)+phi_array(20)-phi_array(19))*10;
00754 phiSplines(12).initializeWithFunctionValues(x_array,phi_array,\
00755 derivative,derivative);
00756 phiSplines(15) = phiSplines(12);
00757 phiSplinesMade(12) = 1;
00758 phiSplinesMade(15) = 1;
00759 }
00760 else if (index == 16 || index == 11)
00761 {
00762 Array1D<double> phi_array;
00763 phi_array = AngleDistributions::getPhiArray(11);
00764 double derivative=(phi_array(1)+phi_array(20)-phi_array(19))*10;
00765 phiSplines(11).initializeWithFunctionValues(x_array,phi_array,\
00766 derivative,derivative);
00767 phiSplines(16) = phiSplines(11);
00768 phiSplinesMade(11) = 1;
00769 phiSplinesMade(16) = 1;
00770 }
00771 else if (index == 17 || index == 14)
00772 {
00773 Array1D<double> phi_array;
00774 phi_array = AngleDistributions::getPhiArray(14);
00775 double derivative=(phi_array(1)+phi_array(20)-phi_array(19))*10;
00776 phiSplines(14).initializeWithFunctionValues(x_array,phi_array,\
00777 derivative,derivative);
00778 phiSplines(17) = phiSplines(14);
00779 phiSplinesMade(14) = 1;
00780 phiSplinesMade(17) = 1;
00781 }
00782 else if (index == 18 || index == 13)
00783 {
00784 Array1D<double> phi_array;
00785 phi_array = AngleDistributions::getPhiArray(13);
00786 double derivative=(phi_array(1)+phi_array(20)-phi_array(19))*10;
00787 phiSplines(13).initializeWithFunctionValues(x_array,phi_array,\
00788 derivative,derivative);
00789 phiSplines(18) = phiSplines(13);
00790 phiSplinesMade(13) = 1;
00791 phiSplinesMade(18) = 1;
00792 }
00793 else
00794 {
00795 Array1D<double> phi_array;
00796 phi_array = AngleDistributions::getPhiArray(index);
00797 double derivative=(phi_array(1)+phi_array(20)-phi_array(19))*10;
00798 phiSplines(index).initializeWithFunctionValues(x_array,\
00799 phi_array,derivative,derivative);
00800 phiSplinesMade(index) = 1;
00801 }
00802 }
00803 phiSplines(index).evaluate(ran.unidev());
00804 return phiSplines(index).getFunctionValue();
00805 }
00806 }
00807
00808 double QMCDansWalkerInitialization::generateThetaCoordinate(int index)
00809 {
00810
00811 if (index == 0)
00812 {
00813 return ran.sindev();
00814 }
00815 else
00816 {
00817
00818 if (thetaSplinesMade(index) == 0)
00819 {
00820
00821
00822 if (index == 3 || index == 4)
00823 {
00824 Array1D<double> th_array;
00825 th_array = AngleDistributions::getThetaArray(3);
00826 double derivative = (th_array(1)+th_array(20)-th_array(19))*10;
00827 thetaSplines(3).initializeWithFunctionValues(x_array,th_array,\
00828 derivative,derivative);
00829 thetaSplines(4) = thetaSplines(3);
00830 thetaSplinesMade(3) = 1;
00831 thetaSplinesMade(4) = 1;
00832 }
00833 else if (index == 6 || index == 7)
00834 {
00835 Array1D<double> th_array;
00836 th_array = AngleDistributions::getThetaArray(6);
00837 double derivative = (th_array(1)+th_array(20)-th_array(19))*10;
00838 thetaSplines(6).initializeWithFunctionValues(x_array,th_array,\
00839 derivative,derivative);
00840 thetaSplines(7) = thetaSplines(6);
00841 thetaSplinesMade(6) = 1;
00842 thetaSplinesMade(7) = 1;
00843 }
00844 else if (index == 8 || index == 9 || index == 10)
00845 {
00846 Array1D<double> th_array = AngleDistributions::getThetaArray(8);
00847 double derivative = (th_array(1)+th_array(20)-th_array(19))*10;
00848 thetaSplines(8).initializeWithFunctionValues(x_array,th_array,\
00849 derivative,derivative);
00850 thetaSplines(9) = thetaSplines(8);
00851 thetaSplines(10) = thetaSplines(8);
00852 thetaSplinesMade(8) = 1;
00853 thetaSplinesMade(9) = 1;
00854 thetaSplinesMade(10) = 1;
00855 }
00856 else if (index == 11 || index == 12 || index == 17 || index == 18)
00857 {
00858 Array1D<double> th_array;
00859 th_array = AngleDistributions::getThetaArray(11);
00860 double derivative = (th_array(1)+th_array(20)-th_array(19))*10;
00861 thetaSplines(11).initializeWithFunctionValues(x_array,th_array,\
00862 derivative,derivative);
00863 thetaSplines(12) = thetaSplines(11);
00864 thetaSplines(17) = thetaSplines(11);
00865 thetaSplines(18) = thetaSplines(11);
00866 thetaSplinesMade(11) = 1;
00867 thetaSplinesMade(12) = 1;
00868 thetaSplinesMade(17) = 1;
00869 thetaSplinesMade(18) = 1;
00870 }
00871 else if (index == 13 || index == 14 || index == 15 || index == 16)
00872 {
00873 Array1D<double> th_array;
00874 th_array = AngleDistributions::getThetaArray(13);
00875 double derivative = (th_array(1)+th_array(20)-th_array(19))*10;
00876 thetaSplines(13).initializeWithFunctionValues(x_array,th_array,\
00877 derivative,derivative);
00878 thetaSplines(14) = thetaSplines(13);
00879 thetaSplines(15) = thetaSplines(13);
00880 thetaSplines(16) = thetaSplines(13);
00881 thetaSplinesMade(13) = 1;
00882 thetaSplinesMade(14) = 1;
00883 thetaSplinesMade(15) = 1;
00884 thetaSplinesMade(16) = 1;
00885 }
00886 else
00887 {
00888 Array1D<double> th_array;
00889 th_array = AngleDistributions::getThetaArray(index);
00890 double derivative = (th_array(1)+th_array(20)-th_array(19))*10;
00891 thetaSplines(index).initializeWithFunctionValues(x_array,
00892 th_array,derivative,derivative);
00893 thetaSplinesMade(index) = 1;
00894 }
00895 }
00896 thetaSplines(index).evaluate(ran.unidev());
00897 return thetaSplines(index).getFunctionValue();
00898 }
00899 }
00900
00901 Array1D<double> QMCDansWalkerInitialization::\
00902 generateRadialDistances(int Z, int n, int nelecs)
00903 {
00904 int atomicNumberIndex = Z-1;
00905 int energyLevelIndex = n-1;
00906 if (radialSplinesMade(atomicNumberIndex,energyLevelIndex) == 0)
00907 {
00908 Array1D<double> r_array;
00909 r_array = RadialDistributions::getRadialArray(Z,n);
00910 double derivativeAtZero = r_array(1)*20;
00911 double derivativeAtOne = (r_array(20) - r_array(19))*20;
00912 radialSplines(atomicNumberIndex,energyLevelIndex).\
00913 initializeWithFunctionValues\
00914 (x_array,r_array,derivativeAtZero,derivativeAtOne);
00915 radialSplinesMade(atomicNumberIndex,energyLevelIndex) = 1;
00916 }
00917 Array1D<double> r_locs(nelecs);
00918 for (int i=0; i<nelecs; i++)
00919 {
00920 radialSplines(atomicNumberIndex,energyLevelIndex).evaluate\
00921 (ran.unidev());
00922 r_locs(i) = radialSplines(atomicNumberIndex,energyLevelIndex).\
00923 getFunctionValue();
00924 }
00925 return r_locs;
00926 }
00927
00928 # undef PI