1 | function stepalpha2(dxix, dxiz, dalpha2) |
---|
2 | % FUNCTION STEPALPHA2 - step chromaticities and alpha2 using sextupole families |
---|
3 | % |
---|
4 | % INPUTS |
---|
5 | % 1. dxix - horizontal tune variation |
---|
6 | % 2. dxiz - vertical tune variation |
---|
7 | % 3. dalpha2 - second order momentum compaction variation |
---|
8 | % |
---|
9 | % Notes |
---|
10 | % 1. Matrix generation |
---|
11 | % [DSx DSz DchroVal] = modelchrosensitivity; |
---|
12 | % [SextuRmcf1 SextuRmcf2]= modelmcfsensitivity('Sextu'); |
---|
13 | % 2. Save matrices for operation |
---|
14 | % [DKx DKz DtuneVal] = modeltunesensitivity; |
---|
15 | % [DSx DSz DchroVal] = modelchrosensitivity; |
---|
16 | % [QuadRmcf1 QuadRmcf2]= modelmcfsensitivity('Quad'); |
---|
17 | % [SextuRmcf1 SextuRmcf2]=modelmcfsensitivity('Sextu'); |
---|
18 | % save('Rmatrix_alphaby10_nouveau_modele_janv10_opt_nonlin', 'DtuneVal', 'DchroVal', 'QuadRmcf1', 'QuadRmcf2', 'SextuRmcf1', 'SextuRmcf2'); |
---|
19 | |
---|
20 | % 3. S11 and S1 are linked together |
---|
21 | % |
---|
22 | % See Also stepalpha1, physics_mcf, modelmcfsensitivity, modelalpharesponsemat |
---|
23 | |
---|
24 | % |
---|
25 | %% Written by Laurent S. Nadolski |
---|
26 | |
---|
27 | InteractiveFlag = 1; |
---|
28 | |
---|
29 | % Check input parameters |
---|
30 | if nargin < 3 |
---|
31 | error('Number of input parameters is at least than 3!') |
---|
32 | end |
---|
33 | |
---|
34 | % Default sextupole families to used |
---|
35 | %familyList = [1 4 9]; % low alpha MAHER : ancien choix |
---|
36 | %familyList = [10 9 8]; % low alpha AMOR : ancien choix |
---|
37 | familyList = [4 9 8]; % low alpha AMOR + MAHER (nouveau choix janvier 2011) |
---|
38 | |
---|
39 | % Load linear response matrices |
---|
40 | % These are the sensibility matrices expressed in amperes |
---|
41 | % DchroVal |
---|
42 | % |
---|
43 | |
---|
44 | dirName = getfamilydata('Directory','OpsData'); |
---|
45 | %load([dirName '..' filesep 'lowalpha_dec08' filesep 'Rmatrix_alphaby20_nouveau_modele_dec08_opt_nonlin']); |
---|
46 | %load([dirName '..' filesep 'lowalpha_dec08' filesep 'Rmatrix_alphaby10_nouveau_modele_janv10_opt_nonlin']); |
---|
47 | FileName = 'Rmatrix_alpha.mat'; |
---|
48 | DirectoryName = getfamilydata('Directory', 'OpsData'); |
---|
49 | load(fullfile(DirectoryName, FileName)); |
---|
50 | |
---|
51 | SextuFamNumber = length(familyList); |
---|
52 | if nargin == 3 |
---|
53 | %DI= ones(SextuFamNumber,1)*NaN; |
---|
54 | DI = pinv([DchroVal(:,familyList); SextuRmcf2(familyList)])*[dxix; dxiz; dalpha2]; |
---|
55 | else |
---|
56 | error('Wrong number of parameters') |
---|
57 | end |
---|
58 | |
---|
59 | %Display variation and ask confirmation |
---|
60 | fprintf('\n\n Sextupole current values to be applied\n'); |
---|
61 | for iSextu = 1:SextuFamNumber, |
---|
62 | fprintf(sprintf('Sextupole step for S%d is %f A\n', familyList(iSextu), DI(iSextu))); |
---|
63 | end |
---|
64 | |
---|
65 | if InteractiveFlag |
---|
66 | % Ask user for applying correction |
---|
67 | reply = input('Apply values (Y/n) \n', 's'); |
---|
68 | if isempty(reply) |
---|
69 | reply = 'Y'; |
---|
70 | end |
---|
71 | |
---|
72 | switch reply |
---|
73 | case {'y', 'Y'} |
---|
74 | for iSextu = 1:SextuFamNumber, |
---|
75 | sprintf('S%d',iSextu); |
---|
76 | if familyList(iSextu) == 1, % step also S11 |
---|
77 | stepsp('S11', DI(iSextu)); |
---|
78 | end |
---|
79 | stepsp(sprintf('S%d',familyList(iSextu)), DI(iSextu)); |
---|
80 | end |
---|
81 | fprintf('Correction applied\n'); |
---|
82 | otherwise |
---|
83 | fprintf('Aborting ...\n'); |
---|
84 | end |
---|
85 | else |
---|
86 | for iSextu = 1:SextuFamNumber, |
---|
87 | sprintf('S%d',iSextu); |
---|
88 | if familyList(iSextu) == 1, % step also S11 |
---|
89 | stepsp('S11', DI(iSextu)); |
---|
90 | end |
---|
91 | stepsp(sprintf('S%d',familyList(iSextu)), DI(iSextu)); |
---|
92 | end |
---|
93 | fprintf('Correction applied\n'); |
---|
94 | end |
---|
95 | |
---|