~ubuntu-branches/ubuntu/karmic/psicode/karmic

« back to all changes in this revision

Viewing changes to src/bin/cints/Tools/rad_extent.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck, Michael Banck, Daniel Leidert
  • Date: 2009-02-23 00:12:02 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090223001202-rutldoy3dimfpesc
Tags: 3.4.0-1
* New upstream release.

[ Michael Banck ]
* debian/patches/01_DESTDIR.dpatch: Refreshed.
* debian/patches/02_FHS.dpatch: Removed, applied upstream.
* debian/patches/03_debian_docdir: Likewise.
* debian/patches/04_man.dpatch: Likewise.
* debian/patches/06_466828_fix_gcc_43_ftbfs.dpatch: Likewise.
* debian/patches/07_464867_move_executables: Fixed and refreshed.
* debian/patches/00list: Adjusted.
* debian/control: Improved description.
* debian/patches-held: Removed.
* debian/rules (install/psi3): Do not ship the ruby bindings for now.

[ Daniel Leidert ]
* debian/rules: Fix txtdir via DEB_MAKE_INSTALL_TARGET.
* debian/patches/01_DESTDIR.dpatch: Refreshed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <stdio.h>
2
 
#include <math.h>
3
 
#include <libint/libint.h>
4
 
 
5
 
#include"defines.h"
6
 
#define EXTERN
7
 
#include"global.h"
8
 
 
9
 
#define MAX_ITER 100
10
 
 
11
 
/*------------------------------------------------------
12
 
  Use Newton-Raphson method to find maximum r for which
13
 
  the radial parts of basis functions drop below
14
 
  some threshold.
15
 
 ------------------------------------------------------*/
16
 
 
17
 
void init_rad_extent(double thresh)
18
 
{
19
 
  int i;
20
 
  int iter;
21
 
  int shell, prim, first_prim, last_prim, am;
22
 
  const double r0 = 4.0;        /* Start at 4.0 bohr ---*/
23
 
  double func, dfuncdr, sum, dsumdr;
24
 
  double r, r_new, tmp;
25
 
 
26
 
  BasisSet.thresh = thresh;
27
 
  
28
 
  for (shell=0;shell<BasisSet.num_shells;shell++) {
29
 
    r_new = r = r0;
30
 
    first_prim = BasisSet.shells[shell].fprim - 1;
31
 
    last_prim = first_prim + BasisSet.shells[shell].n_prims - 1;
32
 
    am = BasisSet.shells[shell].am-1;
33
 
    iter = 0;
34
 
    do {
35
 
      iter++;
36
 
      r = r_new;
37
 
      /*--------------------------------------
38
 
        evaluate the radial part of the shell
39
 
        and its first derivative
40
 
       --------------------------------------*/
41
 
      func = -thresh;
42
 
      dfuncdr = 0;
43
 
      for(prim=first_prim;prim<=last_prim;prim++) {
44
 
        tmp = BasisSet.cgtos[prim].ccoeff[am]*exp(-BasisSet.cgtos[prim].exp*(r*r));
45
 
        switch(am) {
46
 
        case 0:
47
 
          func += tmp;
48
 
          dfuncdr += -2.0*r*BasisSet.cgtos[prim].exp*tmp;
49
 
          break;
50
 
        case 1:
51
 
          func += r*tmp;
52
 
          dfuncdr += (1.0-2.0*r*r*BasisSet.cgtos[prim].exp)*tmp;
53
 
          break;
54
 
        default:
55
 
          for(i=1;i<am;i++)
56
 
            tmp *= r;
57
 
          func += r*tmp;
58
 
          dfuncdr += (1.0-2.0*r*r*BasisSet.cgtos[prim].exp)*tmp;
59
 
        }
60
 
      }
61
 
 
62
 
      /*--- We actually want to look at the
63
 
        absolute value of the basis function ---*/
64
 
      if (func+thresh < 0.0) {
65
 
        func = -(func+thresh)-thresh;
66
 
        dfuncdr *= -1.0;
67
 
      }
68
 
 
69
 
      /*--- If the function is too tight - reduce r ---*/
70
 
      if (func+thresh == 0.0 && dfuncdr == 0.0) {
71
 
        r_new /= 2.5;
72
 
        continue;
73
 
      }
74
 
 
75
 
      /*--- If before or at the maximum (for p-functions and higher)
76
 
            step hopefully past it ---*/
77
 
      if (dfuncdr >= 0.0) {
78
 
        r_new *= 2.5;
79
 
        continue;
80
 
      }
81
 
        
82
 
      r_new = r - func/dfuncdr;
83
 
      if ( r_new <= 0.0 ) {
84
 
        r_new = r / 2.0;
85
 
      }
86
 
 
87
 
      if (iter > MAX_ITER)
88
 
        punt("Too many iterations while computing radial extents");
89
 
      
90
 
    } while (fabs(func/thresh) >= SOFT_ZERO);
91
 
 
92
 
    BasisSet.shells[shell].rad_extent = r_new;
93
 
    if (UserOptions.print_lvl > PRINT_DEBUG)
94
 
      fprintf(outfile,"Shell# = %d    Radial extent = %lf\n",shell,r_new);
95
 
      
96
 
  }
97
 
 
98
 
  return;
99
 
}
100
 
 
101