From ef6a971cf432321ceb057b8c355c8e6814d5aff6 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 13 Nov 2009 12:10:12 +0100 Subject: Work in progress on photon correctness --- src/ewald.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/ewald.c') diff --git a/src/ewald.c b/src/ewald.c index 9d8a0450..e9f36596 100644 --- a/src/ewald.c +++ b/src/ewald.c @@ -19,16 +19,30 @@ #include "cell.h" +/* Pulse energy density in J/m^2 */ +#define PULSE_ENERGY_DENSITY (30.0e7) + + void get_ewald(struct image *image) { int x, y; double k; /* Wavenumber */ + double i0fac; k = 1/image->lambda; + /* How many photons are scattered per electron? */ + i0fac = PULSE_ENERGY_DENSITY * pow(THOMSON_LENGTH, 2.0) + / image->xray_energy; + + printf("%e photons are scattered per electron\n", i0fac); + image->qvecs = malloc(image->width * image->height * sizeof(struct threevec)); + image->phactors = malloc(image->width * image->height + * sizeof(double)); + for ( x=0; xwidth; x++ ) { for ( y=0; yheight; y++ ) { @@ -36,6 +50,7 @@ void get_ewald(struct image *image) double twothetax, twothetay, twotheta; double qx, qy, qz; + /* Calculate q vectors for Ewald sphere */ rx = ((double)x - image->x_centre) / image->resolution; ry = ((double)y - image->y_centre) / image->resolution; r = sqrt(pow(rx, 2.0) + pow(ry, 2.0)); @@ -51,6 +66,9 @@ void get_ewald(struct image *image) image->qvecs[x + image->width*y].u = qx; image->qvecs[x + image->width*y].v = qy; image->qvecs[x + image->width*y].w = qz; + + /* Calculate photon factor ("phactor") */ + } } -- cgit v1.2.3