source: MML/trunk/machine/SOLEIL/StorageRing/measchronat.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.1 KB
Line 
1%function [xix xiz] = measchronat
2% MEASCHRONAT - Measure natural chromaticities by varying dipole fied
3%
4%  INPUTS
5%
6%  OUTPUTS
7%  1. xix - horizontal natural chromaticity
8%  2. xiz - vertical natural chromaticity
9
10%
11% Written by Laurent S. Nadolski
12
13% TODO List
14% Tuning of the time constantes, RMN probe takes around 15 to 20 s to refresh its data
15
16nb = 4;
17tune= [];
18Idip = [];
19Rmn = [];
20itot = 1; % total step for dipole in A
21istep = -itot/nb; % stepsize in A
22
23tune_start = gettune;
24stepsp('BEND',itot);
25fprintf('Dipole current (%f A) is changed by %f\n',getsp('BEND'), itot);
26fprintf('Wait ...');
27pause
28Idip(1) = getsp('BEND');
29% for ik1 = 1:100,
30%     temp(ik1) = getam('BEND'); pause(0.1)
31% end
32%Idip(1) = mean(temp);
33Rmn(1)    = getrmn;
34tune(1,:) = gettune
35
36k1 = 2;
37for k = nb:-1:-nb+1,   
38    stepsp('BEND',istep);   
39    pause(10);
40    %fprintf('Wait ...\n');
41    %pause
42    Idip(k1) = getsp('BEND');
43%     for ik1 = 1:100,
44%         temp(ik1) = getam('BEND'); pause(0.1)
45%     end
46%    Idip(k1) = mean(temp);
47    fprintf('Dipole current (%f A) is changed by %f A\n',Idip(k1), istep);
48    tune(k1,:) = gettune
49    Rmn(k1) = getrmn;
50    k1 = k1 + 1;
51end
52
53stepsp('BEND',itot);
54fprintf('Dipole current (%f A) is changed back to nominal value by %f A\n',getsp('BEND'), itot);
55pause(10);
56
57tune_finish = gettune;
58
59fprintf('Tune variation \n')
60fprintf('begin %f %f\n',tune_start)
61fprintf('end %f %f\n',tune_finish)
62
63% BUG should accept a array
64E = [];
65
66for k = 1:length(Idip),
67    E(k) = bend2gev(Idip(k));
68end
69
70E0 = 2.73913739373611;
71% E = (E-E0)./E0;
72% E = E';
73E = (Rmn-Rmn(nb+1))./Rmn(nb+1);
74E = E';
75
76%%
77p1 = polyfit(E,tune(:,1),1)
78p2 = polyfit(E,tune(:,2),1)
79
80fprintf('natural chromaticity xix = %4.1f xiz = %4.1f\n',p1(1),p2(1));
81
82%%
83figure;
84subplot(2,1,1)
85suptitle(sprintf('Natural chromaticities xix = %4.1f xiz = %4.1f\n',p1(1),p2(1)));
86plot(E*100,tune(:,1),'.-')
87hold on
88plot(E*100,polyval(p1,E), 'k')
89
90ylabel('nux')
91grid on
92subplot(2,1,2)
93plot(E*100,tune(:,2),'.-')
94hold on
95plot(E*100,polyval(p2,E), 'k')
96ylabel('nuz')
97xlabel('Energy deviation [%]');
98grid on
99
100xix = p1(1); xiz = p2(1);
Note: See TracBrowser for help on using the repository browser.