00001 00002 class LocalTCContribution { 00003 private: 00004 double * const gmata; 00005 double * const gmatb; 00006 double * const kmata; 00007 double * const kmatb; 00008 00009 double * const pmata; 00010 double * const pmatb; 00011 double * const opmata; 00012 double * const opmatb; 00013 public: 00014 LocalTCContribution(double *ga, double *pa, double *gb, double *pb, 00015 double *ka, double *opa, double *kb, double *opb) : 00016 gmata(ga), gmatb(gb), kmata(ka), kmatb(kb), 00017 pmata(pa), pmatb(pb), opmata(opa), opmatb(opb) {} 00018 ~LocalTCContribution() {} 00019 00020 void set_bound(double,double) {} 00021 00022 inline void cont1(int ij, int kl, double val) { 00023 gmata[ij] += val*pmata[kl]; 00024 gmata[kl] += val*pmata[ij]; 00025 00026 gmatb[ij] += val*pmatb[kl]; 00027 gmatb[kl] += val*pmatb[ij]; 00028 } 00029 00030 inline void cont2(int ij, int kl, double val) { 00031 val *= 0.25; 00032 gmata[ij] -= val*pmata[kl]; 00033 gmata[kl] -= val*pmata[ij]; 00034 00035 gmatb[ij] -= val*pmatb[kl]; 00036 gmatb[kl] -= val*pmatb[ij]; 00037 00038 kmata[ij] += val*opmata[kl]; 00039 kmata[kl] += val*opmata[ij]; 00040 00041 kmatb[ij] += val*opmatb[kl]; 00042 kmatb[kl] += val*opmatb[ij]; 00043 } 00044 00045 inline void cont3(int ij, int kl, double val) { 00046 val *= 0.5; 00047 gmata[ij] -= val*pmata[kl]; 00048 gmata[kl] -= val*pmata[ij]; 00049 00050 gmatb[ij] -= val*pmatb[kl]; 00051 gmatb[kl] -= val*pmatb[ij]; 00052 00053 kmata[ij] += val*opmata[kl]; 00054 kmata[kl] += val*opmata[ij]; 00055 00056 kmatb[ij] += val*opmatb[kl]; 00057 kmatb[kl] += val*opmatb[ij]; 00058 } 00059 00060 inline void cont4(int ij, int kl, double val) { 00061 gmata[ij] += 0.75*val*pmata[kl]; 00062 gmata[kl] += 0.75*val*pmata[ij]; 00063 00064 gmatb[ij] += 0.75*val*pmatb[kl]; 00065 gmatb[kl] += 0.75*val*pmatb[ij]; 00066 00067 kmata[ij] += 0.25*val*opmata[kl]; 00068 kmata[kl] += 0.25*val*opmata[ij]; 00069 00070 kmatb[ij] += 0.25*val*opmatb[kl]; 00071 kmatb[kl] += 0.25*val*opmatb[ij]; 00072 } 00073 00074 inline void cont5(int ij, int kl, double val) { 00075 val *= 0.5; 00076 gmata[ij] += val*pmata[kl]; 00077 gmata[kl] += val*pmata[ij]; 00078 00079 gmatb[ij] += val*pmatb[kl]; 00080 gmatb[kl] += val*pmatb[ij]; 00081 00082 kmata[ij] += val*opmata[kl]; 00083 kmata[kl] += val*opmata[ij]; 00084 00085 kmatb[ij] += val*opmatb[kl]; 00086 kmatb[kl] += val*opmatb[ij]; 00087 } 00088 }; 00089 00090 class LocalTCEnergyContribution { 00091 private: 00092 double * const pmata; 00093 double * const pmatb; 00094 double * const opmata; 00095 double * const opmatb; 00096 00097 public: 00098 double eca; 00099 double exa; 00100 double ecb; 00101 double exb; 00102 double ecab; 00103 double exab; 00104 00105 LocalTCEnergyContribution(double *pa, double *pb, double *opa, double *opb) : 00106 pmata(pa), pmatb(pb), opmata(opa), opmatb(opb) { 00107 exa=eca=0; 00108 exb=ecb=0; 00109 exab=ecab=0; 00110 } 00111 ~LocalTCEnergyContribution() {} 00112 00113 void set_bound(double,double) {}; 00114 00115 inline void cont1(int ij, int kl, double val) { 00116 eca += val*pmata[ij]*pmata[kl]; 00117 ecb += val*pmatb[ij]*pmatb[kl]; 00118 ecab += val*(pmata[ij]*pmatb[kl]-pmatb[ij]*pmata[kl]); 00119 } 00120 00121 inline void cont2(int ij, int kl, double val) { 00122 exa -= 0.25*val*pmata[ij]*pmata[kl]; 00123 exb -= 0.25*val*pmatb[ij]*pmatb[kl]; 00124 exab -= 0.25*val*(pmata[ij]*pmatb[kl]-pmatb[ij]*pmata[kl]); 00125 } 00126 00127 inline void cont3(int ij, int kl, double val) { 00128 exa -= 0.5*val*pmata[ij]*pmata[kl]; 00129 exb -= 0.5*val*pmatb[ij]*pmatb[kl]; 00130 exab -= 0.5*val*(pmata[ij]*pmatb[kl]-pmatb[ij]*pmata[kl]); 00131 } 00132 00133 inline void cont4(int ij, int kl, double val) { 00134 eca += val*pmata[ij]*pmata[kl]; 00135 ecb += val*pmatb[ij]*pmatb[kl]; 00136 ecab += val*(pmata[ij]*pmatb[kl]-pmatb[ij]*pmata[kl]); 00137 00138 exa -= 0.25*val*pmata[ij]*pmata[kl]; 00139 exb -= 0.25*val*pmatb[ij]*pmatb[kl]; 00140 exab -= 0.25*val*(pmata[ij]*pmatb[kl]-pmatb[ij]*pmata[kl]); 00141 } 00142 00143 inline void cont5(int ij, int kl, double val) { 00144 eca += val*pmata[ij]*pmata[kl]; 00145 ecb += val*pmatb[ij]*pmatb[kl]; 00146 ecab += val*(pmata[ij]*pmatb[kl]-pmatb[ij]*pmata[kl]); 00147 00148 exa -= 0.5*val*pmata[ij]*pmata[kl]; 00149 exb -= 0.5*val*pmatb[ij]*pmatb[kl]; 00150 exab -= 0.5*val*(pmata[ij]*pmatb[kl]-pmatb[ij]*pmata[kl]); 00151 } 00152 }; 00153 00154 class LocalTCGradContribution { 00155 private: 00156 double * const pmat; 00157 double * const pmata; 00158 double * const pmatb; 00159 double c1sq; 00160 double c2sq; 00161 double c1c2; 00162 00163 public: 00164 LocalTCGradContribution(double *p, double *pa, double *pb, 00165 double c1, double c2) : 00166 pmat(p), pmata(pa), pmatb(pb) 00167 { 00168 c1sq = c1*c1; 00169 c2sq = c2*c2; 00170 c1c2 = c1*c2; 00171 } 00172 ~LocalTCGradContribution() {} 00173 00174 inline double cont1(int ij, int kl) { 00175 return pmat[ij]*pmat[kl] + 00176 c1sq*(pmata[ij]*pmat[kl] + pmat[ij]*pmata[kl]) + 00177 c2sq*(pmatb[ij]*pmat[kl] + pmat[ij]*pmatb[kl]) + 00178 0.5*c1sq*pmata[ij]*pmata[kl] + 00179 0.5*c2sq*pmatb[ij]*pmatb[kl]; 00180 } 00181 00182 inline double cont2(int ij, int kl) { 00183 return pmat[ij]*pmat[kl] + 00184 c1sq*(pmata[ij]*pmat[kl] + pmat[ij]*pmata[kl]) + 00185 c2sq*(pmatb[ij]*pmat[kl] + pmat[ij]*pmatb[kl]) - 00186 c1c2*(pmata[ij]*pmatb[kl] + pmatb[ij]*pmata[kl]); 00187 } 00188 };