File: Test_Guides_Curved.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 (131 lines) | stat: -rw-r--r-- 4,320 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
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
/*******************************************************************************
*         McStas instrument definition URL=http://www.mcstas.org
*
* Instrument: Test_Guides_Curved
*
* %Identification
* Written by: P. Willendrup, DTU Fysik
* Date: Nov 1st, 2013
* Origin: DTU Fysik
* %INSTRUMENT_SITE: Tests_optics
*
* Cross comparison of curved Guide components
*
* %Description
* Cross comparison of curved Guide components, using McStas and
* contributed components. It shows that all implementations are to good approximation equivalent.
*
* %Example: Guide=1 Detector: Monitor2_xy1_I=0.00224746
* %Example: Guide=2 Detector: Monitor2_xy2_I=0.00177338
* %Example: Guide=3 Detector: Monitor2_xy3_I=0.00186028
* %Example: Guide=4 Detector: Monitor2_xy4_I=0.00168562
*
* %Parameters
* Guide: [1]      Choice of Guide component to test, with 1=Guide_curved 2=Elliptic_guide_gravity, 3=Pol_bender, 4=Bender.
* curvature: [m]  Radius of curvature
* length: [m]     Length of the guide
* %End
*******************************************************************************/
DEFINE INSTRUMENT Test_Guides_Curved(int Guide=1, curvature=1000, length=100)

DECLARE
%{
  double Circumf, Arcangle, angle, ex, ey, ez, rx, ry, rz, lz;

  double calcAlpha(double length, double radius) {
    // calculate angle of arm after curved guide
    return RAD2DEG * length/radius;
  }

  double calcX(double length, double radius) {
    // calculate position and angle of arm after curved guide
    double alpha = DEG2RAD * calcAlpha(length, radius);
    return radius*(1.0-cos(alpha));
  }

  double calcZ(double length, double radius) {
    // calculate position and angle of arm after curved guide
    double alpha = DEG2RAD * calcAlpha(length, radius);
    return radius*sin(alpha);
  }
%}

INITIALIZE
%{
%}

TRACE

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

COMPONENT Source = Source_gen(
   focus_xw = 0.05, focus_yh = 0.05, lambda0 = 3.39, dlambda = 0.3,
   yheight = 0.05, xwidth = 0.05)
  AT (0, 0, 0) RELATIVE PREVIOUS
EXTEND %{
	t = randtriangle()*1e-3;	/* 1 ms triangle time window */
%}

COMPONENT Monitor1_xt = Monitor_nD(
    options = "x y", xwidth = 0.05, yheight = 0.05)
  AT (0, 0, 1) RELATIVE PREVIOUS

 COMPONENT Guide_Position = Arm( )
  AT (0, 0, 0.1) RELATIVE PREVIOUS

COMPONENT GuideR = Guide_curved(
    w1 = 0.05, h1 = 0.05, l = length, curvature=curvature)
  WHEN (Guide == 1)
  AT (0, 0, 0) RELATIVE Guide_Position


// Current implementation seems to have the opposite sign in the curvature than Guide_curved.
// Does not bend the guide but bends the neutron, via adding centripetal force in gravity
COMPONENT GuideEl = Elliptic_guide_gravity(
  xwidth = 0.05, yheight=0.05, l = length,
  linxw=1e6, linyh=1e6, loutxw=1e6, loutyh=1e6, dimensionsAt="mid", curvature=-curvature)
  WHEN (Guide == 2)
  AT (0, 0, 0) RELATIVE Guide_Position

// For visibility in mcdisplay this component bends the other way
COMPONENT GuideB = Pol_bender(xwidth = 0.05, yheight = 0.05, length = length, radius=-curvature,
	     nslit=1)
WHEN (Guide == 3)  AT (0, 0, 0) RELATIVE Guide_Position

// Does not bend the guide but bends the neutron
COMPONENT GuideB2 = Bender(w = 0.05, h = 0.05, r=curvature, Win=length/curvature,k=1)
WHEN (Guide == 4)  AT (0, 0, 0) RELATIVE Guide_Position

COMPONENT RArm=Arm()
  AT (calcX(length, curvature),0,calcZ(length, curvature)) RELATIVE GuideR
  ROTATED (0, calcAlpha(length,curvature),0) RELATIVE GuideR

COMPONENT Monitor2_xy1 = Monitor_nD(
    options = "x y", xwidth = 0.07, yheight = 0.07)
WHEN (Guide == 1)
 AT (0, 0, 2) RELATIVE RArm


COMPONENT Monitor2_xy2 = Monitor_nD(
    options = "x y", xwidth = 0.07, yheight = 0.07)
  WHEN (Guide == 2)
  AT (0, 0, length+2) RELATIVE Guide_Position

COMPONENT BArm=Arm()
  AT (calcX(length, -curvature),0,calcZ(length, curvature)) RELATIVE GuideR
  ROTATED (0, calcAlpha(length,-curvature),0) RELATIVE GuideR

COMPONENT Monitor2_xy3 = Monitor_nD(
    options = "x y", xwidth = 0.07, yheight = 0.07)
WHEN (Guide == 3)
 AT (0, 0, 2) RELATIVE BArm

COMPONENT Monitor2_xy4 = Monitor_nD(
    options = "x y", xwidth = 0.07, yheight = 0.07)
  WHEN (Guide == 4)
  AT (0, 0, length+2) RELATIVE Guide_Position

COMPONENT dummy = PSD_monitor_4PI(filename="junk", radius=length+1.1, restore_neutron=1)
  WHEN (1==0 ) AT (0,0,0) ABSOLUTE
END