source: MML/trunk/machine/SOLEIL/StorageRing/modelalphasensitivity.m @ 4

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

Initial import--MML version from SOLEIL@2013

File size: 4.7 KB
Line 
1function [Rtune Rchro Rmcf1 Rmcf2]=modelalphasensitivity(varargin)
2%modelmcfsensitivity - Computes 1st and 2nd mcf variation with quadrupole
3% and/or sextupole family magnets
4%  INPUTS
5%  'Quad'/'NoQuad'- Compute or not mcf variation versus quadrupoles
6%  'Sextu'/'NoSextu'- Compute or not mcf variation versus quadrupoles
7%
8%  OUTPUTS
9%  1. Rmcf1  - first order mcf response matrix
10%  2. Rmcf2  - second order mcf response matrix
11%
12%  NOTES
13%  1. S11 and S1 are seen as a unique family
14%  2. Value depends on the optics for the moment see below the sextu steps
15%
16%  See Also modeltunesensitivity, modechrosensitivity
17%
18%  Written by Laurent S. Nadolski
19
20QuadFlag  = 1;
21SextuFlag = 1;
22
23% Flag factory parser
24for i = length(varargin):-1:1
25    if strcmpi(varargin{i},'Quad')
26        QuadFlag = 1;
27        varargin(i) = [];
28    elseif strcmpi(varargin{i},'NoQuad')
29        QuadFlag = 0;
30        varargin(i) = [];
31    elseif strcmpi(varargin{i},'Sextu')
32        SextuFlag = 1;
33        varargin(i) = [];
34    elseif strcmpi(varargin{i},'NoSextu')
35        SextuFlag = 0;
36        varargin(i) = [];
37    end
38end
39
40fprintf('   ******** Summary for ''%s'' ********\n', getlatticename);
41
42
43if QuadFlag
44    quadFamList = findmemberof('QUAD');
45    % remove nanoscopium
46    quadFamList(12) = [];
47    quadFamList(11) = [];
48    % intitialization
49    FamilyNumber= length(quadFamList);
50    Rmcf1 = zeros(1,20);
51    Rmcf2 = zeros(1,20);
52    Rtune = zeros(2,20);
53    Rchro = zeros(2,20);
54   
55    % Quadrupole variation in Ampere
56    StepValue = ones(1,FamilyNumber)*0.1; % A
57   
58    fprintf('Quadrupole change for quadFamList change of %f A \n', StepValue(1));
59    for k = 1:FamilyNumber,
60       
61        Family = quadFamList{k};
62       
63        stepsp(Family, 0.5*StepValue(k), 'Model'); % plus delta
64       
65       
66        % Compute momentum compaction factor
67        [mcf1plus mcf2plus] = physics_mcf('Nodisplay'); %by fitting
68        nuplus   = gettune;
69        chroplus = modelchro;
70       
71        stepsp(Family, -StepValue(k), 'Model'); % minus delta
72       
73        [mcf1minus mcf2minus] = physics_mcf('Nodisplay');
74        numinus   = gettune;
75        chrominus = modelchro;
76           
77    stepsp(Family, 0.5*StepValue(k), 'Model'); % go back to nominal value
78   
79    % first mcf response matrix per Ampere
80    Rmcf1(k)   = (mcf1plus - mcf1minus) / StepValue(k);
81    % second order mcf response matrix per Ampere
82    Rmcf2(k)   = (mcf2plus - mcf2minus) / StepValue(k);
83    Rtune(:,k) = (nuplus-numinus) / StepValue(k);
84    Rchro(:,k) = (chroplus-chrominus) / StepValue(k);
85    fprintf('%4s (1A): Delta MCF1= %+1.2e Delta MCF2= %+1.2e nux=%+1.2e nuz=%+1.2e xix= %+1.2e xiz= %+1.2e\n', ...
86        Family, Rmcf1(k), Rmcf2(k), Rtune(:,k), Rchro(:,k));
87    end
88end
89
90
91if SextuFlag
92    sextuFamList = findmemberof('Sext');
93    sextuFamList(12) = []; % nanoscopium
94    sextuFamList(11) = []; % S11 is linked to S1
95   
96    FamilyNumber= length(sextuFamList);
97   
98    % Sextupole variation in Ampere
99    StepValue = ones(1,FamilyNumber)*0.1; % A
100   
101    fprintf('Sextupole change for sextuFamList change of %f A \n', StepValue(1));
102    for k = 1:FamilyNumber,
103       
104        Family = sextuFamList{k};
105       
106        % step sextupole strength by  plus delta
107        if strcmp(Family, 'S1') % S1 and S11 are linked
108            stepsp('S11', 0.5*StepValue(k), 'Model'); % minus delta
109        end
110        stepsp(Family, 0.5*StepValue(k), 'Model');
111       
112       
113        [mcf1plus mcf2plus] = physics_mcf('Nodisplay');
114        nuplus = gettune;
115        chroplus = modelchro;
116       
117        % step sextupole strength to minus delta
118        if strcmp(Family, 'S1') % S1 and S11 are linked
119            stepsp('S11', -StepValue(k), 'Model'); % minus delta
120        end
121        stepsp(Family, -StepValue(k), 'Model'); % minus delta
122       
123        [mcf1minus mcf2minus] = physics_mcf('Nodisplay');
124        numinus = gettune;
125        chrominus = modelchro;
126       
127        % restore sextupole strength to nominal values
128        if strcmp(Family, 'S1') % S1 and S11 are linked
129            stepsp('S11', 0.5*StepValue(k), 'Model');
130        end
131        stepsp(Family, 0.5*StepValue(k), 'Model'); % come back to nominal value
132       
133        % First order mcf Response matrix per Ampere
134        Rmcf1(k+10) = (mcf1plus - mcf1minus) / StepValue(k);
135        % Second order Response matrix per Ampere
136        Rmcf2(k+10) = (mcf2plus - mcf2minus) / StepValue(k);
137        Rtune(:,k+10) = (nuplus-numinus) / StepValue(k);
138        Rchro(:,k+10) = (chroplus-chrominus) / StepValue(k);
139    fprintf('%4s (1A): Delta MCF1= %+1.2e Delta MCF2= %+1.2e nux=%+1.2e xnuz=%+1.2e xix= %+1.2e xiz=%+1.2e\n', ...
140        Family, Rmcf1(k+10), Rmcf2(k+10), Rtune(:,k+10), Rchro(:,k+10));
141    end
142end
Note: See TracBrowser for help on using the repository browser.