source: MML/trunk/mml/at/getenveloppe.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 11 years ago

Initial import--MML version from SOLEIL@2013

File size: 1.8 KB
Line 
1%%
2solamor2
3BENDINDEX = findcells(THERING,'PassMethod','BndMPoleSymplectic4RadPass');
4QUADSEXTINDEX = findcells(THERING,'PassMethod','StrMPoleSymplectic4RadPass');
5RADELEMINDEX = sort([BENDINDEX QUADSEXTINDEX]);
6
7%% Set tilt error
8% Find  indexes of elements in different families
9Q1I = findcells(THERING,'FamName','Q1');
10% Select some of them to randomly tilt
11TILTI = Q1I;
12
13% NOTE: How to introduce random coupling and misalignment errors:
14% s-rotations(tilts) and transverse displacements (shifts)
15
16% 1.generate random  rotations
17tilterr = 0.2*pi/180;                   % RMS tilt error [radians]
18qftilts = tilterr*randn(1,length(TILTI));
19
20% 2. rotate elements
21settilt(TILTI,qftilts);
22
23%%
24[ENV, DP, DL] = ohmienvelope(THERING,RADELEMINDEX, 1:length(THERING)+1)
25
26%%
27sigmas = cat(2,ENV.Sigma);
28tilt = cat(2,ENV.Tilt);
29spos = findspos(THERING,1:length(THERING)+1);
30
31figure(1)
32plot(spos,tilt*180/pi,'.-')
33set(gca,'XLim',[0 spos(end)])
34title('Rotation angle of the beam ellipse [degrees]');
35xlabel('s - position [m]');
36grid on
37
38figure(2)
39[A, H1, H2] = plotyy(spos,sigmas(1,:)*1e6,spos,sigmas(2,:)*1e6);
40
41set([H1 H2],'Marker','.')
42set(A,'XLim',[0 spos(end)])
43title('Principal axis of the beam ellipse [m]');
44xlabel('s - position [m]');
45grid on
46ylabel('Sigma (um)')
47%%
48[TD, tune] = twissring(THERING,0,1:length(THERING)+1,'chroma');
49ETA        = cat(2,TD.Dispersion);
50BETA       = cat(1,TD.beta)';
51
52emittancex = (power(sigmas(1,:),2)-power(DP*ETA(1,:),2))./BETA(1,:);
53emittancez = (power(sigmas(2,:),2)-power(DP*ETA(3,:),2))./BETA(2,:);
54%%
55figure
56[A, H1, H2] = plotyy(spos,emittancex,spos,emittancez);
57grid on
58set(A,'XLim',[0 spos(end)])
59
60%% couplying end emittance at lattice entrance
61fprintf('Ex = %4.2g m.rad \n',emittancex(1));
62fprintf('Ez = %4.2g m.rad \n',emittancez(2));
63fprintf('Coupling = %4.2g %% \n',emittancez(1)/emittancex(2)*100)
Note: See TracBrowser for help on using the repository browser.