00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef QMCWavefunction_H
00014 #define QMCWavefunction_H
00015
00016 #include <string>
00017 #include <fstream>
00018 #include <iostream>
00019
00020 #include "Array1D.h"
00021 #include "Array2D.h"
00022
00023 using namespace std;
00024
00031 class QMCWavefunction
00032 {
00033 private:
00034 int Norbitals;
00035 int Nbasisfunc;
00036 int Nalpha;
00037 int Nbeta;
00038 int Ncharge;
00039 int Nelectrons;
00040 int Ndeterminants;
00041 double factor;
00042 string trialFunctionType;
00043
00044 int unusedIndicator;
00045
00051 Array2D<qmcfloat> AlphaCoeffs;
00052
00057 Array2D<int> AlphaOrbitals;
00058
00059 Array2D<qmcfloat> BetaCoeffs;
00060 Array2D<int> BetaOrbitals;
00061
00079 void sortOccupations(bool ordered);
00080
00091 void unlinkOrbitals();
00092
00102 void unlinkDeterminants();
00103
00104 public:
00105
00109 QMCWavefunction();
00110
00117 int getNumberOrbitals();
00118
00125 int getNumberOrbitals(bool isAlpha)
00126 {
00127 if(isAlpha)
00128 return AlphaCoeffs.dim1();
00129 else
00130 return BetaCoeffs.dim1();
00131 }
00132
00138 int getNumberOrbitals(Array2D<int> & Occupation);
00139
00148 int getNumberActiveOrbitals();
00149
00156 int getNumberActiveOrbitals(Array2D<int> & Occupation);
00157
00162 int getNumberBasisFunctions();
00163
00168 int getNumberElectrons(bool isAlpha);
00169
00174 int getNumberElectrons();
00175
00180 int getNumberDeterminants();
00181
00186 int getUnusedIndicator();
00187
00193 void makeCoefficients(Array2D<int> & TypeOccupations,
00194 Array2D<qmcfloat> & AllCoeffs,
00195 Array2D<int> & TypeIndices,
00196 Array2D<qmcfloat> & TypeCoeffs,
00197 Array2D<int> & TypeSwaps);
00198
00204 Array2D<qmcfloat> * getCoeff(bool isAlpha);
00205 Array2D<int> * getOccupations(bool isAlpha);
00206 Array2D<int> * getDeterminantSwaps(bool isAlpha);
00207
00214 template <class T>
00215 void getDataForCI(int ci, bool isAlpha, Array2D<T> & from, Array2D<double> & to)
00216 {
00217 #ifdef QMC_DEBUG
00218 if(to.dim1() != from.dim1())
00219 {
00220 cout << "Error: dim1 (num electrons) doesn't match in QMCWavefunction::getDataForCI\n";
00221 cout << " to.n_1 = " << to.dim1() << endl;
00222 cout << " to.n_2 = " << to.dim2() << endl;
00223 cout << " from.n_1 = " << from.dim1() << endl;
00224 cout << " from.n_2 = " << from.dim2() << endl;
00225 assert(0);
00226 }
00227 #endif
00228
00229 Array2D<int> * occ;
00230 if(isAlpha) occ = & AlphaOrbitals;
00231 else occ = & BetaOrbitals;
00232
00233 for(int o = 0; o<to.dim2(); o++){
00234 int orb = occ->get(ci,o);
00235 for(int e = 0; e<to.dim1(); e++)
00236 to(e,o) = from(e,orb);
00237 }
00238 }
00239
00248 void scaleCoeffs(double factor);
00249
00264 Array2D<qmcfloat> OrbitalCoeffs;
00265 Array1D<int> OR_constraints;
00266 int numORIndependent;
00267
00271 Array1D<double> CI_coeffs;
00272 Array1D<int> CI_constraints;
00273 int numCIIndependent;
00280 Array2D<int> AlphaOccupation;
00281
00286 Array2D<int> AlphaSwaps;
00287
00294 Array2D<int> BetaOccupation;
00295
00300 Array2D<int> BetaSwaps;
00301
00306 QMCWavefunction operator=( const QMCWavefunction & rhs );
00307
00311 friend istream& operator >>(istream& strm, QMCWavefunction &rhs);
00312
00316 friend ostream& operator <<(ostream& strm, QMCWavefunction& rhs);
00317
00326 void read(int charge, int numberOrbitals, int numberBasisFunctions,
00327 int numberDeterminants, string functionType, string runfile);
00328
00332 int getNumberCIParameters();
00333
00337 int getNumberORParameters();
00338
00343 void getCIParameters(Array1D<double> & params, int shift);
00344
00349 void getORParameters(Array1D<double> & params, int shift);
00350
00355 void setCIParameters(Array1D<double> & params, int shift);
00356
00360 double getCINorm();
00361
00369 void normalizeCI();
00370
00375 void setORParameters(Array1D<double> & params, int shift);
00376
00377 };
00378
00379 #endif
00380
00381
00382
00383