From 0cff7cf6c478eb767dfc724ab72c7a9f088956e6 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Mon, 2 Mar 2026 20:42:36 +0100 Subject: [PATCH 1/5] Add Test instrument for Be-filter models --- .../Test_filters/Test_filters.instr | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr diff --git a/mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr b/mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr new file mode 100644 index 0000000000..aeb87a5e7d --- /dev/null +++ b/mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr @@ -0,0 +1,114 @@ +/******************************************************************************* +* Instrument: Test_filters +* +* %Identification +* Written by: Peter Willendrup +* Date: March 2026 +* Origin: ESS +* %INSTRUMENT_SITE: PSI +* +* Test instrument for McStas components as Be-filters +* +* %Description +* Test instrument for cross-checking McStas components for use as Be-filters. +* Where applicable, the temperature is set to 80K (corresponding to the header +* of the Be.trm file used in Filter_gen +* +* %Example: Filter=0 Detector: L_out_I=2183.87 +* %Example: Filter=1 T=80 Detector: L_out_I=1875.02 +* %Example: Filter=2 Detector: L_out_I=1868.5 +* %Example: Filter=4 Detector: L_out_I=2011.26 +* +* %Parameters +* Lmin: [Angs] Lowest wavelength from source +* Lmax: [Angs] Highest wavelength from source +* nL: [1] Number of wavelength bins in [Lmin Lmax] interval +* Filter: [1] Choice of filter: Filter_gen, NCrystal, PowderN, Isotropic_Sqw +* zdepth: [m] Depth of Be-filter +* T: [K] Filter temperature (NCrystal only) +* %Link +* Acta Cryst. (1978). A34, 61-65 +* Rev. Sci. Instrum. 59, 380–381 (1988) +* Test instrument written by P Willendrup ESS, March 2026 +* +* %End +*******************************************************************************/ +DEFINE INSTRUMENT Test_filters(double Lmin=0.5, double Lmax=10, int Filter=0, int nL=101, double zdepth=0.15, double T=80) + +DECLARE +%{ + double lambda0; + double dlambda; + char NCcfg[128]; +%} + +INITIALIZE +%{ + lambda0 = (Lmax+Lmin)/2.0; + dlambda = (Lmax-Lmin)/2.0; + sprintf(NCcfg,"Be_sg194.ncmat;temp=%.2gK",T); + + if(Filter==0) { + MPI_MASTER( printf("Running with Filter_gen(filename=\"Be.trm\", zdepth=%g,...)\n",zdepth); ); + } else if (Filter==1) { + MPI_MASTER( printf("Running with NCrystal(cfg=\"%s\", zdepth=%g,...)\n",NCcfg,zdepth); ); + } else if (Filter==2) { + MPI_MASTER( printf("Running with PowderN(reflections=\"Be.laz\", zdepth=%g,...)\n",zdepth); ); + } else if (Filter==2) { + MPI_MASTER( printf("Running with Isotropic_Sqw(Sqw_coh=\"Be.laz\", zdepth=%g,...)\n",zdepth); ); + } else { + MPI_MASTER( fprintf(stderr,"Sorry, Filter=%d not supported!\n",Filter); ); + exit(-1); + } +%} + +TRACE + +COMPONENT a1 = Progress_bar() + AT (0,0,0) ABSOLUTE + +COMPONENT source_div = Source_div( + xwidth=0.1, + yheight=0.1, + focus_aw=0.00001, + focus_ah=0.00001, + lambda0=lambda0, + dlambda=dlambda, + flux=1e14) +AT (0, 0, 0) RELATIVE a1 + +COMPONENT L_in = L_monitor( + nL=nL, + xwidth=0.1, + yheight=0.1, + Lmin=Lmin, + Lmax=Lmax) +AT (0, 0, 1e-3) RELATIVE source_div + +COMPONENT FilterA = Filter_gen( + filename = "Be.trm", + xwidth = 0.2, + yheight = 0.2, + thickness = zdepth) +WHEN Filter==0 AT (0, 0, 1e-3) RELATIVE L_in + +COMPONENT FilterB = NCrystal_sample(yheight=0.2, xwidth=0.2, zdepth=zdepth,cfg=NCcfg) +WHEN Filter==1 AT (0, 0, 1e-3) RELATIVE L_in + + +COMPONENT FilterC = PowderN(yheight=0.2, xwidth=0.2, zdepth=zdepth,reflections="Be.laz") +WHEN Filter==2 AT (0, 0, 1e-3) RELATIVE L_in + +COMPONENT FilterD = Isotropic_Sqw(yheight=0.2, xwidth=0.2, zdepth=zdepth,Sqw_coh="Be.laz") +WHEN Filter==3 AT (0, 0, 1e-3) RELATIVE L_in + + +COMPONENT L_out = L_monitor( + nL=nL, + xwidth=0.1, + yheight=0.1, + Lmin=Lmin, + Lmax=Lmax) +AT (0, 0, zdepth+1e-3) RELATIVE FilterA + +END From c236fa2343c45b128d44277d45991b2cd314e07e Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Mon, 2 Mar 2026 20:47:32 +0100 Subject: [PATCH 2/5] Replace dash char --- .../examples/Tests_optics/Test_filters/Test_filters.instr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr b/mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr index aeb87a5e7d..132253f059 100644 --- a/mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr +++ b/mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr @@ -28,7 +28,7 @@ * T: [K] Filter temperature (NCrystal only) * %Link * Acta Cryst. (1978). A34, 61-65 -* Rev. Sci. Instrum. 59, 380–381 (1988) +* Rev. Sci. Instrum. 59, 380-381 (1988) * Test instrument written by P Willendrup ESS, March 2026 * * %End From 4d26e10c93b3064aeacf2add715a6d6d34d8654b Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Mon, 2 Mar 2026 20:49:09 +0100 Subject: [PATCH 3/5] List filter identifiers in mcdoc string --- .../examples/Tests_optics/Test_filters/Test_filters.instr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr b/mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr index 132253f059..431c86a396 100644 --- a/mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr +++ b/mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr @@ -23,7 +23,7 @@ * Lmin: [Angs] Lowest wavelength from source * Lmax: [Angs] Highest wavelength from source * nL: [1] Number of wavelength bins in [Lmin Lmax] interval -* Filter: [1] Choice of filter: Filter_gen, NCrystal, PowderN, Isotropic_Sqw +* Filter: [1] Choice of filter 0: Filter_gen, 1: NCrystal, 2: PowderN, 3: Isotropic_Sqw * zdepth: [m] Depth of Be-filter * T: [K] Filter temperature (NCrystal only) * %Link From f2707ad0b14c342dff7a92d53db0d5580b713d77 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Mon, 2 Mar 2026 21:09:17 +0100 Subject: [PATCH 4/5] Correct 4th test --- .../examples/Tests_optics/Test_filters/Test_filters.instr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr b/mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr index 431c86a396..696fed8f44 100644 --- a/mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr +++ b/mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr @@ -17,7 +17,7 @@ * %Example: Filter=0 Detector: L_out_I=2183.87 * %Example: Filter=1 T=80 Detector: L_out_I=1875.02 * %Example: Filter=2 Detector: L_out_I=1868.5 -* %Example: Filter=4 Detector: L_out_I=2011.26 +* %Example: Filter=3 Detector: L_out_I=2011.26 * * %Parameters * Lmin: [Angs] Lowest wavelength from source From 292b49a2a7775e919248ad1020492301f819d040 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Mon, 2 Mar 2026 21:26:37 +0100 Subject: [PATCH 5/5] Correct copy-paste typo in if-statement --- .../examples/Tests_optics/Test_filters/Test_filters.instr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr b/mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr index 696fed8f44..62ee4cc574 100644 --- a/mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr +++ b/mcstas-comps/examples/Tests_optics/Test_filters/Test_filters.instr @@ -54,7 +54,7 @@ INITIALIZE MPI_MASTER( printf("Running with NCrystal(cfg=\"%s\", zdepth=%g,...)\n",NCcfg,zdepth); ); } else if (Filter==2) { MPI_MASTER( printf("Running with PowderN(reflections=\"Be.laz\", zdepth=%g,...)\n",zdepth); ); - } else if (Filter==2) { + } else if (Filter==3) { MPI_MASTER( printf("Running with Isotropic_Sqw(Sqw_coh=\"Be.laz\", zdepth=%g,...)\n",zdepth); ); } else { MPI_MASTER( fprintf(stderr,"Sorry, Filter=%d not supported!\n",Filter); );