/******************************************************************************
*         McStas instrument definition URL=http://www.mcstas.org
*
* Instrument: Granroth_SNS_decoupled_poisoned.instr
*
* %Identification
* Written by: Peter Willendrup <pkwi@fysik.dtu.dk>
* Date: May 29,2013
* Origin: DTU Physics
*
* %INSTRUMENT_SITE: SNS
*
* Simple instrumentfile for estimating SNS brilliance, moderator is a the Gallmeier SNS_source_analytic applying Ikeda-Carpenter vs. Pade function fits to MCNPX tables.
*
* %Description
*
* Simple instrumentfile for estimating SNS brilliance, moderator is a the Gallmeier SNS_source_analytic applying Ikeda-Carpenter vs. Pade function fits to MCNPX tables.
*
* %Parameters
* Lambda_min: [AA] Minimum wavelength produced at source
* Lambda_max: [AA] Maximum wavelength produced at source
*
* %Link
*
* %End
*******************************************************************************/
DEFINE INSTRUMENT Gallmeier_SNS_decoupled_poisoned(Lambda_min=0.5,Lambda_max=20)

DECLARE
%{
  double E_min;
  double E_max;
%}

INITIALIZE
%{
  E_min=81.82/(Lambda_max*Lambda_max);
  E_max=81.82/(Lambda_min*Lambda_min);
%}

/* Here comes the TRACE section, where the actual      */
/* instrument is defined as a sequence of components.  */
TRACE

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

  COMPONENT Source = SNS_source_analytic(filename="a1Gw2-2-f5_fit_fit.dat",
			      xwidth=0.01, yheight=0.01,
			      dist=1, focus_xw=0.01, focus_yh=0.01, Emin=E_min,Emax=E_max,sample_E=2, p_power=2)
 AT (0,0,0) ABSOLUTE
EXTEND %{
  // Make intensity units of "Per second"
  p=p*60;
  // Scale from 2 to 1.4 MW
  p/=2;
  p*=1.4;
%}

COMPONENT Brillmon = Brilliance_monitor(
    nlam = 196, nt = 1201, filename = "brill", t_0 = 0,
    t_1 = 1200, lambda_0 = Lambda_min, lambda_1 = Lambda_max,
    Freq =60.0)
  AT (0, 0, 0.0000001) RELATIVE Source


/* This section is executed when the simulation ends (C code). Other    */
/* optional sections are : SAVE                                         */
/* The END token marks the instrument definition end */
END
