/********************************************************************** * * McStas, version 1.0, released October 26, 1998 * Maintained by Kristian Nielsen and Kim Lefmann, * Risoe National Laboratory, Roskilde, Denmark * * Component: Source_flux * * %Identification * Written by: KN * Date: August 1998 * Origin: McStas 1.0 (1998) * * An old variant of the official Source_flux_lambda component. * * %Description * Models a reactor source with a flat energy distribution and a * given neutron flux. * This is useful for simulations where the absolute value of neutron flux, * detector counts, etc. is needed for comparison with real instruments and * experiments. * * %Parameters * INPUT PARAMETERS * * radius: (m) Radius of circle in (x,y,0) plane where neutrons * are generated. * dist: (m) Distance to target along z axis. * xw: (m) Width(x) of target * yh: (m) Height(y) of target * E0: (meV) Mean energy of neutrons. * dE: (meV) Energy spread of neutrons. * flux: (n/s/cm^2) Neutron flux * * %End ***********************************************************************/ DEFINE COMPONENT Source_flux DEFINITION PARAMETERS (radius, dist, xw, yh, E0, dE, flux) SETTING PARAMETERS () OUTPUT PARAMETERS (hdiv, vdiv, p_in) STATE PARAMETERS (x,y,z,vx,vy,vz,t,s1,s2,p) DECLARE %{ double hdiv,vdiv; double p_in; %} INITIALIZE %{ double factor, lambda_min, lambda_max, delta_lambda, source_area; hdiv = atan(xw/(2.0*dist)); vdiv = atan(yh/(2.0*dist)); lambda_min = sqrt(81.81/(E0+dE)); /* AAngstroem */ lambda_max = sqrt(81.81/(E0-dE)); delta_lambda = lambda_max - lambda_min; source_area = radius*radius*PI*1e4; /* cm^2 */ factor = flux/mcget_ncount()*delta_lambda*source_area; p_in = (4*hdiv*vdiv)*factor; /* Small angle approx. */ %} TRACE %{ double theta0,phi0,chi,theta,phi,E,v,r; p=p_in; z=0; chi=2*PI*rand01(); /* Choose point on source */ r=sqrt(rand01())*radius; /* with uniform distribution. */ x=r*cos(chi); y=r*sin(chi); theta0= -atan(x/dist); /* Angles to aim at target centre */ phi0= -atan(y/dist); theta=theta0+hdiv*randpm1(); /* Small angle approx. */ phi=phi0+vdiv*randpm1(); E=E0+dE*randpm1(); /* Assume linear distribution */ v=sqrt(E)*SE2V; vz=v*cos(phi)*cos(theta); vy=v*sin(phi); vx=v*cos(phi)*sin(theta); %} END