File: Test_Jump_Iterate.instr

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 (100 lines) | stat: -rw-r--r-- 3,154 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
93
94
95
96
97
98
99
100
/*******************************************************************************
*         McStas instrument definition URL=http://mcstas.risoe.dk
*
* Instrument: Test_Jump_Iterate
*
* %Identification
* Written by: E. Farhi
* Date: March 30, 2015
* Origin:ILL
* %INSTRUMENT_SITE: Tests_grammar
*
* A test of the JUMP ITERATE keyword to describe a long curved guide in a concise way.
*
* %Description
*
* A curved guide made of only two guide elements which are iterated with  slight
* rotation in between, to describe a long curved guide.
*
* %Example: L=60 Detector: Mon_LambdaDX_Out_I=0.790318
*
* %Parameters
* L: [m]      total length of curved section
* numel: [1]  number of guide elements, each of length L/numel
* R: [m]      curvature radius
* width: [m]  width of guide element
* m: [1]      super-mirror coating wrt Ni, e.g. m=2
*
* %End
*******************************************************************************/
DEFINE INSTRUMENT Test_Jump_Iterate(L=60, numel=30, R=1500, width=0.03, m=2)

DECLARE %{
  double d=0.001; /* gap between guide elements */
%}

INITIALIZE %{
  if (numel < 2) {
    printf("Test_Jump_Iterate: The number of guide elements numel=%f is smaller than 2. Abort.\n",
      numel);
    exit(-1);
  }
%}

TRACE

COMPONENT Origin = Progress_bar()
  AT (0,0,0) ABSOLUTE

COMPONENT Source = Source_simple(
  xwidth=0.05, yheight=0.05, dist=0.5, focus_xw=width, focus_yh=0.2,
  lambda0=10, dlambda=9.5)
  AT (0,0,0) RELATIVE Origin

COMPONENT CG_In = Arm()
  AT (0,0,0.5) RELATIVE Origin

COMPONENT Mon_LambdaX_In = Monitor_nD(
  options="x, lambda limits=[.5 19.5]", bins=100,
  xwidth=.04, yheight=0.3, restore_neutron=1)
  AT      ( 0 , 0 , 0 ) RELATIVE PREVIOUS

COMPONENT Mon_LambdaDX_In = COPY(PREVIOUS)
  (options="dx limits=[-2 2], lambda limits=[.5 19.5]")
  AT      ( 0 , 0 , 0 ) RELATIVE PREVIOUS

/* the first guide element is fixed */
COMPONENT CG_1 = Guide_gravity ( m=m, alpha=1e-4,
  w1=width, h1=0.2, w2=width, h2=0.2, l=10)
  AT      ( 0 , 0 , 0 ) RELATIVE CG_In

/* the other guide elements are in a loop =================================== */

/* the component is rotated only once. When redirected after JUMP
 * the neutron is NOT rotated there. Rotation must occur at the JUMP origin. */
COMPONENT CG_2_Position = Arm( )
  AT      ( 0 , 0 , 10 ) RELATIVE PREVIOUS

COMPONENT CG_2 = COPY(CG_1)(l=L/numel)
  AT      ( 0 , 0 , d/2 ) RELATIVE PREVIOUS
  ROTATED ( 0 , (L/numel+d )/R*RAD2DEG , 0 ) RELATIVE PREVIOUS

/* it is necessary to propagate the neutron to Z=0 after the guide
 * else next iteration would have dt=z/v < 0, and ABSORB
 * we put a monitor that records all reflected events */
COMPONENT CG_2_out = COPY(Mon_LambdaDX_In)(restore_neutron=0)
  AT      ( 0 , 0 , L/numel+d/2 ) RELATIVE PREVIOUS
  JUMP CG_2_Position ITERATE numel

/* end of loop =============================================================== */

COMPONENT CG_Out = Arm()
  AT ( 0 , 0 , 0.1 ) RELATIVE CG_2_out

COMPONENT Mon_LambdaX_Out = COPY(Mon_LambdaX_In)(xwidth=1)
  AT      ( 0 , 0 , 0 ) RELATIVE CG_Out

COMPONENT Mon_LambdaDX_Out = COPY(Mon_LambdaDX_In)(xwidth=0.1)
  AT      ( 0 , 0 , 0 ) RELATIVE CG_Out

END