aboutsummaryrefslogtreecommitdiff
path: root/src/ewald.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-02-05 18:41:10 +0100
committerThomas White <taw@physics.org>2010-02-05 18:41:10 +0100
commit526e497f6a7266dbdf6750c1b23f1e000df1c402 (patch)
tree554c696f30d46e8cbc5b6554d693351ea95dd5f5 /src/ewald.c
parent3c2e1af0410645b6e8c0e2b7dec8d7d07cfa9d00 (diff)
Fix obvious problems
Diffstat (limited to 'src/ewald.c')
-rw-r--r--src/ewald.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/ewald.c b/src/ewald.c
index f24e9273..a72f9dc6 100644
--- a/src/ewald.c
+++ b/src/ewald.c
@@ -57,7 +57,7 @@ static struct rvec quat_rot(struct rvec q, struct quaternion z)
}
-static void add_sphere(struct image *image, double k)
+static void add_sphere(struct image *image, double k, int soffs)
{
int x, y;
@@ -139,7 +139,7 @@ static void add_sphere(struct image *image, double k)
/* Now interpolate between the values to get
* the sampling points */
- i = 0;
+ i = soffs;
for ( sx=0; sx<SAMPLING; sx++ ) {
for ( sy=0; sy<SAMPLING; sy++ ) {
@@ -184,29 +184,30 @@ void get_ewald(struct image *image)
{
double kc; /* Wavenumber */
int i, kstep;
+ int mtotal = 0;
kc = 1/image->lambda; /* Centre */
- image->qvecs = malloc(image->width * image->height
- * sizeof(struct rvec *));
-
image->twotheta = malloc(image->width * image->height
* sizeof(double));
/* Create the spheres */
image->nspheres = SAMPLING*SAMPLING*BWSAMPLING;
+ image->qvecs = malloc(image->nspheres * sizeof(struct rvec *));
+
for ( i=0; i<image->nspheres; i++ ) {
+ mtotal += image->width * image->height * sizeof(struct rvec);
image->qvecs[i] = malloc(image->width * image->height
* sizeof(struct rvec));
}
+ STATUS("%i spheres, %i Mbytes\n", image->nspheres, mtotal/(1024*1024));
for ( kstep=0; kstep<BWSAMPLING; kstep++ ) {
double k;
k = kc + (kstep-(BWSAMPLING/2))*kc*(BANDWIDTH/BWSAMPLING);
-
- add_sphere(image, k);
+ add_sphere(image, k, kstep*SAMPLING);
}
}