00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "QMCJastrowParameters.h"
00034 #include "QMCInput.h"
00035
00036 void QMCJastrowParameters::operator=( const QMCJastrowParameters & rhs )
00037 {
00038 NumberOfEEParameters = rhs.NumberOfEEParameters;
00039 NumberOfEupEdnParameters = rhs.NumberOfEupEdnParameters;
00040 NumberOfEupEupParameters = rhs.NumberOfEupEupParameters;
00041 NumberOfEdnEdnParameters = rhs.NumberOfEdnEdnParameters;
00042 NumberOfNEParameters = rhs.NumberOfNEParameters;
00043 NumberOfNEupParameters = rhs.NumberOfNEupParameters;
00044
00045 EupNuclear = rhs.EupNuclear;
00046 EdnNuclear = rhs.EdnNuclear;
00047 EupEdn = rhs.EupEdn;
00048 EupEup = rhs.EupEup;
00049 EdnEdn = rhs.EdnEdn;
00050
00051 if (globalInput.flags.use_three_body_jastrow == 1)
00052 {
00053 NumberOfNEupEdnParameters = rhs.NumberOfNEupEdnParameters;
00054 NumberOfNEupEupParameters = rhs.NumberOfNEupEupParameters;
00055 NumberOfNEdnEdnParameters = rhs.NumberOfNEdnEdnParameters;
00056
00057 EupEdnNuclear = rhs.EupEdnNuclear;
00058 EupEupNuclear = rhs.EupEupNuclear;
00059 EdnEdnNuclear = rhs.EdnEdnNuclear;
00060 }
00061
00062 EquivalentElectronUpDownParams = rhs.EquivalentElectronUpDownParams;
00063 NucleiTypes = rhs.NucleiTypes;
00064 NumberOfElectronsUp = rhs.NumberOfElectronsUp;
00065 NumberOfElectronsDown = rhs.NumberOfElectronsDown;
00066 }
00067
00068 void QMCJastrowParameters::print(ostream & strm)
00069 {
00070 if(globalInput.flags.set_debug == 1)
00071 return;
00072
00073 if(EupEdn.isUsed())
00074 {
00075 strm << "EupEdn:" << endl;
00076 EupEdn.getCorrelationFunction()->print(strm);
00077 strm << endl;
00078 }
00079
00080 if(EupEup.isUsed())
00081 {
00082 strm << "EupEup:" << endl;
00083 EupEup.getCorrelationFunction()->print(strm);
00084 strm << endl;
00085 }
00086 if(!EquivalentElectronUpDownParams &&
00087 EdnEdn.isUsed())
00088 {
00089 strm << "EdnEdn:" << endl;
00090 EdnEdn.getCorrelationFunction()->print(strm);
00091 strm << endl;
00092 }
00093
00094 for(int i=0; i<EupNuclear.dim1(); i++)
00095 {
00096 if(EupNuclear(i).isUsed())
00097 {
00098 strm << "EupNuclear(" << NucleiTypes(i) << "):"
00099 << endl;
00100 EupNuclear(i).getCorrelationFunction()->print(strm);
00101 strm << endl;
00102 }
00103
00104 if(!EquivalentElectronUpDownParams &&
00105 EdnNuclear(i).isUsed())
00106 {
00107 strm << "EdnNuclear(" << NucleiTypes(i) << "):"
00108 << endl;
00109 EdnNuclear(i).getCorrelationFunction()->print(strm);
00110 strm << endl;
00111 }
00112 }
00113
00114 for(int i=0; i<EupEdnNuclear.dim1(); i++)
00115 {
00116 if(EupEdnNuclear(i).isUsed())
00117 {
00118 strm << "EupEdnNuclear(" << NucleiTypes(i) << "):" << endl
00119 << " Total Parameters = " << EupEdnNuclear(i).getNumberOfTotalParameters() << endl
00120 << " Free Parameters = " << EupEdnNuclear(i).getNumberOfFreeParameters()
00121 << endl;
00122 EupEdnNuclear(i).getThreeBodyCorrelationFunction()->print(strm);
00123 strm << endl;
00124 }
00125
00126 if(globalInput.flags.link_NEE_Jastrows < 2 &&
00127 EupEupNuclear(i).isUsed())
00128 {
00129 strm << "EupEupNuclear(" << NucleiTypes(i) << "):" << endl
00130 << " Total Parameters = " << EupEupNuclear(i).getNumberOfTotalParameters() << endl
00131 << " Free Parameters = " << EupEupNuclear(i).getNumberOfFreeParameters()
00132 << endl;
00133 EupEupNuclear(i).getThreeBodyCorrelationFunction()->print(strm);
00134 strm << endl;
00135 }
00136
00137 if(globalInput.flags.link_NEE_Jastrows < 1 &&
00138 EdnEdnNuclear(i).isUsed())
00139 {
00140 strm << "EdnEdnNuclear(" << NucleiTypes(i) << "):" << endl
00141 << " Total Parameters = " << EdnEdnNuclear(i).getNumberOfTotalParameters() << endl
00142 << " Free Parameters = " << EdnEdnNuclear(i).getNumberOfFreeParameters()
00143 << endl;
00144 EdnEdnNuclear(i).getThreeBodyCorrelationFunction()->print(strm);
00145 strm << endl;
00146 }
00147 }
00148 }
00149
00150 void QMCJastrowParameters::setJWParameters(Array1D<double> & params, int shift)
00151 {
00152 int Counter = 0;
00153 int CurrentNumberOfParams = 0;
00154 Array1D<double> temp;
00155
00156 if( EquivalentElectronUpDownParams )
00157 {
00158
00159 if(getNumberEEParameters() > 0)
00160 {
00161 if( NumberOfElectronsUp > 0 && NumberOfElectronsDown > 0 )
00162 {
00163 CurrentNumberOfParams = EupEdn.getTotalNumberOfParameters();
00164
00165 temp.allocate( CurrentNumberOfParams );
00166
00167 for(int i=0; i<temp.dim1(); i++)
00168 {
00169 temp(i) = params(Counter + shift);
00170 Counter++;
00171 }
00172
00173 EupEdn.setParameters( temp );
00174 }
00175
00176
00177
00178 if( NumberOfElectronsUp > 1 )
00179 {
00180 CurrentNumberOfParams = EupEup.getTotalNumberOfParameters();
00181
00182 temp.allocate(CurrentNumberOfParams);
00183
00184 for(int i=0; i<temp.dim1(); i++)
00185 {
00186 temp(i) = params(Counter + shift);
00187 Counter++;
00188 }
00189
00190 EupEup.setParameters( temp );
00191 }
00192 }
00193
00194
00195 if(getNumberNEParameters() > 0)
00196 {
00197 for(int i=0; i<EupNuclear.dim1(); i++)
00198 {
00199 CurrentNumberOfParams =
00200 EupNuclear(i).getTotalNumberOfParameters();
00201
00202 temp.allocate(CurrentNumberOfParams);
00203
00204 for(int j=0; j<temp.dim1(); j++)
00205 {
00206 temp(j) = params(Counter + shift);
00207 Counter++;
00208 }
00209
00210 EupNuclear(i).setParameters( temp );
00211 }
00212 }
00213
00214
00215
00216 if( NumberOfElectronsDown > 1 )
00217 {
00218 EdnEdn = EupEup;
00219 EdnEdn.setParticle1Type("Electron_down");
00220 EdnEdn.setParticle2Type("Electron_down");
00221 }
00222
00223 if( NumberOfElectronsDown > 0 )
00224 {
00225 EdnNuclear = EupNuclear;
00226
00227 for(int i=0; i<EdnNuclear.dim1(); i++)
00228 EdnNuclear(i).setParticle1Type("Electron_down");
00229 }
00230 }
00231 else
00232 {
00233
00234 if(getNumberEEParameters() > 0)
00235 {
00236 if( NumberOfElectronsUp > 0 && NumberOfElectronsDown > 0 )
00237 {
00238 CurrentNumberOfParams = EupEdn.getTotalNumberOfParameters();
00239
00240 temp.allocate( CurrentNumberOfParams );
00241
00242 for(int i=0; i<temp.dim1(); i++)
00243 {
00244 temp(i) = params(Counter + shift);
00245 Counter++;
00246 }
00247
00248 EupEdn.setParameters( temp );
00249 }
00250
00251
00252
00253 if( NumberOfElectronsUp > 1 )
00254 {
00255 CurrentNumberOfParams = EupEup.getTotalNumberOfParameters();
00256
00257 temp.allocate(CurrentNumberOfParams);
00258
00259 for(int i=0; i<temp.dim1(); i++)
00260 {
00261 temp(i) = params(Counter + shift);
00262 Counter++;
00263 }
00264
00265 EupEup.setParameters( temp );
00266 }
00267
00268
00269
00270 if( NumberOfElectronsDown > 1 )
00271 {
00272 CurrentNumberOfParams = EdnEdn.getTotalNumberOfParameters();
00273
00274 temp.allocate(CurrentNumberOfParams);
00275
00276 for(int i=0; i<temp.dim1(); i++)
00277 {
00278 temp(i) = params(Counter + shift);
00279 Counter++;
00280 }
00281
00282 EdnEdn.setParameters( temp );
00283 }
00284 }
00285
00286
00287 if(getNumberNEParameters() > 0)
00288 {
00289 for(int i=0; i<EupNuclear.dim1(); i++)
00290 {
00291 CurrentNumberOfParams =
00292 EupNuclear(i).getTotalNumberOfParameters();
00293
00294 temp.allocate(CurrentNumberOfParams);
00295
00296 for(int j=0; j<temp.dim1(); j++)
00297 {
00298 temp(j) = params(Counter + shift);
00299 Counter++;
00300 }
00301
00302 EupNuclear(i).setParameters( temp );
00303 }
00304
00305
00306
00307 if( NumberOfElectronsDown > 0 )
00308 {
00309 for(int i=0; i<EdnNuclear.dim1(); i++)
00310 {
00311 CurrentNumberOfParams =
00312 EdnNuclear(i).getTotalNumberOfParameters();
00313
00314 temp.allocate(CurrentNumberOfParams);
00315
00316 for(int j=0; j<temp.dim1(); j++)
00317 {
00318 temp(j) = params(Counter + shift);
00319 Counter++;
00320 }
00321
00322 EdnNuclear(i).setParameters( temp );
00323 }
00324 }
00325 }
00326 }
00327
00328
00329 if (globalInput.flags.use_three_body_jastrow == 1 &&
00330 globalInput.flags.optimize_NEE_Jastrows == 1)
00331 {
00332 for (int nuc=0; nuc<EupEdnNuclear.dim1(); nuc++)
00333 {
00334 if (NumberOfElectronsUp > 0 && NumberOfElectronsDown > 0)
00335 {
00336 CurrentNumberOfParams =
00337 EupEdnNuclear(nuc).getNumberOfFreeParameters();
00338
00339 temp.allocate(CurrentNumberOfParams);
00340
00341 for (int j=0; j<temp.dim1(); j++)
00342 {
00343 temp(j) = params(Counter + shift);
00344 Counter++;
00345 }
00346
00347 EupEdnNuclear(nuc).setFreeParameters( temp );
00348 }
00349
00350
00351 if (NumberOfElectronsUp > 1)
00352 {
00353 if(globalInput.flags.link_NEE_Jastrows < 2)
00354 {
00355 CurrentNumberOfParams =
00356 EupEupNuclear(nuc).getNumberOfFreeParameters();
00357
00358 temp.allocate(CurrentNumberOfParams);
00359
00360 for (int j=0; j<temp.dim1(); j++)
00361 {
00362 temp(j) = params(Counter + shift);
00363 Counter++;
00364 }
00365
00366 EupEupNuclear(nuc).setFreeParameters( temp );
00367 }
00368 else
00369 {
00370 EupEupNuclear = EupEupNuclear;
00371 for (int i=0; i<EdnEdnNuclear.dim1(); i++)
00372 {
00373 EupEupNuclear(i).setParticle2Type("Electron_up");
00374 EupEupNuclear(i).setParticle3Type("Electron_up");
00375 }
00376 }
00377 }
00378
00379
00380 if(NumberOfElectronsDown > 1)
00381 {
00382 if(globalInput.flags.link_NEE_Jastrows < 1)
00383 {
00384 CurrentNumberOfParams =
00385 EdnEdnNuclear(nuc).getNumberOfFreeParameters();
00386
00387 temp.allocate(CurrentNumberOfParams);
00388
00389 for (int j=0; j<temp.dim1(); j++)
00390 {
00391 temp(j) = params(Counter + shift);
00392 Counter++;
00393 }
00394
00395 EdnEdnNuclear(nuc).setFreeParameters( temp );
00396 }
00397 else
00398 {
00399 EdnEdnNuclear = EupEupNuclear;
00400 for (int i=0; i<EdnEdnNuclear.dim1(); i++)
00401 {
00402 EdnEdnNuclear(i).setParticle2Type("Electron_down");
00403 EdnEdnNuclear(i).setParticle3Type("Electron_down");
00404 }
00405 }
00406 }
00407 }
00408 }
00409 }
00410
00411 int QMCJastrowParameters::getNumberJWParameters()
00412 {
00413 return
00414 getNumberEEParameters() +
00415 getNumberNEParameters() +
00416 getNumberNEupEdnParameters() +
00417 getNumberNEupEupParameters() +
00418 getNumberNEdnEdnParameters();
00419 }
00420
00421 int QMCJastrowParameters::getNumberEEParameters()
00422 {
00423 if(globalInput.flags.optimize_EE_Jastrows == 0)
00424 return 0;
00425 return NumberOfEEParameters;
00426 }
00427
00428 int QMCJastrowParameters::getNumberEupEdnParameters()
00429 {
00430 if(globalInput.flags.optimize_EE_Jastrows == 0)
00431 return 0;
00432 return NumberOfEupEdnParameters;
00433 }
00434
00435 int QMCJastrowParameters::getNumberEupEupParameters()
00436 {
00437 if(globalInput.flags.optimize_EE_Jastrows == 0)
00438 return 0;
00439 return NumberOfEupEupParameters;
00440 }
00441
00442 int QMCJastrowParameters::getNumberEdnEdnParameters()
00443 {
00444 if(globalInput.flags.optimize_EE_Jastrows == 0 ||
00445 EquivalentElectronUpDownParams)
00446 return 0;
00447 return NumberOfEdnEdnParameters;
00448 }
00449
00450 int QMCJastrowParameters::getNumberNEParameters()
00451 {
00452 if(globalInput.flags.optimize_EN_Jastrows == 0)
00453 return 0;
00454 return NumberOfNEParameters;
00455 }
00456
00457 int QMCJastrowParameters::getNumberNEupParameters()
00458 {
00459 return NumberOfNEupParameters;
00460 }
00461
00462 int QMCJastrowParameters::getNumberNEupEdnParameters()
00463 {
00464 if(globalInput.flags.optimize_NEE_Jastrows == 0)
00465 return 0;
00466 return NumberOfNEupEdnParameters;
00467 }
00468
00469 int QMCJastrowParameters::getNumberNEupEupParameters()
00470 {
00471 if(globalInput.flags.optimize_NEE_Jastrows == 0 ||
00472 globalInput.flags.link_NEE_Jastrows > 1)
00473 return 0;
00474 return NumberOfNEupEupParameters;
00475 }
00476
00477 int QMCJastrowParameters::getNumberNEdnEdnParameters()
00478 {
00479 if(globalInput.flags.optimize_NEE_Jastrows == 0 ||
00480 globalInput.flags.link_NEE_Jastrows > 0)
00481 return 0;
00482 return NumberOfNEdnEdnParameters;
00483 }
00484
00485 Array1D<double> QMCJastrowParameters::getJWParameters()
00486 {
00487 Array1D<double> params(getNumberJWParameters());
00488 getJWParameters(params,0);
00489 return params;
00490 }
00491
00492 void QMCJastrowParameters::getJWParameters(Array1D<double> & params, int shift)
00493 {
00494 int Counter = 0;
00495 Array1D<double> temp;
00496
00497 if( EquivalentElectronUpDownParams )
00498 {
00499
00500 if(getNumberEEParameters() > 0)
00501 {
00502 if( NumberOfElectronsUp > 0 && NumberOfElectronsDown > 0 )
00503 {
00504 temp = EupEdn.getParameters();
00505
00506 for(int i=0; i<temp.dim1(); i++)
00507 {
00508 params(Counter + shift) = temp(i);
00509 Counter++;
00510 }
00511 }
00512
00513
00514
00515 if( NumberOfElectronsUp > 1 )
00516 {
00517 temp = EupEup.getParameters();
00518
00519 for(int i=0; i<temp.dim1(); i++)
00520 {
00521 params(Counter + shift) = temp(i);
00522 Counter++;
00523 }
00524 }
00525 }
00526
00527
00528
00529 if(getNumberNEParameters() > 0)
00530 for(int i=0; i<EupNuclear.dim1(); i++)
00531 {
00532 temp = EupNuclear(i).getParameters();
00533
00534 for(int j=0; j<temp.dim1(); j++)
00535 {
00536 params(Counter + shift) = temp(j);
00537 Counter++;
00538 }
00539 }
00540 }
00541 else
00542 {
00543
00544 if(getNumberEEParameters() > 0)
00545 {
00546 if( NumberOfElectronsUp > 0 && NumberOfElectronsDown > 0 )
00547 {
00548 temp = EupEdn.getParameters();
00549
00550 for(int i=0; i<temp.dim1(); i++)
00551 {
00552 params(Counter + shift) = temp(i);
00553 Counter++;
00554 }
00555 }
00556
00557
00558
00559 if( NumberOfElectronsUp > 1 )
00560 {
00561 temp = EupEup.getParameters();
00562
00563 for(int i=0; i<temp.dim1(); i++)
00564 {
00565 params(Counter + shift) = temp(i);
00566 Counter++;
00567 }
00568 }
00569
00570
00571
00572 if( NumberOfElectronsDown > 1 )
00573 {
00574 temp = EdnEdn.getParameters();
00575
00576 for(int i=0; i<temp.dim1(); i++)
00577 {
00578 params(Counter + shift) = temp(i);
00579 Counter++;
00580 }
00581 }
00582 }
00583
00584
00585 if(getNumberNEParameters() > 0)
00586 {
00587 for(int i=0; i<EupNuclear.dim1(); i++)
00588 {
00589 temp = EupNuclear(i).getParameters();
00590
00591 for(int j=0; j<temp.dim1(); j++)
00592 {
00593 params(Counter + shift) = temp(j);
00594 Counter++;
00595 }
00596 }
00597
00598
00599
00600 if( NumberOfElectronsDown > 0 )
00601 {
00602 for(int i=0; i<EdnNuclear.dim1(); i++)
00603 {
00604 temp = EdnNuclear(i).getParameters();
00605
00606 for(int j=0; j<temp.dim1(); j++)
00607 {
00608 params(Counter + shift) = temp(j);
00609 Counter++;
00610 }
00611 }
00612 }
00613 }
00614 }
00615
00616 if (globalInput.flags.optimize_NEE_Jastrows == 1)
00617 {
00618 for (int i=0; i<EupEdnNuclear.dim1(); i++)
00619 {
00620 if (NumberOfElectronsUp > 0 && NumberOfElectronsDown > 0)
00621 {
00622 temp = EupEdnNuclear(i).getFreeParameters();
00623
00624 for (int j=0; j<temp.dim1(); j++)
00625 {
00626 params(Counter + shift) = temp(j);
00627 Counter++;
00628 }
00629 }
00630
00631 if(globalInput.flags.link_NEE_Jastrows < 2 && NumberOfElectronsUp > 1)
00632 {
00633 temp = EupEupNuclear(i).getFreeParameters();
00634
00635 for (int j=0; j<temp.dim1(); j++)
00636 {
00637 params(Counter + shift) = temp(j);
00638 Counter++;
00639 }
00640 }
00641
00642 if(globalInput.flags.link_NEE_Jastrows < 1 && NumberOfElectronsDown > 1)
00643 {
00644 temp = EdnEdnNuclear(i).getFreeParameters();
00645
00646 for (int j=0; j<temp.dim1(); j++)
00647 {
00648 params(Counter + shift) = temp(j);
00649 Counter++;
00650 }
00651 }
00652 }
00653 }
00654 }
00655
00656 Array1D<Complex> QMCJastrowParameters::getPoles()
00657 {
00658 list<Complex> allPoles;
00659
00660 if( NumberOfElectronsUp > 1 )
00661 {
00662
00663
00664 Array1D<Complex> poles;
00665 try {
00666 poles = EupEup.getPoles();
00667 }
00668
00669 catch(Exception e){
00670 cout << "Exception: EupEup " << e.getMessage() << endl;
00671 }
00672
00673 for(int i=0; i<poles.dim1(); i++)
00674 {
00675 allPoles.push_back(poles(i));
00676 }
00677 }
00678
00679 if( NumberOfElectronsDown > 1 && !EquivalentElectronUpDownParams)
00680 {
00681
00682 Array1D<Complex> poles;
00683 try {
00684 poles = EdnEdn.getPoles();
00685 }
00686
00687 catch(Exception e){
00688 cout << "Exception: EdnEdn " << e.getMessage() << endl;
00689 }
00690
00691 for(int i=0; i<poles.dim1(); i++)
00692 {
00693 allPoles.push_back(poles(i));
00694 }
00695 }
00696
00697 if( NumberOfElectronsUp > 0 && NumberOfElectronsDown > 0 )
00698 {
00699
00700 Array1D<Complex> poles;
00701 try {
00702 poles = EupEdn.getPoles();
00703 }
00704
00705 catch(Exception e){
00706 cout << "Exception: EupEdn " << e.getMessage() << endl;
00707 }
00708
00709 for(int i=0; i<poles.dim1(); i++)
00710 {
00711 allPoles.push_back(poles(i));
00712 }
00713 }
00714
00715 for(int i=0; i<EupNuclear.dim1(); i++)
00716 {
00717
00718 Array1D<Complex> poles;
00719 try {
00720 poles = EupNuclear(i).getPoles();
00721 }
00722
00723 catch(Exception e){
00724 cout << "Exception: EupNuclear(" << i << ") " << e.getMessage()
00725 << endl;
00726 }
00727
00728 for(int j=0; j<poles.dim1(); j++)
00729 {
00730 allPoles.push_back(poles(j));
00731 }
00732 }
00733
00734 if(!EquivalentElectronUpDownParams)
00735 for(int i=0; i<EdnNuclear.dim1(); i++)
00736 {
00737
00738 Array1D<Complex> poles;
00739 try {
00740 poles = EdnNuclear(i).getPoles();
00741 }
00742
00743 catch(Exception e){
00744 cout << "Exception: EdnNuclear(" << i << ") " << e.getMessage()
00745 << endl;
00746 }
00747
00748 for(int j=0; j<poles.dim1(); j++)
00749 {
00750 allPoles.push_back(poles(j));
00751 }
00752 }
00753
00754
00755 Array1D<Complex> results( (int)allPoles.size() );
00756
00757 int index = 0;
00758 for(list<Complex>::iterator it=allPoles.begin(); it!=allPoles.end(); ++it)
00759 {
00760 results(index) = *it;
00761 index++;
00762 }
00763
00764 return results;
00765 }
00766
00767 double QMCJastrowParameters::calculate_penalty_function()
00768 {
00769 Array1D<Complex> poles = getPoles();
00770 return calculate_penalty_function(poles);
00771 }
00772
00773
00774 double QMCJastrowParameters::calculate_penalty_function(
00775 Array1D<Complex> & poles)
00776 {
00777 double penalty = 0.0;
00778
00779 for(int i=0; i<poles.dim1(); i++)
00780 {
00781
00782 double distance = 0.0;
00783
00784 if( poles(i).real() > 0 )
00785 distance = fabs(poles(i).imaginary());
00786 else
00787 distance = poles(i).abs();
00788
00789 if(distance <= 0)
00790 {
00791 cerr << "Warning: distance from real axis = " << distance << " in calculate_penalty_function, can\'t take log" << endl;
00792 cerr << " poles(" << i << ") = " << poles(i) << endl;
00793 if(poles(i).real() > 50.0)
00794 penalty = 10;
00795 else
00796 penalty = 1e100;
00797 cerr << " penalty will be set to " << penalty << endl;
00798 cerr.flush();
00799 }
00800 else
00801 {
00802
00803
00804
00805
00806
00807 penalty -= log( distance );
00808 }
00809 }
00810
00811 return penalty;
00812 }
00813
00814 void QMCJastrowParameters::read(Array1D<string> & nucleitypes,
00815 bool linkparams, bool nucCuspReplacement,
00816 int nelup, int neldn, string runfile)
00817 {
00818
00819
00820 EquivalentElectronUpDownParams = linkparams;
00821
00822
00823 NucleiTypes = nucleitypes;
00824
00825
00826 NumberOfElectronsUp = nelup;
00827 NumberOfElectronsDown = neldn;
00828
00829 if( NumberOfElectronsDown > NumberOfElectronsUp )
00830 {
00831 cerr << "ERROR: In QMCJastrowParameters::read the number of down "
00832 << "electrons is greater than the number of up electrons. The "
00833 << "opposite is assumed." << endl;
00834 exit(0);
00835 }
00836
00837
00838
00839 ifstream file( runfile.c_str() );
00840
00841 if( !file )
00842 {
00843 cerr << "ERROR: Could not open " << runfile << "!" << endl;
00844 exit(0);
00845 }
00846
00847 string temp;
00848 file >> temp;
00849
00850 while( temp != "&Jastrow" )
00851 {
00852 file >> temp;
00853
00854 if( file.eof() )
00855 {
00856 cerr << "ERROR: No Jastrow secton found in " << runfile << "!"
00857 << endl;
00858 exit(0);
00859 }
00860 }
00861
00862
00863
00864 EupNuclear.allocate( NucleiTypes.dim1() );
00865
00866 if( NumberOfElectronsDown > 0 )
00867 EdnNuclear.allocate( NucleiTypes.dim1() );
00868
00869
00870
00871 int NumberOfCorrelationFunctions = NucleiTypes.dim1();
00872
00873 if(globalInput.flags.link_Jastrow_parameters == 0 && NumberOfElectronsDown > 0 )
00874 NumberOfCorrelationFunctions += NucleiTypes.dim1();
00875
00876 if( NumberOfElectronsUp >0 && NumberOfElectronsDown > 0 )
00877 NumberOfCorrelationFunctions++;
00878
00879 if( NumberOfElectronsUp > 1 )
00880 NumberOfCorrelationFunctions++;
00881
00882 if(globalInput.flags.link_Jastrow_parameters == 0 && NumberOfElectronsDown > 1 )
00883 NumberOfCorrelationFunctions++;
00884
00885
00886 QMCCorrelationFunctionParameters CP;
00887 while(CP.read( file , nucCuspReplacement))
00888 {
00889 bool foundMatch = false;
00890 if( CP.getParticle1Type() == "Electron_up" )
00891 {
00892 if( CP.getParticle2Type() == "Electron_up" )
00893 {
00894 if( NumberOfElectronsUp < 2 )
00895 {
00896 cerr << "ERROR: Electron_up-Electron_up correlation "
00897 << "function loaded when one does not belong!" << endl;
00898 exit(0);
00899 }
00900 foundMatch = true;
00901 EupEup = CP;
00902 }
00903 else if( CP.getParticle2Type() == "Electron_down" )
00904 {
00905 if( NumberOfElectronsUp < 1 || NumberOfElectronsDown < 1 )
00906 {
00907 cerr << "ERROR: Electron_up-Electron_down correlation "
00908 << "function loaded when one does not belong!" << endl
00909 << "Maybe you are using an old ckmf file?" << endl;
00910 exit(0);
00911 }
00912 foundMatch = true;
00913 EupEdn = CP;
00914 }
00915 else
00916 {
00917
00918 for( int j=0; j<NucleiTypes.dim1(); j++ )
00919 if( NucleiTypes(j) == CP.getParticle2Type() )
00920 {
00921 foundMatch = true;
00922 EupNuclear(j) = CP;
00923 break;
00924 }
00925 }
00926 }
00927 else
00928 {
00929 if( CP.getParticle2Type() == "Electron_down" )
00930 {
00931 if( NumberOfElectronsDown < 2 )
00932 {
00933 cerr << "ERROR: Electron_down-Electron_down correlation "
00934 << "function loaded when one does not belong!" << endl;
00935 exit(0);
00936 }
00937 foundMatch = true;
00938 EdnEdn = CP;
00939 }
00940 else
00941 {
00942
00943 for( int j=0; j<NucleiTypes.dim1(); j++ )
00944 if( NucleiTypes(j) == CP.getParticle2Type() )
00945 {
00946 if( NumberOfElectronsDown < 1 )
00947 {
00948 cerr << "ERROR: Electron_down-Nuclear correlation "
00949 << "function loaded when one does not belong!"
00950 << endl;
00951 exit(0);
00952 }
00953 foundMatch = true;
00954 EdnNuclear(j) = CP;
00955 break;
00956 }
00957 }
00958 }
00959
00960 if(!foundMatch){
00961 clog << "Warning: Jastrow from input file ("
00962 << CP.getParticle1Type() << "," << CP.getParticle2Type() << ") was not used:\n";
00963 CP.getCorrelationFunction()->print(clog);
00964 clog << endl << endl;
00965 }
00966 }
00967
00968
00969
00970 NumberOfEEParameters = 0;
00971 NumberOfEupEdnParameters = 0;
00972 NumberOfEupEupParameters = 0;
00973 NumberOfEdnEdnParameters = 0;
00974 NumberOfNEParameters = 0;
00975 NumberOfNEupParameters = 0;
00976
00977 NumberOfEupEupParameters += EupEup.getTotalNumberOfParameters();
00978 NumberOfEEParameters += EupEup.getTotalNumberOfParameters();
00979
00980 NumberOfEupEdnParameters += EupEdn.getTotalNumberOfParameters();
00981 NumberOfEEParameters += EupEdn.getTotalNumberOfParameters();
00982
00983 for(int i=0; i<EupNuclear.dim1(); i++)
00984 {
00985 NumberOfNEParameters +=
00986 EupNuclear(i).getTotalNumberOfParameters();
00987 }
00988
00989 NumberOfNEupParameters = NumberOfNEParameters;
00990
00991 if( EquivalentElectronUpDownParams )
00992 {
00993
00994
00995 if( NumberOfElectronsUp > 1 && NumberOfElectronsDown > 1)
00996 {
00997 EdnEdn = EupEup;
00998 EdnEdn.setParticle1Type("Electron_down");
00999 EdnEdn.setParticle2Type("Electron_down");
01000 }
01001
01002 if( NumberOfElectronsDown > 0 )
01003 {
01004 for (int i=0; i<EupNuclear.dim1(); i++)
01005 {
01006 EdnNuclear(i) = EupNuclear(i);
01007 EdnNuclear(i).setParticle1Type("Electron_down");
01008 }
01009 }
01010 }
01011 else
01012 {
01013 NumberOfEEParameters += EdnEdn.getTotalNumberOfParameters();
01014 NumberOfEdnEdnParameters += EdnEdn.getTotalNumberOfParameters();
01015
01016 for(int i=0; i<EdnNuclear.dim1(); i++)
01017 {
01018 NumberOfNEParameters +=
01019 EdnNuclear(i).getTotalNumberOfParameters();
01020 }
01021 }
01022
01023
01024
01025 if (globalInput.flags.use_three_body_jastrow == 1)
01026 {
01027 int NumberOfThreeBodyCorrelationFunctions = 0;
01028 EupEdnNuclear.allocate( NucleiTypes.dim1() );
01029 EupEupNuclear.allocate( NucleiTypes.dim1() );
01030 EdnEdnNuclear.allocate( NucleiTypes.dim1() );
01031
01032 if (NumberOfElectronsUp > 0 && NumberOfElectronsDown > 0)
01033 NumberOfThreeBodyCorrelationFunctions += NucleiTypes.dim1();
01034
01035 if (NumberOfElectronsUp > 1 &&
01036 globalInput.flags.link_NEE_Jastrows < 2)
01037 NumberOfThreeBodyCorrelationFunctions += NucleiTypes.dim1();
01038
01039 if (NumberOfElectronsDown > 1 &&
01040 globalInput.flags.link_NEE_Jastrows < 1)
01041 NumberOfThreeBodyCorrelationFunctions += NucleiTypes.dim1();
01042
01043
01044 QMCThreeBodyCorrelationFunctionParameters CP;
01045 while(CP.read( file ))
01046 {
01047 bool foundMatch = false;
01048 if( CP.getParticle2Type() == "Electron_up" )
01049 {
01050 if( CP.getParticle3Type() == "Electron_down" )
01051 {
01052 if( NumberOfElectronsUp < 1 && NumberOfElectronsDown < 1 )
01053 {
01054 cerr << "ERROR: Electron_up-Electron_down nuclear "
01055 << "{correlation function loaded when one does not "
01056 << "belong!" << endl;
01057 exit(0);
01058 }
01059 for (int j=0; j<NucleiTypes.dim1(); j++)
01060 if (NucleiTypes(j) == CP.getParticle1Type() )
01061 {
01062 foundMatch = true;
01063 EupEdnNuclear(j) = CP;
01064 break;
01065 }
01066 }
01067 else if( CP.getParticle3Type() == "Electron_up" )
01068 {
01069 if(NumberOfElectronsUp < 2)
01070 {
01071 cerr << "ERROR: Electron_up-Electron_up nuclear "
01072 << "correlation function loaded when one does not "
01073 << "belong!" << endl
01074 << "Maybe you are using an old ckmf file?" << endl;
01075 exit(0);
01076 }
01077 for (int j=0; j<NucleiTypes.dim1(); j++)
01078 if (NucleiTypes(j) == CP.getParticle1Type() )
01079 {
01080 foundMatch = true;
01081 EupEupNuclear(j) = CP;
01082 break;
01083 }
01084 }
01085 }
01086 else if (CP.getParticle2Type() == "Electron_down" &&
01087 CP.getParticle3Type() == "Electron_down")
01088 {
01089 if( NumberOfElectronsDown < 2 )
01090 {
01091 cerr << "ERROR: Electron_down-Electron_down nuclear "
01092 << "correlation function loaded when one does not "
01093 << "belong!" << endl;
01094 exit(0);
01095 }
01096
01097 for( int j=0; j<NucleiTypes.dim1(); j++ )
01098 if( NucleiTypes(j) == CP.getParticle1Type() )
01099 {
01100 foundMatch = true;
01101 EdnEdnNuclear(j) = CP;
01102 break;
01103 }
01104 }
01105
01106 if(!foundMatch){
01107 clog << "Warning: Jastrow from input file ("
01108 << CP.getParticle1Type() << "," << CP.getParticle2Type() << ","
01109 << CP.getParticle3Type() << ") was not used:\n";
01110 CP.getThreeBodyCorrelationFunction()->print(clog);
01111 clog << endl << endl;
01112 }
01113 }
01114
01115
01116
01117 NumberOfNEupEdnParameters = 0;
01118 NumberOfNEupEupParameters = 0;
01119 NumberOfNEdnEdnParameters = 0;
01120
01121 for (int i=0; i<EupEdnNuclear.dim1(); i++)
01122 NumberOfNEupEdnParameters += EupEdnNuclear(i).getNumberOfFreeParameters();
01123
01124 for (int i=0; i<EupEupNuclear.dim1(); i++)
01125 NumberOfNEupEupParameters += EupEupNuclear(i).getNumberOfFreeParameters();
01126
01127 for (int i=0; i<EdnEdnNuclear.dim1(); i++)
01128 NumberOfNEdnEdnParameters += EdnEdnNuclear(i).getNumberOfFreeParameters();
01129
01130 if(globalInput.flags.link_NEE_Jastrows == 1)
01131 {
01132
01133 if( NumberOfElectronsUp > 1 && NumberOfElectronsDown > 1 )
01134 for (int i=0; i<EupEupNuclear.dim1(); i++)
01135 {
01136 EdnEdnNuclear(i) = EupEupNuclear(i);
01137 EdnEdnNuclear(i).setParticle2Type("Electron_down");
01138 EdnEdnNuclear(i).setParticle3Type("Electron_down");
01139 }
01140 }
01141 else if(globalInput.flags.link_NEE_Jastrows == 2)
01142 {
01143
01144 if( NumberOfElectronsUp > 1 && NumberOfElectronsDown > 1 )
01145 for (int i=0; i<EupEupNuclear.dim1(); i++)
01146 {
01147 EdnEdnNuclear(i) = EupEdnNuclear(i);
01148 EupEupNuclear(i) = EupEdnNuclear(i);
01149 EdnEdnNuclear(i).setParticle2Type("Electron_down");
01150 EdnEdnNuclear(i).setParticle3Type("Electron_down");
01151 EupEupNuclear(i).setParticle2Type("Electron_up");
01152 EupEupNuclear(i).setParticle3Type("Electron_up");
01153 }
01154 }
01155 }
01156
01157 print(clog);
01158 }
01159
01160 QMCCorrelationFunctionParameters * QMCJastrowParameters::
01161 getElectronUpElectronDownParameters()
01162 {
01163 return &EupEdn;
01164 }
01165
01166 QMCCorrelationFunctionParameters * QMCJastrowParameters::
01167 getElectronUpElectronUpParameters()
01168 {
01169 return &EupEup;
01170 }
01171
01172 QMCCorrelationFunctionParameters * QMCJastrowParameters::
01173 getElectronDownElectronDownParameters()
01174 {
01175 return &EdnEdn;
01176 }
01177
01178 Array1D<QMCCorrelationFunctionParameters> * QMCJastrowParameters::
01179 getElectronUpNuclearParameters()
01180 {
01181 return &EupNuclear;
01182 }
01183
01184 Array1D<QMCCorrelationFunctionParameters> * QMCJastrowParameters::
01185 getElectronDownNuclearParameters()
01186 {
01187 return &EdnNuclear;
01188 }
01189
01190 Array1D<QMCThreeBodyCorrelationFunctionParameters> * QMCJastrowParameters::
01191 getElectronUpElectronDownNuclearParameters()
01192 {
01193 return &EupEdnNuclear;
01194 }
01195
01196 Array1D<QMCThreeBodyCorrelationFunctionParameters> * QMCJastrowParameters::
01197 getElectronUpElectronUpNuclearParameters()
01198 {
01199 return &EupEupNuclear;
01200 }
01201
01202 Array1D<QMCThreeBodyCorrelationFunctionParameters> * QMCJastrowParameters::
01203 getElectronDownElectronDownNuclearParameters()
01204 {
01205 return &EdnEdnNuclear;
01206 }
01207
01208 Array1D<string> * QMCJastrowParameters::getNucleiTypes()
01209 {
01210 return &NucleiTypes;
01211 }
01212
01213 QMCJastrowParameters::QMCJastrowParameters()
01214 {
01215 }
01216
01217 QMCJastrowParameters::QMCJastrowParameters(const QMCJastrowParameters & rhs)
01218 {
01219 *this = rhs;
01220 }
01221
01222 ostream & operator<<(ostream &strm, QMCJastrowParameters & rhs)
01223 {
01224 strm << "&Jastrow" << endl;
01225
01226 if( rhs.NumberOfElectronsDown > 0 && rhs.NumberOfElectronsUp > 0 &&
01227 rhs.EupEdn.isUsed())
01228 {
01229 strm << rhs.EupEdn << endl;
01230 }
01231
01232 if( rhs.NumberOfElectronsUp > 1 &&
01233 rhs.EupEup.isUsed())
01234 {
01235 strm << rhs.EupEup << endl;
01236 }
01237
01238 if( rhs.NumberOfElectronsDown > 1 &&
01239 !rhs.EquivalentElectronUpDownParams &&
01240 rhs.EdnEdn.isUsed())
01241 {
01242 strm << rhs.EdnEdn << endl;
01243 }
01244
01245 for(int i=0; i<rhs.EupNuclear.dim1(); i++)
01246 {
01247 if(rhs.EupNuclear(i).isUsed())
01248 strm << rhs.EupNuclear(i) << endl;
01249
01250 if( rhs.NumberOfElectronsDown > 0 &&
01251 !rhs.EquivalentElectronUpDownParams)
01252 {
01253 if(rhs.EdnNuclear(i).isUsed())
01254 strm << rhs.EdnNuclear(i) << endl;
01255 }
01256 }
01257
01258 if (globalInput.flags.use_three_body_jastrow == 1)
01259 for (int i=0; i<rhs.EupEdnNuclear.dim1(); i++)
01260 {
01261 if( rhs.NumberOfElectronsDown > 0 && rhs.NumberOfElectronsUp > 0 &&
01262 rhs.EupEdnNuclear(i).isUsed())
01263 strm << rhs.EupEdnNuclear(i) << endl;
01264
01265 if ( rhs.NumberOfElectronsUp > 1 &&
01266 globalInput.flags.link_NEE_Jastrows < 2 &&
01267 rhs.EupEupNuclear(i).isUsed())
01268 strm << rhs.EupEupNuclear(i) << endl;
01269
01270 if ( rhs.NumberOfElectronsDown > 1 &&
01271 globalInput.flags.link_NEE_Jastrows < 1 &&
01272 rhs.EdnEdnNuclear(i).isUsed())
01273 strm << rhs.EdnEdnNuclear(i) << endl;
01274 }
01275
01276 strm << "&Jastrow" << endl;
01277
01278 return strm;
01279 }
01280
01281
01282
01283
01284