/*******************************************************************************
*
* McStas, neutron ray-tracing package
*         Copyright (C) 1997-2008, All rights reserved
*         Risoe National Laboratory, Roskilde, Denmark
*         Institut Laue Langevin, Grenoble, France
*
* Instrument: ILL_H8_IN1
*
* %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
*
* Hot neutron three-axis spectrometer IN1@ILL
*
* %Description
* IN8 is installed on beamtube H10 (diameter F = 200 mm).
*
* IN1 works in a time-sharing mode. This means that the same monochromator is
* also used by the Be-filter spectrometer IN1-BeF and by the liquids
* diffractometer D4. Changing over between the three different instruments can be
* done without difficulty in about two hours.
*
* The monochromator unit carries three different vertically focussing
* monochromators built from copper single crystals (available reflecting planes
* Cu(200), Cu(220) and Cu(331)). The exchange of the monochromator planes is
* controlled by the instrument computer. The radius of curvature can be
* automatically adjusted as function of reflected energy in order to maintain
* maximal flux at the sample position in the course of energy scans. The
* scattering angles on the monochromator cover a range of 10<2theta_m <90  
* allowing for scanning neutron energies from 13 meV to more than 1 eV..
*
* The IN1-TAS spectrometer: the scattering angles at the sample and the analyser
* can be changed in the intervals -115<2theta_S<115 and -120<2theta_S<120. Three
* different analysers (PG(002), Cu(200), Cu(220)) can be installed in order to
* optimise intensity and resolution for a given experiment. Various resonance
* absorption filters (e.g. Er, Sm, Hf ...) can be used to suppress higher order
* contaminations from the incident beam or in the scattered beam. An oriented
* Pyrolytic Graphite filter is designed for experiments eventually demanding
* thermal neutron energy range.
*
* In this TAS configuration, Cu220 are used as monochromator and analyser, 
* with a single type detector.
*
* %Example: QM=1 Sqw_coh=V.lau Detector: D7_SC3_1D_I=1.06671e+09
*
* %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_H8_IN1( KF=10, KI=0, QM=0.5, EN=0, verbose=1, WM=0.18, HM=0.20, RMH=-1,   RMV=-1, DM=1.278, NHM=15, NVM=15, WA=0.16, HA=0.12, RAH=-1,   RAV=-1, DA=1.278, NHA=15, NVA=15, L1=7, ALF1=120, ALF2=120, ALF3=120, ALF4=120, 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,
  E0 = machine_hkl.ei,
  dE = machine_hkl.ei*0.03,
  T1=1695,I1=1.74e13,T2=708,I2=3.9e12)
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
