File: Test_Vertical_Bender.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 (114 lines) | stat: -rw-r--r-- 2,885 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
/*******************************************************************************
* Instrument: Test_Vertical_Bender
*
* %I
* Written by: Peter Willendrup
* Date: January 2023
* Origin: DTU
* %INSTRUMENT_SITE: Tests_optics
*
* Quick and dirty test instrument write-up for Vertical_Bender.
*
* %D
* Quick and dirty test instrument write-up for Vertical_Bender.
*
* %Example: Test_Vertical_Bender.instr -g curvature=10000 Detector: Pout_I=0.00134901
*
* %P
* Lmin:     [AA] Minimum wavelength from source
* Lmax:     [AA] Maximum wavelength from source
* curvature: [m] Radius of curvature of vertical bender
* length:    [m] Length of vertical bender
* xwidth:    [m] Width of vertical bender
* yheight:   [m] Height of vertical bender
* nchan:     [1] Number of channels in vertical bender
* d:         [m] Channel-spacer width
*
* %L
* <reference/HTML link>
*
* %E
*******************************************************************************/
DEFINE INSTRUMENT Test_Vertical_Bender(Lmin=9.9,Lmax=10.1,curvature=10000,length=10,xwidth=0.1,yheight=0.1,nchan=1,d=0)

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

  double calcY(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) RELATIVE ABSOLUTE

// insert components here (e.g. Insert -> Source -> ...)

COMPONENT source = Source_simple(
  yheight = 0.1,
  xwidth = 0.1,
  dist = 2,
  focus_xw = xwidth,
  focus_yh = yheight,
  lambda0 = (Lmin+Lmax)/2.0,
  dlambda = (Lmax-Lmin)/2.0) 
 AT (0, 0, 0) RELATIVE origin

COMPONENT Lin = L_monitor(
  nL = 100,
  Lmin = Lmin-0.1,
  Lmax = Lmax+0.1,
  xwidth=xwidth*1.01,
  yheight=yheight*1.01,
  filename="Lin", restore_neutron=1) 
 AT (0, 0, 0.01) RELATIVE  source

COMPONENT Pin = PSD_monitor(
  nx = 100, ny=100,
  xwidth=xwidth*1.01,
  yheight=yheight*1.01,
  filename="Pin", restore_neutron=1) 
 AT (0, 0, 0.01) RELATIVE source
  
COMPONENT VBender = Vertical_Bender(
  xwidth = xwidth,
  yheight = yheight,
  length = length,
  radius = curvature,
  nchan=nchan, d=d) 
 AT (0, 0, 2) RELATIVE  source

COMPONENT PostBender = Arm()
  AT (0,calcY(length, curvature),calcZ(length, curvature)) RELATIVE VBender
  ROTATED (-calcAlpha(length,curvature),0,0) RELATIVE VBender
  
COMPONENT Lout = COPY(Lin)(filename="Lout") 
  AT (0, 0, 0.01) RELATIVE PostBender

COMPONENT Pout = COPY(Pin)(filename="Pout") 
  AT (0, 0, 0.01) RELATIVE PostBender

  
FINALLY
%{
%}

END