aboutsummaryrefslogtreecommitdiff
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
parent3c2e1af0410645b6e8c0e2b7dec8d7d07cfa9d00 (diff)
Fix obvious problems
-rw-r--r--src/diffraction.c6
-rw-r--r--src/ewald.c15
2 files changed, 11 insertions, 10 deletions
diff --git a/src/diffraction.c b/src/diffraction.c
index b9430ba7..b3d6bef0 100644
--- a/src/diffraction.c
+++ b/src/diffraction.c
@@ -157,8 +157,8 @@ void get_diffraction(struct image *image, int na, int nb, int nc, int no_sfac)
STATUS("Particle size = %i x %i x %i (=%5.2f x %5.2f x %5.2f nm)\n",
na, nb, nc, na*a/1.0e-9, nb*b/1.0e-9, nc*c/1.0e-9);
- image->sfacs = malloc(image->width * image->height
- * sizeof(double complex));
+ image->sfacs = calloc(image->width * image->height,
+ sizeof(double complex));
if ( !no_sfac ) {
if ( image->molecule->reflections == NULL ) {
@@ -190,7 +190,7 @@ void get_diffraction(struct image *image, int na, int nb, int nc, int no_sfac)
}
val = f_molecule * f_lattice;
- image->sfacs[x + image->width*y] = val;
+ image->sfacs[x + image->width*y] += val;
}
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);
}
}