File: Test_Magnetic_Constant.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 (168 lines) | stat: -rw-r--r-- 6,235 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
/***************************************************************************
*         McStas instrument definition URL=http://www.mcstas.org
*
* Instrument: Test_Magnetic_Constant
*
* %Identification
* Written by: Peter Christiansen and Peter Willendrup
* Date: August 2006
* Origin: RISOE
* %INSTRUMENT_SITE: Tests_polarization
*
* This instrument demonstrates how to use the Pol_Bfield
* component with a constant field.
*
* %Description
* This instrument demonstrates how to use the component
* Pol_Bfield with a constant field to make a Mezei Spin flipper.
*
* This instrument matches the example: Test_Pol_MSF (under tests)
* made with the old component: Pol_constBfield
*
* %Example: ROT_ANGLE=180 Detector: pollambdaMonitor2z_I=0.0768972
* %Example: ROT_ANGLE=180 ONOFF=1 Detector: pollambdaMonitor2z_I=0.0768972
* %Example: ROT_ANGLE=180 ONOFF=2 Detector: pollambdaMonitor2z_I=0.0768972
* %Example: ROT_ANGLE=180 ONOFF=3 Detector: pollambdaMonitor2z_I=0.0768972
*
* %Parameters
* ROT_ANGLE: [deg]  Angle that the spin of a 5AA neutron rotates in the 0.2 m magnet
* ONOFF: [ ]        Should we use a window description (with a _stop comp) to turn the field on and off.
* %Link
*
* %End
****************************************************************************/
DEFINE INSTRUMENT Test_Magnetic_Constant(ROT_ANGLE=180, ONOFF=0)

/* The DECLARE section allows us to declare variables or  small      */
/* functions in C syntax. These may be used in the whole instrument. */
DECLARE
%{
  const double LAMBDA       = 5.0; // AA
  const double DLAMBDA      = 4.9; // AA
  const double MAGNETLENGTH = 0.2; // m
  double BVALUE;
%}

/* The INITIALIZE section is executed when the simulation starts     */
/* (C code). You may use them as component parameter values.         */
INITIALIZE
%{
  BVALUE = GetConstantField(MAGNETLENGTH, LAMBDA, ROT_ANGLE);
  printf("By should be %f T, to be able to rotate a %f AA neutron\n"
	 " %f degrees over a length of %f m\n",
	 BVALUE, LAMBDA, ROT_ANGLE, MAGNETLENGTH);
%}

/* 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.01, dist = 1.0, focus_xw = 0.05, focus_yh = 0.05,
	      lambda0 = LAMBDA, dlambda = DLAMBDA, flux = 1)
     AT (0, 0, 0) RELATIVE Origin

COMPONENT polSetter =
Set_pol(px=1)
     AT (0, 0, 0.5) RELATIVE Origin

COMPONENT pollambdaMonitor1x =
PolLambda_monitor(xwidth=0.1, yheight=0.1,
		  nL=100, Lmin = 0.0, Lmax = 10.0, npol=21,
		  mx=1, my=0, mz=0, filename="pollambdaMon1x.data")
     AT (0, 0, 0.7) RELATIVE Origin

COMPONENT pollambdaMonitor1y =
PolLambda_monitor(xwidth=0.1, yheight=0.1,
		  nL=100, Lmin = 0.0, Lmax = 10.0, npol=21,
		  mx=0, my=1, mz=0, filename="pollambdaMon1y.data")
     AT (0, 0, 0.75) RELATIVE Origin

COMPONENT pollambdaMonitor1z =
PolLambda_monitor(xwidth=0.1, yheight=0.1,
		  nL=100, Lmin = 0.0, Lmax = 10.0, npol=21,
		  mx=0, my=0, mz=1, filename="pollambdaMon1z.data")
     AT (0, 0, 0.8) RELATIVE Origin

COMPONENT armMSF = Arm()
     AT (0,0,1) RELATIVE Origin

// The By field is set to rotate the spin 180 degrees for neutrons of wavelenth
// 5 AA

COMPONENT msf =
  Pol_Bfield(field_type=1, xwidth=0.08, yheight=0.08, zdepth=MAGNETLENGTH, Bx=0, By=BVALUE, Bz=0, concentric = 0)
WHEN (!ONOFF) AT (0, 0, 0) RELATIVE armMSF

COMPONENT msf_onoff =
  Pol_Bfield(field_type=1, xwidth=0.08, yheight=0.08, Bx=0, By=BVALUE, Bz=0, concentric = 1)
WHEN (ONOFF==1) AT (0, 0, 0) RELATIVE armMSF

COMPONENT msf_onoff_stop = Pol_Bfield_stop( xwidth=0.08, yheight=0.08)
WHEN (ONOFF==1) AT (0, 0, MAGNETLENGTH) RELATIVE armMSF

COMPONENT msfieldbox =
  Pol_FieldBox(xwidth=0.08, yheight=0.08, zdepth=MAGNETLENGTH, Bx=0, By=BVALUE, Bz=0)
WHEN (ONOFF==2) AT (0, 0, 0) RELATIVE armMSF

COMPONENT msf_onoff2 =
  Pol_Bfield(field_type=1, xwidth=0.18, yheight=0.18, zdepth=MAGNETLENGTH, Bx=0, By=BVALUE, Bz=0, concentric = 1)
WHEN (ONOFF==3) AT (0, 0, MAGNETLENGTH/2.0) RELATIVE armMSF

COMPONENT msf_onoff2_stop = Pol_Bfield_stop( xwidth=0.18, yheight=0.18, zdepth=MAGNETLENGTH)
WHEN (ONOFF==3) AT (0, 0, MAGNETLENGTH/2.0) RELATIVE armMSF
 
COMPONENT pollambdaMonitor2x =
PolLambda_monitor(xwidth=0.1, yheight=0.1,
		  nL=100, Lmin = 0.0, Lmax = 10.0, npol=21,
		  mx=1, my=0, mz=0, filename="pollambdaMon2x.data")
     AT (0, 0, 0.3) RELATIVE armMSF

COMPONENT pollambdaMonitor2y =
PolLambda_monitor(xwidth=0.1, yheight=0.1,
		  nL=100, Lmin = 0.0, Lmax = 10.0, npol=21,
		  mx=0, my=1, mz=0, filename="pollambdaMon2y.data")
     AT (0, 0, 0.3) RELATIVE armMSF

COMPONENT pollambdaMonitor2z =
PolLambda_monitor(xwidth=0.1, yheight=0.1,
		  nL=100, Lmin = 0.0, Lmax = 10.0, npol=21,
		  mx=0, my=0, mz=1, filename="pollambdaMon2z.data")
     AT (0, 0, 0.3) RELATIVE armMSF

COMPONENT mpollambdaMonitor2x =
MeanPolLambda_monitor(xwidth=0.1, yheight=0.1,
		      nL=100, Lmin = 0.0, Lmax = 10.0,
		      mx=1, my=0, mz=0, filename="mpollambdaMon2x.data")
     AT (0, 0, 0.3) RELATIVE armMSF

COMPONENT mpollambdaMonitor2y =
MeanPolLambda_monitor(xwidth=0.1, yheight=0.1,
		      nL=100, Lmin = 0.0, Lmax = 10.0,
		      mx=0, my=1, mz=0, filename="mpollambdaMon2y.data")
     AT (0, 0, 0.3) RELATIVE armMSF

COMPONENT mpollambdaMonitor2z =
MeanPolLambda_monitor(xwidth=0.1, yheight=0.1,
		      nL=100, Lmin = 0.0, Lmax = 10.0,
		      mx=0, my=0, mz=1, filename="mpollambdaMon2z.data")
     AT (0, 0, 0.3) RELATIVE armMSF


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