1/*******************************************************************************
2*         McStas instrument definition URL=http://mcstas.risoe.dk
3*
4* Instrument: ILL_IN13
5*
6* %Identification
7* Written by: E. Farhi and A. Dennison
8* Date: March 25, 2015
9* Origin:ILL
10* %INSTRUMENT_SITE: ILL
11*
12* IN13 Thermal neutron backscattering spectrometer (without guide)
13*
14* %Description
15* IN13 Thermal neutron backscattering spectrometer (without guide)
16*
17* Because of its high energy resolution and high momentum transfer the
18* backscattering spectrometer IN13 is particularly useful for the microscopic
19* study of single particle motions (jump reorientation, rotational and
20* translational diffusion, tunnelling) observed by incoherent neutron scattering.
21*
22* The high energy resolution of the order of a few μeV together with the
23* availability of high momentum transfer (Q<4.9 Å-1) makes the spectrometer IN13
24* particularly useful for the microscopic study of single particle motions (jump
25* reorientation, rotational and translational diffusion, tunnelling) observed by
26* incoherent neutron scattering. The instrument partly fills the gap of (Q, ω)
27* space between IN10 and IN5.
28*
29* Temperature gradient monochromator
30* The monochromator and analyser CaF2(422) crystals are oriented in near
31* backscattering geometry thereby achieving an energy resolution of a few μeV. The
32* energy of the incident neutrons is scanned by variation of the temperature of
33* the monochromator at a fixed Bragg-angle. In an optional mode the 10 mm thick
34* monochromator crystals are kept at a fixed temperature gradient and energy
35* variation is performed by scanning the monochromator Bragg-angle. This achieves
36* an increased flux at the sample position and slightly increases the energy
37* resolution width.
38*
39* A vertically curved Graphite deflector focusses the beam onto
40* the sample. The scattered neutrons are energy analysed by a set of seven
41* spherically curved composite crystal analysers, each covering a large solid
42* angle of 0.18 sr. An additional three circular analysers centred around the
43* transmitted beam cover the small-angle region.
44*
45* The neutron time-of-flight is used to suppress (i) the background of neutrons
46* scattered directly from the sample into the detectors and (ii) second order
47* contamination. The neutrons are counted with a cylindrical multidetector
48* consisting of 35 3He detector tubes, arranged in staggered circular rows. The
49* small Q range from 0.2 to 0.8 Å-1 is covered by a 3He Position Sensitive
50* Detector (PSD) arranged to see the circular analysers in exact backscattering.
51*
52* Monochromator: CaF2(422)
53*   temperature range:  -125 < ΔE/µeV < 150
54*   angular range:       81° < θM < 89°
55*   incident energy:     16.45 meV (TM≥25°C)
56*   incident wavelength: 2.23 Å
57*   energy resolution:   8 µeV
58*
59* Deflector: PG(002)
60*
61* Sample: here incoherent elastic scatterer (Vanadium)
62*   sample size          3.5 x 3.5 cm2
63*   flux at sample       2e4 n cm-2 s-1 (when fed from H24, NOT in this model)
64*
65* Analyser: CaF2(422)
66*   Q-range:             0.2 < Q/Å-1 < 4.9
67*   Q-resolution:        ΔQ/Å-1 < 0.1
68*
69* %Example: TM=301 Detector: SamposPSD_I=5905.14
70*
71* %Parameters
72* RMV: [m]           monochromator vertical curvature. Use 0=flat, -1=auto.
73* RDV: [m]           deflector vertical curvature. Use 0=flat, -1=auto.
74* RDH: [m]           deflector horizontal curvature. Use 0=flat, -1=auto.
75* TM: [K]            monochromator temperature, from 77 to 500 K
76* LMD: [m]           monochromator-deflector distance
77* CaF2mos: [arcmin]  monochromator mosaic
78* mos_ana: [arcmin]  analyser mosaic
79* gW: []
80*
81* %Link
82* The <a href="http://www.ill.fr/YellowBook/IN3">IN3 TAS</a> at the ILL
83*
84* %End
85*******************************************************************************/
86DEFINE INSTRUMENT ILL_IN13( RMV=0, RDV=4.6, RDH=0, TM=301, LMD=1.8, mos_ana=2, CaF2mos=10, gW=0.030)
87
88DECLARE
89%{
90
91  /* Declaration of IN13 instrument parameters */
92
93  /*temperature things for mono*/
94  double beta1=1.9406e-5, beta2=1.8744e-8, T0=301;
95  double d0 =  1.1115;
96
97
98  double DM;
99
100  /* Monochromator general parameters */
101
102  /*mono angle*/
103  double TH0 =-88.31; /* this is fixed. Bragg spot moves aside, and so does the deflector and spectrometer */
104  /*gap from guide exit/source-mono*/
105  double GM = 0.2;
106  /*nominal wavelength for IN13*/
107  double IN13lam; /* should be around 2.23 */
108  double IN13energy;
109  /*monochromator crystal mosaic spread*/
110  double CaF2mos = 2.5;
111
112  /* Deflector general parameters*/
113
114  /* deflector angle */
115  double dTH0;
116
117
118  double LDS = 2.3; /* distance from deflector to sample */
119  double LSD = 0.25;/* sample to detector */
120  double LSA = 1.0; /* sample to analyser */
121
122  /* Incident beam collimation is 2 slits. Slit distances and sizes can be set here. */
123  /* At other take-off angles this will need to be implemented as a function in below section. */
124  double defl_slit = 0.5;
125  double S1W = 0.1;
126  double S1H = 0.15;
127  double S2W = 0.03;
128  double S2H = 0.04;
129
130  double RotateNeutronX; /* the angle to rotate neutron so that neutrons go to the analyser */
131  double RotateNeutronY; /* the angle to rotate neutron so that neutrons go to the analyser */
132  double RVA;            /* curvature of analyser (local approx) */
133
134  double flag_mono_transmitted=0;
135  double flag_sample=0;
136%}
137
138/* The INITIALIZE section is executed when the simulation starts     */
139/* (C code). You may use them as component parameter values.         */
140INITIALIZE
141%{
142  double L1;
143  double mGuide=2;
144  double Ki,Vi;
145
146  /* This expression calculates the d-spacing of a CaF2 crystal in function
147	  of the temperature x. Data found in Bee, Quasielastic Neutron Scattering,
148	  Hilger, 1988. For the nominal wavelength of 2.23A the value of TEM should be set
149	  to TEM= (gives d-spacing of 1.115A)
150    */
151  DM      = d0*(1+beta1*(TM-T0)+beta2/2*(TM-T0)*(TM-T0));
152  IN13lam = fabs(2*DM*sin(TH0*DEG2RAD));     /* should be around 2.23 */
153  dTH0    = asin(IN13lam/(2*1.607))*RAD2DEG; /* Defelector half take-off */
154
155  Ki         = 2*PI/IN13lam;
156  Vi         = K2V*Ki;
157  IN13energy = VS2E*Vi*Vi;
158
159  L1 = 0.15/( mGuide/4 * 0.1 * IN13lam * DEG2RAD ); /* divergence from guide */
160
161  /* curvature radii: automatic setting from optical formulae */
162  if (RMV < 0) {
163    double L  = 1/(1/L1 + 1/(LMD+LDS));
164    RMV = 2*L*sin(DEG2RAD*TH0);
165  }
166
167  RMV = fabs(RMV)*(TH0 > 0 ? 1 : -1);
168
169  if (RDV < 0) {
170    double L =1/(1/(L1+LMD) + 1/LDS);
171    RDV = 2*L*sin(DEG2RAD*dTH0);
172  }
173  if (RDH < 0) {
174    double L =1/(1/(L1+LMD) + 1/LDS);
175    RDH = 2*L/sin(DEG2RAD*dTH0);
176  }
177
178  RDV = fabs(RDV)*(dTH0 > 0 ? 1 : -1);
179  RDH = fabs(RDH)*(dTH0 > 0 ? 1 : -1);
180
181  RVA = 1/((1/LSA)+(1/(LSA+LSD))); /* we use e.g. 20 cm from sample to detector */
182
183  /* display some stuff */
184  MPI_MASTER(
185    printf ("%s: IN13 Thermal neutron backscattering spectrometer\n",
186      NAME_CURRENT_COMP);
187    printf ("  Monochromator CaF2(422) lambda=%3.2f [Angs] Ei=%g [meV] RMV=%g [m]\n",
188      IN13lam, IN13energy, RMV);
189    printf ("  Deflector PG(002): angle=%3.2f [deg] RDV=%g [m] RDH=%g [m]\n",dTH0, RDV, RDH);
190  );
191%}
192
193/* Here comes the TRACE section, where the actual      */
194/* instrument is defined as a sequence of components.  */
195TRACE
196
197/* should be located at the end of the H24@ILL guide */
198REMOVABLE COMPONENT Progress = Progress_bar()
199  AT (0, 0, 0)  ABSOLUTE
200
201REMOVABLE COMPONENT Source = Source_gen(
202  lambda0=IN13lam, dlambda=0.005, xwidth=0.03, yheight=.125,
203  focus_xw=0.045*sin(TH0*DEG2RAD), focus_yh=0.15, target_index=+1,
204  I1=2e11, T1=300)
205  AT (0, 0, 0)  ABSOLUTE
206
207REMOVABLE COMPONENT EndOfFakeGuide = Arm()
208  AT (0, 0, 3.8) RELATIVE PREVIOUS
209
210/*
211   Monochromator Coordinate System =============================================
212*/
213COMPONENT mono_pos = Arm()
214AT (0, 0, 0.2)      RELATIVE PREVIOUS
215
216COMPONENT CaF2_incoming = Monitor_nD(
217  xwidth=0.05, yheight=0.17, options="x y", bins=100, restore_neutron=1)
218  AT (0, 0, 0) RELATIVE mono_pos
219
220SPLIT COMPONENT mono_cradle = Arm()
221AT (0, 0, 0)        RELATIVE mono_pos
222ROTATED (0, TH0, 0) RELATIVE mono_pos
223
224
225COMPONENT CaF2_mono = Monochromator_curved(width=0.045, height=0.15, NV=3, NH=1,
226  DM = DM, mosaic=CaF2mos, RV=RMV)
227  AT (0, 0, 0) RELATIVE mono_cradle
228  EXTEND %{
229    flag_mono_transmitted = !SCATTERED;
230  %}
231
232COMPONENT CaF2_transmitted = Monitor_nD(
233  xwidth=0.05, yheight=0.17, options="x y", bins=100, restore_neutron=1)
234  WHEN (flag_mono_transmitted)
235  AT (0, 0, 0.3) RELATIVE mono_pos
236  EXTEND %{
237    if (SCATTERED) ABSORB;
238  %}
239
240/*
241COMPONENT CaF2_crys1 = Single_crystal(
242    reflections = need_CaF2_file_here.lau, xwidth = 0.045,
243    yheight = 0.045, zdepth = 0.01, mosaic = 2.5, order = 1)
244  AT (0, 0.045, 0) RELATIVE mono_cradle
245  ROTATED (0, 0, -atan2(.045, RMV)) RELATIVE monocradle
246
247COMPONENT CaF2_crys1 = Single_crystal(
248    reflections = need_CaF2_file_here.lau, xwidth = 0.045,
249    yheight = 0.045, zdepth = 0.01, mosaic = 2.5, order = 1)
250  AT (0, 0.045, 0) RELATIVE mono_cradle
251  ROTATED (0, 0, 0) RELATIVE monocradle
252
253COMPONENT CaF2_crys1 = Single_crystal(
254    reflections = need_CaF2_file_here.lau, xwidth = 0.045,
255    yheight = 0.045, zdepth = 0.01, mosaic = 2.5, order = 1)
256  AT (0, 0.045, 0) RELATIVE mono_cradle
257  ROTATED (0, 0, atan2(.045, RMV)) RELATIVE monocradle
258*/
259
260 /*
261   This is the mono-deflector axis
262*/
263COMPONENT out_mono = Arm()
264AT(0, 0, 0) RELATIVE mono_cradle
265ROTATED (0, TH0, 0) RELATIVE mono_cradle
266
267/*
268   Deflector Coordinate System =================================================
269*/
270
271SPLIT COMPONENT defl_cradle = Arm()
272AT (0, 0, LMD) RELATIVE out_mono
273ROTATED (0, dTH0, 0) RELATIVE out_mono
274
275/* beam there is about 7x16 cm */
276COMPONENT Defl_XY = Monitor_nD(
277    bins=90, options="x y", restore_neutron = 1,
278    filename = "Defl_XY.psd", xwidth = 0.07, yheight = 0.2)
279  AT (0, 0, 0) RELATIVE PREVIOUS
280  ROTATED (0, 90, 0) RELATIVE PREVIOUS
281
282COMPONENT Defl_lambda = L_monitor(
283    nL = 500, filename = "Defl_lambda.lam", xwidth = 0.07,
284    yheight = 0.2, Lmin = 0, Lmax = 3, restore_neutron = 1)
285  AT (0, 0, 0) RELATIVE PREVIOUS
286
287COMPONENT IN13_deflector = Monochromator_curved(width=0.05, height=9*1.5e-2, NV=9, NH=9,
288  DM = 1.607, mosaic=50, RV=RDV, RH=RDH)
289  AT (0,0,0) RELATIVE defl_cradle
290  EXTEND %{
291    if (!SCATTERED) ABSORB;
292  %}
293
294/*
295   Claudia Mondelli's deflector model
296	DENNISON: variation on model based on actual focus and mosaic of individual crystals
297	Values and location of crystals in mono are taken from IN13 deflector schematic.
298	Crystals are defined from top to bottom of deflector.
299	HalfDW = 2.5 cm
300	mosaic = 46 54 45 44 40 49 53 48 63
301*/
302
303/*
304   This is the deflector-sample axis
305*/
306COMPONENT out_defl = Arm()
307AT(0, 0, 0) RELATIVE defl_cradle
308ROTATED (0, dTH0, 0) RELATIVE defl_cradle
309
310COMPONENT source_slit = Slit(
311    xwidth = S1W, yheight = S1H)
312  AT (0, 0, defl_slit) RELATIVE out_defl
313
314COMPONENT sample_slit = Slit(
315    xwidth = 0.03, yheight = 0.04)
316  AT (0, 0, LDS-0.3) RELATIVE out_defl
317
318SPLIT COMPONENT SamplePos = Arm()
319  AT (0, 0, LDS) RELATIVE out_defl
320
321COMPONENT SamposPSD = PSD_monitor(
322    nx = 100, ny = 100, restore_neutron = 1,
323    filename = "SamposPSD.psd", xwidth = 0.1, yheight = 0.1)
324  AT (0, 0, 0) RELATIVE SamplePos
325
326COMPONENT SamposEnergy = Monitor_nD(
327    options="energy",
328    bins=100, min=IN13energy-20e-3, max=IN13energy+20e-3,
329    restore_neutron = 1,
330    xwidth = 0.1, yheight = 0.1)
331  AT (0, 0, 0) RELATIVE SamplePos
332
333COMPONENT SamposPSDcm2 = Monitor_nD(
334  options="x y", xwidth=.01, yheight=.01, restore_neutron = 1)
335  AT (0, 0, 0) RELATIVE SamplePos
336
337/* Vanadium sample ========================================================== */
338/* incoming beam at 86.4 deg (GIMP)
339   left  analyser side: 36.2 deg from incoming beam
340   right analyser side: +180 from left side
341 */
342COMPONENT Sample = Incoherent(xwidth=0.03, yheight=0.05, zdepth=0.5e-3,
343  focus_ah=2*atan2(0.62/2,LSA)*RAD2DEG)
344  AT (0, 0, 0)     RELATIVE SamplePos
345  ROTATED (0,45,0) RELATIVE SamplePos
346  EXTEND %{
347    if (!SCATTERED) ABSORB;
348    flag_sample = SCATTERED;
349  %}
350
351COMPONENT PSD_scattered = Monitor_nD
352  (xwidth=2, bins=180, yheight=1,
353    options = "sphere theta limits=[-60 120], y limits=[-0.17 0.17]",
354    restore_neutron=1)
355  AT (0,0,0) RELATIVE SamplePos
356
357/* now we should rotate the neutron by RotateNeutron angle to bring it in the YZ plane */
358COMPONENT RotateNeutron = Arm()
359  AT (0,0,0)       RELATIVE SamplePos
360  ROTATED (0,90,0) RELATIVE SamplePos
361  EXTEND %{
362
363/* this code is copied from Rotator.comp which parameters are set static at INIT
364 * here we want a dynamic rotation for every neutron
365 * the rotation angle must be computed modulo the maximum divergence, so that we
366 * retain the full beam divergence on the analyser.
367 * The max divergence is given by the deflector size seen from the sample, adding
368 * the sample size. Deflector: width=0.05, height=9*1.5e-2
369 */
370    Rotation R;
371    double   n;
372    double   RX, RY;
373
374    RotateNeutronX  = atan2(0.05+0.03, LDS);
375    RX              = atan2(vx,vz);
376    n               = nearbyint(RX/RotateNeutronX); /* e.g. 2 deg */
377    RotateNeutronX *= n; /* RotateNeutronX is quantified */
378
379    rot_set_rotation(R, 0, RotateNeutronX, 0); /* will rotate neutron instead of comp: negative side */
380    /* apply rotation to centered coordinates */
381    coords_get(rot_apply(R, coords_set(x,y,z)),    &x, &y, &z);
382    /* rotate speed */
383    coords_get(rot_apply(R, coords_set(vx,vy,vz)), &vx, &vy, &vz);
384
385    RotateNeutronY  = atan2(9*1.5e-2+0.05, LDS); /* e.g. 4.6 deg */
386    RY              = atan2(vy,vz);
387    n               = nearbyint(RY/RotateNeutronY);
388    RotateNeutronY *= n; /* RotateNeutronY is quantified */
389
390    rot_set_rotation(R, -RotateNeutronY, 0, 0); /* will rotate neutron instead of comp: negative side */
391    /* apply rotation to centered coordinates */
392    coords_get(rot_apply(R, coords_set(x,y,z)),    &x, &y, &z);
393    /* rotate speed */
394    coords_get(rot_apply(R, coords_set(vx,vy,vz)), &vx, &vy, &vz);
395    RotateNeutronY *= RAD2DEG;
396    RY             *= RAD2DEG;
397    RX             *= RAD2DEG;
398
399    /* absorb if the rotation does not fit in the analyser active area */
400    if (!(-60 < RX && RX < 120)) ABSORB;
401    if (!(-17 < RY && RY < 17)) ABSORB;
402
403    /* keep exact rotation angle for the final detector */
404    RotateNeutronX  = RX;
405
406  %}
407
408/* install the analyser. */
409COMPONENT AnalyserMount = Arm()
410  AT (0,0,LSA)       RELATIVE RotateNeutron
411
412/* d-spacing is CaF2 one, at reference T=301 K */
413
414/* in case you want to see how the beam is gathered onto a smaller analyser plate:
415COMPONENT Analyser_In = Monitor_nD(
416  xwidth=2*atan2(0.05+0.03, LDS)*LSA, yheight=2*atan2(9*1.5e-2+0.05, LDS)*LSA,
417  options="x y", restore_neutron=1)
418AT (0,0,0)       RELATIVE AnalyserMount
419*/
420COMPONENT Analyser = Monochromator_curved(
421  width=2*atan2(0.05+0.03, LDS)*LSA, height=2*atan2(9*1.5e-2+0.05, LDS)*LSA,
422  RV=RVA, RH=RVA, NV=10, NH=10, DM=1.1115, mosaic=mos_ana, gap=0 )
423  AT (0,0,0)       RELATIVE AnalyserMount
424  ROTATED(0,90,0)  RELATIVE AnalyserMount
425  EXTEND %{
426    if (!SCATTERED) ABSORB; /* perfect beam stop to account for the B4C block */
427  %}
428
429/* compensate the initial rotation: rotate back to recover vertical beam distribution */
430COMPONENT Sample_copy = COPY(Sample)(p_interact=0.1)
431  AT (0, 0, 0)     RELATIVE SamplePos
432  ROTATED (0,45,0) RELATIVE SamplePos
433  EXTEND %{
434    flag_sample += SCATTERED;
435
436    rot_set_rotation(R, RotateNeutronY*DEG2RAD, 0, 0);
437
438    coords_get(rot_apply(R, coords_set(x,y,z)),    &x, &y, &z);
439
440    coords_get(rot_apply(R, coords_set(vx,vy,vz)), &vx, &vy, &vz);
441  %}
442
443/* detector is backwards
444   35 tubes + PSD small angle = 3 more angles (integrated in angle)
445   height 25 cm, diameter 2.54 P=4bars+1bars
446   4440 cm3 at 5 bars: 20 bar.L
447   could use 2-3 layers of 1/2" tubes
448*/
449
450COMPONENT DetectorMount = Arm()
451  AT (0,0,-LSD) RELATIVE RotateNeutron
452
453COMPONENT Detector = Monitor_nD(
454  xwidth=0.1, yheight=.25, user1=RotateNeutronX, username1="Angle [deg]",
455  options="user1 limits=[-60 120], y", restore_neutron=1, bins=100)
456  AT (0, 0, 0)       RELATIVE DetectorMount
457
458COMPONENT DetectorEnergy = Monitor_nD(
459    options="energy",
460    bins=100, min=IN13energy-20e-3, max=IN13energy+20e-3,
461    restore_neutron = 1,
462    xwidth=.1, yheight=.25)
463  AT (0, 0, 0) RELATIVE DetectorMount
464
465COMPONENT DetectorShape = Monitor_nD(
466  xwidth=LSD*2, yheight=.25,
467  options="banana, theta limits=[-240 -60]")
468  AT (0, 0, 0) RELATIVE SamplePos
469
470/* End of section bastardised from ILL-Lagrange */
471
472END
473
474
475
476
477