1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
---|
2 | "http://www.w3.org/TR/REC-html40/loose.dtd"> |
---|
3 | <html> |
---|
4 | <head> |
---|
5 | <title>Description of thinmpoleraddiffm</title> |
---|
6 | <meta name="keywords" content="thinmpoleraddiffm"> |
---|
7 | <meta name="description" content="FINDTHINMPOLERADDIFFM"> |
---|
8 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
9 | <meta name="generator" content="m2html © 2003 Guillaume Flandin"> |
---|
10 | <meta name="robots" content="index, follow"> |
---|
11 | <link type="text/css" rel="stylesheet" href="../../m2html.css"> |
---|
12 | </head> |
---|
13 | <body> |
---|
14 | <a name="_top"></a> |
---|
15 | <div><a href="../../index.html">Home</a> > <a href="../index.html">at</a> > <a href="index.html">atphysics</a> > thinmpoleraddiffm.m</div> |
---|
16 | |
---|
17 | <!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png"> Master index</a></td> |
---|
18 | <td align="right"><a href="index.html">Index for at/atphysics <img alt=">" border="0" src="../../right.png"></a></td></tr></table>--> |
---|
19 | |
---|
20 | <h1>thinmpoleraddiffm |
---|
21 | </h1> |
---|
22 | |
---|
23 | <h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
24 | <div class="box"><strong>FINDTHINMPOLERADDIFFM</strong></div> |
---|
25 | |
---|
26 | <h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
27 | <div class="box"><strong>function [B66, M, rout] = findthinmpoleraddiffm(rin, PolynomA, PolynomB, L, irho, E0, max_order) </strong></div> |
---|
28 | |
---|
29 | <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
30 | <div class="fragment"><pre class="comment">FINDTHINMPOLERADDIFFM</pre></div> |
---|
31 | |
---|
32 | <!-- crossreference --> |
---|
33 | <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
34 | This function calls: |
---|
35 | <ul style="list-style-image:url(../../matlabicon.gif)"> |
---|
36 | </ul> |
---|
37 | This function is called by: |
---|
38 | <ul style="list-style-image:url(../../matlabicon.gif)"> |
---|
39 | </ul> |
---|
40 | <!-- crossreference --> |
---|
41 | |
---|
42 | <h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
43 | <ul style="list-style-image:url(../../matlabicon.gif)"> |
---|
44 | <li><a href="#_sub1" class="code">function b2 = B2perp(B, irho, rin)</a></li></ul> |
---|
45 | <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
46 | <div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [B66, M, rout] = findthinmpoleraddiffm(rin, PolynomA, PolynomB, L, irho, E0, max_order)</a> |
---|
47 | 0002 <span class="comment">%FINDTHINMPOLERADDIFFM</span> |
---|
48 | 0003 |
---|
49 | 0004 <span class="comment">% Physical constants used in calculations</span> |
---|
50 | 0005 <span class="keyword">persistent</span> TWOPI CGAMMA M0C2 LAMBDABAR CER CU |
---|
51 | 0006 <span class="keyword">if</span> isempty(TWOPI) <span class="comment">%Initialize constansts on the first call</span> |
---|
52 | 0007 TWOPI = 2*pi; |
---|
53 | 0008 CGAMMA = 8.846056192e-05; <span class="comment">% [m]/[GeV^3] Ref[1] (4.1)</span> |
---|
54 | 0009 M0C2 = 5.10999060e5; <span class="comment">% Electron rest mass [eV]</span> |
---|
55 | 0010 LAMBDABAR = 3.86159323e-13; <span class="comment">% Compton wavelength/2pi [m]</span> |
---|
56 | 0011 CER = 2.81794092e-15; <span class="comment">% Classical electron radius [m]</span> |
---|
57 | 0012 CU = 1.323094366892892; <span class="comment">% 55/(24*sqrt(3))</span> |
---|
58 | 0013 <span class="keyword">end</span> |
---|
59 | 0014 |
---|
60 | 0015 |
---|
61 | 0016 <span class="comment">% Calculate field from polynomial coefficients</span> |
---|
62 | 0017 P1 = i*PolynomA(1:max_order+1)+PolynomB(1:max_order+1); |
---|
63 | 0018 Z1 = cumprod([1, (rin(1)+i*rin(3))*ones(1,max_order)]); |
---|
64 | 0019 S1 = sum(P1.*Z1); |
---|
65 | 0020 Bx = real(S1); |
---|
66 | 0021 By = imag(S1); |
---|
67 | 0022 |
---|
68 | 0023 B2P = <a href="#_sub1" class="code" title="subfunction b2 = B2perp(B, irho, rin)">B2perp</a>([Bx; By+irho; 0], irho, rin); |
---|
69 | 0024 B3P = B2P^(3/2); |
---|
70 | 0025 p_norm = 1/(1+rin(5)); |
---|
71 | 0026 p_norm2 = p_norm^2; |
---|
72 | 0027 |
---|
73 | 0028 CRAD = CGAMMA*E0^3/(TWOPI*1e27); |
---|
74 | 0029 BB = CU * CER * LAMBDABAR * (E0/M0C2)^5 * L * B3P * (1+rin(5))^4*<span class="keyword">...</span> |
---|
75 | 0030 (1+rin(1)*irho + (rin(2)^2+rin(4)^2)*p_norm2/2); |
---|
76 | 0031 |
---|
77 | 0032 <span class="comment">% Propagate particle</span> |
---|
78 | 0033 rout = rin; |
---|
79 | 0034 |
---|
80 | 0035 <span class="comment">% Loss of energy (dp/p) due to radiation</span> |
---|
81 | 0036 rout(5) = rin(5) - CRAD*(1+rin(5))^2*B2P*<span class="keyword">...</span> |
---|
82 | 0037 (1+rin(1)*irho + (rin(1)^2+rin(3)^2)*p_norm2/2)*L; |
---|
83 | 0038 |
---|
84 | 0039 <span class="comment">% Change in transverse momentum due to radiation</span> |
---|
85 | 0040 <span class="comment">% Angle does not change but dp/p changes due to radiation</span> |
---|
86 | 0041 <span class="comment">% and therefore transverse canonical momentum changes</span> |
---|
87 | 0042 <span class="comment">% px = x'*(1+dp/p)</span> |
---|
88 | 0043 <span class="comment">% py = y'*(1+dp/p)</span> |
---|
89 | 0044 rout([2 4]) = rin([2 4])*(1+rout(5))/(1+rin(5)); |
---|
90 | 0045 |
---|
91 | 0046 <span class="comment">% transverse kick due to magnetic field</span> |
---|
92 | 0047 rout(2) = rout(2) - L*(Bx-(rin(5)-rin(1)*irho)*irho); |
---|
93 | 0048 rout(4) = rout(4) + L*By; |
---|
94 | 0049 |
---|
95 | 0050 <span class="comment">% pathlength</span> |
---|
96 | 0051 rout(6) = rout(6) + L*irho*rin(1); |
---|
97 | 0052 |
---|
98 | 0053 |
---|
99 | 0054 <span class="comment">% Calculate transfer matrix at rin</span> |
---|
100 | 0055 P2 = i*PolynomA(2:max_order+1)+PolynomB(2:max_order+1); |
---|
101 | 0056 Z2 = cumprod([1, (rin(1)+i*rin(3))*ones(1,max_order-1)]); |
---|
102 | 0057 S2 = sum(P2.*(1:max_order).*Z2); |
---|
103 | 0058 |
---|
104 | 0059 M = eye(6); |
---|
105 | 0060 M(2,1) = -L*real(S2); |
---|
106 | 0061 M(2,3) = L*imag(S2); |
---|
107 | 0062 M(4,1) = L*imag(S2); |
---|
108 | 0063 M(4,3) = L*real(S2); |
---|
109 | 0064 M(2,5) = L*irho; |
---|
110 | 0065 M(2,1) = M(2,1) - L*irho*irho; |
---|
111 | 0066 M(6,1) = L*irho; |
---|
112 | 0067 |
---|
113 | 0068 |
---|
114 | 0069 <span class="comment">% Calculate Ohmi's diffusion matrix of a thin multipole element</span> |
---|
115 | 0070 <span class="comment">% For elements with straight coordinate system irho = 0</span> |
---|
116 | 0071 <span class="comment">% For curved elements the B polynomial (PolynomB in MATLAB)</span> |
---|
117 | 0072 <span class="comment">% MUST NOT include the guide field By0 = irho * E0 /(c*e)</span> |
---|
118 | 0073 |
---|
119 | 0074 B66 = zeros(6); |
---|
120 | 0075 B66(2,2) = BB*rin(2)^2*p_norm2; |
---|
121 | 0076 B66(2,4) = BB*rin(2)*rin(4)*p_norm2; |
---|
122 | 0077 B66(4,2) = B66(2,4); |
---|
123 | 0078 B66(4,4) = BB*rin(4)^2*p_norm2; |
---|
124 | 0079 B66(5,2) = BB*rin(2)*p_norm; |
---|
125 | 0080 B66(2,5) = B66(5,2); |
---|
126 | 0081 B66(5,4) = BB*rin(4)*p_norm; |
---|
127 | 0082 B66(4,5) = B66(5,4); |
---|
128 | 0083 B66(5,5) = BB; |
---|
129 | 0084 |
---|
130 | 0085 <a name="_sub1" href="#_subfunctions" class="code">function b2 = B2perp(B, irho, rin)</a> |
---|
131 | 0086 <span class="comment">% Calculates sqr(|e x B|) , where 'e' is a unit vector in the direction of</span> |
---|
132 | 0087 <span class="comment">% velocity. Components of the velocity vector:</span> |
---|
133 | 0088 <span class="comment">% ex = xpr;</span> |
---|
134 | 0089 <span class="comment">% ey = ypr;</span> |
---|
135 | 0090 <span class="comment">% ez = (1+x*irho);</span> |
---|
136 | 0091 |
---|
137 | 0092 E = [rin(2)/(1+rin(5));rin(4)/(1+rin(5));1+rin(1)*irho]; |
---|
138 | 0093 b2 = sum(cross(E/norm(E),B).^2); |
---|
139 | 0094</pre></div> |
---|
140 | <hr><address>Generated on Mon 21-May-2007 15:26:45 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address> |
---|
141 | </body> |
---|
142 | </html> |
---|