/******************************************************************************* * McStas instrument definition URL=http://www.mcstas.org * * Instrument: ESS_Brilliance_2014 * * %Identification * Written by: Peter Willendrup (pkwi@fysik.dtu.dk) * Date: 20130425 * Origin: DTU Fysik * Release: McStas 2.x * Version: 0.2 * %INSTRUMENT_SITE: ESS * * This instrument produces the ESS 2014 updated brilliance, including the "pancake" moderator option. * * %Description * This instrument produces the ESS 2014 updated brilliance, including the "pancake" moderator option. * * The Brilliance_monitor is used to determine both the mean and peak brilliances, plus pulse-shapes for different wavelengths. * * Note that to reproduce the curves listed in Troels Schoenfeldt's paper on the topic, you need to look at the "collimated" monitors that * take neutrons from only part of the moderator surface. * * Note also that the 2014 version of the moderator spectra emits neutrons from a FLAT surface through the component origo, positioned tangentially to * the cold moderator "bucket". This means that you may need to shift the position of the moderator along z, when introducing it to your existing instruments. * * %Parameters * * %Link * A reference/HTML link for more information * * %End *******************************************************************************/ /* Change name of instrument and input parameters with default values */ DEFINE INSTRUMENT ESS_Brilliance_2014(frac=0.5, power=5, Yheight=0.015, np=1, ISleft=0.5, lambdamin=0.1, lambdamax=20) /* The DECLARE section allows us to declare variables or small */ /* functions in C syntax. These may be used in the whole instrument. */ DECLARE %{ //double lambdamin,lambdamax; int IsCold; double SrcX, SrcY, SrcZ; double Theta; double MonTransl; double XW, YH; char options1[256],options2[256],options3[256],options4[256]; char srcdef[128]; double WidthC=0.23,WidthT=0.12; %} /* The INITIALIZE section is executed when the simulation starts */ /* (C code). You may use them as component parameter values. */ INITIALIZE %{ // lambdamin=0.2; // lambdamax=20; XW=1.05*(WidthC+2*WidthT); YH=1.05*Yheight; sprintf(options1,"user1 bins=201 limits=[-%g,%g]",XW/2,XW/2); sprintf(options4,"user1 bins=201 limits=[-%g,%g]",YH/2,YH/2); sprintf(options2,"user1 bins=201 limits=[-%g,%g], user2 bins=201 limits=[-%g,%g]",XW/2,XW/2,YH/2,YH/2); sprintf(options3,"user1 bins=201 limits=[-%g,%g], user2 bins=201 limits=[-%g,%g]",1.05*(WidthC/2),1.05*(WidthC/2),1.05*Yheight/2,1.05*Yheight/2); sprintf(srcdef,"2014"); %} /* 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=ESS_moderator(yheight_t=Yheight,yheight_c=Yheight,dist=1,focus_xw=0.01,focus_yh=0.01,Lmin=lambdamin,Lmax=lambdamax, cold_frac=frac, sourcedef=srcdef, acc_power=power, n_pulses=np, isleft=ISleft) AT (0, 0, 0) RELATIVE Origin EXTEND %{ IsCold=cold; SrcX=x;SrcY=y;SrcZ=z; %} COMPONENT MonND1 = Monitor_nD(xwidth=XW, yheight=YH, user1=SrcX, username1="Horizontal position / [m]", options=options1, restore_neutron=1) AT (0, 0, 1) RELATIVE Source COMPONENT MonND2 = Monitor_nD(xwidth=XW, yheight=YH, user1=SrcY, username1="Vertical position / [m]", options=options4, restore_neutron=1) WHEN(IsCold) AT (0, 0, 1) RELATIVE Source COMPONENT MonND3 = Monitor_nD(xwidth=XW, yheight=YH, user1=SrcX, username1="Horizontal position / [m]", user2=SrcY,username2="Vertical position / [m]", options=options2, restore_neutron=1) AT (0, 0, 1) RELATIVE Source COMPONENT MonND4 = Monitor_nD(xwidth=XW, yheight=YH, user1=SrcX, username1="Horizontal position / [m]", user2=SrcY,username2="Vertical position / [m]", options=options2, restore_neutron=1) WHEN(IsCold && fabs(SrcY)0.12) AT (0, 0, 1) RELATIVE Source COMPONENT BrillmonCOLD = Brilliance_monitor( nlam = 101, nt = 101, filename = "brillCOLD", t_0 = 0, t_1 =10000, lambda_0 = lambdamin, lambda_1 = lambdamax, Freq =14, toflambda=0,tofcuts=0, srcarea=(100*WidthC*100*Yheight), restore_neutron=1) WHEN(IsCold) AT (0, 0, 1) RELATIVE Source COMPONENT BrillmonCOLD_COLL = Brilliance_monitor( nlam = 101, nt = 101, filename = "brillCOLD_COLL", t_0 = 0, t_1 =10000, lambda_0 = lambdamin, lambda_1 = lambdamax, Freq =14, toflambda=0,tofcuts=0, srcarea=(100*0.1*100*2*Yheight/2.5), restore_neutron=1) WHEN(IsCold && fabs(SrcY)0.12) AT (0, 0, 1) RELATIVE Source /* 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