<div dir="ltr">Hi Tom,<br><br>Upon a quick review of your instrument file, I have the following suggestions to improve efficiency:<br><br>In such an instrument that involves a long pre-sample guide, I would suggest using the virtual_input/virtual_output component (see documentation). <br>
<br>Insert a virtual_input after the PSDafterSlit_before component. Run a simulation such that a statistically appropriate distribution of neutrons is observed on this detector.<br><br>Create a new instrument, starting from the Sample component, using the virtual_output as a source. The repeat parameter the virtual_output should then be used to set the number of neutron histories to simulation (do not let ncount be the limiting factor or relative intensities will not be correct).<br>
<br>Append the SPLIT keyword (something like SPLIT 10 COMPONENT Sample=...) to your Sample component (see documentation).<br><br>Using the dphi parameter of the PowderN component to limit vertical scattering to an appropriate range.<br>
<br>Your source focusing seems a little strange. You have as a default dist = 2. Try focusing to the M2Exit slit, which would give dist =4.049 and make xw and yh slightly larger than the dimensions of this slit (use your own discretion). You might even try focusing to the end of the collimator1 component. Just be sure that xw and yh are not limiting factors to divergence or neutron distribution.<br>
<br>I'm also curious to know what your ncount was for this simulation. My feeling would be that with your current setup, you'd probably need an ncount of around 1e11 to get a sufficient signal into your final detector.<br>
<br>I would stress that you use virtual_input and virtual_output to split this simulation into two parts. This will greatly help your efficiency, especially if you will be detecting more than one diffraction peak from your sample. The logic is that since your pre-sample guide and collimation will probably be static, there is no need to continuously simulate this part of the instrument. If you build a data file with sufficient neutron histories at the slit_before component, then you can simply repeat this set of histories to build enough statistics on your final detector. The SPLIT 10 appended to the sample component will also increase your efficiency by ~10x.<br>
<br>Should you have further questions, feel free to ask, as I have extensive experience simulating this type of two-axis instrument.<br><br>Cheers,<br><br>Aaron<br><br><div class="gmail_quote">2008/7/24 wokaoyan1981 <span dir="ltr"><<a href="mailto:wokaoyan1981@126.com">wokaoyan1981@126.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>Hello colleagues,<br><br> I've set up a residual stress instrument.The simulation result suggests(Neutron count=10<font size="1">9<font size="3">)</font></font>: Neutrons after Fe(211) diffraction are I I_err N=[29927.1 31233.5 3];And neutrons reaching the detector through aperture are I I_err N=[0 0 0]. Both I and N are too low.<br>
I raised horizontal divergences of the first and second collimator but I and N remain too low. What should I do in order to get high I and N on detector?<br> <br> Here is the code:<br>/*******************************************************************************<br>
* McStas instrument definition URL=<a href="http://www.mcstas.org" target="_blank">http://www.mcstas.org</a><br>*<br>* Instrument: residual stress instrument <br>*<br>* %Identification<br>* Written by: Tom<br>* Date:10 Jan 2008<br>
* Origin: institute<br>* Release: McStas 1.6<br>* Version: 0.2<br>* %INSTRUMENT_SITE:thesis<br>*<br>* residual stress instrument <br>*<br>* %Description<br>* try to optimize parameters of residual stress instrument. default geometry is <br>
* from blueprints of residual stress instruments at CARR,FRM-II(Germany),E3* (Germany) * and SALSA(France) <br>* Example: mcrun residual_stress.instr <RV=-1><br>*<br>* %Parameters<br>* dist: [m] focusing distance from source to SlitIn<br>
* GapM2_G: [m] distance between M2Exit and guide entrance<br>* xw: [m] width of neutron guide entrance<br>* yh: [m] height of neutron guide entrance<br>* l: [m] length of straight neutron guide<br>
* m: [1] m-value of material1.5~3<br>* CH1: ['] horizontal divergence of the first collimator<br>* len_C1 [m] length of the first collimator<br>* L1: [m] distance between exit of first collimator and <br>
* monochromator,0.01~0.3m<br>* A1: [deg] rotation of mono<br>* DM: [Angs] d-spacing of monochromator<br>* NH: [columns] number of slabs horizontal <br>* NV: [rows] number of slabs vertical <br>
* mosaich: ['] Horisontal mosaic FWHM <br>* mosaicv: ['] Vertical mosaic FWHM <br>* RV: [m] Monochromator vertical curvature, 0 for flat, -1 for automatic<br>* setting(then RV=2*L2*sin(DEG2RAD*A1) )<br>
* RH: [m] Monochromator horizontal curvature, 0 for flat, -1 for automatic<br>* setting(then RH = 2*L2/sin(DEG2RAD*A1))<br>* L2: [m] distance between monochromator and sample,1.9~2.2<br>
* CH2: ['] horizontal divergence of the second collimator<br>* DS: [Angs] d-spacing of sample:default Fe(hkl) <br>* L3: [m] distance between sample and detector <br>* %Link<br>* A reference/HTML link for more information<br>
*<br>* %End<br>*******************************************************************************/<br>/* Change name of instrument and input parameters with default values */<br>DEFINE INSTRUMENT residual_stress(<br> dist=2, GapM2_G=0, xw=0.06, yh=0.11, l=6, m=2, CH1=10,<br>
L1=0.3, A1=45, DM=1.0886, len_C1=0.6, NH=1, NV=15, mosaich=30,mosaicv=30,<br> RV=-1, RH=0, L2=1.9,CH2=30,DS=1.1782,L3=1.0) <br>/* The DECLARE section allows us to declare variables or small */<br>/* functions in C syntax. These may be used in the whole instrument. */<br>
<br>DECLARE<br>%{<br>double M2Exit_mono; /* distance between M2Exit and monochromator */<br>double lambda; /*wavelength after diffraction*/<br>double monow; /*width of mono*/ <br>double A2; /*half of sample take off angle*/<br>
%}<br><br>/* The INITIALIZE section is executed when the simulation starts */<br>/* (C code). You may use them as component parameter values. */<br>INITIALIZE<br>%{<br>M2Exit_mono=GapM2_G+l+len_C1+L1;<br>lambda=2*DM*sin(DEG2RAD*A1);<br>
if (RV<0) RV=2*L2*sin(DEG2RAD*A1);<br>if (RH<0) RH = 2*L2/sin(DEG2RAD*A1);<br>monow=xw/sin(DEG2RAD*A1);<br>A2=asin(lambda/(2*DS))*RAD2DEG;<br>printf("\nlambda=%f\tRV=%f\tRH=%f\tmonow=%f\tA2=%f\n",lambda,RV,RH,monow,A2); <br>
%}<br><br>/* Here comes the TRACE section, where the actual */<br>/* instrument is defined as a sequence of components. */<br>TRACE<br>/* Progress_bar is an Arm displaying simulation progress.*/<br>COMPONENT Origin = Progress_bar()<br>
AT (0,0,0) ABSOLUTE<br><br>/********************* neutron source********************************/<br>COMPONENT Source = Source_Maxwell_3(<br> height = 0.75, width =0.52988 , <br> l_low =0.2,l_high =7, <br>
dist = dist, <br> xw = 0.06, yh = 0.11,<br> T1 = 320,I1 =9.87E12) <br> AT (0, 0, 0) RELATIVE Origin<br><br>/************channel(Al and Fe) inside reactor, length:4.049m**********/<br>COMPONENT SlitIn = Slit(<br>
width = 0.06, height = 0.11)<br> AT (0, 0, 0 ) RELATIVE Source<br><br>COMPONENT M2Exit = Slit(<br> width = 0.06, height = 0.11)<br> AT (0, 0, 4.049 ) RELATIVE SlitIn <br><br><br> /*************************straight_guide*******************/<br>
COMPONENT straight_guide = Guide(<br> w1 = xw, h1 = yh, w2 = xw, h2 = yh, l =l, m = m)<br> AT (0, 0, GapM2_G) RELATIVE M2Exit<br><br><br>/**************************first collimator**************************/<br>COMPONENT collimator1 = Collimator_linear(<br>
xmin = -xw/2, xmax = xw/2, ymin = -yh/2, ymax = yh/2,<br> len = len_C1, divergence = CH1)<br> AT (0, 0, l) RELATIVE straight_guide<br><br><br>/*************************mono_craddle***************************/<br>COMPONENT mono_craddle = Arm(<br>
)<br> AT (0, 0, M2Exit_mono) RELATIVE M2Exit<br> ROTATED (0, A1, 0) RELATIVE Origin<br><br>/***************************monochromator Ge(511)****************************/<br>COMPONENT monochromator = Monochromator_curved(<br>
width=monow, height=0.15, NH=NH, NV=NV,reflect = "0", transmit = "0",<br> gap = 0.0005, mosaich = mosaich, mosaicv = mosaicv, r0 = 0.7, <br> t0 = 1.0, RV = RV, RH = RH, DM = DM)<br> AT (0, 0, 0) RELATIVE mono_craddle<br>
<br>/*********************mono_out*******************/<br>COMPONENT mono_out = Arm(<br> )<br> AT (0, 0, 0) RELATIVE mono_craddle<br> ROTATED (0, 2*A1, 0) RELATIVE Origin<br><br>/********************detectors before second collimator**************************/<br>
COMPONENT LDbeforeC2 = L_monitor(<br> nchan = 200, filename = "LDbeforeC2", xwidth = 0.15,<br> yheight = 0.15, Lmin = 0, Lmax = lambda+0.1)<br> AT (0, 0, 0.8) RELATIVE mono_out<br><br>COMPONENT PSDbeforeC2 = PSD_monitor(<br>
filename = "PSDbeforeC2", xwidth = 0.15, yheight = 0.15)<br> AT (0, 0, 0.8) RELATIVE mono_out<br><br>/***********************second collimator***************************/<br> COMPONENT collimator2 = Collimator_linear(<br>
xmin = -xw/2, xmax = xw/2, ymin = -yh/2, ymax = yh/2, len = 0.4,<br> divergence = CH2)<br> AT (0, 0, 0.8) RELATIVE mono_out<br><br>/**********************detector after second collimator********************/<br>COMPONENT PSDafterC2 = PSD_monitor(<br>
filename = "PSDafterC2", xwidth = 0.06, yheight = 0.11)<br> AT (0, 0, 0.4) RELATIVE collimator2<br><br><br>/**********************aperture before sample*************************/<br> COMPONENT slit_before = Slit(<br>
width = 0.008, height = 0.008)<br> AT (0, 0, 1.88) RELATIVE mono_out<br><br>/**********************detector behind Slit_before***********************/<br>COMPONENT PSDafterSlit_before = PSD_monitor(<br> filename = "PSDafterSlit_before", xwidth = 0.01, yheight = 0.01)<br>
AT (0, 0, 0.01) RELATIVE slit_before<br><br><br>/************************Fe(221) sample****************************/<br>COMPONENT Sample = PowderN(<br> reflections = "Fe.laz", radius = 0.004, yheight = 0.8)<br>
AT (0, 0, L2) RELATIVE mono_out<br>EXTEND<br>%{<br>if(!SCATTERED) ABSORB; /*perfect beamstop*/<br>%}<br><br>/************************sample_out************************/<br>COMPONENT sample_out = Arm(<br> )<br>
AT (0, 0, 0) RELATIVE Sample<br> ROTATED (0, -2*A2, 0) RELATIVE Sample<br><br>/************************detector before slit_after********************/<br>COMPONENT PSDbeforeSlit_after = PSD_monitor(<br> filename = "PSDbeforeSlit_after", xwidth = 0.008,<br>
yheight = 0.050)<br> AT (0, 0, 0.01) RELATIVE sample_out<br><br>/************************aperture after sample***************************/<br>COMPONENT slit_after = Slit(<br> width = 0.008, height = 0.050)<br> AT (0, 0, 0.02) RELATIVE sample_out<br>
<br>/************************detector*********************************/<br>COMPONENT PSDafterSample = PSDlin_monitor(<br> nx = 200, filename = "PSDafterSample", xwidth = 0.2,<br> yheight = 0.2)<br> AT (0, 0, L3) RELATIVE sample_out<br>
<br> <br>/* This section is executed when the simulation ends (C code). Other */<br>/* optional sections are : SAVE */<br>FINALLY<br>%{<br>%}<br>/* The END token marks the instrument definition end */<br>
END<br><br>Regards,<br>Tom<br><br><br> <br> <br></div><div> </div><div> </div><br><br>
<hr>
<a style="font-size: 12px; line-height: 15px; color: blue; text-decoration: underline;" href="http://popme.163.com/link/004572_0721_2489.html" target="_blank">想免费升级vip邮箱吗?</a><font style="font-size: 12px; line-height: 15px;">快来参加喝汇源游网易活动吧!</font><br>
_______________________________________________<br>
mcstas-users mailing list<br>
<a href="mailto:mcstas-users@mcstas.org">mcstas-users@mcstas.org</a><br>
<a href="http://mailman.mcstas.org/cgi-bin/mailman/listinfo/mcstas-users" target="_blank">http://mailman.mcstas.org/cgi-bin/mailman/listinfo/mcstas-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>*************************************************<br>Aaron M. Percival<br>M.Sc. Candidate<br>Dept. of Physics, Engineering Physics & Astronomy<br>Queen's University<br>
Kingston, Ontario, Canada, K7L 3N6<br>Office: 613-533-6000 ext. 74789<br>Fax: 613-533-6463<br>*************************************************<br>
</div>