File: RTP_DIF.instr

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 (186 lines) | stat: -rw-r--r-- 6,508 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/*******************************************************************************
*         McStas instrument definition URL=http://www.mcstas.org
*
* Instrument: RTP_DIF
*
* %Identification
* Written by: E. Farhi and Megat Harun Al-Rashid
* Date: June 2014
* Origin: ILL/RTP
* %INSTRUMENT_SITE: TRIGA
*
* A powder diffractometer at Reactor TRIGA PUSPATI (Malaysia)
*
* %Description
*
*
* Example: mcrun RTP_DIF.instr lambda=2.36 Detector: det_I=170
*
* %Parameters
* lambda: [Angs]       Monochromator selected wavelength
* DM: [Angs]           d-spacing for the monochromator reflection
* Mono_tilt: [deg]     Tilt angle magnitude for the inner/outer mono slabs
* powder: [str]        Filename of the powder sample
* det_rotation: [deg]  Rotation of the portable detector
*
* %Link
* <a href="http://www.nuclearmalaysia.gov.my/Plant&Facilities/reactor.php">Nuclear Malaysia</a>
* %Link
* M. Sufi et al., J. AppL Cryst. (1997). 30, 884-888 [doi:10.1107/S0021889897001738]
*
* %End
*******************************************************************************/
DEFINE INSTRUMENT RTP_DIF(lambda=2.36, DM=3.355, Mono_tilt=0, string powder="Na2Ca3Al2F14.laz", det_rotation=45)

/* The DECLARE section allows us to declare variables or  small      */
/* functions in C syntax. These may be used in the whole instrument. */
USERVARS
%{
  double mono_index;
%}

/* The INITIALIZE section is executed when the simulation starts     */
/* (C code). You may use them as component parameter values.         */
INITIALIZE
%{
  printf("RTP_DIF: Monochromator take-off angle=%g [deg]\n",
    2*asin(lambda/2/DM)*RAD2DEG);
%}

/* Here comes the TRACE section, where the actual      */
/* instrument is defined as a sequence of components.  */
TRACE

/* The Arm() class component defines reference points and orientations  */
/* in 3D space. Every component instance must have a unique name. Here, */
/* Origin is used. This Arm() component is set to define the origin of  */
/* our global coordinate system (AT (0,0,0) ABSOLUTE). It may be used   */
/* for further RELATIVE reference, Other useful keywords are : ROTATED  */
/* EXTEND GROUP PREVIOUS. Also think about adding a neutron source !    */
/* Progress_bar is an Arm displaying simulation progress.               */
COMPONENT Origin = Progress_bar()
  AT (0,0,0) ABSOLUTE

/* the source is focused in wavelength to provide 5 Angs neutrons */
/* to study the Be filter, use white beam e.g. dlambda = 4.5      */
COMPONENT source = Source_gen(
    radius = .154/2,
    dist = 1.16+1.50, focus_xw = .11, focus_yh = .03, lambda0 = lambda,
    dlambda = .2, I1 = 2.79e12/4/PI, T1 = 300)
  AT (0, 0, 0) RELATIVE Origin

COMPONENT CoarseCollimator1 = Guide(w1=.154, h1=.154, l=1.16125,m=0)
  AT (0, 0, .01) RELATIVE PREVIOUS

COMPONENT CoarseCollimator2 = Guide(w1=.11, h1=.11, l=1.5,m=0)
  AT (0, 0, 1.16125+0.003) RELATIVE PREVIOUS

/* a slit that also detects wavelength */
COMPONENT lmon = Monitor_nD(
  xwidth=.11, options="slit disk, auto wavelength", bins=50)
  AT (0, 0, 1.5+0.01) RELATIVE PREVIOUS

/* Be filter ---------------------------------------------------------------- */
COMPONENT Be_Position = Arm()
  AT (0, 0, .147+.15/2) RELATIVE PREVIOUS

/* monochromator ------------------------------------------------------------ */
SPLIT COMPONENT mono_cradle = Arm()
  AT (0, 0, .145+.15/2+.176) RELATIVE Be_Position

COMPONENT mono_rotation = Arm()
  AT (0, 0, 0) RELATIVE mono_cradle
  ROTATED (0, -asin(lambda/2/DM)*RAD2DEG, 0) RELATIVE mono_cradle
  EXTEND %{
    mono_index=0;
  %}

COMPONENT mono1 = Monochromator_curved(
    width=.11, height=.03, NH=1,NV=1, RH=0, RV=0,
    DM=DM, mosaich=48, mosaicv=48,
    reflect="HOPG.rfl", transmit="HOPG.trm")
  AT (-.01, 0, 0) RELATIVE mono_rotation
  ROTATED (0, Mono_tilt, 0) RELATIVE mono_rotation
  EXTEND %{
    if (SCATTERED) mono_index=1;
  %}

COMPONENT mono2 = COPY(mono1)
  AT (0, 0, 0) RELATIVE mono_rotation
  ROTATED (0, 0, 0) RELATIVE mono_rotation
  EXTEND %{
    if (SCATTERED) mono_index=2;
  %}

COMPONENT mono3 = COPY(mono1)
  AT (0.01, 0, 0) RELATIVE mono_rotation
  ROTATED (0, -Mono_tilt, 0) RELATIVE mono_rotation
  EXTEND %{
    if (SCATTERED) mono_index=3;
  %}

COMPONENT mono_takeoff = Arm()
  AT (0, 0, 0) RELATIVE mono_cradle
  ROTATED (0, -2*asin(lambda/2/DM)*RAD2DEG, 0) RELATIVE mono_cradle

COMPONENT psd_transmit = Monitor_nD(xwidth=.12, yheight=.12, options="x y", bins=50)
  AT (0, 0, 0.25) RELATIVE mono_cradle
  GROUP mono_rt

/* primary collimator (flight path) 3.8 m ----------------------------------- */
COMPONENT psd_reflect = Monitor_nD(xwidth=.12, yheight=.12, options="x y", bins=50)
  AT (0, 0, 0.574) RELATIVE mono_takeoff
  GROUP mono_rt

/*COMPONENT lmon_reflect = Monitor_nD(
  xwidth=.02, yheight=.02, user1=mono_index,
  options="disk slit, auto wavelength, user1 limits=[0 4]", bins=50)
  AT (0, 0, 0.575) RELATIVE mono_takeoff*/

COMPONENT sample_psd = Monitor_nD(
  xwidth=.02, yheight=.02, options="disk slit, x y", bins=50)
  AT (0, 0, 0.575+.50) RELATIVE mono_takeoff

/* sample ------------------------------------------------------------------- */
/* from JAC 1997: flux at sample = 3900 n/s/cm2 */
SPLIT 100 COMPONENT sample_position = Arm()
  AT (0, 0, .575+.5+.01) RELATIVE mono_takeoff

COMPONENT container_in = PowderN(
  radius=0.01/2, yheight=0.04, thickness=-50e-6,
  reflections="V.lau", concentric=1, d_phi=50, p_transmit=.95)
  AT (0, 0, 0) RELATIVE sample_position

COMPONENT sample = PowderN(
  radius=0.01/2, yheight=0.04, reflections=powder, d_phi=atan2(0.5,1)*RAD2DEG)
  AT (0, 0, 0) RELATIVE sample_position
EXTEND %{
  if (!SCATTERED) ABSORB;
%}

COMPONENT container_out = COPY(container_in)(concentric=0)
  AT (0, 0, 0) RELATIVE sample_position

COMPONENT sample_out = Arm()
  AT (0,0,0) RELATIVE sample_position
  ROTATED (0,det_rotation,0) RELATIVE sample_position

COMPONENT det_big = Monitor_nD( options="banana theta limits=[-150 150] bins=300, y bins=64",
  radius=1, yheight=.5)
  AT (0, 0, 0) RELATIVE sample_position

/* secondary flight path (detector tube) 4m --------------------------------- */
COMPONENT det = Monitor_nD(xwidth=.5, yheight=.0254, bins=25, options="x")
  AT (0, 0, 1) RELATIVE sample_out


COMPONENT reactor = Shape(radius=.7/2, yheight=.4)
  AT (0,0,-.35) RELATIVE Origin

/* This section is executed when the simulation ends (C code). Other    */
/* optional sections are : SAVE                                         */
FINALLY
%{
%}
/* The END token marks the instrument definition end */
END