aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/examples/lcls-dec.beam5
-rw-r--r--doc/examples/lcls-june.beam5
-rw-r--r--src/beam-parameters.c19
-rw-r--r--src/beam-parameters.h4
-rw-r--r--src/diffraction-gpu.c8
-rw-r--r--src/diffraction.c7
6 files changed, 34 insertions, 14 deletions
diff --git a/doc/examples/lcls-dec.beam b/doc/examples/lcls-dec.beam
index e19709a3..5fe6ea24 100644
--- a/doc/examples/lcls-dec.beam
+++ b/doc/examples/lcls-dec.beam
@@ -7,6 +7,11 @@ beam/radius = 3.0e-6 / 2.0
; Photon energy in eV
beam/photon_energy = 2000.0
+; Bandwidth: FWHM(wavelength) over wavelength.
+; Note: current simulation code just uses a rectangular
+; distribution with this as its (full) width.
+beam/bandwidth = 0.001
+
; Detector's quantum efficiency
detector/dqe = 0.9
diff --git a/doc/examples/lcls-june.beam b/doc/examples/lcls-june.beam
index cc6cf28f..367e9921 100644
--- a/doc/examples/lcls-june.beam
+++ b/doc/examples/lcls-june.beam
@@ -7,6 +7,11 @@ beam/radius = 3.0e-6 / 2.0
; Photon energy in eV
beam/photon_energy = 2000.0
+; Bandwidth: FWHM(wavelength) over wavelength.
+; Note: current simulation code just uses a rectangular
+; distribution with this as its (full) width.
+beam/bandwidth = 0.001
+
; Detector's quantum efficiency
detector/dqe = 0.9
diff --git a/src/beam-parameters.c b/src/beam-parameters.c
index 73dc2897..9f5a0dde 100644
--- a/src/beam-parameters.c
+++ b/src/beam-parameters.c
@@ -37,6 +37,7 @@ struct beam_params *get_beam_parameters(const char *filename)
b->fluence = -1.0;
b->beam_radius = -1.0;
b->photon_energy = -1.0;
+ b->bandwidth = -1.0;
b->dqe = -1.0;
b->adu_per_photon = -1.0;
b->water_radius = -1.0;
@@ -66,17 +67,19 @@ struct beam_params *get_beam_parameters(const char *filename)
}
if ( strcmp(bits[0], "beam/fluence") == 0 ) {
- b->fluence = atof(bits[0]);
+ b->fluence = atof(bits[2]);
} else if ( strcmp(bits[0], "beam/radius") == 0 ) {
- b->beam_radius = atof(bits[0]);
+ b->beam_radius = atof(bits[2]);
} else if ( strcmp(bits[0], "beam/photon_energy") == 0 ) {
- b->photon_energy = atof(bits[0]);
+ b->photon_energy = atof(bits[2]);
+ } else if ( strcmp(bits[0], "beam/bandwidth") == 0 ) {
+ b->bandwidth = atof(bits[2]);
} else if ( strcmp(bits[0], "detector/dqe") == 0 ) {
- b->dqe = atof(bits[0]);
+ b->dqe = atof(bits[2]);
} else if ( strcmp(bits[0], "detector/adu_per_photon") == 0 ) {
- b->adu_per_photon = atof(bits[0]);
+ b->adu_per_photon = atof(bits[2]);
} else if ( strcmp(bits[0], "jet/radius") == 0 ) {
- b->water_radius = atof(bits[0]);
+ b->water_radius = atof(bits[2]);
} else {
ERROR("Unrecognised field '%s'\n", bits[0]);
}
@@ -102,6 +105,10 @@ struct beam_params *get_beam_parameters(const char *filename)
" 'beam/photon_energy'.\n");
reject = 1;
}
+ if ( b->bandwidth < 0.0 ) {
+ ERROR("Invalid or unspecified value for 'beam/bandwidth'.\n");
+ reject = 1;
+ }
if ( b->dqe < 0.0 ) {
ERROR("Invalid or unspecified value for 'detector/dqe'.\n");
reject = 1;
diff --git a/src/beam-parameters.h b/src/beam-parameters.h
index 84d95b49..aec2c6aa 100644
--- a/src/beam-parameters.h
+++ b/src/beam-parameters.h
@@ -23,6 +23,10 @@ struct beam_params
double fluence; /* photons per pulse */
double beam_radius; /* metres */
double photon_energy; /* eV per photon */
+ double bandwidth; /* FWHM(wavelength) over wavelength.
+ * Note: current simulation code just uses
+ * a rectangular distribution with this as
+ * its (full) width. */
double dqe; /* Detector DQE (fraction) */
double adu_per_photon; /* Detector "gain" */
diff --git a/src/diffraction-gpu.c b/src/diffraction-gpu.c
index 7a5bef85..409178b9 100644
--- a/src/diffraction-gpu.c
+++ b/src/diffraction-gpu.c
@@ -23,11 +23,11 @@
#include "diffraction.h"
#include "sfac.h"
#include "cl-utils.h"
+#include "beam-parameters.h"
#define SAMPLING (4)
-#define BWSAMPLING (1)
-#define BANDWIDTH (0.0 / 100.0)
+#define BWSAMPLING (10)
#define SINC_LUT_ELEMENTS (4096)
@@ -137,8 +137,8 @@ void get_diffraction_gpu(struct gpu_context *gctx, struct image *image,
/* Calculate wavelength */
k = 1.0/image->lambda; /* Centre value */
- klow = k - k*(BANDWIDTH/2.0); /* Lower value */
- bwstep = k * BANDWIDTH / BWSAMPLING;
+ klow = k - k*(image->beam->bandwidth/2.0); /* Lower value */
+ bwstep = k * image->beam->bandwidth / BWSAMPLING;
/* Orientation */
orientation.s[0] = image->orientation.w;
diff --git a/src/diffraction.c b/src/diffraction.c
index 00a73b94..66a2ba27 100644
--- a/src/diffraction.c
+++ b/src/diffraction.c
@@ -26,8 +26,7 @@
#define SAMPLING (4)
-#define BWSAMPLING (1)
-#define BANDWIDTH (0.0 / 100.0)
+#define BWSAMPLING (10)
static double lattice_factor(struct rvec q, double ax, double ay, double az,
@@ -313,8 +312,8 @@ void get_diffraction(struct image *image, int na, int nb, int nc,
image->twotheta = malloc(image->width * image->height * sizeof(double));
k = 1.0/image->lambda; /* Centre value */
- klow = k - k*(BANDWIDTH/2.0); /* Lower value */
- bwstep = k * BANDWIDTH / BWSAMPLING;
+ klow = k - k*(image->beam->bandwidth/2.0); /* Lower value */
+ bwstep = k * image->beam->bandwidth / BWSAMPLING;
for ( xs=0; xs<image->width*SAMPLING; xs++ ) {
for ( ys=0; ys<image->height*SAMPLING; ys++ ) {