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

« back to all changes in this revision

Viewing changes to src/bin/cints/DFT/init_unf_prim_atomic_grid.cc

  • 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
/*! \file init_unf_prim_atomic_grid.cc
 
2
    \ingroup CINTS
 
3
    \brief Enter brief description of file here 
 
4
*/
 
5
#include<cstdio>
 
6
#include<cstdlib>
 
7
#include<cmath>
 
8
#include <libipv1/ip_lib.h>
 
9
#include <libciomr/libciomr.h>
 
10
 
 
11
#include"defines.h"
 
12
#define EXTERN
 
13
#include"global.h"
 
14
#include <stdexcept>
 
15
#include"lebedev_init.h"
 
16
#include"physconst.h"
 
17
 
 
18
namespace psi { namespace CINTS {
 
19
 
 
20
prim_atomic_grid_t init_uniform_prim_atomic_grid(int n_rpoints,int n_angpoints,int num_chunks){
 
21
    int i,j,k;
 
22
    int start,end;
 
23
    int chunk_size;
 
24
    int n_rpoints_plus_two;
 
25
    double qr;
 
26
    double r;
 
27
    double rind;
 
28
    double n_rpoints_d;
 
29
    double four_pi_div_by_rps;
 
30
    double x,y,z;
 
31
    double drdq;
 
32
    
 
33
    prim_atomic_grid_t prim_atomic_grid;
 
34
    leb_sphere_t unit_sphere;
 
35
    leb_sphere_t *sph;
 
36
    
 
37
    /* Constants */
 
38
    
 
39
    n_rpoints_plus_two = n_rpoints+1.0;
 
40
    n_rpoints_d = (double) n_rpoints+1.0;
 
41
    four_pi_div_by_rps = 4.0*_pi/n_rpoints_d;
 
42
    
 
43
    prim_atomic_grid.chunk_num = num_chunks;
 
44
 
 
45
/*-------------------------
 
46
  Initialize the unit sphere, 
 
47
  there is only one here 
 
48
  ---------------------------*/
 
49
    
 
50
    unit_sphere = lebedev_init(n_angpoints);
 
51
    
 
52
    /* ------------------------
 
53
       Set up primitive chunks
 
54
       -----------------------*/
 
55
    
 
56
    chunk_size = n_rpoints/num_chunks;
 
57
    
 
58
    prim_atomic_grid.leb_chunk = (prim_leb_chunk_t *)
 
59
        malloc(sizeof(prim_leb_chunk_t)*num_chunks);
 
60
    
 
61
    for(i=0;i<num_chunks;i++){
 
62
        
 
63
        /* ----- Set up radial offsets for each chunk ------*/
 
64
        
 
65
        start = i*chunk_size+1;
 
66
        end = start+chunk_size;
 
67
        
 
68
        
 
69
        if(i == num_chunks-1){
 
70
            end = n_rpoints+1;
 
71
            chunk_size = end-start; 
 
72
        }
 
73
        
 
74
        
 
75
        
 
76
        /*------------------------------
 
77
          Here I am actually going to 
 
78
          calculate the r values as
 
79
          if the Bragg radii was 1.0.
 
80
          This way the primitive 
 
81
          atomic grid will be self contained
 
82
          ------------------------------*/
 
83
        
 
84
        prim_atomic_grid.leb_chunk[i].spheres = (leb_sphere_t *)
 
85
            malloc(sizeof(leb_sphere_t)*chunk_size);
 
86
        
 
87
        for(j=0;j<chunk_size;j++){
 
88
            sph = &(prim_atomic_grid.leb_chunk[i].spheres[j]);
 
89
            
 
90
            rind = (double) j + (double) start;
 
91
            
 
92
            qr = rind/n_rpoints_d;
 
93
            
 
94
            /* -------------------------------
 
95
               Straight from the Murray, Handy, Laming paper
 
96
               for mr = 2 
 
97
               ----------------------------------*/
 
98
                
 
99
            r = rind*rind/((n_rpoints_d  - rind)
 
100
                           *(n_rpoints_d  - rind));
 
101
            
 
102
            /*drdq = four_pi_div_by_rps*r*r*2.0*qr/((1-qr)*(1-qr)*(1-qr));*/
 
103
            drdq = 2.0*pow(rind,5)*(n_rpoints_d)*pow(n_rpoints_d-rind,-7.0);
 
104
            sph->points = (leb_point_t *)malloc(sizeof(leb_point_t)*n_angpoints);
 
105
            
 
106
            for(k=0;k<n_angpoints;k++){
 
107
                
 
108
                sph->points[k].p_cart.x = 
 
109
                    unit_sphere.points[k].p_cart.x*r;
 
110
                sph->points[k].p_cart.y =
 
111
                    unit_sphere.points[k].p_cart.y*r;
 
112
                sph->points[k].p_cart.z =
 
113
                    unit_sphere.points[k].p_cart.z*r;
 
114
                sph->points[k].ang_weight =
 
115
                    unit_sphere.points[k].ang_weight;
 
116
            }
 
117
 
 
118
            sph->r = r;
 
119
            
 
120
            sph->drdq = drdq;
 
121
            sph->n_ang_points = unit_sphere.n_ang_points;
 
122
        }
 
123
        
 
124
        prim_atomic_grid.leb_chunk[i].radial_start = start;
 
125
        prim_atomic_grid.leb_chunk[i].radial_end = end;
 
126
        prim_atomic_grid.leb_chunk[i].size = chunk_size;    
 
127
    }
 
128
    return prim_atomic_grid;
 
129
}          
 
130
};}