diff options
Diffstat (limited to 'tests/spectrum_check.c')
-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; } |