1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
|
/*******************************************************************************
*
* McStas, neutron ray-tracing package
* Copyright (C) 1997-2006, All rights reserved
* Risoe National Laboratory, Roskilde, Denmark
* Institut Laue Langevin, Grenoble, France
*
* Component: Exact_radial_coll
*
* %I
* Written by: Roland Schedler <roland.schedler at hmi.de>
* Modified by: using Collimator_radial Component
* Date: October 2006
* Origin: HMI
* Modified by: E. Farhi, uniformize parameter names (Jul 2008)
*
* An exact radial Soller collimator.
*
* %D
* Radial Soller collimator with rectangular opening, specified length and
* specified foil thickness.
* The collimator is made of many trapezium shaped nslit stacked radially.
* The nslit are separated by absorbing foils, the whole stuff is inside
* an absorbing housing.
* The component should be positioned at the radius center. The model is exact.
* The neutron beam outside the collimator area is transmitted unaffected.
*
* Example: Exact_radial_coll(theta_min=-5, theta_max=5, nslit=100,
* radius=1.0, length=.3, h_in=.2, h_out=.3, d=0.0001)
*
*
* %P
* INPUT PARAMETERS:
*
* theta_min: [deg] Minimum Theta angle for the radial setting
* theta_max: [deg] Maximum Theta angle for the radial setting
* nslit: [1] Number of channels in the theta range
* radius: [m] Inner radius (focus point to foil start point).
* length: [m] Length of the foils / collimator
* h_in: [m] Input window height
* h_out: [m] Output window height
* d: [m] Thickness of the absorbing foils
* verbose: [0/1] Gives additional information
*
* %E
*******************************************************************************/
DEFINE COMPONENT Exact_radial_coll
SETTING PARAMETERS (theta_min=-5, theta_max=5, nslit=100,
radius=1.0, length=.5, h_in=.3, h_out=.4,
d=0.0001, verbose=0)
/* Neutron parameters: (x,y,z,vx,vy,vz,t,sx,sy,sz,p) */
DECLARE
%{
double alpha_in;
double alpha_out;
double beta_in;
double beta_out;
double theta;
double out_radius;
double iw;
double ow;
double divergence;
%}
INITIALIZE
%{
/* check for input parameters */
if (radius <= 0) exit(printf("Exact_radial_coll: %s: radius must be positive\n", NAME_CURRENT_COMP));
if (h_in <= 0) exit(printf("Exact_radial_coll: %s: h_in must be positive\n", NAME_CURRENT_COMP));
if (h_out <= 0) exit(printf("Exact_radial_coll: %s: h_out must be positive\n", NAME_CURRENT_COMP));
if (d <= 0) exit(printf("Exact_radial_coll: %s: d must be positive\n", NAME_CURRENT_COMP));
if (nslit <= 0) exit(printf("Exact_radial_coll: %s: number of channels must be positive\n", NAME_CURRENT_COMP));
if ((nslit - floor (nslit)) > 0) exit(printf("Exact_radial_coll: %s: number of channels must be an integer\n", NAME_CURRENT_COMP));
if (length <= 0) exit(printf("Exact_radial_coll: %s: collimator length must be positive\n", NAME_CURRENT_COMP));
if (theta_max <= theta_min) exit(printf("Exact_radial_coll: %s: theta_max must be greater than theta_min\n", NAME_CURRENT_COMP));
theta_max *= DEG2RAD;
theta_min *= DEG2RAD;
theta = theta_max - theta_min;
out_radius = radius + length;
beta_in = 2*asin(d / (2 * radius));
beta_out= 2*asin(d / (2 * out_radius));
if (theta < nslit*beta_in) exit(printf("Exact_radial_coll: %s: the %6.0f foils of %g [meter]\n"
"do not fit within the angular range theta = %4.2f [deg]\n",
NAME_CURRENT_COMP, nslit, d, theta*RAD2DEG));
alpha_in = (theta - nslit*beta_in)/nslit;
alpha_out = (theta - nslit*beta_out)/nslit;
iw = 2*radius*sin((alpha_in/2));
ow = 2*out_radius*sin((alpha_out/2));
divergence=(iw+ow)/(sqrt(4*length*length-(ow-iw)*(ow-iw)));
if (verbose) {
printf("Exact_radial_coll: %s: foil thickness is %.2g [millimeter]\n", NAME_CURRENT_COMP, d*1000);
printf(" opening each input slit [%.3g:%.0f] [millimeter]\n", iw*1000, h_in*1000);
printf(" opening each output slit [%.3g:%.0f] [millimeter]\n", ow*1000, h_out*1000);
printf(" divergence per channel is %g [min] \n", divergence*RAD2MIN);
}
%}
TRACE
%{
double phi, t0, t1, t2, t3;
int intersect;
long input_chan, output_chan;
double input_theta, output_theta;
double input_center,output_center;
double window_theta;
char ok=0;
/* first compute intersection time with input cylinder */
intersect=cylinder_intersect(&t0,&t3,x,y,z,vx,vy,vz,radius,h_in);
if (!intersect) ABSORB;
else if (t3 > t0) t0 = t3;
intersect=cylinder_intersect(&t1,&t2,x,y,z,vx,vy,vz,out_radius,h_out);
if (!intersect) ABSORB;
else if (t2 > t1) t1 = t2;
/* get index of input slit */
if (t0 > 0 && t1 > t0) {
PROP_DT(t0);
input_theta = atan2(x, z);
/* channel number (start at 0) */
window_theta = (theta_max - theta_min)/nslit;
input_chan = floor((input_theta - theta_min)/window_theta);
if (input_chan >= 0 && input_chan < nslit && fabs(y) < h_in/2) ok=1;
if (ok) {
input_center= theta_min + input_chan*window_theta + (window_theta)/2;
/* are we outside the soller or in the foil? */
phi = input_theta - input_center;
if (fabs(phi) > alpha_in/2) ABSORB; /* inside the foil*/
SCATTER;
/* propagate to output radius */
PROP_DT(t1-t0);
SCATTER;
output_theta = atan2(x, z);
/* channel number (start at 0) */
output_chan = floor((output_theta - theta_min)/window_theta);
/* did we change channel ? */
if (output_chan != input_chan) ABSORB; /* changed slit */
output_center= theta_min + output_chan*window_theta
+ (window_theta)/2;
/* are we outside the soller */
phi = output_theta -output_center;
if (fabs(phi) > alpha_out/2 || fabs(y) > h_out/2) ABSORB; /* outside output slit */
} /* else we pass aside the entrance window of radial collimator */
else {
/* propagate to output radius */
PROP_DT(t1-t0);
SCATTER;
output_theta = atan2(x, z);
/* channel number (start at 0) */
output_chan = floor((output_theta - theta_min)/window_theta);
/* are we come from outside into the soller or in the foil?*/
if (output_chan >= 0 || output_chan < nslit) ABSORB;
} /* else we pass aside the exit window of radial collimator */
} /* else did not encounter collimator */
%}
MCDISPLAY
%{
int i;
double theta1, theta2, theta3, theta4;
double x_in_l, z_in_l, x_in_r, z_in_r;
double x_out_l, z_out_l, x_out_r, z_out_r;
double window_theta, y1, y2;
window_theta = alpha_in + beta_in;
y1 = h_in/2;
y2 = h_out/2;
theta1 = theta_min;
theta3 = theta1+beta_in/2;
theta4 = theta1+beta_out/2;
z_in_l = radius*cos(theta1);
x_in_l = radius*sin(theta1);
z_in_r = radius*cos(theta3);
x_in_r = radius*sin(theta3);
z_out_l = out_radius*cos(theta1);
x_out_l = out_radius*sin(theta1);
z_out_r = out_radius*cos(theta4);
x_out_r = out_radius*sin(theta4);
multiline(5,
x_in_l, -y1, z_in_l,
x_in_l, y1, z_in_l,
x_out_l, y2, z_out_l,
x_out_l,-y2, z_out_l,
x_in_l, -y1, z_in_l);
line(x_in_l, y1, z_in_l, x_in_r, y1, z_in_r);
line(x_in_l, -y1, z_in_l, x_in_r, -y1, z_in_r);
line(x_out_l, y2, z_out_l, x_out_r, y2, z_out_r);
line(x_out_l, -y2, z_out_l, x_out_r,-y2, z_out_r);
multiline(5,
x_in_r, -y1, z_in_r,
x_in_r, y1, z_in_r,
x_out_r, y2, z_out_r,
x_out_r,-y2, z_out_r,
x_in_r, -y1, z_in_r);
for (i = 1; i < nslit; i++) {
theta1 = i*window_theta+theta_min-beta_in/2;
theta2 = i*window_theta+theta_min+beta_in/2;
theta3 = i*window_theta+theta_min-beta_out/2;
theta4 = i*window_theta+theta_min+beta_out/2;
z_in_l = radius*cos(theta1);
x_in_l = radius*sin(theta1);
z_in_r = radius*cos(theta2);
x_in_r = radius*sin(theta2);
z_out_l = out_radius*cos(theta3);
x_out_l = out_radius*sin(theta3);
z_out_r = out_radius*cos(theta4);
x_out_r = out_radius*sin(theta4);
/* left side */
multiline(5,
x_in_l, -y1, z_in_l,
x_in_l, y1, z_in_l,
x_out_l, y2, z_out_l,
x_out_l,-y2, z_out_l,
x_in_l, -y1, z_in_l);
/* left -> right lines */
line(x_in_l, y1, z_in_l, x_in_r, y1, z_in_r);
line(x_in_l, -y1, z_in_l, x_in_r, -y1, z_in_r);
line(x_out_l, y2, z_out_l, x_out_r, y2, z_out_r);
line(x_out_l, -y2, z_out_l, x_out_r,-y2, z_out_r);
/* right side */
multiline(5,
x_in_r, -y1, z_in_r,
x_in_r, y1, z_in_r,
x_out_r, y2, z_out_r,
x_out_r,-y2, z_out_r,
x_in_r, -y1, z_in_r);
}
/* remaining bits */
theta1 = theta_max;
theta3 = theta1-beta_in/2;
theta4 = theta1-beta_out/2;
z_in_l = radius*cos(theta1);
x_in_l = radius*sin(theta1);
z_in_r = radius*cos(theta3);
x_in_r = radius*sin(theta3);
z_out_l = out_radius*cos(theta1);
x_out_l = out_radius*sin(theta1);
z_out_r = out_radius*cos(theta4);
x_out_r = out_radius*sin(theta4);
multiline(5,
x_in_l, -y1, z_in_l,
x_in_l, y1, z_in_l,
x_out_l, y2, z_out_l,
x_out_l,-y2, z_out_l,
x_in_l, -y1, z_in_l);
line(x_in_l, y1, z_in_l, x_in_r, y1, z_in_r);
line(x_in_l, -y1, z_in_l, x_in_r, -y1, z_in_r);
line(x_out_l, y2, z_out_l, x_out_r, y2, z_out_r);
line(x_out_l, -y2, z_out_l, x_out_r,-y2, z_out_r);
multiline(5,
x_in_r, -y1, z_in_r,
x_in_r, y1, z_in_r,
x_out_r, y2, z_out_r,
x_out_r,-y2, z_out_r,
x_in_r, -y1, z_in_r);
%}
END
|