00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "QMCHarmonicOscillator.h"
00014
00015 QMCHarmonicOscillator::QMCHarmonicOscillator(QMCInput *input)
00016 {
00017 Input = input;
00018
00019
00020 w = 1.0;
00021 a = w/2.0;
00022
00023
00024 a *= 1.01;
00025
00026 cout << "Using Harmonic Oscilator w = " << w << endl;
00027 cout << "and a = " << a << endl;
00028
00029
00030 a2 = a*a;
00031 w2div2 = 0.5*w*w;
00032 }
00033
00034 void QMCHarmonicOscillator::evaluate(Array1D<QMCWalkerData *> &walkerData,
00035 Array1D<Array2D<double> * > &xData,
00036 int num)
00037 {
00038 for(int i=0; i<num; i++)
00039 {
00040 double psi = 0;
00041 double ke = 0;
00042 double pe = 0;
00043 double grad = 0;
00044
00045 for(int e=0; e<xData(i)->dim1(); e++)
00046 {
00047 for(int d=0; d<xData(i)->dim2(); d++)
00048 {
00049 double x = (*xData(i))(e,d);
00050 double x2 = x*x;
00051
00052 psi += - a * x2;
00053
00054
00055 ke += a - 2.0*a2*x2;
00056 pe += w2div2*x2;
00057
00058 grad = -2.0 * x * a;
00059
00060 walkerData(i)->gradPsiRatio(e,d) = grad;
00061 }
00062 }
00063
00064 walkerData(i)->psi = exp(psi);
00065 walkerData(i)->neEnergy = 0;
00066 walkerData(i)->eeEnergy = 0;
00067 walkerData(i)->kineticEnergy = ke;
00068 walkerData(i)->potentialEnergy = pe;
00069 walkerData(i)->localEnergy = ke + pe;
00070 walkerData(i)->singular = false;
00071 walkerData(i)->modifiedGradPsiRatio = walkerData(i)->gradPsiRatio;
00072
00073 if(false)
00074 {
00075 printf("Psi %20.10e ", psi );
00076 printf("KE %20.10e ", (*walkerData(i)).kineticEnergy );
00077 printf("PE %20.10e ", (*walkerData(i)).potentialEnergy );
00078
00079 printf("TE %20.10e\n", (*walkerData(i)).localEnergy );
00080 cout << walkerData(i)->modifiedGradPsiRatio << endl;
00081 }
00082 }
00083 }
00084
00085
00086
00087
00088