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
|
/************************************************************************
*
* McStas, X-ray tracing package
* Copyright (C) 2015, All rights reserved
* DTU Physics, Kgs. Lyngby, Denmark
*
* Component: Semi_miror
*
* %I
*
* Written by: Erik B Knudsen
* Date:
* Version: Revision: 1.0
* Release: McXtrace manual
* Origin: DTU Physics
*
* Simple flat semi-reflecting mirror with constant reflectivity
*
* %D
* A perfectly flat plane mirror example, intended as an example of a
* very simple component.
* It also illustrates the concept of MC-choice for governing statstics.
*
* %P
* Input parameters:
* xwidth: (m) Width of the mirror.
* yheight: (m) Height of the mirror.
* reflectivity: ( ) Constant scalar reflectivity of mirror.
* frac_reflect: ( ) Fraction of statistics for reflecting branch.
* %E
************************************************************************/
DEFINE COMPONENT Semi_mirror
DEFINITION PARAMETERS ()
SETTING PARAMETERS (xwidth, yheight, reflectivity, frac_reflect)
SHARE
%{
%}
INITIALIZE
%{
%}
TRACE
%{
PROP_Z0;
if( x>-xwidth/2.0 && x<xwidth/2.0 && y>-yheight/2.0 && y<yheight/2.0){
double r;
r=rand01();
SCATTER;
if(r<frac_reflect){
vz=-vz;
p*=reflectivity/frac_reflect;
internal_color=1;
}else{
internal_color=0;
p*=(1-reflectivity)/(1-frac_reflect);
}
}else{
RESTORE_XRAY(INDEX_CURRENT_COMP,x,y,z,kx,ky,kz,phi,t,Ex,Ey,Ez,p);
}
%}
MCDISPLAY
%{
multiline(5, -xwidth/2.0, -yheight/2.0, 0.0,
xwidth/2.0, -yheight/2.0, 0.0,
xwidth/2.0, yheight/2.0, 0.0,
-xwidth/2.0, yheight/2.0, 0.0,
-xwidth/2.0, -yheight/2.0, 0.0);
%}
END
|