source: MML/trunk/machine/SOLEIL/StorageRing/stepalpha1.m @ 17

Last change on this file since 17 was 17, checked in by zhangj, 10 years ago

To have a stable version on the server.

  • Property svn:executable set to *
File size: 2.7 KB
Line 
1function stepalpha1(dnux, dnuz, dalpha1, dalpha2)
2% FUNCTION STEPALPHA1 - step tunes and alpha1 (and alpha2) using quadrupole families
3%
4%  INPUTS
5%  1. dnux - horizontal tune variation
6%  2. dnuz - vertical tune variation
7%  3. dalpha1 - first order momentum compaction variation
8%  4. dalpha2 - second order momentum compaction variation
9%
10%  Notes
11%  1. Matrix generation
12%  [DKx DKz DtuneVal]   = modeltunesensitivity;
13%  [QuadRmcf1 QuadRmcf2]= modelmcfsensitivity('Quad');
14%
15%  See Also stepalpha2, physics_mcf, modelalpharesponsemat
16
17
18
19%
20%% Written by Laurent S. Nadolski
21
22InteractiveFlag = 1;
23
24if nargin < 3
25    error('Number of input parameters is at least than 3!')
26end
27
28% Default families to used
29if nargin == 3
30    %familyList = [5 7 8]; % anciennes valeurs
31    familyList = [5 6 7]; % valeurs décidées le 18 avril 2011, commune à MAHER et AMOR
32end
33
34if nargin == 4
35    familyList = [5 7 8 10]; % lowalpha MAHER
36    %familyList = [2 5 6 7]; % lowalpha AMOR
37end
38
39% Load linear response matrices
40% These are the sensibility matrices expressed in amperes
41% DtuneVal
42%
43
44dirName = 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_alphaby20_nouveau_modele_janv10_opt_nonlin']);
47FileName = 'Rmatrix_alpha.mat';
48DirectoryName = getfamilydata('Directory', 'OpsData');
49load(fullfile(DirectoryName, FileName));
50
51QuadFamNumber = length(familyList);
52if nargin == 3
53    DI = pinv([DtuneVal(:,familyList); QuadRmcf1(familyList)])*[dnux dnuz dalpha1]';
54elseif nargin == 4
55    %% step tunes and alpha1 and alpha2
56    DI = pinv([DtuneVal(:,familyList); QuadRmcf1(familyList); QuadRmcf2(familyList)])*[dnux dnuz dalpha1 dalpha2]';
57elseif nargin == 2
58    DI = pinv([QuadRmcf1(familyList); QuadRmcf2(familyList)])*[dnux dnuz]';   
59else
60    error('Wrong number of parameters')
61end
62
63%Display variation and ask confirmation
64fprintf('\n\n Quadrupole current values to be applied\n');
65for iQuad = 1:QuadFamNumber,
66    fprintf(sprintf('Quad step for Q%d is %f A\n', familyList(iQuad), DI(iQuad)));
67end
68
69if InteractiveFlag
70
71    % Ask user for applying correction
72    reply = input('Apply values (Y/n) \n', 's');
73    if isempty(reply)
74        reply = 'Y';
75    end
76
77    switch reply
78        case {'y', 'Y'}
79            for iQuad = 1:QuadFamNumber,
80                sprintf('Q%d',iQuad);
81                stepsp(sprintf('Q%d',familyList(iQuad)), DI(iQuad));
82            end
83            fprintf('Correction applied\n');
84        otherwise
85            fprintf('Aborting ...\n');
86    end
87else
88    for iQuad = 1:QuadFamNumber,
89        sprintf('Q%d',iQuad);
90        stepsp(sprintf('Q%d',familyList(iQuad)), DI(iQuad));
91    end
92    fprintf('Correction applied\n');
93end
94
Note: See TracBrowser for help on using the repository browser.