aboutsummaryrefslogtreecommitdiff
path: root/src/diffraction.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2014-01-17 16:52:57 +0100
committerThomas White <taw@physics.org>2014-01-20 17:20:14 +0100
commit90ee3c269580104f2d16d28aeaa565063f6fc1f2 (patch)
treebd3c69f932648dc6fb01e4cce69bd27fb4831be2 /src/diffraction.c
parent8e2f2f44f46c18f7bd621a2ef9a3d0aa813d76d9 (diff)
RNG overhaul
Previously, we were using random(), which is really really bad.
Diffstat (limited to 'src/diffraction.c')
-rw-r--r--src/diffraction.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/diffraction.c b/src/diffraction.c
index 826aac77..92e18521 100644
--- a/src/diffraction.c
+++ b/src/diffraction.c
@@ -456,7 +456,7 @@ static struct sample *get_gaussian_spectrum(double eV_cen, double eV_step,
}
-static int add_sase_noise(struct sample *spectrum, int nsteps)
+static int add_sase_noise(struct sample *spectrum, int nsteps, gsl_rng *rng)
{
struct sample *noise;
int i, j;
@@ -483,7 +483,7 @@ static int add_sase_noise(struct sample *spectrum, int nsteps)
noise[i].weight = 0.0;
/* Gaussian noise with mean = 0, std = 1 */
- gaussianNoise[i] = gaussian_noise(noise_mean, noise_sigma);
+ gaussianNoise[i] = gaussian_noise(rng, noise_mean, noise_sigma);
gaussianNoise[i+nsteps] = gaussianNoise[i];
gaussianNoise[i+2*nsteps] = gaussianNoise[i];
}
@@ -546,7 +546,7 @@ struct sample *generate_tophat(struct image *image)
}
-struct sample *generate_SASE(struct image *image)
+struct sample *generate_SASE(struct image *image, gsl_rng *rng)
{
struct sample *spectrum;
int i;
@@ -555,7 +555,7 @@ struct sample *generate_SASE(struct image *image)
const double jitter_sigma_eV = 8.0;
/* Central wavelength jitters with Gaussian distribution */
- eV_cen = gaussian_noise(ph_lambda_to_eV(image->lambda),
+ eV_cen = gaussian_noise(rng, ph_lambda_to_eV(image->lambda),
jitter_sigma_eV);
/* Convert FWHM to standard deviation. Note that bandwidth is taken to
@@ -571,7 +571,7 @@ struct sample *generate_SASE(struct image *image)
spectrum = get_gaussian_spectrum(eV_cen, eV_step, sigma, spec_size);
/* Add SASE-type noise to Gaussian spectrum */
- add_sase_noise(spectrum, spec_size);
+ add_sase_noise(spectrum, spec_size, rng);
/* Normalise intensity (before taking restricted number of samples) */
double total_weight = 0.0;