From cfb3b8bcb4f0e3c6329d65ac181a8019176e39e6 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 4 Mar 2011 16:49:44 +0100 Subject: Make CPU simulation more similar to GPU version --- src/diffraction.c | 52 ++++++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/src/diffraction.c b/src/diffraction.c index 88be4ffe..a09d993b 100644 --- a/src/diffraction.c +++ b/src/diffraction.c @@ -343,58 +343,54 @@ void get_diffraction(struct image *image, int na, int nb, int nc, khigh = 1.0/(image->lambda*(1.0 - image->beam->bandwidth/2.0)); bwstep = (khigh-klow) / BWSAMPLING; - for ( fs=0; fswidth*SAMPLING; fs++ ) { - for ( ss=0; ssheight*SAMPLING; ss++ ) { + for ( fs=0; fswidth; fs++ ) { + for ( ss=0; ssheight; ss++ ) { - struct rvec q; - double twotheta; - double sw = 1.0/(SAMPLING*SAMPLING); /* Sample weight */ - - const double dfs = fs / SAMPLING; - const double dss = ss / SAMPLING; - - int kstep; + int fs_step, ss_step, kstep; + int idx = fs + image->width*ss; + for ( fs_step=0; fs_steptwotheta[sfs + image->width*sss] = twotheta; - f_lattice = lattice_factor(q, ax, ay, az, bx, by, bz, cx, cy, cz, na, nb, nc); - if ( intensities == NULL ) { - I_molecule = 1.0e10; - } else { - I_molecule = molecule_factor(intensities, - phases, flags, q, - ax,ay,az, - bx,by,bz,cx,cy,cz, - m, sym); - } + I_molecule = molecule_factor(intensities, + phases, flags, q, + ax,ay,az,bx,by,bz,cx,cy,cz, + m, sym); I_lattice = pow(f_lattice, 2.0); + intensity = I_lattice * I_molecule; - intensity = sw * kw * I_lattice * I_molecule; - image->data[sfs + image->width*sss] += intensity; + image->data[idx] += intensity; + if ( fs_step + ss_step + kstep == 0 ) { + image->twotheta[idx] = twotheta; + } + + } } + } + + image->data[idx] /= SAMPLING*SAMPLING*BWSAMPLING; } -- cgit v1.2.3