/*******************************************************************************
*
* McStas, neutron ray-tracing package
*         Copyright (C) 1997-2008, All rights reserved
*         Risoe National Laboratory, Roskilde, Denmark
*         Institut Laue Langevin, Grenoble, France
*
* Instrument: ILL_H10_IN8
*
* %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 IN8@ILL
*
* %Description
* IN8 is installed on beamtube H10 (diameter F = 200 mm).
* The incident wavelength selection is obtained through a double focusing
* monochromator , which has three faces equipped with PG002, Cu200 and bent
* perfect Si111 crystals, respectively. Horizontal focusing allows increasing the
* monochromatic flux at the expense of momentum but not energy resolution when
* the horizontal virtual source (an adjustable entrance slit) is introduced at a
* distance before the monochromator which matches the monochromator-sample
* distance.
*
* The aperture of the horizontal virtual source can be varied but is typically
* kept below 50 mm. This reduces the background level of the instrument.
* Converging collimators as well as diaphragms can be placed in the beam path
* before and after the monochromator to optimize the beam dimension and
* definition. For special high-resolution experiments using a flat monochromator,
* Soller collimators are available.
*
* The shielding drum allows varying the monochromator take-off angle in the range
* 10 < 2theta_m < 90. The secondary spectrometer has heavy borated polyethylene
* shielding installed around the analyzer and detector elements. The scattering
* angle at the sample position is in the range 0 < 2theta_s < 130 independent of
* the monochromator take-off angle.
*
* In this TAS configuration, Cu200 is used as monochromator and Cu111 as
* analyser, with a single type detector.
*
* %Example: QM=1 EN=0 Sqw_coh=V.lau Detector: D7_SC3_1D_I=9.36585e+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_H10_IN8( KF=5, KI=0, QM=0.5, EN=0, verbose=1, WM=0.233, HM=0.197, RMH=-1, RMV=-1, DM=1.807, NHM=15, NVM=15, WA=0.16, HA=0.08, RAH=-1,   RAV=-1, DA=2.087, NHA=15, NVA=15, L1=2.3, 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: tube H10 is twice as brilliant as H12 */
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
