/****************************************************************************** * McStas instrument definition URL=http://www.mcstas.org * * Instrument: Test_Pol_Mirror * * %Identification * Written by: Peter Christiansen * Date: July 2006 * Origin: RISOE * Version: $Revision: 1.3 $ * %INSTRUMENT_SITE: tests * * Test that Pol_mirror reflects, transmits, and polarizes. * * %Description * An unpolarized beam is shot into a polarizing mirror and the * intensity and polarization of the transmitted and reflected beam * is measured. * * The intensity on the first monitor should be the same as the sum * of the two polarization monitors. * * Example: mcrun Test_Pol_Mirror.instr * * %Parameters * mirrorOption: Option for mirror (1:T+R, 2:R, 3:T) (1) * * %Link * * %End ******************************************************************************/ /* Change name of instrument and input parameters with default values */ DEFINE INSTRUMENT Test_Pol_Mirror(int mirrorOption = 1) /* The DECLARE section allows us to declare variables or small */ /* functions in C syntax. These may be used in the whole instrument. */ DECLARE %{ int reflected; %} /* 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.001, dist = 1.0, xw = 0.01, yh = 0.01, Lambda0 = 15, dLambda = 14.5, flux = 1) AT (0, 0, 0) RELATIVE Origin COMPONENT lamStart = L_monitor(nchan = 30, filename = "lambdaStart.dat", xwidth = 0.20, yheight = 0.20, Lmin = 0.0, Lmax = 30) AT (0, 0, 0.5) RELATIVE Origin COMPONENT mirror = Pol_mirror(zw = 0.40, yh = 0.40, option=mirrorOption, rUpPar={1.0, 0.0219, 6.07, 2.0, 0.003}, rDownPar={0.1, 0.0219, 6.07, 2.0, 0.003}) AT (0, 0, 1.0) RELATIVE Origin ROTATED (0, 2, 0) RELATIVE Origin /* COMPONENT mirror = */ /* Pol_mirror(zw = 0.40, yh = 0.40, option=mirrorOption, */ /* rUpFunc=TableReflecFunc, rUpPar="supermirror_m3.rfl", */ /* rDownFunc=TableReflecFunc, rDownPar="supermirror_m2.rfl", */ /* useTables=1) */ /* AT (0, 0, 1.0) RELATIVE Origin ROTATED (0, 2, 0) RELATIVE Origin */ COMPONENT armTransmit = Arm() AT (0, 0, 1) RELATIVE Origin COMPONENT armReflec = Arm() AT (0, 0, 1) RELATIVE Origin ROTATED (0, 4, 0) RELATIVE Origin COMPONENT pollambdaMonitorReflecY = MeanPolLambda_monitor(xw=0.05, yh=0.05, nlam=30, Lmin = 0, Lmax = 30, my=1, filename="pollambdaMonReflecY.data") AT (0, 0, 1.0) RELATIVE armReflec GROUP monitorGroup EXTEND %{ reflected=1; %} COMPONENT pollambdaMonitorTransmitY = MeanPolLambda_monitor(xw=0.05, yh=0.05, nlam=30, Lmin = 0, Lmax = 30, my=1, filename="pollambdaMonTransY.data") AT (0, 0, 1.0) RELATIVE armTransmit GROUP monitorGroup EXTEND %{ reflected=0; %} COMPONENT lamReflec = L_monitor(nchan = 30, filename = "lambdaReflec.dat", xwidth = 0.20, yheight = 0.20, Lmin = 0.0, Lmax = 30) WHEN (reflected==1) AT (0, 0, 1.0) RELATIVE armReflec COMPONENT lamTrans = L_monitor(nchan = 30, filename = "lambdaTrans.dat", xwidth = 0.20, yheight = 0.20, Lmin = 0.0, Lmax = 30) WHEN (reflected==0) AT (0, 0, 1.0) RELATIVE armTransmit /* 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