00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "QMCCorrelationFunctionParameters.h"
00014
00015 Array1D < double > QMCCorrelationFunctionParameters::getParameters()
00016 {
00017 return Parameters;
00018 }
00019
00020 Array1D < Complex > QMCCorrelationFunctionParameters::getPoles()
00021 {
00022 return CorrelationFunction->getPoles();
00023 }
00024
00025 void QMCCorrelationFunctionParameters::operator = (const
00026 QMCCorrelationFunctionParameters & rhs)
00027 {
00028 NumberOfParameterTypes = rhs.NumberOfParameterTypes;
00029 NumberOfParameters = rhs.NumberOfParameters;
00030 Parameters = rhs.Parameters;
00031 BeginningIndexOfParameterType = rhs.BeginningIndexOfParameterType;
00032 TotalNumberOfParameters = rhs.TotalNumberOfParameters;
00033
00034 NumberOfConstantTypes = rhs.NumberOfConstantTypes;
00035 NumberOfConstants = rhs.NumberOfConstants;
00036 Constants = rhs.Constants;
00037 BeginningIndexOfConstantType = rhs.BeginningIndexOfConstantType;
00038 TotalNumberOfConstants = rhs.TotalNumberOfConstants;
00039
00040 ParticleTypes = rhs.ParticleTypes;
00041 CorrelationFunctionType = rhs.CorrelationFunctionType;
00042
00043 setCorrelationFunction();
00044 initializeCorrelationFunctionParameters();
00045 }
00046
00059 bool QMCCorrelationFunctionParameters::read(istream & strm, bool nucCuspReplacement)
00060 {
00061 bool ok = true;
00062 string temp;
00063 int start = strm.tellg();
00064
00065
00066 string pt1, pt2;
00067 strm >> temp;
00068
00069 if(temp != "ParticleTypes:")
00070 {
00071 strm.seekg(start);
00072 return false;
00073 }
00074
00075 strm >> pt1 >> pt2;
00076 pt1 = StringManipulation::toFirstUpperRestLower(pt1);
00077 pt2 = StringManipulation::toFirstUpperRestLower(pt2);
00078
00079
00080
00081 if( pt1 == "Electron_up" )
00082 {
00083 ParticleTypes(0) = pt1;
00084 ParticleTypes(1) = pt2;
00085 }
00086 else if( pt2 == "Electron_up" )
00087 {
00088 ParticleTypes(0) = pt2;
00089 ParticleTypes(1) = pt1;
00090 }
00091 else if( pt1 == "Electron_down" )
00092 {
00093 ParticleTypes(0) = pt1;
00094 ParticleTypes(1) = pt2;
00095 }
00096 else if( pt2 == "Electron_down" )
00097 {
00098 ParticleTypes(0) = pt2;
00099 ParticleTypes(1) = pt1;
00100 }
00101 else
00102 {
00103 cerr << "ERROR: Two non-electron particles (" << pt1 << ", " << pt2 << ") in one correlation function!"
00104 << endl;
00105 ok = false;
00106 }
00107
00108
00109
00110 strm >> temp;
00111
00112 if(temp != "CorrelationFunctionType:")
00113 {
00114
00115 strm.seekg(start);
00116 return false;
00117 }
00118
00119 strm >> CorrelationFunctionType;
00120
00121
00122
00123 strm >> temp >> temp;
00124 NumberOfParameterTypes = atoi(temp.c_str());
00125
00126
00127
00128 NumberOfParameters.allocate(NumberOfParameterTypes);
00129 strm >> temp;
00130
00131 for (int i = 0; i < NumberOfParameterTypes; i++)
00132 {
00133 strm >> temp;
00134 NumberOfParameters(i) = atoi(temp.c_str());
00135 }
00136
00137
00138
00139 BeginningIndexOfParameterType.allocate(NumberOfParameterTypes);
00140
00141 for (int i = 0; i < NumberOfParameterTypes; i++)
00142 {
00143 if (i == 0)
00144 {
00145 BeginningIndexOfParameterType(0) = 0;
00146 }
00147 else
00148 {
00149 BeginningIndexOfParameterType(i) =
00150 BeginningIndexOfParameterType(i - 1) +
00151 NumberOfParameters(i-1);
00152 }
00153 }
00154
00155
00156
00157 if( NumberOfParameterTypes > 0 )
00158 {
00159 TotalNumberOfParameters = BeginningIndexOfParameterType(
00160 NumberOfParameterTypes - 1) +
00161 NumberOfParameters(NumberOfParameterTypes - 1);
00162 }
00163 else
00164 {
00165 TotalNumberOfParameters = 0;
00166 }
00167
00168
00169
00170 Parameters.allocate(TotalNumberOfParameters);
00171 strm >> temp;
00172
00173 int pi = Parameters.read(strm,0.0,"2 particle Jastrow");
00174
00175
00176 strm >> temp >> temp;
00177 NumberOfConstantTypes = atoi(temp.c_str());
00178
00179
00180
00181 NumberOfConstants.allocate(NumberOfConstantTypes);
00182 strm >> temp;
00183
00184 for (int i = 0; i < NumberOfConstantTypes; i++)
00185 {
00186 strm >> temp;
00187 NumberOfConstants(i) = atoi(temp.c_str());
00188 }
00189
00190
00191
00192 BeginningIndexOfConstantType.allocate(NumberOfConstantTypes);
00193
00194 for (int i = 0; i < NumberOfConstantTypes; i++)
00195 {
00196 if (i == 0)
00197 {
00198 BeginningIndexOfConstantType(0) = 0;
00199 }
00200 else
00201 {
00202 BeginningIndexOfConstantType(i) =
00203 BeginningIndexOfConstantType(i - 1) +
00204 NumberOfConstants(i-1);
00205 }
00206 }
00207
00208
00209
00210 if( NumberOfConstantTypes > 0 )
00211 {
00212 TotalNumberOfConstants = BeginningIndexOfConstantType(
00213 NumberOfConstantTypes - 1) +
00214 NumberOfConstants(NumberOfConstantTypes - 1);
00215 }
00216 else
00217 {
00218 TotalNumberOfConstants = 0;
00219 }
00220
00221
00222
00223 Constants.allocate(TotalNumberOfConstants);
00224 strm >> temp;
00225
00226 pi = Constants.read(strm,0.0,"2 particle Jastrow");
00227 if(TotalNumberOfConstants != pi)
00228 {
00229 clog << "Error: you didn't enter the right number of constants in 2 particle Jastrow";
00230 clog << " (" << ParticleTypes(0) << "," << ParticleTypes(1) << "):" << endl;
00231 clog << " Number expected = " << TotalNumberOfConstants << endl;
00232 clog << " Number found = " << pi << endl;
00233
00234 exit(0);
00235 }
00236
00237 if( ParticleTypes(1) != "Electron_up" && ParticleTypes(1) != "Electron_down"
00238 && nucCuspReplacement && CorrelationFunctionType != "None")
00239 {
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253 }
00254
00255
00256
00257
00258
00259 if( CorrelationFunctionType == "None" )
00260 {
00261 NumberOfParameterTypes = 0;
00262 TotalNumberOfParameters = 0;
00263 NumberOfParameters.deallocate();
00264 Parameters.deallocate();
00265 BeginningIndexOfParameterType.deallocate();
00266
00267 NumberOfConstantTypes = 0;
00268 TotalNumberOfConstants = 0;
00269 NumberOfConstants.deallocate();
00270 Constants.deallocate();
00271 BeginningIndexOfConstantType.deallocate();
00272
00273 }
00274
00275
00276 setCorrelationFunction();
00277 initializeCorrelationFunctionParameters();
00278
00279 return ok;
00280 }
00281
00282 QMCCorrelationFunctionParameters::QMCCorrelationFunctionParameters()
00283 {
00284 CorrelationFunctionType = "None";
00285 CorrelationFunction = 0;
00286 ParticleTypes.allocate(2);
00287 setCorrelationFunction();
00288 }
00289
00290 QMCCorrelationFunctionParameters::QMCCorrelationFunctionParameters(const
00291 QMCCorrelationFunctionParameters & rhs)
00292 {
00293 CorrelationFunction = 0;
00294 * this = rhs;
00295 }
00296
00297 string QMCCorrelationFunctionParameters::getParticle1Type()
00298 {
00299 return ParticleTypes(0);
00300 }
00301
00302 string QMCCorrelationFunctionParameters::getParticle2Type()
00303 {
00304 return ParticleTypes(1);
00305 }
00306
00307 int QMCCorrelationFunctionParameters::getTotalNumberOfParameters()
00308 {
00309 return TotalNumberOfParameters;
00310 }
00311
00312 void QMCCorrelationFunctionParameters::setParameters(Array1D<double> & params)
00313 {
00314 if( params.dim1() != Parameters.dim1() )
00315 {
00316 cerr << "ERROR: Parameters of the incorrect size are trying to be set "
00317 << "in QMCCorrelationFunctionParameters" << endl;
00318 }
00319
00320 Parameters = params;
00321 initializeCorrelationFunctionParameters();
00322 }
00323
00324 void QMCCorrelationFunctionParameters::setParticle1Type(string val)
00325 {
00326 ParticleTypes(0) = val;
00327 }
00328
00329 void QMCCorrelationFunctionParameters::setParticle2Type(string val)
00330 {
00331 ParticleTypes(1) = val;
00332 }
00333
00334 void QMCCorrelationFunctionParameters::setCorrelationFunction()
00335 {
00336 if( CorrelationFunction != 0 )
00337 {
00338 delete CorrelationFunction;
00339 CorrelationFunction = 0;
00340 }
00341 CorrelationFunction = QMCCorrelationFunctionFactory::
00342 correlationFunctionFactory(CorrelationFunctionType);
00343 }
00344
00345 QMCCorrelationFunction * QMCCorrelationFunctionParameters::
00346 getCorrelationFunction()
00347 {
00348 return CorrelationFunction;
00349 }
00350
00351 bool QMCCorrelationFunctionParameters::isUsed()
00352 {
00353 if(CorrelationFunctionType == "None")
00354 return false;
00355 return true;
00356 }
00357
00358 QMCCorrelationFunctionParameters::~QMCCorrelationFunctionParameters()
00359 {
00360 NumberOfParameters.deallocate();
00361 Parameters.deallocate();
00362 ParticleTypes.deallocate();
00363 BeginningIndexOfParameterType.deallocate();
00364
00365 if( CorrelationFunction != 0 )
00366 {
00367 delete CorrelationFunction;
00368 CorrelationFunction = 0;
00369 }
00370 }
00371
00372 bool QMCCorrelationFunctionParameters::isSingular()
00373 {
00374 return CorrelationFunction->isSingular();
00375 }
00376
00377 void QMCCorrelationFunctionParameters::
00378 initializeCorrelationFunctionParameters()
00379 {
00380 CorrelationFunction->initializeParameters(BeginningIndexOfParameterType,
00381 Parameters,
00382 BeginningIndexOfConstantType,
00383 Constants);
00384 }
00385
00386 ostream & operator << (ostream & strm, QMCCorrelationFunctionParameters & rhs)
00387 {
00388 strm << "ParticleTypes:\t" << rhs.ParticleTypes(0) << "\t"
00389 << rhs.ParticleTypes(1) << endl;
00390
00391 strm << "CorrelationFunctionType:\t" << rhs.CorrelationFunctionType << endl;
00392
00393 strm << "NumberOfParameterTypes:\t" << rhs.NumberOfParameterTypes << endl;
00394
00395 strm << "NumberOfParametersOfEachType:";
00396
00397 for (int i = 0; i < rhs.NumberOfParameterTypes; i++)
00398 {
00399 strm << "\t" << rhs.NumberOfParameters(i);
00400 }
00401 strm << endl;
00402
00403 strm << "Parameters:";
00404
00405 for (int i = 0; i < rhs.TotalNumberOfParameters; i++)
00406 {
00407 strm << "\t" << rhs.Parameters(i);
00408 }
00409
00410 strm << endl;
00411
00412 strm << "NumberOfConstantTypes:\t" << rhs.NumberOfConstantTypes << endl;
00413
00414 strm << "NumberOfConstantsOfEachType:";
00415
00416 for (int i = 0; i < rhs.NumberOfConstantTypes; i++)
00417 {
00418 strm << "\t" << rhs.NumberOfConstants(i);
00419 }
00420 strm << endl;
00421
00422 strm << "Constants:";
00423
00424 for (int i = 0; i < rhs.TotalNumberOfConstants; i++)
00425 {
00426 strm << "\t" << rhs.Constants(i);
00427 }
00428
00429 strm << endl;
00430
00431 return strm;
00432 }