/*******************************************************************************
*
* McStas, neutron ray-tracing package
*         Copyright (C) 1997-2008, All rights reserved
*         Risoe National Laboratory, Roskilde, Denmark
*         Institut Laue Langevin, Grenoble, France
*
* Instrument: ILL_H13_IN20
*
* %Identification
* Written by: <a href="mailto:farhi@ill.fr">Emmanuel Farhi</a>
* Date: 2006
* Origin: <a href="http://www.ill.fr">ILL (France)</a>
* %INSTRUMENT_SITE: ILL
*
* Thermal neutron three-axis spectrometer IN20@ILL (unpolarized configuration)
*
* %Description
* IN20 is installed at the H13 thermal beam tube (Phi 170 mm) in the reactor hall.
*
* Both the primary and the secondary spectrometer employ a monochromatic
* horizontal focusing geometry. A heavy input slit of an adjustable size, placed
* in the casemate, serves as a virtual source, providing a large solid angle for
* the monochromatic beam, while reducing, together with a sapphire filter window,
* the fast neutron background. The neutron energy is selected either by a doubly
* focusing polarizing Heusler 111 monochromator (230 x 150 mm2 w x h) or by an
* unpolarised Si 111 monochromator (elastically bent crystals, 195 x 200 mm2 w x
* h) free of higher-order contamination in the incident beam at wave-numbers ki >
* 3 Angs-1. The analysis of the energy and polarisation state of the scattered
* neutrons is effectuated by a similar horizontally focusing Heusler crystal
* analyzer. Further PG 002 and Si 111 analyzers are available for occasional
* unpolarised work.
*
* The energy transfer range accessible in the present configuration of IN20
* extends to 100 meV with maximum incident neutron energies reaching 150 meV. The
* typical energy widths (FWHM) measured with a reference vanadium sample at the
* graphite filter wave-numbers ki = 2.66 A-1 and 4.1 A-1 are 0.82(3) meV and 3.05
* (15) meV, respectively.
*
* This model uses two Si111 monochromator and analyzers (unpolarized
* configuration).
*
* %Example: QM=1 EN=0 Sqw_coh=V.lau Detector: D7_SC3_1D_I=4.83869e+08
*
* %Parameters
* KI: [Angs-1]     Incoming neutron wavevector
* KF: [Angs-1]     Outgoing neutron wavevector
* EN: [meV]        Energy transfer in crystal
* QM: [Angs-1]     Wavevector transfer in crystal
* L1: [m]          Source-Monochromator distance. Contains 1st Collimator of length 5.34
* DM: [Angs]       Monochromator d-spacing
* DA: [Angs]       Analyzer d-spacing
* RMV: [m]         Monochromator vertical curvature, 0 for flat, -1 for automatic setting
* RMH: [m]         Monochromator horizontal curvature, 0 for flat, -1 for automatic setting
* RAV: [m]         Analyzer vertical curvature, 0 for flat, -1 for automatic setting
* RAH: [m]         Analyzer horizontal curvature, 0 for flat, -1 for automatic setting
* ALF1: [arc min]  Horizontal collimation from Source to Monochromator
* ALF2: [arc min]  Horizontal collimation from Monochromator to Sample A
* ALF3: [arc min]  Horizontal collimation from Sample to Analyzer
* ALF4: [arc min]  Horizontal collimation from Analyzer to Detector
* BET1: [arc min]  Vertical collimation from Source to Monochromator
* BET2: [arc min]  Vertical collimation from Monochromator to Sample A
* BET3: [arc min]  Vertical collimation from Sample to Analyzer
* BET4: [arc min]  Vertical collimation from Analyzer to Detector
* verbose: [1]     print TAS configuration. 0 to be quiet
*
* WM: [m]          Width of monochromator
* HM: [m]          Height of monochromator
* NVM: [1]         Number of vertical slabs composing the monochromator
* NHM: [1]         Number of horizontal slabs composing the monochromator
* WA: [m]          Width of analyzer
* HA: [m]          Height of analyzer
* NVA: [1]         Number of vertical slabs composing the analyzer
* NHA: [1]         Number of horizontal slabs composing the analyzer
*
*
* %Link
* Rescal for Matlab at http://www.ill.eu/instruments-support/computing-for-science/cs-software/all-software/matlab-ill/
* %Link
* Restrax at http://omega.ujf.cas.cz/restrax/
* %End
*******************************************************************************/
DEFINE INSTRUMENT ILL_H13_IN20( KF=3, KI=0, QM=0.5, EN=0, verbose=1, WM=0.20, HM=0.19, RMH=-1, RMV=-1, DM=3.155, NHM=15, NVM=15, WA=0.16, HA=0.08, RAH=-1, RAV=-1, DA=3.155, NHA=15, NVA=15, L1=2.33, ALF1=60, ALF2=60, ALF3=60, ALF4=60, BET1=120, BET2=120, BET3=120, BET4=120 )

TRACE

REMOVABLE COMPONENT Origin=Progress_bar()
AT (0,0,0) ABSOLUTE

/* a flat constant source */
REMOVABLE COMPONENT Source = Source_gen(
  radius  = 0.10,
  dist = machine_hkl.l1,
  focus_xw = fabs(WM*sin(machine_real.a1*DEG2RAD)), focus_yh = HM,
  T1=683.7,I1=0.5874e+13,T2=257.7,I2=2.5099e+13,T3=16.7 ,I3=1.0343e+12,
  E0 = machine_hkl.ei,
  dE = machine_hkl.ei*0.03)
AT (0,0,0) ABSOLUTE

REMOVABLE COMPONENT SC1 = Collimator_linear(
  xmin =-WM/2, ymin =-HM/2,
  xmax = WM/2, ymax = HM/2,
  length = machine_hkl.l1/2,
  divergence=ALF1,
  divergenceV=BET1)
WHEN (ALF1 && BET1)
AT (0, 0, machine_hkl.l1/4) ABSOLUTE

REMOVABLE COMPONENT Guide_out=Arm()
AT (0, 0, machine_hkl.l1-0.2) ABSOLUTE

%include "Templates/templateTAS/templateTAS.instr"

END
