4
#include <libipv1/ip_lib.h>
5
#include <libciomr/libciomr.h>
10
#include"lebedev_init.h"
13
prim_atomic_grid_t init_uniform_prim_atomic_grid(int n_rpoints,int n_angpoints,int num_chunks){
17
int n_rpoints_plus_two;
22
double four_pi_div_by_rps;
26
prim_atomic_grid_t prim_atomic_grid;
27
leb_sphere_t unit_sphere;
32
n_rpoints_plus_two = n_rpoints+1.0;
33
n_rpoints_d = (double) n_rpoints+1.0;
34
four_pi_div_by_rps = 4.0*_pi/n_rpoints_d;
36
prim_atomic_grid.chunk_num = num_chunks;
38
/*-------------------------
39
Initialize the unit sphere,
40
there is only one here
41
---------------------------*/
43
unit_sphere = lebedev_init(n_angpoints);
45
/* ------------------------
46
Set up primitive chunks
47
-----------------------*/
49
chunk_size = n_rpoints/num_chunks;
51
prim_atomic_grid.leb_chunk = (prim_leb_chunk_t *)
52
malloc(sizeof(prim_leb_chunk_t)*num_chunks);
54
for(i=0;i<num_chunks;i++){
56
/* ----- Set up radial offsets for each chunk ------*/
58
start = i*chunk_size+1;
59
end = start+chunk_size;
62
if(i == num_chunks-1){
64
chunk_size = end-start;
69
/*------------------------------
70
Here I am actually going to
71
calculate the r values as
72
if the Bragg radii was 1.0.
73
This way the primitive
74
atomic grid will be self contained
75
------------------------------*/
77
prim_atomic_grid.leb_chunk[i].spheres = (leb_sphere_t *)
78
malloc(sizeof(leb_sphere_t)*chunk_size);
80
for(j=0;j<chunk_size;j++){
81
sph = &(prim_atomic_grid.leb_chunk[i].spheres[j]);
83
rind = (double) j + (double) start;
85
qr = rind/n_rpoints_d;
87
/* -------------------------------
88
Straight from the Murray, Handy, Laming paper
90
----------------------------------*/
92
r = rind*rind/((n_rpoints_d - rind)
93
*(n_rpoints_d - rind));
95
/*drdq = four_pi_div_by_rps*r*r*2.0*qr/((1-qr)*(1-qr)*(1-qr));*/
96
drdq = 2.0*pow(rind,5)*(n_rpoints_d)*pow(n_rpoints_d-rind,-7.0);
97
sph->points = (leb_point_t *)malloc(sizeof(leb_point_t)*n_angpoints);
99
for(k=0;k<n_angpoints;k++){
101
sph->points[k].p_cart.x =
102
unit_sphere.points[k].p_cart.x*r;
103
sph->points[k].p_cart.y =
104
unit_sphere.points[k].p_cart.y*r;
105
sph->points[k].p_cart.z =
106
unit_sphere.points[k].p_cart.z*r;
107
sph->points[k].ang_weight =
108
unit_sphere.points[k].ang_weight;
114
sph->n_ang_points = unit_sphere.n_ang_points;
117
prim_atomic_grid.leb_chunk[i].radial_start = start;
118
prim_atomic_grid.leb_chunk[i].radial_end = end;
119
prim_atomic_grid.leb_chunk[i].size = chunk_size;
121
return prim_atomic_grid;