1 | function [DSx DSz DchroVal] = modelchrosensitivity(varargin) |
---|
2 | %modelchrosensitivity - Computes sextupole change for FamilyList given dxi |
---|
3 | % |
---|
4 | % INPUTS |
---|
5 | % 1. dxix - horizontal tune change |
---|
6 | % 2. dxiz - vertical tune change |
---|
7 | % |
---|
8 | % OUTPUTS |
---|
9 | % 1. DSx - sextupole change to get dxix |
---|
10 | % 2. DSz - sextupole change to get dxiz |
---|
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, modelmcfsensitivity |
---|
17 | |
---|
18 | % |
---|
19 | % Written by Laurent S. Nadolski |
---|
20 | |
---|
21 | NumericFlag = 1; |
---|
22 | Unit = 'Hardware'; |
---|
23 | Mode = 'Model'; |
---|
24 | DebugFlag = 0; |
---|
25 | |
---|
26 | timeout = 1; % second |
---|
27 | |
---|
28 | DSx= NaN; DSz=NaN; |
---|
29 | |
---|
30 | % Switchyard factory |
---|
31 | for i = length(varargin):-1:1 |
---|
32 | if strcmpi(varargin{i},'Model') |
---|
33 | Mode = 'Model'; |
---|
34 | varargin(i) = []; |
---|
35 | elseif strcmpi(varargin{i},'Online') |
---|
36 | Mode = 'Online'; |
---|
37 | varargin(i) = []; |
---|
38 | elseif strcmpi(varargin{i},'Simulator') |
---|
39 | Mode = 'Simulator'; |
---|
40 | varargin(i) = []; |
---|
41 | elseif strcmpi(varargin{i},'Physics') |
---|
42 | Unit = 'Physics'; |
---|
43 | varargin(i) = []; |
---|
44 | elseif strcmpi(varargin{i},'Hardware') |
---|
45 | Unit = 'Hardware'; |
---|
46 | varargin(i) = []; |
---|
47 | end |
---|
48 | end |
---|
49 | |
---|
50 | |
---|
51 | if isempty(varargin) |
---|
52 | dxix = 1e-1; |
---|
53 | dxiz = 1e-1; |
---|
54 | elseif nvargin == 1 |
---|
55 | dxix = varargin{1}; |
---|
56 | dxiz = dxix; |
---|
57 | end |
---|
58 | |
---|
59 | fprintf(' ******** Summary for ''%s'' ********\n', getlatticename); |
---|
60 | |
---|
61 | %fprintf('Sextupole change for dxix of %f and dxiz = %f \n',dxix,dxiz); |
---|
62 | |
---|
63 | % get all sextupoles |
---|
64 | FamilyList = findmemberof('SEXT'); |
---|
65 | FamilyList(12) = []; % remove nanoscopium |
---|
66 | FamilyList(11) = []; % S11 seen as same family as S1 |
---|
67 | FamilyNumber= length(FamilyList); |
---|
68 | |
---|
69 | if ~NumericFlag |
---|
70 | for k = 1:FamilyNumber, |
---|
71 | |
---|
72 | Family = FamilyList{k}; |
---|
73 | |
---|
74 | [bx bz] = modeltwiss('beta',Family); |
---|
75 | [etax etaz] = modeldisp(Family); |
---|
76 | |
---|
77 | L = getleff(Family); |
---|
78 | NQ = length(getspos(Family)); |
---|
79 | |
---|
80 | DSx(k) = 2*pi*dxix/bx(1)/etax(1)/NQ/L(1); |
---|
81 | DSz(k) = -2*pi*dxiz/bz(1)/etax(1)/NQ/L(1); |
---|
82 | |
---|
83 | fprintf('%s : DSxL = %1.2e DSzL = %1.2e betax = %2.2f m betaz = %2.2f m etax = %2.2f m NQ = %2.0f L= %1.2e m \n', ... |
---|
84 | Family, DSx(k)*L(1), DSz(k)*L(1), bx(1), bz(1), etax(1), NQ, L(1)); |
---|
85 | end |
---|
86 | else |
---|
87 | DchroVal = zeros(2,FamilyNumber)*NaN; |
---|
88 | |
---|
89 | % sextupole variation in Ampere |
---|
90 | % alphaby10_nouveau_modele_dec08_opt_lin_1 |
---|
91 | % S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 |
---|
92 | StepValue = [10 40 10 10 50 50 50 25 5 10]; % A |
---|
93 | %StepValue = [1 1 1 1 1 1 1 1 1 1]*0.1; % A |
---|
94 | |
---|
95 | |
---|
96 | for k = 1:FamilyNumber, |
---|
97 | |
---|
98 | Family = FamilyList{k}; |
---|
99 | |
---|
100 | if DebugFlag |
---|
101 | fprintf('%s changed by %f\n', Family, 0.5*StepValue(k)); |
---|
102 | end |
---|
103 | |
---|
104 | % step sextupole strength by plus delta |
---|
105 | if strcmp(Family, 'S1') % S1 and S11 are linked |
---|
106 | fprintf('S11 Delta I = %f\n', 0.5*StepValue(k)); |
---|
107 | stepsp('S11', 0.5*StepValue(k), ... |
---|
108 | Mode, Unit); % plus delta |
---|
109 | end |
---|
110 | fprintf('%s Delta I = %f\n', Family, 0.5*StepValue(k)); |
---|
111 | stepsp(Family, 0.5*StepValue(k), Mode, Unit); % plus delta |
---|
112 | |
---|
113 | |
---|
114 | if strcmp(Mode, 'Model') |
---|
115 | ChroValplus = modelchro(Mode); |
---|
116 | else |
---|
117 | pause(timeout); |
---|
118 | ChroValplus = measchro(Mode, 'NoDisplay'); |
---|
119 | end |
---|
120 | if DebugFlag |
---|
121 | fprintf('Xix = %f Xiz = %f \n', ChroValplus); |
---|
122 | end |
---|
123 | |
---|
124 | |
---|
125 | % step sextupole strength to minus delta |
---|
126 | if strcmp(Family, 'S1') % S1 and S11 are linked |
---|
127 | fprintf('S11 Delta I = %f\n', -StepValue(k)); |
---|
128 | stepsp('S11', -StepValue(k), Mode, Unit); % minus delta |
---|
129 | end |
---|
130 | fprintf('%s Delta I = %f\n', Family, -StepValue(k)); |
---|
131 | stepsp(Family, -StepValue(k), Mode, Unit); % minus delta |
---|
132 | |
---|
133 | if strcmp(Mode, 'Model') |
---|
134 | ChroValminus = modelchro; |
---|
135 | else |
---|
136 | pause(timeout); |
---|
137 | ChroValminus = measchro(Mode, 'NoDisplay'); |
---|
138 | end |
---|
139 | |
---|
140 | if DebugFlag |
---|
141 | fprintf('Xix = %f Xiz = %f \n', ChroValminus); |
---|
142 | end |
---|
143 | |
---|
144 | DchroVal(:,k) = (ChroValplus - ChroValminus) / StepValue(k); |
---|
145 | |
---|
146 | % restore sextupole strength to nominal value |
---|
147 | if strcmp(Family, 'S1') % S1 and S11 are linked |
---|
148 | fprintf('S11 Delta I = %f\n', 0.5*StepValue(k)); |
---|
149 | stepsp('S11', 0.5*StepValue(k), Mode, Unit); |
---|
150 | end |
---|
151 | fprintf('%s Delta I = %f\n\n', Family, 0.5*StepValue(k)); |
---|
152 | stepsp(Family, 0.5*StepValue(k), Mode, Unit); % come back to nominal value |
---|
153 | end |
---|
154 | end |
---|
155 | |
---|
156 | for k = 1:FamilyNumber, |
---|
157 | fprintf('%3s (%3.1f A): Dxix = % 1.2e Dxiz = % 1.2e\n', ... |
---|
158 | FamilyList{k}, StepValue(k), DchroVal(1,k)*StepValue(k), ... |
---|
159 | DchroVal(2,k)*StepValue(k)); |
---|
160 | end |
---|