diff options
author | Thomas White <taw@physics.org> | 2019-05-24 17:08:04 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2019-05-29 10:42:14 +0200 |
commit | 0e1726e01645c110e9935cc8c3e8f35291b2b82d (patch) | |
tree | b2e2fad656dda0dbd36b2e109944bd111a57bb7b /tests | |
parent | 581f8e8ab1b1d2833fd689540a2758bea1fc93ee (diff) |
Spectrum generation
Diffstat (limited to 'tests')
-rw-r--r-- | tests/spectrum_check.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/spectrum_check.c b/tests/spectrum_check.c index 7d37689d..e910aad3 100644 --- a/tests/spectrum_check.c +++ b/tests/spectrum_check.c @@ -59,12 +59,30 @@ static int check_integral(Spectrum *s, int nsamp) } +static void plot_spectrum(Spectrum *s) +{ + double min, max, step; + int i; + const int nsamp = 100; + + spectrum_get_range(s, &min, &max); + step = (max-min)/nsamp; + for ( i=0; i<=nsamp; i++ ) { + double x = min+i*step; + double y = spectrum_get_density_at_k(s, x); + printf("%e %e\n", x, y); + } +} + int main(int argc, char *argv[]) { Spectrum *s; struct gaussian gauss; + gsl_rng *rng; int r = 0; + rng = gsl_rng_alloc(gsl_rng_mt19937); + s = spectrum_new(); gauss.kcen = ph_eV_to_k(9000); gauss.sigma = ph_eV_to_k(100); @@ -73,5 +91,11 @@ int main(int argc, char *argv[]) r += check_integral(s, 100); spectrum_free(s); + s = spectrum_generate_sase(ph_eV_to_k(9000), 0.01, 0.0005, rng); + plot_spectrum(s); + spectrum_free(s); + + gsl_rng_free(rng); + return r; } |