/*******************************************************************************
*
* McStas, neutron ray-tracing package
*         Copyright (C) 1997-2006, All rights reserved
*         Risoe National Laboratory, Roskilde, Denmark
*         Institut Laue Langevin, Grenoble, France
*
* Instrument: HET
*
* %Identification
* Written by: <a href="mailto:d.champion@rl.ac.uk">Dickon Champion</a>
* Date: 22nd Jan 2004.
* Origin: <a href="http://www.isis.rl.ac.uk">ISIS (UK)</a>
* Release: McStas 1.7/1.8
* Version: $Revision: 1.2 $
* %INSTRUMENT_SITE: ISIS
*
* HET: High Energy Transfer Chopper Spectrometer
*
* %Description
* This instrument is a simple model of the HET spectrometer at the ISIS neutron
* facility. The input arguments are hardwired so that the Fermi chopper position
* is 10 metres from the moderator. This instrument uses the FC module written by
* Andrew Garret which comes with no guarantees as to its accuracy in modelling the
* Fermi Chopper.
*
*
* Example: mcrun HETfull.instr E_0=443.0,E_1=470.0,chop_select=450.0,nu_chop=600.0, type=2
*
* %Parameters
* INPUT PARAMETERS:
* E_0  : lowest energy sampled      [meV]
* E_1  : highest energy sampled     [meV]
* chop_select : energy selected by chopper [meV]
* nu_chop : frequency of chopper rotation [Hz]
* type : chopper package selected [sloppy chopper = 1, B chopper = 2]
*
* %End
*******************************************************************************/





DEFINE INSTRUMENT HET(E_0=443.0,E_1=470.0,chop_select=450.0,nu_chop=600.0,int type=2)
DECLARE
%{
/* chopper variables to compute according to "type" input */
double c_h1,c_h2, roc, chan_w,chop_phase;
int nslits;
%}

INITIALIZE
%{
/*  type=1 sloppy chopper
  type=2 B chopper
*/
if (type==1)
  {c_h1=-0.032;
   c_h2=0.032;
   roc=-1.3;
   nslits=16;
   chan_w=0.00283;
   fprintf(stderr,"sloppy chopper selected");
  }
if (type==2)
  {c_h1=-0.026;
   c_h2=0.026;
   roc=-0.92;
   nslits=24;
   chan_w=0.00184;
   fprintf(stderr,"250mev chopper selected");
  }

/* hardwired for FC position 10m from moderator */
chop_phase=0.002528*9.044/sqrt(chop_select);

%}
TRACE
COMPONENT a1 = Arm()
  AT (0,0,0) ABSOLUTE

COMPONENT ts1_mod = ISIS_moderator(
    Face ="Water", E0 = E_0, E1 = E_1, dist = 9.85, xw = 0.045,
    yh = 0.045, modXsize = 0.074, modYsize = 0.074, CAngle = 0.0, SAC=1)
  AT (0, 0, 0) RELATIVE a1

COMPONENT FC = Chopper_Fermi(
radius=0.05, nu=nu_chop, delta=chop_phase, ymin=c_h1, ymax=c_h2,
 w=chan_w, n=nslits, r_slit=roc)
AT (0,0,10) RELATIVE ts1_mod

COMPONENT FCslit1 = Slit(
    xmin = -0.0225, xmax = 0.0225, ymin = -0.0225, ymax = 0.0225)
  AT (0, 0, 0.15) RELATIVE FC

COMPONENT monT = Monitor_nD(
    options = "square auto t bins=100",
    filename = "FC_mon.dat", xwidth=0.2, yheight = 0.2)
  AT (0, 0, 0.035) RELATIVE FCslit1

COMPONENT postFCslit = Slit(
    xmin = -0.0225, xmax = 0.0225, ymin = -0.0225, ymax = 0.0225)
  AT (0, 0, 0.2) RELATIVE FC

COMPONENT presampslit = Slit(
    xmin = -0.0225, xmax = 0.0225, ymin = -0.0225, ymax = 0.0225)
  AT (0, 0, 1.4) RELATIVE postFCslit

COMPONENT target = V_sample(radius_o=0.00,
xwidth=0.04,yheight=0.04,zthick=0.002,
  focus_aw=19.38,focus_ah=3.435,
  pack = 1,
  target_x=0.8139,target_y=0.0,target_z=2.3678)
  AT (0,0,0.2) RELATIVE presampslit

COMPONENT a2=Arm()
AT (0,0,0) RELATIVE target

COMPONENT cyl = Monitor_nD(
    options = "banana, auto t bins=100  , theta limits[9.31 28.69] bins=1",
    filename = "det_out.dat",   xwidth=5.0,   yheight = 0.3)
  AT (0, 0, 0) RELATIVE a2



END
























































