aboutsummaryrefslogtreecommitdiff
path: root/src/ewald.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2009-11-13 12:10:12 +0100
committerThomas White <taw@physics.org>2009-11-13 12:10:12 +0100
commitef6a971cf432321ceb057b8c355c8e6814d5aff6 (patch)
tree1d8d7373a1b7c1591cf28fcf61230122e19c1ca4 /src/ewald.c
parent857cc8c991a5ee4e717d01822da271ae34f5adaa (diff)
Work in progress on photon correctness
Diffstat (limited to 'src/ewald.c')
-rw-r--r--src/ewald.c18
1 files changed, 18 insertions, 0 deletions
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; x<image->width; x++ ) {
for ( y=0; y<image->height; 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") */
+
}
}