aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2009-11-25 16:19:31 +0100
committerThomas White <taw@physics.org>2009-11-25 16:19:31 +0100
commit3a895d677389fa4d5048d9ebc0f9c2496ac1faca (patch)
tree66886f7a08c877ec0dff0c9567dbce2f4fb9b675 /src
parent76cbb192f4abdd5f5c280cee964357c64364c783 (diff)
Water fixes
Diffstat (limited to 'src')
-rw-r--r--src/detector.c11
-rw-r--r--src/diffraction.c10
2 files changed, 13 insertions, 8 deletions
diff --git a/src/detector.c b/src/detector.c
index 2d095611..a0b09799 100644
--- a/src/detector.c
+++ b/src/detector.c
@@ -157,20 +157,25 @@ void record_image(struct image *image)
for ( x=0; x<image->width; x++ ) {
for ( y=0; y<image->height; y++ ) {
- double counts, intensity, sa;
+ double counts, intensity, sa, water;
double complex val;
val = image->sfacs[x + image->width*y];
intensity = (double)(val * conj(val));
/* Add intensity contribution from water */
- intensity += water_intensity(image->qvecs[x + image->width*y],
- image->xray_energy);
+ water = water_intensity(image->qvecs[x + image->width*y],
+ image->xray_energy);
+
+ //printf("%e + %e", intensity, water);
+ intensity += water;
+ //printf(" = %e\n", intensity);
/* What solid angle is subtended by this pixel? */
sa = sa_per_pixel * cos(image->twotheta[x + image->width*y]);
counts = intensity * ph_per_e * sa;
+ //printf("%e counts\n", counts);
image->hdr[x + image->width*y] = counts;
diff --git a/src/diffraction.c b/src/diffraction.c
index 6351042d..8cf3f4ed 100644
--- a/src/diffraction.c
+++ b/src/diffraction.c
@@ -103,7 +103,7 @@ double water_intensity(struct threevec q, double en)
{
double complex fH, fO;
double s, modq;
- double intensity;
+ double complex ifac;
/* Interatomic distances in water molecule */
const double rOH = 0.09584e-9;
@@ -128,15 +128,15 @@ double water_intensity(struct threevec q, double en)
fO = get_sfac("O", s, en);
/* Four O-H cross terms */
- intensity = 4.0*fH*fO * sin(modq*rOH)/(modq*rOH);
+ ifac = 4.0*fH*fO * sin(2.0*M_PI*modq*rOH)/(2.0*M_PI*modq*rOH);
/* Three H-H cross terms */
- intensity += 3.0*fH*fH * sin(modq*rHH)/(modq*rHH);
+ ifac += 3.0*fH*fH * sin(2.0*M_PI*modq*rHH)/(2.0*M_PI*modq*rHH);
/* Three diagonal terms */
- intensity += 2.0*fH*fH + fO*fO;
+ ifac += 2.0*fH*fH + fO*fO;
- return intensity * n_water;
+ return cabs(ifac) * n_water;
}