Home > atdemos > opticsAndBeamSizes > linoptdemo.m

linoptdemo

PURPOSE ^

LINOPTDEMO script illustrates the use of LINOPT

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

LINOPTDEMO script illustrates the use of LINOPT
 It reproduces plots of couplig parameters - figures 1,2 for Ref[1]

 [1] A.Terebilo, Accelerator Modeling with MATLAB Accelerator Toolbox
     Proceedings of PAC 2001

 See also LINOPT

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %LINOPTDEMO script illustrates the use of LINOPT
0002 % It reproduces plots of couplig parameters - figures 1,2 for Ref[1]
0003 %
0004 % [1] A.Terebilo, Accelerator Modeling with MATLAB Accelerator Toolbox
0005 %     Proceedings of PAC 2001
0006 %
0007 % See also LINOPT
0008 
0009 
0010 % The lattice for this type of analysis must NOT contain time-dependent
0011 % elements (RF cavity). Elements should NOT use pass-methods with radiation
0012 % (StrMPoleSymplectic4Pass)
0013 % load spear2 lattice
0014 spear2;
0015 
0016 % Find  indexes of elements in QF quadrupole family
0017 QFI = findcells(THERING,'FamName','QF');
0018 % Select some of them to randomly tilt
0019 TILTI = QFI([3:7 10:12]);
0020 
0021 % NOTE: How to introduce random coupling and misalignment errors:
0022 % s-rotations(tilts) and transverse displacements (shifts)
0023 
0024 % 1.generate random  rotations
0025 tilterr = 1*pi/180;            % RMS tilt error [degrees]
0026 qftilts = tilterr*randn(1,length(TILTI));
0027 
0028 % 2. rotate elements
0029 settilt(TILTI,qftilts);
0030 
0031 NE = length(THERING)+1;
0032 LinOptOutput = linopt(THERING,0,1:NE);
0033 
0034 % copy LINOPT output 'LinOptOutput' into separate arrays for plotting
0035 GG = cat(1,LinOptOutput.gamma);
0036 spos = cat(1,LinOptOutput.SPos);
0037 CC = reshape(cat(2,LinOptOutput.C),4,[]);
0038 
0039 subplot(2,1,1)
0040 plot(spos,CC(1,:),'.-r')
0041 hold on
0042 plot(spos,CC(2,:),'.-k')
0043 plot(spos,CC(3,:),'.-b')
0044 plot(spos,CC(4,:),'.-g')
0045 
0046 %Scale axis
0047 SCALE = axis;
0048 SCALE(2) = 0;
0049 SCALE(2) = spos(end);
0050 axis(SCALE);
0051 %Annotate
0052 legend('C_1_1','C_2_1','C_1_2','C_2_2')
0053 title('Elements of coupling matrix C_i_j');
0054 hold off
0055 
0056 % Second subplot
0057 subplot(2,1,2)
0058 plot(spos,GG,'.-k')
0059 title('Mixing parameter \gamma')
0060 
0061 %Scale
0062 SCALE = axis;
0063 SCALE(1) = 0;
0064 SCALE(2) = spos(end);
0065 axis(SCALE);
0066 
0067 %Annotate
0068 legend('\gamma')
0069 xlabel('s - position [m]')

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