aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcrystfel/src/detector.c10
-rw-r--r--libcrystfel/src/detector.h2
-rw-r--r--libcrystfel/src/image.h2
-rw-r--r--src/partial_sim.c2
-rw-r--r--src/pattern_sim.c33
-rw-r--r--tests/gpu_sim_check.c2
6 files changed, 36 insertions, 15 deletions
diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c
index 9972e2ba..4a202f2e 100644
--- a/libcrystfel/src/detector.c
+++ b/libcrystfel/src/detector.c
@@ -323,7 +323,7 @@ double get_tt(struct image *image, double fs, double ss, int *err)
void record_image(struct image *image, int do_poisson, int background,
- gsl_rng *rng)
+ gsl_rng *rng, double beam_radius, double nphotons)
{
int x, y;
double total_energy, energy_density;
@@ -338,14 +338,14 @@ void record_image(struct image *image, int do_poisson, int background,
int n_nan2 = 0;
/* How many photons are scattered per electron? */
- area = M_PI*pow(image->beam->beam_radius, 2.0);
- total_energy = image->beam->fluence * ph_lambda_to_en(image->lambda);
+ area = M_PI*pow(beam_radius, 2.0);
+ total_energy = nphotons * ph_lambda_to_en(image->lambda);
energy_density = total_energy / area;
- ph_per_e = (image->beam->fluence /area) * pow(THOMSON_LENGTH, 2.0);
+ ph_per_e = (nphotons /area) * pow(THOMSON_LENGTH, 2.0);
STATUS("Fluence = %8.2e photons, "
"Energy density = %5.3f kJ/cm^2, "
"Total energy = %5.3f microJ\n",
- image->beam->fluence, energy_density/1e7, total_energy*1e6);
+ nphotons, energy_density/1e7, total_energy*1e6);
for ( x=0; x<image->width; x++ ) {
for ( y=0; y<image->height; y++ ) {
diff --git a/libcrystfel/src/detector.h b/libcrystfel/src/detector.h
index ba88c12e..519de050 100644
--- a/libcrystfel/src/detector.h
+++ b/libcrystfel/src/detector.h
@@ -181,7 +181,7 @@ extern double get_tt(struct image *image, double xs, double ys, int *err);
extern int in_bad_region(struct detector *det, double fs, double ss);
extern void record_image(struct image *image, int do_poisson, int background,
- gsl_rng *rng);
+ gsl_rng *rng, double beam_radius, double nphotons);
extern struct panel *find_panel(struct detector *det, double fs, double ss);
diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h
index 0a64e081..bc78147e 100644
--- a/libcrystfel/src/image.h
+++ b/libcrystfel/src/image.h
@@ -100,8 +100,6 @@ struct sample
struct beam_params
{
- double fluence; /* photons per pulse */
- double beam_radius; /* metres */
double photon_energy; /* eV per photon */
char *photon_energy_from; /* HDF5 dataset name */
double photon_energy_scale; /* Scale factor for photon energy, if the
diff --git a/src/partial_sim.c b/src/partial_sim.c
index 32c5bb01..8d8bc885 100644
--- a/src/partial_sim.c
+++ b/src/partial_sim.c
@@ -449,8 +449,6 @@ int main(int argc, char *argv[])
beam.photon_energy = 9000.0;
/* Beam parameters which it doesn't make sense to use here */
- beam.fluence = -1.0;
- beam.beam_radius = -1.0;
beam.photon_energy_scale = 1.0;
/* Long options */
diff --git a/src/pattern_sim.c b/src/pattern_sim.c
index 14d533c5..7bbad81d 100644
--- a/src/pattern_sim.c
+++ b/src/pattern_sim.c
@@ -270,6 +270,8 @@ int main(int argc, char *argv[])
Stream *st = NULL;
int no_fringes = 0;
struct beam_params beam;
+ double nphotons = 1e12;
+ double beam_radius = 1e-6; /* metres */
/* Default beam parameters */
beam.bandwidth = 0.01;
@@ -277,8 +279,6 @@ int main(int argc, char *argv[])
beam.photon_energy = 9000.0;
/* Beam parameters which it doesn't make sense to use here */
- beam.fluence = -1.0;
- beam.beam_radius = -1.0;
beam.photon_energy_scale = 1.0;
beam.divergence = -1.0; /* (not implemented .. yet?) */
@@ -312,6 +312,8 @@ int main(int argc, char *argv[])
{"beam-bandwidth", 1, NULL, 7},
{"profile-radius", 1, NULL, 8},
{"photon-energy", 1, NULL, 9},
+ {"nphotons", 1, NULL, 10},
+ {"beam-radius", 1, NULL, 11},
{0, 0, NULL, 0}
};
@@ -457,6 +459,30 @@ int main(int argc, char *argv[])
}
break;
+ case 10 :
+ nphotons = strtod(optarg, &rval);
+ if ( *rval != '\0' ) {
+ ERROR("Invalid number of photons.\n");
+ return 1;
+ }
+ if ( nphotons < 0.0 ) {
+ ERROR("Number of photons must be positive.\n");
+ return 1;
+ }
+ break;
+
+ case 11 :
+ beam_radius = strtod(optarg, &rval);
+ if ( *rval != '\0' ) {
+ ERROR("Invalid beam radius.\n");
+ return 1;
+ }
+ if ( beam_radius < 0.0 ) {
+ ERROR("Beam radius must be positive.\n");
+ return 1;
+ }
+ break;
+
case 0 :
break;
@@ -770,7 +796,8 @@ int main(int argc, char *argv[])
goto skip;
}
- record_image(&image, !config_nonoise, background, rng);
+ record_image(&image, !config_nonoise, background, rng,
+ beam_radius, nphotons);
if ( powder_fn != NULL ) {
diff --git a/tests/gpu_sim_check.c b/tests/gpu_sim_check.c
index 7edb180a..a829d1db 100644
--- a/tests/gpu_sim_check.c
+++ b/tests/gpu_sim_check.c
@@ -152,8 +152,6 @@ int main(int argc, char *argv[])
gpu_image.det = det;
beam = calloc(1, sizeof(struct beam_params));
- beam->fluence = 1.0e15; /* Does nothing */
- beam->beam_radius = 1.0e-6;
beam->photon_energy = 6000.0;
beam->bandwidth = 1.0 / 100.0;
beam->divergence = 0.0;