/*******************************************************************************
*         McStas instrument definition URL=http://www.mcstas.org
*
* Instrument: Test_Pol_SF_ideal
*
* %Identification
* Written by: Erik B Knudsen (erkn@fysik.dtu.dk)
* Date: Current Date
* Origin: DTU Physics 
* Release: McStas
* Version: 2.4
* %INSTRUMENT_SITE: Tests_polarization
*
* Unit test of the Pol_SF_ideal component
*
* %Description
* Simply test the ideal spin flippers function
*
* Example: mcrun test.instr <parameters=values>
*
* %Parameters
* SX: [ ] x-component of initial polarization
* SY: [ ] y-component of initial polarization
* SZ: [ ] z-component of initial polarization
*
* %End
*******************************************************************************/

/* Change name of instrument and input parameters with default values */
DEFINE INSTRUMENT Test_Pol_SF_ideal(SX=0, SY=1, SZ=0)

/* The DECLARE section allows us to declare variables or  small      */
/* functions in C syntax. These may be used in the whole instrument. */
DECLARE
%{
%}

/* The INITIALIZE section is executed when the simulation starts     */
/* (C code). You may use them as component parameter values.         */
INITIALIZE
%{
%}

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

/* The Arm() class component defines reference points and orientations  */
/* in 3D space. Every component instance must have a unique name. Here, */
/* Origin is used. This Arm() component is set to define the origin of  */
/* our global coordinate system (AT (0,0,0) ABSOLUTE). It may be used   */
/* for further RELATIVE reference, Other useful keywords are : ROTATED  */
/* EXTEND GROUP PREVIOUS. Also think about adding a neutron source !    */
/* Progress_bar is an Arm displaying simulation progress.               */
COMPONENT Origin = Progress_bar()
  AT (0,0,0) ABSOLUTE

COMPONENT source = Source_simple(
    radius = 0.2, dist = 2, focus_xw = 0.1, focus_yh = 0.1, lambda0=1, dlambda=0.5)
  AT (0, 0, 0) RELATIVE Origin

COMPONENT polarizer = Set_pol(
    px = SX, py = SY, pz=SZ)
  AT (0, 0, 0.5) RELATIVE source


COMPONENT pm0 = Pol_monitor(
    xwidth = 0.4, yheight = 0.4, restore_neutron = 1, mx = 0,
    my = 1, mz = 0)
  AT (0, 0, 1) RELATIVE source

COMPONENT sf = Pol_SF_ideal(
	xwidth=0.1, yheight=0.1, zdepth=0.2, nx=0, ny=1, nz=0)
AT(0,0,2) RELATIVE source

 COMPONENT pm1 = COPY(pm0)
AT(0,0,1) RELATIVE PREVIOUS
/* This section is executed when the simulation ends (C code). Other    */
/* optional sections are : SAVE                                         */
FINALLY
%{
%}
/* The END token marks the instrument definition end */
END

