1 | function varargout = plotbeta(varargin) |
---|
2 | % PLOTBETA(RING) finds and plots bea-functions of RING |
---|
3 | % It calls FindOrbit4 and LinOpt which assume a lattice |
---|
4 | % with NO accelerating cavities and NO radiation |
---|
5 | % |
---|
6 | % PLOTBETA with no argumnts uses THERING as a default RING |
---|
7 | % |
---|
8 | % See also PLOTCOD |
---|
9 | if nargin == 0 |
---|
10 | global THERING |
---|
11 | RING = THERING; |
---|
12 | end |
---|
13 | L = length(RING); |
---|
14 | spos = findspos(RING,1:L+1); |
---|
15 | [twissdata, tunes, chrom] = twissring(RING,0,1:L+1,'chrom'); |
---|
16 | RINGLength = spos(L)+RING{L}.Length; |
---|
17 | betax = zeros(1,L); |
---|
18 | betay = zeros(1,L); |
---|
19 | for i =1:L |
---|
20 | betax(i) = twissdata(i).beta(1); |
---|
21 | betay(i) = twissdata(i).beta(2); |
---|
22 | end |
---|
23 | betax(L+1) = betax(1); |
---|
24 | betay(L+1) = betay(1); |
---|
25 | fprintf('nux=%g, nuy=%g\n',tunes(1),tunes(2)); |
---|
26 | fprintf('chromaticity xix=%g, xiy=%g\n',chrom(1),chrom(2)); |
---|
27 | |
---|
28 | figure |
---|
29 | % plot betax and betay in two subplots |
---|
30 | |
---|
31 | subplot(2,1,1) |
---|
32 | %plot(spos,betax,'.-b'); Laurent sometimes negative ! |
---|
33 | plot(spos,abs(betax),'.-b'); |
---|
34 | A= axis; |
---|
35 | A(1) = 0; |
---|
36 | A(2) = RINGLength; |
---|
37 | axis(A); |
---|
38 | xlabel('s - position [m]'); |
---|
39 | ylabel('\beta_x [m]'); |
---|
40 | grid on |
---|
41 | |
---|
42 | |
---|
43 | title('beta-functions'); |
---|
44 | |
---|
45 | subplot(2,1,2) |
---|
46 | %plot(spos,betay,'.-r'); Laurent sometimes negative ! |
---|
47 | plot(spos,abs(betay),'.-r'); |
---|
48 | A= axis; |
---|
49 | A(1) = 0; |
---|
50 | A(2) = RINGLength; |
---|
51 | axis(A); |
---|
52 | xlabel('s - position [m]'); |
---|
53 | ylabel('\beta_y [m]'); |
---|
54 | grid on |
---|
55 | addlabel(datestr(now)); |
---|
56 | |
---|
57 | if nargout > 0 |
---|
58 | varargout{1}=betax; |
---|
59 | end |
---|
60 | if nargout ==2 |
---|
61 | varargout{2}=betay; |
---|
62 | end |
---|