00001 #include "Yukawa2CorrelationFunction.h"
00002 #include <sstream>
00003
00004 void Yukawa2CorrelationFunction::initializeParameters(
00005 Array1D<int> & BeginningIndexOfParameterType,
00006 Array1D<double> &Parameters,
00007 Array1D<int> & BeginningIndexOfConstantType,
00008 Array1D<double> & Constants)
00009 {
00010 if( Constants.dim1() != 1 )
00011 {
00012 cerr << "ERROR: Yukawa correlation function entered "
00013 << "without a constant for the cusp condition!" << endl;
00014 exit(0);
00015 }
00016
00017 if( BeginningIndexOfParameterType.dim1() != 1 )
00018 {
00019 cerr << "ERROR: Yukawa correlation function entered with an incorrect "
00020 << "number of parameter types!" << endl;
00021 exit(0);
00022 }
00023
00024
00025 g = Constants(0);
00026
00027
00028
00029 A = Parameters(0);
00030
00031 if(g <= 0){
00032 cerr << "ERROR: Yukawa correlation function can not be used to set cusp condition "
00033 << " g = " << g << endl;
00034 exit(0);
00035 }
00036
00037 s2g = -1.0 * sqrt(2.0 * g);
00038 F = s2g / A;
00039 A2 = A * A;
00040 A2F = A2 * F;
00041 }
00042
00043 void Yukawa2CorrelationFunction::evaluate( double _r )
00044 {
00045 r = _r;
00046
00047 if(isSingular())
00048 {
00049 FunctionValue = 0.0;
00050 dFunctionValue = 0.0;
00051 d2FunctionValue = -1e10;
00052 return;
00053 }
00054
00055 ir = 1.0 / r;
00056 t1 = exp( r * F );
00057 t2 = A2F * t1 * ir;
00058
00059 FunctionValue = - A2 * (1.0 - t1) * ir;
00060 dFunctionValue = t2 - FunctionValue * ir;
00061 d2FunctionValue = t2 * F - 2.0 * dFunctionValue * ir;
00062
00063
00064
00065
00066
00067
00068
00069
00070 }
00071
00072 double Yukawa2CorrelationFunction::get_p_a(int ai)
00073 {
00074 double p_a = 0.0;
00075 switch(ai)
00076 {
00077
00078 case 0:
00079 p_a = 2.0 * FunctionValue / A - t1 * s2g;
00080
00081 break;
00082
00083
00084 default:
00085 clog << "Error: Yukawa Jastrow function doesn't use parameter"
00086 << " index = " << ai << endl;
00087 break;
00088 }
00089
00090 return p_a;
00091 }
00092
00093 double Yukawa2CorrelationFunction::get_p2_xa(int ai)
00094 {
00095 double p2_xa = 0.0;
00096 switch(ai)
00097 {
00098
00099 case 0:
00100 p2_xa = 2.0 * dFunctionValue / A - t1 * F * s2g;
00101
00102 break;
00103
00104
00105 default:
00106 clog << "Error: Yukawa Jastrow function doesn't use parameter"
00107 << " index = " << ai << endl;
00108 break;
00109 }
00110
00111 return p2_xa;
00112 }
00113
00114 double Yukawa2CorrelationFunction::get_p3_xxa(int ai)
00115 {
00116 double p3_xxa = 0.0;
00117 switch(ai)
00118 {
00119
00120 case 0:
00121 p3_xxa = 2.0 * d2FunctionValue / A - t1 * F * F * s2g;
00122
00123 break;
00124
00125
00126 default:
00127 clog << "Error: Yukawa Jastrow function doesn't use parameter"
00128 << " index = " << ai << endl;
00129 break;
00130 }
00131 return p3_xxa;
00132 }
00133
00134 void Yukawa2CorrelationFunction::print(ostream& strm)
00135 {
00136 strm << "Yukawa Jastrow parameters:" << endl;
00137 strm << " g = " << g;
00138 strm << " A = " << A << endl;
00139 strm << " F = " << F << endl;
00140
00141 strm << "-" << A2 << " (1.0 - Exp[ " << F << " r ])/r" << endl;
00142 }
00143
00144 bool Yukawa2CorrelationFunction::isSingular()
00145 {
00146 return g <= 0.0 || A <= 0.0;
00147 }