From 0309dfadf55b72023bb9d9131b80a701c211f684 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 25 Oct 2010 16:25:57 +0200 Subject: Add "bandwidth" to beam parameters file Also, fix previous commit. --- src/beam-parameters.c | 19 +++++++++++++------ src/beam-parameters.h | 4 ++++ src/diffraction-gpu.c | 8 ++++---- src/diffraction.c | 7 +++---- 4 files changed, 24 insertions(+), 14 deletions(-) (limited to 'src') 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; xswidth*SAMPLING; xs++ ) { for ( ys=0; ysheight*SAMPLING; ys++ ) { -- cgit v1.2.3