/******************************************************************************* * mcstas instrument definition url=http://www.mcstas.org * * instrument: Loki * * %identification * written by: andrew jackson (andrew.jackson@esss.se) * date: 2016-02-03 2017-07-17 * origin: ess * release: mcstas 2.4 * version: 2.0 * %instrument_site: ess * * Loki * * %description * model of Loki using ESS moderator * * Notes: * - Testing new vertical bender component that works with gravity on * - Benders do not use realistic reflectivities * - Does not contain "realistic" detector array * * Example: * * %parameters * *******************************************************************************/ DEFINE INSTRUMENT loki_master_model_Mantid(double collen=3.0, double reardet=10.0, double l_min=3.0, double l_max=9.95, double sourceapx=0.015, double sampleapx=0.005, double gw=0.03, gh=0.025, gw1=0.03, gh1=0.025, double insertangle=0.8, double bendrad=61.25, int pulseskip=0, int sampletype=0, double incohb=0.00001, int gout=0, int mcplout = 0, int windows=0, int virtualout=0, int idebug=0, int ialwaystrack=0) DECLARE %{ //include loki functions for chopper calcs etc #include "loki_functions.c" //variable declaration double bandwidth, l_min_source, l_max_source; int windowsused; int usesample; int usedetectors; int iflag_scatt = 0; int iflag_scatt_12 = 0; int geantoutputenabled; int mcploutputenabled; // Moderator variables for 2015 moderator double modwidth_c = 0.1; double modwidth_t = 0.18; double modheight = 0.03; double modopening = 120; char* moderator = "2015"; int beamport_pos = 25; // default to port 7 // Moderator variables for butterfly int beamport_number = 7; // default to port 7 char * beamport_sector = "N"; // default to North sector //optics variables double opticsstart, guidewidth, guideheight, guidewidth1, guideheight1; double defaultm; double bend1pos, bend1r, bend1l, bend1nchan, bend1top, bend1bottom, bend1sides, bend1d; double bend2pos, bend2r, bend2l, bend2nchan, bend2top, bend2bottom, bend2sides, bend2d; double windowgap = 0.01; // Gap before a beamline window in the bunker double guide1l, guide2al, guide2bl, guide3l, guide3al, guide3bl, guide3cl, guide3dl; double guide4l, guide5al, guide5bl, guide6l; double colguide1l, colguide2l; double collimatorgap; int fourjawslit1used, fourjawslit2used, aperturechangerused; double fourjawthickness; double samplepos, sampleappos; // Allow for future asymmetry in apertures. // Currently, set y values same as xvalues unless they are larger than the guide. double sampleapy, sourceapy; //Chopper variables double chopperfreq; double chopper1pos,chopper2pos,reschopper1pos,reschopper2pos,reschopper3pos; double choppergap, diskgap, diskthickness, diskoffset; double chopper1_slit,chopper2_slit; double chopper1opent,chopper1adelay,chopper1bdelay; double chopper2opent,chopper2adelay,chopper2bdelay; //Strings char virtualoutput_filename[256]; char mcploutput_filename[256]; %} INITIALIZE %{ // sanity check on wavelength band // take l_min as basis // bandwidth = 71.4*(1.0+(double)pulseskip)*3.96/reardet; // printf("bandwidth = %g\n",bandwidth); // if (l_max > (l_min+bandwidth)) { l_max = l_min+bandwidth;} //Initialise some values //Are we using optional windows? windowsused=windows; //Logic for whether to enable back end if (virtualout == 1){ // Turn off back end components // All backend components must have WHEN statements usesample = 0; usedetectors = 0; geantoutputenabled = 0; mcploutputenabled = 0; } else { //Disable sample if sampletype is negative if (sampletype < 0){ usesample = 0; } else { usesample = 1;}; //Enable detectors usedetectors = 1; //Set whether geant compatible output is generated geantoutputenabled = gout; //Set whether mcpl format output is generated //Note that as of 2017-03 the mcpl output is generated whether or not this is set mcploutputenabled = mcplout; }; //Set up filenames for virtualoutput //Assumes virtualoutput is after sample aperture and before sample sprintf (virtualoutput_filename, "loki_vsource-collen_%.1fm-ap1_%.0fmm-ap2_%.0fmm-lmin_%.1fA-lmax_%.1fA.list", collen, sourceapx*1000.0, sampleapx*1000.0, l_min, l_max ); if (virtualout == 1){ printf("Virtual output enabled to file %s\n",virtualoutput_filename); }; sprintf (mcploutput_filename, "loki-collen_%.1fm-ap1_%.0fmm-ap2_%.0fmm-lmin_%.1fA-lmax_%.1fA.mcpl.gz", collen, sourceapx*1000.0, sampleapx*1000.0, l_min, l_max ); if (mcplout == 1){ printf("MCPL output enabled to file %s\n",virtualoutput_filename); }; // Overall coordinate is the ESS TCS (target centre system) on which // the moderator should be centred. // // The guide, however, has to point at the correct part of the butterfly moderator. // // basic reference positions and lengths opticsstart = 1.9; // start of beam extraction relative to source guidewidth = gw; // guide width for benders and collimation guideheight = gh; // guide height for benders and collimation guidewidth1 = gw1; // guide width for intermediate section - allowance for misalignment guideheight1 = gh1; // guide height for intermediate section - allowance for misalignment defaultm = 2.0; // bender 1 details //bend1pos = opticsstart-opticsstart;// position of bender entrance bend1r = -bendrad; // bender radius in m bend1l = 3.5; // bender length in m bend1nchan = 5; // number of bender channels // This isn't working at the moment - all defined at bender component instance //bend1top = {0.99, 0.0219, 6.07, 3.0, 0.003}; //reflectivity of top //bend1bottom = {0.99, 0.0219, 6.07, 3.0, 0.003}; //reflectivity of bottom //bend1sides = {0.99, 0.0219, 6.07, 2.0, 0.003}; // reflectivity of sides bend1d = 0.0005; // thickness of channel walls // bender 2 details //bend2pos = 7.55-opticsstart;// position of bender entrance ... should do a relative position bend2r = bendrad; // bender radius in m bend2l = 3.5; // bender length in m bend2nchan = 5; // number of bender channels // This isn't working at the moment - all defined at bender component instance // bend2top = {0.99, 0.0219, 6.07, 3.0, 0.003}; //reflectivity of top // bend2bottom = {0.99, 0.0219, 6.07, 3.0, 0.003}; //reflectivity of bottom // bend2sides = {0.99, 0.0219, 6.07, 2.0, 0.003}; // reflectivity of sides bend2d = 0.0005; // thickness of channel walls //choppers //Gaps //10gap+17blade+16gap+17+10=70mm choppergap = 0.01; //Gap before or after a chopper disk or pair diskgap = 0.016; // Gap between chopper disks diskthickness = 0.017; // Chopper disk thickness //Openings chopper1_slit = 120; // angular opening in each disk in chopper 1 pair chopper2_slit = 190; // angular opening in each disk in chopper 2 pair //Positions chopper1pos = 6.5-opticsstart; //Position of centre of bandwidth chopper pair chopper2pos = 15.21-opticsstart; //Position of centre of frame overlap pair reschopper1pos = 7.0-opticsstart; //Postion of resolution chopper 1 pair reschopper2pos = 9.5-opticsstart; //Position of resolution chopper 2 pair reschopper3pos = 10.5-opticsstart; //Position of resolution chopper 3 pair //Chopper calculations diskoffset = (diskgap+diskthickness)/2.0; // Distance from centre of pair to centre of disk thickness chopperfreq = 14.0/(1.0+(double)pulseskip); //chopper 1 chopper1opent = calcopentime(chopper1pos+opticsstart, l_min, l_max); chopper1adelay = calcdisk1delay(chopper1pos-diskoffset+opticsstart,chopper1_slit,l_min,chopperfreq); chopper1bdelay = calcdisk2delay(chopper1pos+diskoffset+opticsstart,chopper1_slit,l_max,chopperfreq); //chopper 2 chopper2opent = calcopentime(chopper2pos+opticsstart, l_min, l_max); chopper2adelay = calcdisk1delay(chopper2pos-diskoffset+opticsstart,chopper2_slit,l_min,chopperfreq); chopper2bdelay = calcdisk2delay(chopper2pos+diskoffset+opticsstart,chopper2_slit,l_max,chopperfreq); printf("-- Chopper Calcs --\n"); printf("L_min = %g A\n",l_min); printf("L_max = %g A\n", l_max); printf("---- chopper1 open time = %g ms\n",chopper1opent); printf("---- chopper1a delay = %g ms\n",chopper1adelay); printf("---- chopper1b delay = %g ms\n",chopper1bdelay); printf("---- chopper2 open time = %g ms\n",chopper2opent); printf("---- chopper2a delay = %g ms\n",chopper2adelay); printf("---- chopper2b delay = %g ms\n",chopper2bdelay); //Guide lengths etc guide1l = 0.48; // in light shutter guide2al = 0.44; // before bandwidth chopper guide2bl = 0.44; // after bandwidth chopper /// options for next part ... //////////////////////////////////////////////// /// all guide : guide3l = 3.9; // Guide between bandwidth chopper and intermediate shutter // or resolution choppers ... lengths are not currently correct!!! guide3al = 0.4; // Guide before res chopper 1 guide3bl = 1.8; // Guide between res chopper 1 and res chopper 2 guide3cl = 1.0; // Guide between res chopper 2 and res chopper 3 guide3dl = 0.4; // Guide between res chopper 3 and intermediate shutter ////////////////////////////////////////////////////////////////////////////// guide4l = 0.6; // guide through intermediate shutter guide5al = 0.14; // guide before frame overlap chopper guide5bl = 0.28; // guide after frame overlap chopper //guide6l = 0.4; // //Slit assembly fourjawthickness = 0.05; //Collimators collimatorgap = 0.020; colguide1l = 3.0 - collimatorgap/2.0; colguide2l = 2.0 - collimatorgap/2.0; //Default configuration is 3m collimation length fourjawslit1used = 0; aperturechangerused = 0; fourjawslit2used = 1; //Set aperture sizes // If the width is greater than guide height, limit aperture height // Otherwise, set height and width equal if (sourceapx > guideheight1){ sourceapy = guideheight1; } else { sourceapy = sourceapx; } if (sampleapx > guideheight1){ sampleapy = guideheight1; } else { sampleapy = sampleapx; } // apertures if (collen == 8.0){ fourjawslit1used = 1; aperturechangerused = 0; fourjawslit2used = 0; } else if(collen == 5.0) { fourjawslit1used = 0; aperturechangerused = 1; fourjawslit2used = 0; } else if(collen == 3.0) { fourjawslit1used = 0; aperturechangerused = 0; fourjawslit2used = 1; } else { collen = 3.0; // default to 3.0 m collimation fourjawslit1used = 0; aperturechangerused = 0; fourjawslit2used = 1; } samplepos = 23.5-opticsstart; sampleappos = samplepos-0.005; // position of sample aperture relative to sample //Calculation based on leading edge of first chopper pair and trailing edge of second chopper pair //Need to feed a wider band from the source than just the penumbra to allow the choppers to chop. l_min_source = 0.8*calclambda(2.86,l_min*(chopper1pos-diskoffset+opticsstart)/3.96,chopper1pos-diskoffset+opticsstart); l_max_source = 1.2*calclambda(0, l_max*(chopper2pos+diskoffset+opticsstart)/3.96+2.86, chopper2pos+diskoffset+opticsstart); printf ("l_min_source = %g : l_max_source = %g\n",l_min_source,l_max_source); %} TRACE COMPONENT Origin = Progress_bar() AT (0,0,0) ABSOLUTE COMPONENT Source = ESS_butterfly( sector=beamport_sector,beamline=beamport_number, Lmin=l_min_source,Lmax=l_max_source,target_index=3, cold_frac=0.5, yheight=0.03,focus_xw=guidewidth, focus_yh=guideheight) // , n_pulses=14 AT (0,0,0) RELATIVE Origin // COMPONENT Source = ESS_moderator( // sourcedef="2015", beamport_angle=beamport_pos, // xwidth_c=modwidth_c, xwidth_t=modwidth_t, yheight_c=modheight, // extraction_opening=modopening, // Lmin = l_min_source, Lmax = l_max_source, // dist = opticsstart, focus_xw = guidewidth ,focus_yh = guideheight // ) // AT (0,0,0) RELATIVE Origin COMPONENT ISCS = Arm() AT (-0.04162,0,0.00977) RELATIVE Source COMPONENT InstrumentArm = Arm() AT (0,0,0) RELATIVE ISCS ROTATED (0,insertangle,0) RELATIVE ISCS COMPONENT FirstMon = Monitor_nD( xwidth = 0.03, yheight = 0.025, options="lambda bins=20", restore_neutron = 1 ) AT (0,0,opticsstart-0.001) RELATIVE InstrumentArm /// Bender 1 /////////////////////////////////////////////////////////////////// COMPONENT Bender1Arm = Arm() AT (0,0,opticsstart) RELATIVE InstrumentArm COMPONENT bender1 = Vertical_Bender( xwidth = guidewidth, yheight = guideheight, radius = bend1r, nchan = bend1nchan, length = bend1l, d=bend1d, rTopPar = {0.99, 0.0219, 6.07, 3.0, 0.003}, rBottomPar = {0.99, 0.0219, 6.07, 3.0, 0.003}, rSidesPar = {0.99, 0.0219, 6.07, 2.0, 0.003}, endFlat=0.0, drawOption=1.0, debug = idebug, alwaystrack = ialwaystrack) AT (0, 0, 0.001) RELATIVE Bender1Arm ROTATED (0, 0, 0) RELATIVE Bender1Arm /// End Bender 1 /////////////////////////////////////////////////////////////// COMPONENT Mon1_PostBend1 = Monitor_nD( xwidth=guidewidth+0.001, yheight=0.03, options="lambda, time, multiple, auto", restore_neutron = 1 ) AT (0,-calcY(bend1l, abs(bend1r)), calcZ(bend1l, abs(bend1r))+0.001) RELATIVE PREVIOUS COMPONENT Mon1a_PostBend1 = Monitor_nD( xwidth=guidewidth+0.001, yheight= 0.03, user1 = MC_GETPAR(bender1, i_bounce), username1= "i_bounce1", options="lambda limits=[0,20], user1 limits=[0,20]", restore_neutron = 1 ) AT (0,0,0.0001) RELATIVE PREVIOUS /// Arm for bunker components ////////////////////////////////////////////////// COMPONENT BunkerArm = Arm() AT (0.0, -calcY(bend1l, abs(bend1r)), calcZ(bend1l, abs(bend1r))+0.004) RELATIVE Bender1Arm ROTATED (calcAlpha(bend1l,abs(bend1r)), 0 , 0) RELATIVE Bender1Arm /// Monolith window //////////////////////////////////////////////////////////// COMPONENT window1 = Al_window(thickness=0.002) WHEN (windowsused == 1) AT (0, 0, 0.001) RELATIVE BunkerArm //////////////////////////////////////////////////////////////////////////////// /// Light Shutter ////////////////////////////////////////////////////////////// COMPONENT g2_win1 = Al_window(thickness=0.001) WHEN (windowsused == 1) AT (0, 0, windowgap) RELATIVE BunkerArm COMPONENT guide1 = Guide_gravity( w1 = guidewidth1, w2 = guidewidth1, h1 = guideheight1, h2 = guideheight1, l = guide1l, m = defaultm ) AT (0,0,windowgap) RELATIVE PREVIOUS COMPONENT g2_win2 = Al_window(thickness=0.001) WHEN (windowsused == 1) AT (0,0,guide1l+windowgap) RELATIVE PREVIOUS /// End Light Shutter ////////////////////////////////////////////////////////// COMPONENT Mon2_PostLS = Monitor_nD( xwidth=0.03, yheight=0.03, options="lambda, time, multiple, auto", restore_neutron = 1 ) AT (0,0,0.001) RELATIVE PREVIOUS //////////////////////////////////////////////////////////////////////////////// // Chopper pit 1 // Piece of guide, two chopper disks, next piece of guide COMPONENT cp1_win1 = Al_window(thickness=0.001) WHEN (windowsused == 1) AT (0,0,windowgap) RELATIVE PREVIOUS COMPONENT guide2a = Guide_gravity( w1 = guidewidth1, w2 = guidewidth1, h1 = guideheight1, h2 = guideheight1, l = guide2al, m = defaultm ) AT (0,0,windowgap) RELATIVE PREVIOUS COMPONENT Chopper1A = DiskChopper( radius=0.35, yheight=0.04, theta_0=chopper1_slit, nslit=1, nu=chopperfreq, delay=chopper1adelay/1000) AT (0, 0, guide2al+choppergap+diskthickness*0.5) RELATIVE PREVIOUS COMPONENT Chopper1B = DiskChopper( radius=0.35, yheight=0.04, theta_0=chopper1_slit, nslit=1, nu=chopperfreq, delay=chopper1bdelay/1000) AT (0, 0, diskgap+diskthickness*0.5) RELATIVE PREVIOUS COMPONENT guide2b = Guide_gravity( w1 = guidewidth1, w2 = guidewidth1, h1 = guideheight1, h2 = guideheight1, l = guide2bl, m = defaultm ) AT (0,0,choppergap+diskthickness*0.5) RELATIVE PREVIOUS COMPONENT cp1_win2 = Al_window(thickness=0.001) WHEN (windowsused == 1) AT (0,0,guide2bl+0.001) RELATIVE PREVIOUS /// End Chopper Pit 1 ////////////////////////////////////////////////////////// COMPONENT Mon3_PostBWC = Monitor_nD( xwidth=guidewidth, yheight=0.03, options="lambda, time, multiple, auto", restore_neutron = 1 ) AT (0,0,0.001) RELATIVE PREVIOUS //////////////////////////////////////////////////////////////////////////////// /// Next section - either use straight guide /// from bandwidth choppers to intermediate shutter /// or set of choppers with associated guides //////////////////////////////////////////////////////////////////////////////// /// Guide 3 //////////////////////////////////////////////////////////////////// COMPONENT g3_win1 = Al_window(thickness=0.001) WHEN (windowsused == 1) AT (0, 0, windowgap) RELATIVE PREVIOUS COMPONENT guide3 = Guide_gravity( w1 = guidewidth1, w2 = guidewidth1, h1 = guideheight1, h2 = guideheight1, l = guide3l, m = defaultm ) AT (0,0,0.001) RELATIVE PREVIOUS //or put resolution chopper assembly here COMPONENT g3_win2 = Al_window(thickness=0.001) WHEN (windowsused == 1) AT (0,0,guide3l+0.001) RELATIVE PREVIOUS /// End Guide 3 //////////////////////////////////////////////////////////////// COMPONENT Mon7_PreIS = Monitor_nD( xwidth=guidewidth1, yheight=0.03, options="lambda, time, multiple, auto", restore_neutron = 1 ) AT (0,0,0.001) RELATIVE PREVIOUS /// Guide 4 with intermediate shutter ////////////////////////////////////////// COMPONENT g4_win1 = Al_window(thickness=0.001) WHEN (windowsused == 1) AT (0, 0, windowgap) RELATIVE PREVIOUS COMPONENT guide4 = Guide_gravity( w1 = guidewidth1, w2 = guidewidth1, h1 = guideheight1, h2 = guideheight1, l = guide4l, m = defaultm ) AT (0,0,0.001) RELATIVE PREVIOUS COMPONENT g4_win2 = Al_window(thickness=0.001) WHEN (windowsused == 1) AT (0,0,guide4l+0.001) RELATIVE PREVIOUS /// End Guide 4 with intermediate shutter ////////////////////////////////////// COMPONENT Mon8_PostIS = Monitor_nD( xwidth=guidewidth1, yheight=0.03, options="lambda, time, multiple, auto", restore_neutron = 1 ) AT (0,0,0.0005) RELATIVE PREVIOUS COMPONENT Mon8a_PostIS = Monitor_nD( xwidth=guidewidth1+0.02, yheight= guideheight1+0.02, options="y all auto", restore_neutron = 1 ) AT (0,0,0.0005) RELATIVE PREVIOUS /// Bender 2 /////////////////////////////////////////////////////////////////// COMPONENT bender2_win1 = Al_window(thickness=0.001) WHEN (windowsused==1) AT (0,0,windowgap) RELATIVE PREVIOUS COMPONENT bender2 = Vertical_Bender( xwidth = guidewidth, yheight = guideheight, radius = bend2r, nchan = bend2nchan, length = bend2l, d=bend2d, rTopPar = {0.99, 0.0219, 6.07, 3.0, 0.003}, rBottomPar = {0.99, 0.0219, 6.07, 3.0, 0.003}, rSidesPar = {0.99, 0.0219, 6.07, 2.0, 0.003}, endFlat=0.0, drawOption=1.0, debug = idebug, alwaystrack = ialwaystrack) AT (0, 0, 0) RELATIVE Previous ROTATED (0, 0, 0) RELATIVE BunkerArm /// !!! NEED straight guide bit here ????...//// // COMPONENT bender2_win2 = Al_window(thickness=0.001) // WHEN (windowsused==1) // AT (0,0,bend2l+windowgap) RELATIVE PREVIOUS /// End Bender 2 /////////////////////////////////////////////////////////////// COMPONENT CollimationArm = Arm() AT (0,calcY(bend2l, abs(bend2r)),calcZ(bend2l, abs(bend2r))) RELATIVE PREVIOUS ROTATED (-calcAlpha(bend2l,abs(bend2r)), 0 , 0) RELATIVE PREVIOUS COMPONENT Mon9_PostBend2 = Monitor_nD( xwidth=guidewidth, yheight=0.03, options="lambda, time, multiple, auto", restore_neutron = 1 ) AT (0,0,0.001) RELATIVE PREVIOUS COMPONENT Mon9a_PostBend2 = Monitor_nD( xwidth=guidewidth, yheight=0.03, options="ydiv lambda all auto", restore_neutron = 1 ) AT (0,0,0.0001) RELATIVE PREVIOUS COMPONENT Mon9b_PostBend2 = Monitor_nD( xwidth=guidewidth, yheight=0.03, options="xdiv lambda all auto", restore_neutron = 1 ) AT (0,0,0.0001) RELATIVE PREVIOUS COMPONENT Mon9c_PostBend2 = Monitor_nD( xwidth=guidewidth, yheight=0.03, options="x y all auto", restore_neutron = 1 ) AT (0,0,0.0001) RELATIVE PREVIOUS COMPONENT Mon9d_PostBend2 = Monitor_nD( xwidth=guidewidth+0.02, yheight= 0.030 +0.005, options="y bins=120, all auto", restore_neutron = 1 ) AT (0,0,0.0001) RELATIVE PREVIOUS COMPONENT Mon9e_PostBend2 = Monitor_nD( xwidth=guidewidth+0.005, yheight= 0.030 +0.02, options="x bins=35, all auto", restore_neutron = 1 ) AT (0,0,0.0001) RELATIVE PREVIOUS COMPONENT Mon9f_PostBend2 = Monitor_nD( xwidth=guidewidth, yheight= 0.03, user2 = MC_GETPAR(bender2, i_bounce), username2= "i_bounce2", options="lambda limits=[0,20], user2 limits=[0,20]", restore_neutron = 1 ) AT (0,0,0.0001) RELATIVE PREVIOUS /// Chopper Pit 3 - Frame overlap chopper ////////////////////////////////////// /// Over/Under Chopper pair // COMPONENT cp2_win1 = Al_window(thickness=0.001) // WHEN (windowsused == 1) // AT (0,0,windowgap) RELATIVE CollimationArm /// Straight guide here /////////// COMPONENT guide5a = Guide_gravity( w1 = guidewidth, w2 = guidewidth, h1 = guideheight, h2 = guideheight, l = guide5al, m = defaultm ) AT (0,0,0.0001) RELATIVE PREVIOUS COMPONENT Chopper2A = DiskChopper( radius=0.35, yheight=0.04, theta_0=chopper2_slit, nslit=1, nu=chopperfreq, delay=chopper2adelay/1000) AT (0, 0, guide5al+choppergap+diskthickness*0.5+0.05) RELATIVE PREVIOUS COMPONENT Chopper2B = DiskChopper( radius=0.35, yheight=0.04, theta_0=chopper2_slit, nslit=1, nu=chopperfreq, delay=chopper2bdelay/1000) AT (0, 0, diskgap+diskthickness*0.5) RELATIVE PREVIOUS COMPONENT guide5b = Guide_gravity( w1 = guidewidth, w2 = guidewidth, h1 = guideheight, h2 = guideheight, l = guide5bl, m = defaultm ) AT (0,0,choppergap+diskthickness*0.5) RELATIVE PREVIOUS // COMPONENT cp2_win2 = Al_window(thickness=0.001) // WHEN (windowsused == 1) // AT (0,0,guide5bl+windowgap) RELATIVE PREVIOUS COMPONENT Mon10_PostFOC = Monitor_nD( xwidth=guidewidth, yheight=0.03, options="lambda, time, multiple, auto", restore_neutron = 1 ) AT (0,0,guide5bl+0.001) RELATIVE PREVIOUS /// Slits at start of collimation ////////////////////////////////////////////// COMPONENT fourjawslit1 = Slit( xmin = -sourceapx/2.0, xmax = sourceapx/2.0, ymin = -sourceapy/2.0, ymax = sourceapy/2.0 ) WHEN (fourjawslit1used == 1) AT (0,0,fourjawthickness/2.0) RELATIVE PREVIOUS /// End slits ////////////////////////////////////////////////////////////////// COMPONENT Mon11_PostJaw1 = Monitor_nD( xwidth=guidewidth, yheight=0.03, options="lambda, time, multiple, auto", restore_neutron = 1 ) AT (0,0,0.001+fourjawthickness/2.0) RELATIVE PREVIOUS /// Collimator system including apertures ////////////////////////////////////// // COMPONENT collimator_win1 = Al_window(thickness=0.001) // AT (0,0,windowgap) RELATIVE PREVIOUS // Colguide1 inserted if collimation length is <= 5m COMPONENT colGuide1 = Guide_gravity( w1 = guidewidth, h1 = guideheight, w2 = guidewidth, h2 = guideheight, l = colguide1l, m = defaultm ) WHEN (collen <= 5.0) AT (0,0,0.001) RELATIVE PREVIOUS COMPONENT Mon12_PostCG1 = Monitor_nD( xwidth=0.03, yheight=0.03, options="lambda, time, multiple, auto", restore_neutron = 1 ) AT (0,0,colguide1l+0.001) RELATIVE PREVIOUS // Aperture used if collimation length is 5m // Source aperture COMPONENT aperturechanger1 = Slit( xmin = -sourceapx/2.0, xmax = sourceapx/2.0, ymin = -sourceapy/2.0, ymax = sourceapy/2.0 ) WHEN (aperturechangerused == 1) AT (0,0,collimatorgap/2.0) RELATIVE PREVIOUS COMPONENT Mon13_PostApertureChanger = Monitor_nD( xwidth=guidewidth, yheight=0.03, options="lambda, time, multiple, auto", restore_neutron = 1 ) AT (0,0,0.001) RELATIVE PREVIOUS // Collguide2 inserted if collimation length is <= 3 m COMPONENT colGuide2 = Guide_gravity( w1 = guidewidth, h1 = guideheight, w2 = guidewidth, h2 = guideheight, l = colguide2l, m = defaultm ) WHEN (collen <= 3.0) AT (0,0,collimatorgap/2.0) RELATIVE PREVIOUS COMPONENT Mon14_PostCG2 = Monitor_nD( xwidth=guidewidth, yheight=0.03, options="lambda, time, multiple, auto", restore_neutron = 1 ) AT (0,0,colguide2l+0.001) RELATIVE PREVIOUS // Slits used for 3m collimation COMPONENT fourjawslit2 = Slit( xmin = -sourceapx/2.0, xmax = sourceapx/2.0, ymin = -sourceapy/2.0, ymax = sourceapy/2.0 ) WHEN (fourjawslit2used == 1) AT (0,0,fourjawthickness/2.0) RELATIVE PREVIOUS COMPONENT Mon15_PostJaw2 = Monitor_nD( xwidth=guidewidth, yheight=0.03, options="lambda, time, multiple, auto", restore_neutron = 1 ) AT (0,0,0.001+fourjawthickness/2.0) RELATIVE PREVIOUS /// flight tube and sample aperture //////////////////////////////////////////// COMPONENT sampleaperture = Slit( xmin = -sampleapx/2.0, xmax = sampleapx/2.0, ymin = -sampleapy/2.0, ymax = sampleapy/2.0 ) AT (0,0,3.0-0.005) RELATIVE PREVIOUS /* Mantid needs a straight instrument-axis for correct ki-transformation of the events. The following Arm is a trick to ensure this - and is propagated length of the primary optics "back" from the orientation of the last guide-element / slit /... */ //COMPONENT sourceMantid = Arm() // AT (0, 0, -24.5915) RELATIVE sampleaperture COMPONENT sourceMantid = Arm() AT (0, 0, -24.8515) RELATIVE sampleaperture //COMPONENT sourceMantid = Arm() // AT (0, 0, -24.9915) RELATIVE sampleaperture // Spectrum before sample COMPONENT lmon2 = L_monitor( nL = 140, filename = "Edet0.dat", xmin = -0.0075, xmax = 0.0075, ymin = -0.0075, ymax = 0.0075, Lmin = 0.0, Lmax = 17.0) AT (0.0, 0.0, 0.0001) RELATIVE sampleaperture COMPONENT Mon16_PostSampleAperture = Monitor_nD( xwidth=0.03, yheight=0.03, options="multiple, lambda bins=50 limits=[1.0,20.0], time bins=50", restore_neutron = 1 ) AT (0,0,0.0001) RELATIVE PREVIOUS COMPONENT Mon16a_PostSampleAperture = Monitor_nD( xwidth=guidewidth, yheight=0.03, options="ydiv lambda all auto", restore_neutron = 1 ) AT (0,0,0.0001) RELATIVE PREVIOUS COMPONENT Mon16b_PostSampleAperture = Monitor_nD( xwidth=guidewidth, yheight=0.03, options="xdiv lambda all auto", restore_neutron = 1 ) AT (0,0,0.0001) RELATIVE PREVIOUS COMPONENT Mon16c_PostSampleAperture = Monitor_nD( xwidth=guidewidth, yheight=0.03, options="x y all auto", restore_neutron = 1 ) AT (0,0,0.0001) RELATIVE PREVIOUS /////////////////////////////////////////////////////////////////////////////// /// Virtual output ///////////////////////////////////////////////////////////// COMPONENT VirtualSourceCreator = Virtual_output( filename = virtualoutput_filename ) WHEN (virtualout == 1) AT (0, 0, 0.0001) RELATIVE PREVIOUS COMPONENT PreSampleMonitor = Monitor_nD( xwidth=0.03, yheight=0.03, options="lambda, time, multiple, auto", restore_neutron = 1 ) AT (0,0,0.0001) RELATIVE PREVIOUS //////////////////////////////////////////////////////////// // TOF-Lambda COMPONENT time_lambda_presample= TOFLambda_monitor( nL = 1000, nt = 2000, filename = "Time_Lambda_PreSample.dat", xmin = -0.0075, xmax = 0.0075, ymin = -0.0075, ymax = 0.0075, tmin = 0, tmax =90000, Lmin = 0, Lmax = 17 ) AT (0, 0, 0.001) RELATIVE sampleaperture /// Sample ///////////////////////////////////////////////////////////////////// SPLIT 10 COMPONENT sampleMantid = Arm() AT (0, 0, 0.0049) RELATIVE sampleaperture /*COMPONENT WaterSample = Isotropic_Sqw( xwidth=sampleapx,yheight=sampleapy, zdepth=0.001, Sqw_coh="H2O_liq.qSq", Sqw_inc=NULL, d_phi=75, p_interact=0.5) WHEN (sampletype == 0 && usesample == 1) AT (0, 0, 0.005) RELATIVE sampleaperture EXTEND %{ if (!SCATTERED) iflag_scatt = 0; if (SCATTERED) iflag_scatt = 1; if (!SCATTERED) iflag_scatt_12 = 1; if (SCATTERED) iflag_scatt_12 = 2; %} COMPONENT Sample = SANS_benchmark( xwidth=sampleapx,yheight=sampleapy, zthick=0.001, dsdw_inc=incohb,model=sampletype) WHEN (sampletype > 0 && usesample == 1) AT (0, 0, 0.0051) RELATIVE sampleaperture EXTEND %{ if (!SCATTERED) iflag_scatt = 0; if (SCATTERED) iflag_scatt = 1; if (!SCATTERED) iflag_scatt_12 = 1; if (SCATTERED) iflag_scatt_12 = 2; %} */ COMPONENT Sample = SANS_benchmark2( xwidth=sampleapx,yheight=sampleapy, zthick=0.001,model=sampletype, dsdw_inc=0.0, sc_aim=1.0, sans_aim=1.00, singlesp = 1.0) AT (0, 0, 0.0051) RELATIVE sampleaperture EXTEND %{ if (!SCATTERED) iflag_scatt = 0; if (SCATTERED) iflag_scatt = 1; if (!SCATTERED) iflag_scatt_12 = 1; if (SCATTERED) iflag_scatt_12 = 2; if (!SCATTERED) ABSORB; %} //////////////////////////////////////////////////////////////////////////////// COMPONENT PostSampleMonitor = Monitor_nD( xwidth=0.03, yheight=0.03, options="lambda, time, multiple, auto", restore_neutron = 1 ) AT (0,0,0.0001) RELATIVE PREVIOUS /// Geant output /////////////////////////////////////////////////////////////// /// Output for Geant simulations to use // /* the output ============================================================== */ // COMPONENT mcpl_out_postsample = MCPL_output( // filename=mcploutput_filename, verbose=1, userflag=iflag_scatt_12, // userflagcomment="user flag for neutrons SCATTERing in the sample component, 1: if no, 2: if yes") // WHEN (mcploutputenabled == 1) // AT(0,0,0.0001) RELATIVE PREVIOUS // currently located at 0.0002 relative to Sample //Capture all the post sample trajectories to use for generating Geant source COMPONENT geantOutput = Monitor_nD( user1=iflag_scatt, options = "x y z kx ky kz t lambda user1, list all", filename="geantInput_loki", xwidth=2.0, yheight=2.0, restore_neutron=1 ) WHEN (geantoutputenabled == 1) AT (0, 0, 0.1) RELATIVE Sample COMPONENT geantOutputRear = Monitor_nD( user1=iflag_scatt, options = "x y z kx ky kz t lambda user1, list all", filename="geantInputRear_loki", xwidth=1.0, yheight=1.0, restore_neutron=1 ) WHEN (geantoutputenabled == 1) AT (0, 0, reardet) RELATIVE Sample //////////////////////////////////////////////////////////////////////////////// /// Detectors ////////////////////////////////////////////////////////////////// //Simple 2x2m detector 1m from sample for diagnostics COMPONENT simpleDetector = Monitor_nD( options="x bins=1000 y bins=1000", xwidth=2.0, yheight=2.0, filename="simpleDetectorView", restore_neutron=1 ) WHEN (usedetectors == 1) AT (0, 0, 2.0) RELATIVE Sample /*COMPONENT nD_Mantid_1 = Monitor_nD( options ="mantid square x limits=[-1.5 1.5] bins=100 y limits=[-1.5 1.5] bins=100, neutron pixel min=0 t, list all neutrons", xmin = -1.5, xmax = 1.5, ymin = -1.5, ymax = 1.5, restore_neutron = 1, filename = "bank01_events.dat") AT (0, 0, 0.01) RELATIVE simpleDetector GROUP Det COMPONENT nD_Mantid_2 = Monitor_nD( options ="mantid square x limits=[-1.5 1.5] bins=100 y limits=[-1.5 1.5] bins=100, neutron pixel min=20000 t, list all neutrons", xmin = -1.5, xmax = 1.5, ymin = -1.5, ymax = 1.5, restore_neutron = 1, filename = "bank02_events.dat") AT (2.0, 0, 0.1) RELATIVE simpleDetector GROUP Det */ /// Front top panel /// x_width = 1200 /// y_width = 539.6 COMPONENT nD_Mantid_9 = Monitor_nD( options ="mantid square x limits=[-0.6 0.6] bins=480 y limits=[-0.2698 0.2698] bins=216, neutron pixel min=9000000 t, list all neutrons", xmin = -0.6, xmax = 0.6, ymin = -0.2698, ymax = 0.2698, //restore_neutron = 1, filename = "bank0_events.dat") AT (0, 0.629, 1.18) RELATIVE Sample ROTATED (-8.45, 0, 0) RELATIVE Sample GROUP Det /// Front bottom panel /// x_width = 1200 /// y_width = 539.6 COMPONENT nD_Mantid_8 = Monitor_nD( options ="mantid square x limits=[-0.6 0.6] bins=480 y limits=[-0.2698 0.2698] bins=216, neutron pixel min=8000000 t, list all neutrons", xmin = -0.6, xmax = 0.6, ymin = -0.2698, ymax = 0.2698, //restore_neutron = 1, filename = "bank0_events.dat") AT (0, -0.629, 1.18) RELATIVE Sample ROTATED (8.45, 0, 0) RELATIVE Sample GROUP Det /// Front right panel /// x_width = 994 /// y_width = 1200 COMPONENT nD_Mantid_7 = Monitor_nD( options ="mantid square x limits=[-0.497 0.497] bins=398 y limits=[-0.6 0.6] bins=480, neutron pixel min=7000000 t, list all neutrons", xmin = -0.497, xmax = 0.497, ymin = -0.6, ymax = 0.6, //restore_neutron = 1, filename = "bank0_events.dat") AT (0.7567, 0, 1.58) RELATIVE Sample ROTATED (0, 8.45, 0) RELATIVE Sample GROUP Det /// Front left panel /// x_width = 994 /// y_width = 1200 COMPONENT nD_Mantid_6 = Monitor_nD( options ="mantid square x limits=[-0.497 0.497] bins=398 y limits=[-0.6 0.6] bins=480, neutron pixel min=6000000 t, list all neutrons", xmin = -0.497, xmax = 0.497, ymin = -0.6, ymax = 0.6, //restore_neutron = 1, filename = "bank0_events.dat") AT (-0.7567, 0, 1.58) RELATIVE Sample ROTATED (0, -8.45, 0) RELATIVE Sample GROUP Det /// /// MID DETECTOR /// /// Middle right panel /// x_width = 369.2 /// y_width = 500 COMPONENT nD_Mantid_1 = Monitor_nD( options ="mantid square x limits=[-0.1845 0.1845] bins=148 y limits=[-0.25 0.25] bins=200, neutron pixel min=1000000 t, list all neutrons", xmin = -0.1845, xmax = 0.1845, ymin = -0.25, ymax = 0.25, //restore_neutron = 1, filename = "bank0_events.dat") AT (0.374, 0, 3.28) RELATIVE Sample ROTATED (0, 8.45, 0) RELATIVE Sample GROUP Det /// Middle left panel /// x_width = 369.2 /// y_width = 500 COMPONENT nD_Mantid_2 = Monitor_nD( options ="mantid square x limits=[-0.1845 0.1845] bins=148 y limits=[-0.25 0.25] bins=200, neutron pixel min=2000000 t, list all neutrons", xmin = -0.1845, xmax = 0.1845, ymin = -0.25, ymax = 0.25, //restore_neutron = 1, filename = "bank0_events.dat") AT (-0.374, 0, 3.28) RELATIVE Sample ROTATED (0, -8.45, 0) RELATIVE Sample GROUP Det /// Middle top panel /// x_width = 1200 /// y_width = 539.6 COMPONENT nD_Mantid_3 = Monitor_nD( options ="mantid square x limits=[-0.6 0.6] bins=480 y limits=[-0.2698 0.2698] bins=216, neutron pixel min=3000000 t, list all neutrons", xmin = -0.6, xmax = 0.6, ymin = -0.2698, ymax = 0.2698, //restore_neutron = 1, filename = "bank0_events.dat") AT (0, 0.497, 2.91) RELATIVE Sample ROTATED (-8.45, 0, 0) RELATIVE Sample GROUP Det /// Middle bottom panel /// x_width = 1200 /// y_width = 539.6 COMPONENT nD_Mantid_4 = Monitor_nD( options ="mantid square x limits=[-0.6 0.6] bins=480 y limits=[-0.2698 0.2698] bins=216, neutron pixel min=4000000 t, list all neutrons", xmin = -0.6, xmax = 0.6, ymin = -0.2698, ymax = 0.2698, //restore_neutron = 1, filename = "bank0_events.dat") AT (0, -0.497, 2.91) RELATIVE Sample ROTATED (8.45, 0, 0) RELATIVE Sample GROUP Det /// Rear detector /// x_width = 1000 /// y_width = 1505 COMPONENT nD_Mantid_5 = Monitor_nD( options ="mantid square x limits=[-0.5 0.5] bins=400 y limits=[-0.7525 0.7525] bins=602, neutron pixel min=5000000 t, list all neutrons", xmin = -0.5, xmax = 0.5, ymin = -0.7525, ymax = 0.7525, //restore_neutron = 1, filename = "bank0_events.dat") AT (0, 0, reardet) RELATIVE Sample //ROTATED (13.5, 0, 0) RELATIVE Sample GROUP Det //////////////////////////////////////////////////////////////////////////////// FINALLY %{ %} END