/******************************************************************************* * McStas instrument definition URL=http://www.mcstas.org * * Instrument: Test Monitor_nD against basic monitors * * %Identification * Written by: P. Willendrup * Date: 30. September 2020 * Origin: DTU * %INSTRUMENT_SITE: Tests * * Test Monitor_nD against basic monitor * * %Description * A test instrument to compare Monitor_nD output against basic 1D and 2D monitors. * * %Example: lambda=1 Detector: PSD_mon_I=8.34136e+10 * * %Parameters * lambda: [Angs] Wavelength at monochromator, computed from DM and THETA_M if left as 0. * DM: [Angs] d-spacing of monochromator, computed from lambda and THETA_M if left as 0. * THETA_M: [deg] Monochromator take-off angle, computed from lambda and DM if left as 0. * RV: [m] Monochromator vertical curvature, 0 for flat, -1 for automatic setting * L1: [m] Source-Monochromator distance * L2: [m] Monochromator-Sample distance * L3: [m] Sample-Detector distance * ALPHA1: [min] Horizontal collimator divergence for L1 arm (before monochromator) * ALPHA2: [min] Horizontal collimator divergence for L2 arm (monochromator-sample) * ALPHA3: [min] Horizontal collimator divergence for L3 arm (sample-detector) * ETA: [min] Monochromator horizontal mosaic (gaussian) * Powder: [str] File name for powder description * verbose: [int] Print DIF configuration. 0 to be quiet * SM: [int] Scattering sense of beam from Monochromator. 1:left, -1:right * * %End *******************************************************************************/ DEFINE INSTRUMENT Test_Monitor_nD(lambda=1, L1=10, int bins=100, xw=0.11, yh=0.16, hdiv=2, vdiv=2) DECLARE %{ char lmonopts[128]; char xyopts[128]; char tofopts[128]; char divopts[128]; char eopts[128]; double mudist=1e-6; double V,E,T; %} /* The INITIALIZE section is executed when the simulation starts */ /* (C code). You may use them as component parameter values. */ INITIALIZE %{ V=K2V*(2*PI/lambda); E=VS2E*V*V; T=L1/V; sprintf(lmonopts,"lambda limits=[%g %g] bins=%i",0.985*lambda,1.025*lambda,bins); sprintf(xyopts,"x bins=%i, y bins=%i",bins,bins); sprintf(divopts,"hdiv limits=[%g %g] bins=%i, vdiv limits=[%g %g] bins=%i",-hdiv,hdiv,bins,-vdiv,vdiv,bins); sprintf(eopts,"energy limits=[%g %g] bins=%i",0.9*E,1.1*E,bins); sprintf(tofopts,"tof limits=[%g %g] bins=%i",0.985*T,1.025*T,bins); %} /* Here comes the TRACE section, where the actual */ /* instrument is defined as a sequence of components. */ TRACE REMOVABLE COMPONENT Origin = Progress_bar() AT (0,0,0) ABSOLUTE /* source with constant flux */ REMOVABLE COMPONENT Source = Source_gen( radius = 0.11, dist = L1, focus_xw = 0.1, focus_yh = 0.15, lambda0 = lambda, dlambda = lambda*0.01, T1=229.6,I1=5.32e13,T2=1102, I2=4.37e12, T3=437.1,I3=3.84e13) AT (0, 0, 0) RELATIVE Origin /* TIP: monochromator cradle */ COMPONENT mon_cradle = Arm() AT (0, 0, L1) RELATIVE PREVIOUS COMPONENT PSD_mon = PSD_monitor(nx=bins,ny=bins, xwidth = xw, yheight = yh, restore_neutron=1, filename="PSD") AT (0, 0, 0) RELATIVE mon_cradle COMPONENT nD_PSD = Monitor_nD(options=xyopts, xwidth = xw, yheight = yh, restore_neutron=1) AT (0, 0, mudist) RELATIVE PREVIOUS COMPONENT L_mon = L_monitor(nL=100, xwidth = 0.1, yheight = 0.15, restore_neutron=1, filename="L",Lmin=0.985*lambda,Lmax=1.025*lambda) AT (0, 0, mudist) RELATIVE PREVIOUS COMPONENT nD_L = Monitor_nD(options=lmonopts, xwidth = xw, yheight = yh, restore_neutron=1) AT (0, 0, mudist) RELATIVE PREVIOUS COMPONENT E_mon = E_monitor(nE=100, xwidth = 0.1, yheight = 0.15, restore_neutron=1, filename="E",Emin=0.9*E,Emax=1.1*E) AT (0, 0, mudist) RELATIVE PREVIOUS COMPONENT nD_E = Monitor_nD(options=eopts, xwidth = xw, yheight = yh, restore_neutron=1) AT (0, 0, mudist) RELATIVE PREVIOUS COMPONENT Tof_mon = TOF_monitor(nt=100, xwidth = 0.1, yheight = 0.15, restore_neutron=1, filename="ToF",tmin=0.985*1e6*T,tmax=1.025*1e6*T) AT (0, 0, mudist) RELATIVE PREVIOUS COMPONENT nD_ToF = Monitor_nD(options=tofopts, xwidth = xw, yheight = yh, restore_neutron=1) AT (0, 0, mudist) RELATIVE PREVIOUS COMPONENT Div_mon = Divergence_monitor(xwidth = xw, yheight = yh, restore_neutron=1, filename="Div", nh=bins, nv=bins,maxdiv_h=hdiv, maxdiv_v=vdiv) AT (0, 0, mudist) RELATIVE PREVIOUS COMPONENT nD_Div = Monitor_nD(options=divopts, xwidth = xw, yheight = yh, restore_neutron=1) AT (0, 0, mudist) RELATIVE PREVIOUS /* The END token marks the instrument definition end */ END