71 tbgrad(tbg), pmax_(pm), accuracy_(a), threadno_(tn), nthread_(nt)
84 int nproc = grp_->n();
93 double *tbint =
new double[mol.
natom()*3];
94 memset(tbint, 0,
sizeof(
double)*mol.
natom()*3);
97 int PPmax = (int) (log(6.0*pmax_*pmax_)/log(2.0));
98 int threshold = (int) (log(accuracy_)/log(2.0));
102 for (
int i=0; i < gbs.
nshell(); i++) {
106 int ni=gbs(i).nfunction();
109 for (
int j=0; j <= i; j++) {
110 int ij=i_offset(i)+j;
117 int nj=gbs(j).nfunction();
120 for (
int k=0; k <= i; k++,kindex++) {
121 if (kindex%nproc != me)
125 if (threadind % nthread_ != threadno_)
128 int nk=gbs(k).nfunction();
131 for (
int l=0; l <= ((i==k)?j:k); l++) {
135 int kl=i_offset(k)+l;
137 if (!(qijkl=pl.in_p4(ij,kl,i,j,k,l)))
140 int nl=gbs(l).nfunction();
146 const double * buf = tbi.
buffer();
150 this->set_scale(cscl, escl, i, j, k, l);
155 for (
int x=0; x < nx; x++) {
158 for (
int ixyz=0; ixyz < 3; ixyz++) {
159 double tx = tbint[ixyz+ix*3];
160 double to = tbint[ixyz+io*3];
162 for (
int ip=0, ii=fi; ip < ni; ip++, ii++) {
163 for (
int jp=0, jj=fj; jp < nj; jp++, jj++) {
164 for (
int kp=0, kk=fk; kp < nk; kp++, kk++) {
165 for (
int lp=0, ll=fl; lp < nl; lp++, ll++, indijkl++) {
167 double qint = buf[indijkl]*qijkl;
170 TBGrad<T>::contribution.cont1(ij_offset(ii,jj),
177 TBGrad<T>::contribution.cont2(ij_offset(ii,kk),
185 TBGrad<T>::contribution.cont2(ij_offset(ii,ll),
196 tbint[ixyz+ix*3] = tx;
197 tbint[ixyz+io*3] = to;
208 for (
int alpha=0; alpha < mol.
natom(); alpha++) {
209 double tbx = tbint[alpha*3+0];
210 double tby = tbint[alpha*3+1];
211 double tbz = tbint[alpha*3+2];
213 for (
int g=1; g < ct.
order(); g++) {
215 int ap = pl.atom_map(alpha,g);
217 tbx += tbint[ap*3+0]*so(0,0) + tbint[ap*3+1]*so(1,0) +
218 tbint[ap*3+2]*so(2,0);
219 tby += tbint[ap*3+0]*so(0,1) + tbint[ap*3+1]*so(1,1) +
220 tbint[ap*3+2]*so(2,1);
221 tbz += tbint[ap*3+0]*so(0,2) + tbint[ap*3+1]*so(1,2) +
222 tbint[ap*3+2]*so(2,2);
224 double scl = 1.0/(double)ct.
order();
225 tbgrad[alpha*3+0] += tbx*scl;
226 tbgrad[alpha*3+1] += tby*scl;
227 tbgrad[alpha*3+2] += tbz*scl;