00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "JuliusCorrelationFunction.h"
00016
00017 void JuliusCorrelationFunction::initializeParameters(
00018 Array1D<int> & BeginningIndexOfParameterType,
00019 Array1D<double> &Parameters,
00020 Array1D<int> & BeginningIndexOfConstantType,
00021 Array1D<double> & Constants)
00022 {
00023 if( BeginningIndexOfParameterType.dim1() != 2 )
00024 {
00025 cerr << "ERROR: Julius correlation function entered with an incorrect "
00026 << "number of parameter types!" << endl;
00027 exit(0);
00028 }
00029
00030
00031
00032
00033 type = Constants(0);
00034 if (type == 0.0)
00035 {
00036
00037
00038
00039 Array1D<double> numeratorParameters(BeginningIndexOfParameterType(1) +
00040 Constants.dim1() - 1);
00041 for (int i = 1; i < Constants.dim1(); i++)
00042 numeratorParameters(i - 1) = Constants(i);
00043 Numerator.initialize(numeratorParameters);
00044 }
00045 else if (type == 1.0)
00046 {
00047 for (int i = 1; i < Constants.dim1(); i++)
00048 {
00049 params[i - 1] = Constants(i);
00050 if (i > 10)
00051 {
00052 printf("Exceeded max num of parameters in ");
00053 printf("JuliusCorrelationFunction.\n");
00054 exit(1);
00055 }
00056 }
00057 }
00058
00059 else
00060 {
00061 printf("Jastrow type %f unknown in JuliusCorrelationFunction, exiting.\n", Constants(0));
00062 exit(1);
00063 }
00064 }
00065
00066 bool JuliusCorrelationFunction::isSingular()
00067 {
00068 return false;
00069 }
00070
00071 Array1D<Complex> JuliusCorrelationFunction::getPoles()
00072 {
00073 Array1D<Complex> result;
00074 return result;
00075 }
00076
00077 void JuliusCorrelationFunction::evaluate( double r )
00078 {
00079
00080
00081
00082
00083 double a, ap, app;
00084 if (type == 0.0)
00085 {
00086
00087
00088 Numerator.evaluate(r);
00089 a = Numerator.getFunctionValue();
00090 ap = Numerator.getFirstDerivativeValue();
00091 app = Numerator.getSecondDerivativeValue();
00092 }
00093 else if (type == 1.0)
00094 {
00095
00096
00097 double a0 = params[0], a1 = params[1], a2 = params[2];
00098 double t1, t2;
00099 t1 = exp(-(1-a0)*r/a0);
00100 a = sqrt(1-(a0-r*r*(a1+a2*r))* t1);
00101 ap = -t1*(a0*a0+r*r*(a1+a2*r)-a0*(1+a1*r*(2+r)+a2*r*r*(3+r))) /
00102 (2*a0*a);
00103 t2 = a0*a0+r*r*(a1+a2*r)-a0*(1+a1*r*(2+r)+a2*r*r*(3+r));
00104 app = (t1*t1*(-t2*t2-2*(-a0+1.0/t1+r*r*(a1+a2*r))*(a0*a0*a0-r*r*(a1+a2*r)
00105 + a0*(1+2*a1*r*(2+r)+2*a2*r*r*(3+r))
00106 - a0*a0*(2+a1*(2+r*(4+r))+a2*r*(6+r*(6+r)))))) / (4*a0*a0*a*a*a);
00107 }
00108 else
00109 {
00110 printf("Jastrow type %f unknown in JuliusCorrelationFunction, exiting.\n", type);
00111 exit(1);
00112 }
00113 FunctionValue = a;
00114 dFunctionValue = ap;
00115 d2FunctionValue = app;
00116 }
00117
00118 double JuliusCorrelationFunction::getFunctionValue()
00119 {
00120 return FunctionValue;
00121 }
00122
00123 double JuliusCorrelationFunction::getFunctionValue(double r)
00124 {
00128 if (type == 0.0)
00129 {
00130 return Numerator.getFunctionValue(r);
00131 }
00132 else if (type == 1.0)
00133 {
00134
00135
00136 double a0 = params[0], a1 = params[1], a2 = params[2];
00137 double t1;
00138 t1 = exp(-(1-a0)*r/a0);
00139 return sqrt(1-(a0-r*r*(a1+a2*r))* t1);
00140 }
00141 else
00142 {
00143 printf("Jastrow type %f unknown in JuliusCorrelationFunction, exiting.\n", type);
00144 exit(1);
00145 }
00146 }
00147
00148 double JuliusCorrelationFunction::get_p_a(int ai)
00149 {
00150 cout << "Parameter derivatives not implemented!\n";
00151 return 0.0;
00152 }
00153
00154 double JuliusCorrelationFunction::getFirstDerivativeValue()
00155 {
00156 return dFunctionValue;
00157 }
00158
00159 double JuliusCorrelationFunction::get_p2_xa(int ai)
00160 {
00161 cout << "Parameter derivatives not implemented!\n";
00162 return 0.0;
00163 }
00164
00165 double JuliusCorrelationFunction::getSecondDerivativeValue()
00166 {
00167 return d2FunctionValue;
00168 }
00169
00170 double JuliusCorrelationFunction::get_p3_xxa(int ai)
00171 {
00172 cout << "Parameter derivatives not implemented!\n";
00173 return 0.0;
00174 }
00175
00176 Array1D<double> JuliusCorrelationFunction::getNumeratorCoeffs()
00177 {
00178 return Numerator.getCoefficients();
00179 }
00180
00181 Array1D<double> JuliusCorrelationFunction::getDenominatorCoeffs()
00182 {
00183 Array1D<double> temp(1);
00184 temp(0) = 1;
00185 return temp;
00186 }
00187
00188
00189
00190