DEFINE INSTRUMENT Exercise3c_BiSpectral_McStas() DECLARE %{ double source_rand = 0; double source_colour= 0; %} TRACE COMPONENT Origin = Progress_bar() AT (0,0,0) ABSOLUTE EXTEND %{ source_rand = rand01(); source_colour= 0; %} /* two moderators 12 cm apart. The cold one is rotated so that it illuminates the same target window 10x10 cm2 at 2 m distance */ COMPONENT thermal_source = Source_gen( Lmin=.1, Lmax=10, xwidth=0.12, yheight=0.12, focus_xw=0.1, focus_yh=0.1, dist=2, T1=325, I1=1e13) WHEN (source_rand > 0.5) AT(0,0,0) RELATIVE Origin EXTEND %{ if (SCATTERED) source_colour=1; %} COMPONENT cold_source = COPY(thermal_source)( T1=50, I1=1e13) WHEN (source_rand <= 0.5) AT(0,0.12+tan(1.0*DEG2RAD)*2.88,0) RELATIVE Origin ROTATED(atan2(.12,2)*RAD2DEG, 0, 0) RELATIVE Origin EXTEND %{ if (SCATTERED) source_colour=2; %} /* put a Monitor at the guide entrance */ COMPONENT Mon_input = Monitor_nD(xwidth=0.1, yheight=0.18, user1=source_colour, username1="Moderator index [1=thermal, 2=cold]", options="user1 limits=[0.9 2.1] bins=2, auto lambda") AT(0,0,1.99) RELATIVE Origin /* the Pol_mirror lies in the YZ plane, and is positioned at its centre */ /* so we translate by half dimensions, and rotate 90 deg around Z */ /* shift due to inclination is tan(1*PI/180)*2.88/2 */ COMPONENT off = Guide_anyshape(geometry="extractor.off", m=5, transmit=1) AT(0,-0.05,0) RELATIVE PREVIOUS COMPONENT guide = Guide(w1=0.1, h1=0.1, l=10) AT(0,0,0.01+2.88) RELATIVE PREVIOUS(2) /* and a copy at the exit */ COMPONENT Mon_output = COPY(Mon_input) AT(0,0,10.01) RELATIVE PREVIOUS END