DEFINE INSTRUMENT template_body_simple(Par1=1) DECLARE %{ double nbounces; %} INITIALIZE %{ nbounces = 0; %} TRACE COMPONENT origin = Progress_bar() AT (0, 0, 0) RELATIVE ABSOLUTE COMPONENT source_simple = Source_simple( radius=0.000001, dist=1, focus_xw=0.00001, focus_yh=0.00001, lambda0=5, dlambda=4.9, flux=1e14) AT (0, 0, 0) RELATIVE origin COMPONENT l_monitor = L_monitor( nL=100, filename="l_source.txt", xwidth=0.1, yheight=0.1, Lmin=0.1, Lmax=10, restore_neutron=1) AT (0, 0, 0.1) RELATIVE origin COMPONENT divergence_monitor = Divergence_monitor( nh=100, nv=100, filename="div.txt", xwidth=0.1, yheight=0.1, maxdiv_h=0.1, maxdiv_v=0.1, restore_neutron=1) AT (0, 0, 0.11) RELATIVE origin COMPONENT guide_gravity = Guide_gravity( w1=0.3, h1=0.3, l=0.3, nslit=500, d=0.00001, reflect="constant.rfl") AT (0, 0, 0.3) RELATIVE origin ROTATED (0, 2, 0) RELATIVE origin /* EXTEND %{ if(SCATTERED) nbounces += GVars.N-reflection[0]; %} */ COMPONENT l_monitor_2 = L_monitor( nL=100, filename="l_after.txt", xwidth=0.3, yheight=0.3, Lmin=0, Lmax=10, restore_neutron=1) AT (0, 0, 0.301) RELATIVE PREVIOUS /* COMPONENT UserMonitor = Monitor_nD( user1 = bounces, username1 = "Number of bounces", options = "auto user1") AT (0,0,1) RELATIVE PREVIOUS */ FINALLY %{ %} END