File: CavitiesIn.comp

package info (click to toggle)
mccode 3.5.19%2Bds5-2
  • links: PTS, VCS
  • area: main
  • in suites: 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 (92 lines) | stat: -rw-r--r-- 1,978 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
88
89
90
91
92
/*******************************************************************************
*         neutron ray-tracing package
*         Copyright (C) 1997-2007, All rights reserved
*         Risoe National Laboratory, Roskilde, Denmark
*         Institut Laue Langevin, Grenoble, France
*
* Component: CavitiesIn
*
* %I
* Written by: Henrich Frielinghaus
* Date: Oct 2007
* Origin: JCNS - FZ-Juelich
*
* Slit - sorting in channels
*
* %D
* This routine sorts the 'full' neutron beam (given by xw,yw)
* in xc,yc channels. These can be imagined as cavities.
* CavitiesOut sorts these channels back to normal coordinates. 
*
* Example: Slit(xw=0.05, yw=0.05, xc=4, yc=1)
*
* %P
* INPUT PARAMETERS
*
* xw: [m]  width in X-dir 
* yw: [m]  width in Y-dir 
* xc: [m]  channels in X-dir 
* yc: [m]  channels in Y-dir 
*
*
* %E
*******************************************************************************/

DEFINE COMPONENT CavitiesIn



SETTING PARAMETERS (xw=0.05, yw=0.05, xc=1, yc=1)


DECLARE
%{
  int xcc;
  int ycc;
  int mcs_xc;
  int mcs_yc;
%}

INITIALIZE
%{
  xcc = floor(fabs(xc));
  ycc = floor(fabs(yc));
  if (xcc==0) xcc=1;
  if (ycc==0) ycc=1;
  mcs_xc = 0;
  mcs_yc = 0;
%}

TRACE
%{
  PROP_Z0;
  if (x<-0.5*xw || x>0.5*xw || y<-0.5*yw || y>0.5*yw)
    ABSORB;
  else
   {
    SCATTER;
    mcs_xc = floor((x+0.5*xw)*xcc/xw);
    mcs_yc = floor((y+0.5*yw)*ycc/yw);
    x = x+(-mcs_xc-0.5+0.5*xcc)*xw/xcc;
    y = y+(-mcs_yc-0.5+0.5*ycc)*yw/ycc;
   }
%}

MCDISPLAY
%{
  
  multiline(3, -(double)xw, 0.5*yw, 0.0,
               -0.5*xw,     0.5*yw, 0.0,
               -0.5*xw, (double)yw, 0.0);
  multiline(3,  (double)xw, 0.5*yw, 0.0,
                0.5*xw,     0.5*yw, 0.0,
                0.5*xw, (double)yw, 0.0);
  multiline(3, -(double)xw,-0.5*yw, 0.0,
               -0.5*xw,    -0.5*yw, 0.0,
               -0.5*xw,-(double)yw, 0.0);
  multiline(3,  (double)xw,-0.5*yw, 0.0,
                0.5*xw,    -0.5*yw, 0.0,
                0.5*xw,-(double)yw, 0.0);
%}

END