⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inttest.cc

📁 大型并行量子化学软件;支持密度泛函(DFT)。可以进行各种量子化学计算。支持CHARMM并行计算。非常具有应用价值。
💻 CC
📖 第 1 页 / 共 2 页
字号:
                }            }        }    }}voiddo_shell_quartet_test(const Ref<Int2eV3> &int2ev3,                      int print, int printbounds, int bounds, int permute,                      const Ref<KeyVal>& keyval,                      int i, int j, int k, int l){  int sh[4], sizes[4];  int ibuf;  int ii, jj, kk, ll;  sh[0] = i;  sh[1] = j;  sh[2] = k;  sh[3] = l;  double maxintegral, integralbound;  int boundijkl;  if (bounds) {      integralbound          = int2ev3->logbound_to_bound(              (boundijkl = int2ev3->erep_4bound(i,j,k,l))              );    }  double *buffer = int2ev3->buffer();  int2ev3->erep(sh,sizes);  ibuf = 0;  maxintegral = 0.0;  for (ii=0; ii<sizes[0]; ii++) {      for (jj=0; jj<sizes[1]; jj++) {          for (kk=0; kk<sizes[2]; kk++) {              for (ll=0; ll<sizes[3]; ll++) {                  double absint = fabs(buffer[ibuf]);                  if (absint > maxintegral) {                      maxintegral = absint;                    }                  if (bounds &&  absint > integralbound) {                      cout << scprintf("((%d %d)(%d %d)|(%d %d)(%d %d)) = %15.11f, "                             "bound = %15.11f\n",                             sh[0], ii, sh[1], jj, sh[2], kk, sh[3], ll,                             buffer[ibuf], integralbound);                      abort();                    }                  if (print && (absint > 1.0e-9                                || (bounds && integralbound > 1.0e-9))) {                      cout << scprintf(" ((%d %d)(%d %d)|(%d %d)(%d %d))"                             " = %15.11f",                             sh[0],ii,                             sh[1],jj,                             sh[2],kk,                             sh[3],ll,                             buffer[ibuf]);                      if (bounds) {                          cout << scprintf(" (%2d%% of bound)",                                 (int)(100*(absint/integralbound)));                        }                      cout << scprintf("\n");                    }                  ibuf++;                }            }        }    }  if (permute) {      double buff1[maxint][maxint][maxint][maxint];      sh[0] = i;      sh[1] = j;      sh[2] = k;      sh[3] = l;      init_shell_perm(int2ev3, buffer, buff1, sh, sizes);      check_shell_perm(int2ev3, buffer, buff1, sh, sizes, 0, 1, 2, 3);      check_shell_perm(int2ev3, buffer, buff1, sh, sizes, 1, 0, 2, 3);      check_shell_perm(int2ev3, buffer, buff1, sh, sizes, 0, 1, 3, 2);      check_shell_perm(int2ev3, buffer, buff1, sh, sizes, 1, 0, 3, 2);      check_shell_perm(int2ev3, buffer, buff1, sh, sizes, 2, 3, 0, 1);      check_shell_perm(int2ev3, buffer, buff1, sh, sizes, 2, 3, 1, 0);      check_shell_perm(int2ev3, buffer, buff1, sh, sizes, 3, 2, 0, 1);      check_shell_perm(int2ev3, buffer, buff1, sh, sizes, 3, 2, 1, 0);    }  if (bounds) {      int boundij = int2ev3->erep_4bound(i,j,-1,-1);      int boundkl = int2ev3->erep_4bound(-1,-1,k,l);      int badbound = 0;      if (boundij < boundijkl || boundkl < boundijkl) {          badbound = 1;        }      if (badbound || printbounds) {          cout << scprintf("max(%d,%d,%d,%d)=%7.4f, bnd=%7.4f, "                 "bnd(%d,%d,*,*)=%7.4f, bnd(*,*,%d,%d)=%7.4f\n",                 i, j, k, l, maxintegral, integralbound,                 i,j, int2ev3->logbound_to_bound(boundij),                 k,l, int2ev3->logbound_to_bound(boundkl));        }      if (badbound) {          cout << scprintf("ERROR: bad bound\n");          abort();        }    }}voiddo_4_center_test(const Ref<Int2eV3> &int2ev3, int print, int printbounds,                 int bounds, int permute,                 const Ref<KeyVal>& keyval){  int ii,jj,kk,ll, i,j,k,l, ibuf;  int nshell = int2ev3->basis()->nshell();  int unique = keyval->booleanvalue("unique");  int timestats = keyval->booleanvalue("timestats");  Ref<RegionTimer> timer = new RegionTimer();  if (!timestats) {      for (i=0; i<nshell; i++) {          int jmax = nshell - 1;          if (unique) jmax = i;          for (j=0; j<=jmax; j++) {              int kmax = nshell - 1;              if (unique) kmax = i;              for (k=0; k<=kmax; k++) {                  int lmax = nshell - 1;                  if (unique) {                      if (k==i) lmax = j;                      else lmax = k;                    }                  for (l=0; l<=lmax; l++) {                      do_shell_quartet_test(int2ev3, print, printbounds,                                            bounds, permute,                                            keyval, i, j, k, l);                    }                }            }        }    }  if (timestats && nshell) {      unsigned short seed = 1234;      seed48(&seed);      const int nsample = 5000;      const int ntrials = 50;      double times[ntrials];      for (i=0; i<ntrials; i++) {          double t1 = timer->get_cpu_time();          for (j=0; j<nsample; j++) {              // pick an integral at random              int ish = int(drand48()*nshell);              int jsh = int(drand48()*ish);              int ksh = int(drand48()*ish);              int lsh;              if (ish==ksh) lsh = int(drand48()*jsh);              else lsh = int(drand48()*ksh);              int sh[4], sizes[4];              if (ish >= nshell) ish = nshell-1;              if (jsh >= nshell) jsh = nshell-1;              if (ksh >= nshell) ksh = nshell-1;              if (lsh >= nshell) lsh = nshell-1;              sh[0] = ish;              sh[1] = jsh;              sh[2] = ksh;              sh[3] = lsh;              int2ev3->erep(sh,sizes);            }          double t2 = timer->get_cpu_time();          times[i] = t2-t1;        }      double ave = 0.0;      for (i=0; i<ntrials; i++) {          ave += times[i];        }      ave /= ntrials;      double sigma2 = 0.0;      for (i=0; i<ntrials; i++) {          double diff = times[i] - ave;          sigma2 += diff*diff;        }      double sigma = sqrt(sigma2/ntrials);      // adjust sigma and ave from the trial average results to      // the integral results      ave /= nsample;      sigma /= sqrt(double(nsample));      cout << scprintf(" ave = %10.8f sigma = %10.8f (microsecs)\n"                       " sigma/ave = %10.4f",                       ave*1e6, sigma*1e6,                       sigma/ave)           << endl;    }}voidtest_4_center(const Ref<KeyVal>& keyval, const Ref<Int2eV3> &int2ev3){  int i;  cout << scprintf("4 center test:\n");  cout << scprintf("  on entry int2ev3 used %d bytes\n", int2ev3->used_storage());  int2ev3->set_permute(0);  int2ev3->set_redundant(1);  int storage = keyval->intvalue("storage") - int2ev3->used_storage();  if (storage < 0) storage = 0;  if (keyval->booleanvalue("store_integrals")) storage = 0;  int niter = keyval->intvalue("niter");  int print = keyval->booleanvalue("print");  int bounds = keyval->booleanvalue("bounds");  int permute = keyval->booleanvalue("permute");  int printbounds = keyval->booleanvalue("printbounds");  cout << scprintf("  storage   = %d\n", storage);  cout << scprintf("  niter     = %d\n", niter);  cout << scprintf("  print     = %d\n", print);  cout << scprintf("  bounds    = %d\n", bounds);  cout << scprintf("  permute   = %d\n", permute);  cout << scprintf("printbounds = %d\n", printbounds);  if (bounds) int2ev3->init_bounds();  int2ev3->init_storage(storage);  for (i=0; i<niter; i++) {      do_4_center_test(int2ev3, print, printbounds, bounds, permute, keyval);    }  if (keyval->count("quartet") == 4) {      do_shell_quartet_test(int2ev3, print, printbounds, bounds, permute,                            keyval,                            keyval->intvalue("quartet", 0),                            keyval->intvalue("quartet", 1),                            keyval->intvalue("quartet", 2),                            keyval->intvalue("quartet", 3));    }  int2ev3->done_storage();  int2ev3->done_bounds();}voiddo_shell_quartet_der_test(const Ref<Int2eV3> &int2ev3,                          double* buffer, int print, int printbounds,                          int bounds, int permute,                          const Ref<KeyVal>& keyval,                          int i, int j, int k, int l){  int ii,jj,kk,ll, ibuf, ider, xyz;  der_centersv3_t dercenters;  int sh[4], sizes[4];  sh[0] = i;  sh[1] = j;  sh[2] = k;  sh[3] = l;  double maxintegral = 0.0, integralbound;  int boundijkl;  if (bounds) {      integralbound          = int2ev3->logbound_to_bound(              (boundijkl = int2ev3->erep_4bound_1der(i,j,k,l))              );    }  int2ev3->erep_all1der(sh,sizes,&dercenters);  ibuf = 0;  for (ider=0; ider<dercenters.n; ider++) {      for (xyz=0; xyz<3; xyz++) {          for (ii=0; ii<sizes[0]; ii++) {              for (jj=0; jj<sizes[1]; jj++) {                  for (kk=0; kk<sizes[2]; kk++) {                      for (ll=0; ll<sizes[3]; ll++) {                          double absint = fabs(buffer[ibuf]);                          if (absint > maxintegral) {                              maxintegral = absint;                            }                          if (bounds &&  absint > integralbound) {                              cout << scprintf("((%d %d)(%d %d)|(%d %d)(%d %d))"                                     " = %15.11f, bound = %15.11f\n",                                     sh[0], ii, sh[1], jj,                                     sh[2], kk, sh[3], ll,                                     buffer[ibuf], integralbound);                              abort();                            }                          if (print && absint > 1.0e-15) {                              cout << scprintf(" ((%d %d)(%d %d)"                                     "|(%d %d)(%d %d))(%d %d)"                                     " = %15.11f\n",                                     sh[0],ii,                                     sh[1],jj,                                     sh[2],kk,                                     sh[3],ll,                                     dercenters.num[ider], xyz,                                     buffer[ibuf]                                  );                            }                          ibuf++;                        }                    }                }            }        }    }  if (bounds) {      int boundij = int2ev3->erep_4bound_1der(i,j,-1,-1);      int boundkl = int2ev3->erep_4bound_1der(-1,-1,k,l);      int badbound = 0;      if (boundij < boundijkl || boundkl < boundijkl) {          badbound = 1;        }      if (badbound || printbounds) {          cout << scprintf("max(%d,%d,%d,%d)=%7.4f, bnd=%7.4f, "                 "bnd(%d,%d,*,*)=%8.4f, bnd(*,*,%d,%d)=%8.4f\n",                 i, j, k, l, maxintegral, integralbound,                 i,j, int2ev3->logbound_to_bound(boundij),                 k,l, int2ev3->logbound_to_bound(boundkl));        }      if (badbound) {          cout << scprintf("ERROR: bad bound\n");          abort();        }    }}voiddo_test_4der_center(const Ref<Int2eV3> &int2ev3,                    double* buffer, int print, int printbounds,                    int bounds, int permute,                    const Ref<KeyVal>& keyval){  int i,j,k,l;  int nshell = int2ev3->basis()->nshell();  for (i=0; i<nshell; i++) {      for (j=0; j<nshell; j++) {          for (k=0; k<nshell; k++) {              for (l=0; l<nshell; l++) {                  do_shell_quartet_der_test(int2ev3, buffer,                                            print, printbounds,                                            bounds, permute,                                            keyval,                                            i, j, k, l);                }            }        }    }}voidtest_4der_center(const Ref<KeyVal>& keyval, const Ref<Int2eV3> &int2ev3){  int i;  int2ev3->set_permute(0);  int2ev3->set_redundant(1);  double *buffer = int2ev3->buffer();  int niter = keyval->intvalue("niter");  int print = keyval->booleanvalue("print");  int bounds = keyval->booleanvalue("bounds");  int printbounds = keyval->booleanvalue("printbounds");  int permute = keyval->booleanvalue("permute");  cout << scprintf("4 center derivative test:\n");  cout << scprintf("  niter      = %d\n", niter);  cout << scprintf("  print      = %d\n", print);  cout << scprintf("  bounds     = %d\n", bounds);  cout << scprintf("printbounds  = %d\n", printbounds);  cout << scprintf("  permute    = %d\n", permute);  if (bounds) int2ev3->init_bounds_1der();  for (i=0; i<niter; i++) {      do_test_4der_center(int2ev3, buffer,                          print, printbounds, bounds, permute, keyval);    }  if (keyval->count("quartet") == 4) {      do_shell_quartet_der_test(int2ev3, buffer, print, printbounds,                                bounds, permute,                                keyval,                                keyval->intvalue("quartet", 0),                                keyval->intvalue("quartet", 1),                                keyval->intvalue("quartet", 2),                                keyval->intvalue("quartet", 3));    }  if (bounds) int2ev3->done_bounds_1der();}/////////////////////////////////////////////////////////////////////////////// Local Variables:// mode: c++// c-file-style: "CLJ"// End:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -