Home > atdemos > responseMatrix > findrespmdemo.m

findrespmdemo

PURPOSE ^

FINDRESPMDEMO response matrix demo

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

FINDRESPMDEMO response matrix demo
 This script illustrates the use of AT function FINDRESPM

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %FINDRESPMDEMO response matrix demo
0002 % This script illustrates the use of AT function FINDRESPM
0003 
0004 spear2
0005 % The most common RM is corrector-to-BPM
0006 % In this demonstration we will not use the actual correctors
0007 % to keep the lattice simple.
0008 
0009 % We will use all focusing quadrupoles as correctors:
0010 % In order to do this we need to use StrMPolesymplectic4 pass-method
0011 % for them. This mehod looks at all terms of the polynomial
0012 % expansion of transverse magnetic field.
0013 % (QuadLinearPass only looks at field 'K')
0014 % PolynomB(1) gives horizontal kick
0015 % PolynomA(1) gives a vertical kick
0016 
0017 % Find indexes of elements that belong to QF Q1 Q2 Q3 families
0018 % We will use them as corrector elements
0019 QFI = findcells(THERING,'FamName','QF');
0020 Q1I = findcells(THERING,'FamName','Q1');
0021 Q2I = findcells(THERING,'FamName','Q2');
0022 Q3I = findcells(THERING,'FamName','Q3');
0023 CORRINDEX = sort([ QFI Q1I Q2I Q3I]);
0024 % Install the new pass-method 'StrMPoleSymplectic4Pass'
0025 THERING = setcellstruct(THERING,'PassMethod',CORRINDEX,'StrMPoleSymplectic4Pass');
0026 
0027 % We will use etrance points of all bending magnets as observation points (BPMs)
0028 BPMINDEX = findcells(THERING,'BendingAngle');
0029 
0030 NBPM = length(BPMINDEX);
0031 NCOR = length(CORRINDEX);
0032 
0033 % Prepare input parameters for FINDRESPM that will tell it, which
0034 % parameters to use as orbit perturbations
0035 % See help for FINDRESPM
0036 
0037 % Set the size of a parameter change for numeric differentiation
0038 KICKSIZE = 1e-5;
0039 
0040 RX = findrespm(THERING,BPMINDEX ,CORRINDEX, KICKSIZE, 'PolynomB',1,1);
0041 RY = findrespm(THERING,BPMINDEX ,CORRINDEX, KICKSIZE, 'PolynomA',1,1);
0042 % Build the response matrix
0043 % In the form
0044 %
0045 % | HH HV |
0046 % | VH VV |
0047 %
0048 % HH - Horizontal BPM response to horizontal orbit kicks
0049 % HV - Horizontal BPM response to vertical orbit kicks
0050 % VH - vertical BPM response to horizontal orbit kicks
0051 % VV - vertical BPM response to vertical orbit kicks
0052 RespM_XY = [RX{1} RY{1}; RX{3} RY{3}];
0053 figure(1);
0054 mesh(RespM_XY);
0055 colormap('copper');
0056 xlabel('Corrector Number')
0057 ylabel('BPM Number');
0058 zlabel('Normalized Orbit Response');
0059 title('Orbit Response Matrix - uncoupled lattice')
0060 
0061 % Now we wish to introduce coupling:
0062 QDI = findcells(THERING,'FamName','QD');
0063 % Generate random rotations:
0064 QDTILTS =   1*(pi/180)*randn(1,length(QDI));
0065 % Put random values in the ring
0066 settilt(QDI,QDTILTS);
0067 
0068 % Generate the new response matrix for the lattice with errors
0069 RX = findrespm(THERING,BPMINDEX ,CORRINDEX, KICKSIZE, 'PolynomB',1,1);
0070 RY = findrespm(THERING,BPMINDEX ,CORRINDEX, KICKSIZE, 'PolynomA',1,1);
0071 
0072 RespM_XY_Coupled = [RX{1} RY{1}; RX{3} RY{3}];
0073 figure(2);
0074 mesh(RespM_XY_Coupled);
0075 colormap('copper');
0076 title('Orbit Response Matrix - coupled lattice')
0077 xlabel('Corrector Number')
0078 ylabel('BPM Number');
0079 zlabel('Normalized Orbit Response');
0080

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