File: SimplePowderDiffractometer.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 (165 lines) | stat: -rw-r--r-- 5,518 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
/*******************************************************************************
*         McStas instrument definition URL=http://www.mcstas.org
*
* Instrument: test (rename also the example and DEFINE lines below)
*
* %Identification
* Written by: Linda Udby <udby@nbi.dk>
* Date: 26/02/2015
* Origin: Your institution
* Release: McStas CVS-080208
* Version: 0.2
* %INSTRUMENT_SITE: e-learning
*
* Instrument short description
* A simple monochromatic powder diffractometer with variable bandwidth, aluminium sample container with powder sample (default nickel powder).
*
* %Description
* A simple monochromatic powder diffractometer with variable bandwidth, collimation, aluminium sample container and powder sample.
* The sample container (Al can) is optional.
* A banana detector records scattering agles [20,100]
*
* Example: mcrun SimplePowderDIffractometer.instr coll=40, container=1
*
* %Parameters
* lambda0: [AA]  The mean value of  incoming wavelegths (Gaussian distribution)
* dlambda: [AA] Gaussian sigma of incoming wavelength distribution
* coll: [arcmin] horizontal collimation 
* container: [1] When >0 a 2mm thick Al pressed powder can is inserted around the sample
* sample: [1] 0=Ni, 1=Fe, 2=SiO2, 3=C_diamond, otherwise empty
* %Link
* http://vnt.nmi3.org/mcstas-web
*
* %End
*******************************************************************************/

/* Change name of instrument and input parameters with default values */
DEFINE INSTRUMENT SimplePowderDIffractometer(lambda0=1, dlambda=0.005, coll=120, int container=0, int sample=0)

/* The DECLARE section allows us to declare variables or  small      */
/* functions in C syntax. These may be used in the whole instrument. */
DECLARE
%{
double L1=3;
double LC=1;
double sample_radius=0.005;
double sample_height=0.05;
double al_thickness=0.002;
char samplestring[128];
%}

/* The INITIALIZE section is executed when the simulation starts     */
/* (C code). You may use them as component parameter values.         */
INITIALIZE
%{

if (sample==0) {
  sprintf(samplestring,"Ni.laz");
} else if (sample==1) {
  sprintf(samplestring,"Fe.laz");
} else if (sample==2) {
  sprintf(samplestring,"SiO2_quartza.laz");
} else if (sample==3) {
  sprintf(samplestring,"C_diamond.laz");
} else {
  sprintf(samplestring,"NULL");
}


%}

/* 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


COMPONENT source = Source_simple(
    radius = 0.1, dist=L1, focus_xw = 2*sample_radius+2*al_thickness,
    focus_yh = sample_height+2*al_thickness, lambda0 = lambda0,
    dlambda = dlambda, flux = 5e10, gauss = 1, dist=L1)
  AT (0, 0, 0) RELATIVE Origin


/*COMPONENT PSD_precoll =  PSD_monitor(
    xwidth=0.15, yheight=0.15,
    nx=80, ny=80, filename="PSD_precoll.dat", restore_neutron=1)
  AT ( 0, 0, LC-0.04) RELATIVE source 
*/

COMPONENT collimator = Collimator_linear(
    xwidth = 0.2, yheight = 0.2, length = 0.2, divergence = coll)
  AT (0, 0, LC) RELATIVE source 

//The following two monitors are sample size
/*COMPONENT PSD_sample =  PSD_monitor(
    xwidth=2*sample_radius+2*al_thickness, yheight=sample_height+2*al_thickness,
    nx=80, ny=80, filename="PSD_sample.dat", restore_neutron=1)
  AT ( 0, 0, L1-0.0101) RELATIVE source

COMPONENT lambda_sample =  L_monitor(
    xwidth=2*sample_radius+2*al_thickness, yheight=sample_height+2*al_thickness,
    Lmin=lambda0-5*dlambda, Lmax=lambda0+5*dlambda, nL=128, filename="L_sample.dat")
  AT ( 0, 0, L1-0.01) RELATIVE source 
*/

COMPONENT entry_side= PowderN(
   reflections="Al.laz",barns=1, radius=sample_radius+al_thickness, thickness=al_thickness, yheight=sample_height +2*al_thickness,d_phi=2, p_transmit=0.8,concentric=1)
WHEN (container >0)
AT (0, 0, L1) RELATIVE source


COMPONENT sample = PowderN(
    reflections = samplestring, radius = sample_radius, yheight=sample_height,
    pack = 1, sigma_abs = -1, sigma_inc = -1, p_inc=0,
    delta_d_d = 0, d_phi = 2,barns=1,DW=0, p_transmit=0.1)
  AT (0, 0, L1) RELATIVE source


COMPONENT exit_side= COPY(entry_side)(concentric=0)
WHEN (container >0)
AT  (0, 0, L1) RELATIVE source 

/*COMPONENT PSD_4pi = PSD_monitor_4PI(
    filename = "PSD_4pi.dat", radius = 0.4, restore_neutron=1)
  AT (0, 0, 0) RELATIVE sample 
 */

COMPONENT Detector = Monitor_nD(
    xwidth=L1,yheight=0.20,
    options="banana, theta" , filename="detector.dat",min=20, max=100,bins=400,restore_neutron=1)
  // options="banana, theta bins=800 limits [20 100] , file=detector.dat") // works too
   // options="banana, theta longitude bins=800  limits [20 80] auto y, file=detector.dat ")// does not work
  AT (0,0,0) RELATIVE sample
  ROTATED (0,0,180) RELATIVE sample



/* 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