File: templateTOF.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 (197 lines) | stat: -rw-r--r-- 6,467 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
187
188
189
190
191
192
193
194
195
196
197
/*******************************************************************************
* Instrument: templateTOF.instr
*
* %Identification
* Written by: E. Farhi
* Date: Jan 2004
* Origin: ILL
*
* %INSTRUMENT_SITE: Templates
*
* A test instrument for the S(q,w) sample, with furnace/container
*
* %Description
* This instrument is a test instrument for the S(q,w) sample.
* It produces a tof-angle and q-energy detectors and also exports the
* S(q,w) and S(q) data.
* The sample environment is a single cylinder.
* The sample container has the same shape as the sample itself, but is not
* active when using a spherical sample shape (height=0).
* detector is 2.5 m diameter, with 40 cm heigh, 1 inch diameter detector tubes.
*
* %Example: -s 1000 E0=4.94 Detector:  M_single_coh_I=5e-11
* %Example: -s 1000 E0=33 dE=1.07 dt=9.6e-6 Detector: M_single_coh_I=6.6e-10
*
* %Parameters
* E0: [meV]                   incident neutron beam energy
* dE: [meV]                   incident neutron beam energy spread
* dt: [s]                     time spread from chopper distribution
* coh: [str]                  sample coherent Sqw data file or NULL
* inc: [str]                  sample incoherent Sqw data file or NULL
* radius: [m]                 radius of sample (outer)
* thickness: [m]              thickness of sample. 0=filled
* yheight: [m]                height of sample. 0=sphere
* container: [str]            container material or NULL
* container_thickness: [m]    container thickness
* environment: [str]          sample environment material or NULL
* environment_radius: [m]     sample environment outer radius
* environment_thickness: [m]  sample environment thickness
*
* %Link
* The Isotropic_Sqw sample
* %Link
* The Samples_Isotropic_Sqw example instrument
* %End
*******************************************************************************/
DEFINE INSTRUMENT templateTOF(E0=4.94, dE=0.24, dt=6.4e-6,
  string coh="Rb_liq_coh.sqw", string inc="Rb_liq_inc.sqw", thickness=1e-4,
  yheight=0.0168,radius=0.005, string container="Nb.laz",
  container_thickness=50e-6, string environment="Al.laz",
  environment_radius=0.025, environment_thickness=2e-3, dt0=0)

DECLARE
%{
  /* monitoring sample env */
  double vi;
  char op[256];
  double _dt0;
  #pragma acc declare create(_dt0)
%}

USERVARS %{
  /* flags per detector */
  char flag_single;    /* sample single scatt */
  char flag_multi;     /* sample multi scatt */
  char flag_env;    /* sample environment scatt */
  char flag_container;  /* container scatt */
%}

INITIALIZE
%{
  vi=SE2V*sqrt(E0);
  double ki=V2K*vi;
  double t0=1.25/vi; // time from sample to det.
  double lambda=2*PI/ki;
  sprintf(op,   "energy limits=[%g %g] bins=50, theta limits=[5 175] bins=150, banana, parallel", 0.5*E0, 2*E0);

  printf("templateTOF: lambda=%g [Angs], k=%g [Angs-1], v=%g [m/s], E=%g [meV]. Time=[%g %g %g]\n",
    lambda,ki,vi, E0, t0*.75, t0, t0*1.5);
  printf("templateTOF: sample is %s, with %s%s geometry.\n",
    coh, thickness ? "hollow " : "", yheight ? "cylindrical" : "spherical");
  if (yheight && container_thickness)
    printf("templateTOF: container is %s (outer cylinder)\n", container);
  if (environment_thickness > 0)
    printf("templateTOF: external environment is %s\n", environment);
  dt0=dt;
  if (environment_thickness > 0 && radius > environment_radius-environment_thickness)
    exit(printf("templateTOF: sample radius %g is larger than sample environment %g\n",
      radius, environment_radius-environment_thickness));
  if (container_thickness > 0 && environment_thickness > 0 && yheight > 0
      && radius+container_thickness+0.0001 > environment_radius-environment_thickness)
    exit(printf("templateTOF: sample container radius %g is larger than sample environment %g\n",
      radius+container_thickness+0.0001, environment_radius-environment_thickness));

  _dt0=dt0;
  #pragma acc update device(_dt0)
%}

TRACE

COMPONENT a1 = Progress_bar(percent=5)
  AT (0,0,0) ABSOLUTE
EXTEND
%{
 flag_single=flag_multi=flag_env=flag_container=0;
%}

/* thermal source */
COMPONENT csource = Source_gen(
   radius = 0.02, focus_xw = 2*radius, focus_yh = yheight ? yheight : 2*radius, dist = 2.88,
   E0 = E0, dE = dE/2,
   T1=300.0,I1=1)
AT (0,0,0) RELATIVE a1

COMPONENT SampleIn=Arm()
AT (0,0,2.88) RELATIVE a1

/* sample position */
/* external shield */
COMPONENT Environment_in=Isotropic_Sqw(
  radius = environment_radius, yheight = 0.1, thickness=environment_thickness,
  Sqw_coh=environment, concentric=1, verbose=0
) WHEN (environment_thickness > 0)
AT (0, 0, 0) RELATIVE SampleIn
EXTEND %{
  if (SCATTERED) flag_env=1;
%}

/* sample container */
COMPONENT Container_in=Isotropic_Sqw(
  radius = radius+0.0001+container_thickness, yheight = yheight, thickness=container_thickness,
  Sqw_coh=container, concentric=1, verbose=0
  ) WHEN(yheight && container_thickness > 0)
AT (0, 0, 0) RELATIVE SampleIn
EXTEND
%{
  if (SCATTERED) flag_container=1;
%}

COMPONENT Sample_in=Isotropic_Sqw(
  radius = radius, thickness=thickness, yheight = yheight,
  Sqw_coh=coh, Sqw_inc=inc, p_interact=0.9
) AT (0, 0, 0) RELATIVE SampleIn
EXTEND
%{
  if      (SCATTERED == 1) flag_single=(type == 'c' ? 1 : 2);
  else if (SCATTERED >  1) flag_multi =(type == 'c' ? 1 : 2);
  else                     flag_multi =flag_single=0;
  t = randtriangle()*2*_dt0;  // we assume that in the real instrument, the chopper is close to sample
%}

COMPONENT Container_out=COPY(Container_in)(concentric=0)
WHEN(yheight && container_thickness)
AT (0, 0, 0) RELATIVE SampleIn
EXTEND
%{
  if (SCATTERED) flag_container=1;
%}

/* external shield */
COMPONENT Environment_out=COPY(Environment_in)(concentric=0)
WHEN (environment_thickness > 0)
AT (0, 0, 0) RELATIVE SampleIn
EXTEND %{
  if (SCATTERED) flag_env=1;
%}


COMPONENT SampleOut = Arm()
AT (0, 0, 0) RELATIVE SampleIn

/* theta - time detectors */
/* 2.54 cm det at 1.25 m from sample = 1.16 deg horz coverage */

COMPONENT M_total = Monitor_nD(
 xwidth=2.5, yheight=0.4,
 options=op)
AT (0,0,0) RELATIVE SampleOut

/* single coherent */
COMPONENT M_single_coh = COPY(M_total)
  WHEN (flag_single == 1)
AT (0,0,0) RELATIVE SampleOut

/* single incoherent */
COMPONENT M_single_inc = COPY(M_total)
  WHEN (flag_single == 2)
AT (0,0,0) RELATIVE SampleOut

COMPONENT M_multi = COPY(M_total)
  WHEN (flag_multi)
AT (0,0,0) RELATIVE SampleOut

COMPONENT M_env_container = COPY(M_total)
  WHEN (flag_env || flag_container)
AT (0,0,0) RELATIVE SampleOut

END