|
| 1 | +/******************************************************************************* |
| 2 | +* Instrument: Test_filters |
| 3 | +* |
| 4 | +* %Identification |
| 5 | +* Written by: <a href="mailto: [email protected]">Peter Willendrup</a> |
| 6 | +* Date: March 2026 |
| 7 | +* Origin: <a href="http://www.ess.eu">ESS</a> |
| 8 | +* %INSTRUMENT_SITE: PSI |
| 9 | +* |
| 10 | +* Test instrument for McStas components as Be-filters |
| 11 | +* |
| 12 | +* %Description |
| 13 | +* Test instrument for cross-checking McStas components for use as Be-filters. |
| 14 | +* Where applicable, the temperature is set to 80K (corresponding to the header |
| 15 | +* of the Be.trm file used in Filter_gen |
| 16 | +* |
| 17 | +* %Example: Filter=0 Detector: L_out_I=2183.87 |
| 18 | +* %Example: Filter=1 T=80 Detector: L_out_I=1875.02 |
| 19 | +* %Example: Filter=2 Detector: L_out_I=1868.5 |
| 20 | +* %Example: Filter=3 Detector: L_out_I=2011.26 |
| 21 | +* |
| 22 | +* %Parameters |
| 23 | +* Lmin: [Angs] Lowest wavelength from source |
| 24 | +* Lmax: [Angs] Highest wavelength from source |
| 25 | +* nL: [1] Number of wavelength bins in [Lmin Lmax] interval |
| 26 | +* Filter: [1] Choice of filter 0: Filter_gen, 1: NCrystal, 2: PowderN, 3: Isotropic_Sqw |
| 27 | +* zdepth: [m] Depth of Be-filter |
| 28 | +* T: [K] Filter temperature (NCrystal only) |
| 29 | +* %Link |
| 30 | +* <a href="https://doi.org/10.1107/S0567739478000121">Acta Cryst. (1978). A34, 61-65</a> |
| 31 | +* <a href="https://doi.org/10.1063/1.1140212">Rev. Sci. Instrum. 59, 380-381 (1988)</a> |
| 32 | +* Test instrument written by P Willendrup < [email protected]> ESS, March 2026 |
| 33 | +* |
| 34 | +* %End |
| 35 | +*******************************************************************************/ |
| 36 | +DEFINE INSTRUMENT Test_filters(double Lmin=0.5, double Lmax=10, int Filter=0, int nL=101, double zdepth=0.15, double T=80) |
| 37 | + |
| 38 | +DECLARE |
| 39 | +%{ |
| 40 | + double lambda0; |
| 41 | + double dlambda; |
| 42 | + char NCcfg[128]; |
| 43 | +%} |
| 44 | + |
| 45 | +INITIALIZE |
| 46 | +%{ |
| 47 | + lambda0 = (Lmax+Lmin)/2.0; |
| 48 | + dlambda = (Lmax-Lmin)/2.0; |
| 49 | + sprintf(NCcfg,"Be_sg194.ncmat;temp=%.2gK",T); |
| 50 | + |
| 51 | + if(Filter==0) { |
| 52 | + MPI_MASTER( printf("Running with Filter_gen(filename=\"Be.trm\", zdepth=%g,...)\n",zdepth); ); |
| 53 | + } else if (Filter==1) { |
| 54 | + MPI_MASTER( printf("Running with NCrystal(cfg=\"%s\", zdepth=%g,...)\n",NCcfg,zdepth); ); |
| 55 | + } else if (Filter==2) { |
| 56 | + MPI_MASTER( printf("Running with PowderN(reflections=\"Be.laz\", zdepth=%g,...)\n",zdepth); ); |
| 57 | + } else if (Filter==3) { |
| 58 | + MPI_MASTER( printf("Running with Isotropic_Sqw(Sqw_coh=\"Be.laz\", zdepth=%g,...)\n",zdepth); ); |
| 59 | + } else { |
| 60 | + MPI_MASTER( fprintf(stderr,"Sorry, Filter=%d not supported!\n",Filter); ); |
| 61 | + exit(-1); |
| 62 | + } |
| 63 | +%} |
| 64 | + |
| 65 | +TRACE |
| 66 | + |
| 67 | +COMPONENT a1 = Progress_bar() |
| 68 | + AT (0,0,0) ABSOLUTE |
| 69 | + |
| 70 | +COMPONENT source_div = Source_div( |
| 71 | + xwidth=0.1, |
| 72 | + yheight=0.1, |
| 73 | + focus_aw=0.00001, |
| 74 | + focus_ah=0.00001, |
| 75 | + lambda0=lambda0, |
| 76 | + dlambda=dlambda, |
| 77 | + flux=1e14) |
| 78 | +AT (0, 0, 0) RELATIVE a1 |
| 79 | + |
| 80 | +COMPONENT L_in = L_monitor( |
| 81 | + nL=nL, |
| 82 | + xwidth=0.1, |
| 83 | + yheight=0.1, |
| 84 | + Lmin=Lmin, |
| 85 | + Lmax=Lmax) |
| 86 | +AT (0, 0, 1e-3) RELATIVE source_div |
| 87 | + |
| 88 | +COMPONENT FilterA = Filter_gen( |
| 89 | + filename = "Be.trm", |
| 90 | + xwidth = 0.2, |
| 91 | + yheight = 0.2, |
| 92 | + thickness = zdepth) |
| 93 | +WHEN Filter==0 AT (0, 0, 1e-3) RELATIVE L_in |
| 94 | + |
| 95 | +COMPONENT FilterB = NCrystal_sample(yheight=0.2, xwidth=0.2, zdepth=zdepth,cfg=NCcfg) |
| 96 | +WHEN Filter==1 AT (0, 0, 1e-3) RELATIVE L_in |
| 97 | + |
| 98 | + |
| 99 | +COMPONENT FilterC = PowderN(yheight=0.2, xwidth=0.2, zdepth=zdepth,reflections="Be.laz") |
| 100 | +WHEN Filter==2 AT (0, 0, 1e-3) RELATIVE L_in |
| 101 | + |
| 102 | +COMPONENT FilterD = Isotropic_Sqw(yheight=0.2, xwidth=0.2, zdepth=zdepth,Sqw_coh="Be.laz") |
| 103 | +WHEN Filter==3 AT (0, 0, 1e-3) RELATIVE L_in |
| 104 | + |
| 105 | + |
| 106 | +COMPONENT L_out = L_monitor( |
| 107 | + nL=nL, |
| 108 | + xwidth=0.1, |
| 109 | + yheight=0.1, |
| 110 | + Lmin=Lmin, |
| 111 | + Lmax=Lmax) |
| 112 | +AT (0, 0, zdepth+1e-3) RELATIVE FilterA |
| 113 | + |
| 114 | +END |
0 commit comments