Home > atdemos > opticsAndBeamSizes > ohmienvelopedemo.m

ohmienvelopedemo

PURPOSE ^

OHMIENVELOPEDEMO illustrates the use of OHMIENVELOPE function

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

OHMIENVELOPEDEMO illustrates the use of OHMIENVELOPE function

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %OHMIENVELOPEDEMO illustrates the use of OHMIENVELOPE function
0002 clear all
0003 spear2rad
0004 for i=1:272 THERING{i}.Energy = 3e9; end
0005 
0006 BENDINDEX = findcells(THERING,'PassMethod','BndMPoleSymplectic4RadPass');
0007 QUADSEXTINDEX = findcells(THERING,'PassMethod','StrMPoleSymplectic4RadPass');
0008 
0009 RADELEMINDEX = sort([BENDINDEX QUADSEXTINDEX]);
0010 
0011 
0012 % Find  indexes of elements in different families
0013 QFI = findcells(THERING,'FamName','QF');
0014 % Select some of them to randomly tilt
0015 TILTI = QFI([3:7 10:12]);
0016 
0017 % NOTE: How to introduce random coupling and misalignment errors:
0018 % s-rotations(tilts) and transverse displacements (shifts)
0019 
0020 % 1.generate random  rotations
0021 tilterr = 0.1*pi/180;            % RMS tilt error [radians]
0022 qftilts = tilterr*randn(1,length(TILTI));
0023 
0024 % 2. rotate elements
0025 settilt(TILTI,qftilts);
0026 
0027 [ENV, DP, DL] = ohmienvelope(THERING(:),RADELEMINDEX, 1:length(THERING)+1);
0028 sigmas = cat(2,ENV.Sigma);
0029 tilt = cat(2,ENV.Tilt);
0030 spos = findspos(THERING,1:length(THERING)+1);
0031 
0032 figure(1)
0033 plot(spos,tilt*180/pi,'.-')
0034 set(gca,'XLim',[0 spos(end)])
0035 title('Rotation angle of the beam ellipse [degrees]');
0036 xlabel('s - position [m]');
0037 
0038 figure(2)
0039 [A, H1, H2] = plotyy(spos,sigmas(1,:),spos,sigmas(2,:));
0040 
0041 set(H1,'Marker','.')
0042 set(A(1),'XLim',[0 spos(end)])
0043 set(H2,'Marker','.')
0044 set(A(2),'XLim',[0 spos(end)])
0045 title('Principal axis of the beam ellipse [m]');
0046 xlabel('s - position [m]');

Generated on Thu 24-Aug-2017 18:47:33 by m2html © 2005