From 911a5a47ecee5fce2ad3d16bd1460f779011c083 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 7 Dec 2017 11:51:56 +0100 Subject: pattern_sim: Add --flat --- src/diffraction-gpu.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/diffraction-gpu.c') diff --git a/src/diffraction-gpu.c b/src/diffraction-gpu.c index 22abcfd2..ea50b3fa 100644 --- a/src/diffraction-gpu.c +++ b/src/diffraction-gpu.c @@ -72,7 +72,8 @@ struct gpu_context }; -static void check_sinc_lut(struct gpu_context *gctx, int n, int no_fringes) +static void check_sinc_lut(struct gpu_context *gctx, int n, + int no_fringes, int flat) { cl_int err; cl_image_format fmt; @@ -105,8 +106,10 @@ static void check_sinc_lut(struct gpu_context *gctx, int n, int no_fringes) for ( i=1; i 1.0/n) && (1.0-x > 1.0/n) ) { + if ( (flat || no_fringes) && (x > 1.0/n) && (1.0-x > 1.0/n) ) { val = 0.0; + } else if ( flat ) { + val = n; } else { val = fabs(sin(M_PI*n*x)/sin(M_PI*x)); } @@ -279,7 +282,7 @@ static int do_panels(struct gpu_context *gctx, struct image *image, int get_diffraction_gpu(struct gpu_context *gctx, struct image *image, int na, int nb, int nc, UnitCell *ucell, - int no_fringes) + int no_fringes, int flat) { double ax, ay, az; double bx, by, bz; @@ -297,9 +300,9 @@ int get_diffraction_gpu(struct gpu_context *gctx, struct image *image, } /* Ensure all required LUTs are available */ - check_sinc_lut(gctx, na, no_fringes); - check_sinc_lut(gctx, nb, no_fringes); - check_sinc_lut(gctx, nc, no_fringes); + check_sinc_lut(gctx, na, no_fringes, flat); + check_sinc_lut(gctx, nb, no_fringes, flat); + check_sinc_lut(gctx, nc, no_fringes, flat); /* Unit cell */ cell_get_cartesian(ucell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz); -- cgit v1.2.3