/******************************************************************************* * McStas instrument definition URL=http://www.mcstas.org * * Instrument: test (rename also the example and DEFINE lines below) * * %Identification * Written by: Linda Udby (udby@fys.ku.dk) * Date: 09.04.10 * Origin: University of Copenhagen * Release: McStas CVS-080208 * Version: 0.2 * %INSTRUMENT_SITE: Institution_name_as_a_single word * * Instrument short description * * %Description * Instrument longer description (type, elements, usage...) * * Example: mcrun test.instr * * %Parameters * Par1: [unit] Parameter1 description * * %Link * A reference/HTML link for more information * * %End *******************************************************************************/ /* Change name of instrument and input parameters with default values */ DEFINE INSTRUMENT Ex_5(a1=37.07,a2=74.14,LMIN=3.9,LMAX=4.1,MOSH=40,MOSV=40,RV=1,string sample="SiO2_quartza.lau") /* The DECLARE section allows us to declare variables or small */ /* functions in C syntax. These may be used in the whole instrument. */ DECLARE %{ double nm=1e-9; double LSPREAD; double LMEAN; int flag_env, flag_sample; %} /* The INITIALIZE section is executed when the simulation starts */ /* (C code). You may use them as component parameter values. */ INITIALIZE %{ LSPREAD = (LMAX - LMIN)/2; LMEAN = LMIN + LSPREAD; %} /* 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 EXTEND %{ flag_env=flag_sample=0; %} COMPONENT Source = Source_simple( height = 0.1, width = 0.1, dist = 10, xw = 0.1, yh = 0.1, Lambda0 = LMEAN, dLambda = LSPREAD, flux = 1, gauss = 0) AT (0, 0, 0) RELATIVE Origin COMPONENT Arm1 = Arm( ) AT (0, 0, 10) RELATIVE Source ROTATED (0, a1, 0) RELATIVE Source COMPONENT Arm2 = Arm( ) AT (0, 0, 10) RELATIVE Source ROTATED (0, a2, 0) RELATIVE Source COMPONENT Monochromator = Monochromator_curved( reflect = "HOPG.rfl", transmit = "HOPG.trm", zwidth = 0.1, yheight = 0.02, NH = 1, NV = 5, mosaich = MOSH, mosaicv = MOSV, r0 = 1, t0 = 1, Q = 1.8734, RV = RV, RH = 0, width = 0.1, height = 0.1, verbose = 1) AT (0, 0, 0) RELATIVE Arm1 EXTEND %{ if(!SCATTERED) ABSORB; %} SPLIT 10 COMPONENT Arm3=Arm() AT (0,0,1) RELATIVE Arm2 EXTEND %{ flag_env=0; flag_sample=0; %} COMPONENT entry_side = PowderN( reflections = "Al.laz", d_phi = 50, radius = 0.035, radius_i = 0.035-0.002, yheight = 10, tfrac = 0.8, concentric = 1) AT (0, 0, 0) RELATIVE Arm3 EXTEND %{ if(SCATTERED) flag_env=1; %} COMPONENT Sample=PowderN( reflections=sample, radius=0.005,yheight=0.02,d_phi=50) AT(0,0,0) RELATIVE Arm3 EXTEND %{ if(SCATTERED) flag_sample=1; %} COMPONENT exit_Side = COPY(entry_side)(concentric = 0) AT (0, 0, 0) RELATIVE Arm3 COMPONENT Detector=Monitor_nD( xwidth=2,yheight=1, options="banana theta y, auto", bins=180) AT(0,0,0) RELATIVE Sample COMPONENT Det_sample=COPY(Detector) WHEN (flag_sample) AT(0,0,0) RELATIVE Sample COMPONENT Det_env=COPY(Detector) WHEN (flag_env) AT(0,0,0) RELATIVE Sample /* 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