File: Beamstop.comp

package info (click to toggle)
mccode 3.5.19%2Bds5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,113,256 kB
  • sloc: ansic: 40,697; python: 25,137; yacc: 8,438; sh: 5,405; javascript: 4,596; lex: 1,632; cpp: 742; perl: 296; lisp: 273; makefile: 226; fortran: 132
file content (87 lines) | stat: -rw-r--r-- 2,439 bytes parent folder | download
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
/*******************************************************************************
*
* McXtrace, x-ray tracing package
*         Copyright, All rights reserved
*         DTU Physics, Kgs. Lyngby, Denmark
*         Synchrotron SOLEIL, Saint-Aubin, France
*
* Component: Beamstop
*
* %Identification
*
* Written by: Kristian Nielsen
* Modified by Erik Bergbäck Knudsen
* Date: March 2011
* Release: McXtrace 1.0rc1
* Origin: Risoe
*
* Rectangular/circular beam stop.
*
* %Description
* A simple rectangular or circular beam stop.
* Infinitely thin and infinitely absorbing.
* The beam stop is by default rectangular. You may either
* specify the radius (circular shape), or the rectangular bounds.
*
* Example: Beamstop(xmin=-0.05, xmax=0.05, ymin=-0.05, ymax=0.05)
*          Beamstop(radius=0.1)
*
* %Parameters
*
* INPUT PARAMETERS
*
* radius: [m] Radius of the beam stop in the z=0 plane, centered at Origo
* xmin:   [m] Lower x bound
* xmax:   [m] Upper x bound
* ymin:   [m] Lower y bound
* ymax:   [m] Upper y bound
* xwidth: [m] Width of beamstop (x). Overrides xmin,xmax.
* yheight:[m] Height of beamstop (y). Overrides ymin,ymax.
*
* %END
*******************************************************************************/

DEFINE COMPONENT Beamstop

SETTING PARAMETERS (xmin=-0.05, xmax=0.05, ymin=-0.05, ymax=0.05,
  xwidth=0, yheight=0, radius=0)

/* X-ray parameters: (x,y,z,kx,ky,kz,phi,t,Ex,Ey,Ez,p) */ 

INITIALIZE
%{
  if (xwidth  > 0) { xmax = xwidth/2;  xmin = -xmax; }
  if (yheight > 0) { ymax = yheight/2; ymin = -ymax; }
  
  if (xmin == 0 && xmax == 0 && ymin == 0 & ymax == 0 && radius == 0)
  { fprintf(stderr,"Beamstop: %s: Error: give geometry\n", NAME_CURRENT_COMP); exit(-1); }
%}

TRACE
%{
    double dz,z0=z;
    ALLOW_BACKPROP;
    PROP_Z0;
    dz=z-z0;/*dz<0 means photon must travel backwards to hit beamstop*/
    if ( ((dz>=0) && ((radius!=0) && (x*x + y*y <= radius*radius)))
        || ((dz>=0) && (radius==0) && (x>xmin && x<xmax && y>ymin && y<ymax)) ){
      ABSORB;
    } else {
      RESTORE_XRAY(INDEX_CURRENT_COMP, x, y, z, kx, ky, kz, phi, t, Ex, Ey, Ez, p);
    }
%}

MCDISPLAY
%{
  
  if (radius != 0)
    circle("xy", 0, 0, 0, radius);
  else
    multiline(5, (double)xmin, (double)ymin, 0.0,
               (double)xmax, (double)ymin, 0.0,
               (double)xmax, (double)ymax, 0.0,
               (double)xmin, (double)ymax, 0.0,
               (double)xmin, (double)ymin, 0.0);
%}

END