Home > machine > Soleil > StorageRing > measchronat.m

measchronat

PURPOSE ^

function [xix xiz] = measchronat

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

function [xix xiz] = measchronat
 MEASCHRONAT - Measure natural chromaticity by varyiong dipole fied

  INPUTS

  OUTPUTS
  1. xix - horizontal natural chromaticity
  2. xiz - vertical natural chromaticity

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %function [xix xiz] = measchronat
0002 % MEASCHRONAT - Measure natural chromaticity by varyiong dipole fied
0003 %
0004 %  INPUTS
0005 %
0006 %  OUTPUTS
0007 %  1. xix - horizontal natural chromaticity
0008 %  2. xiz - vertical natural chromaticity
0009 
0010 %
0011 % Written by Laurent S. Nadolski
0012 
0013 % TODO List
0014 % ajouter fit automatique
0015 % Regler les contantes de temps, la RMN mais entre 15 et 20 s pour mettre à jour la lecture du champ B
0016 
0017 nb = 4;
0018 tune= [];
0019 Idip = [];
0020 Rmn = [];
0021 itot = 1.0; % total step for dipole in A
0022 istep = -itot/nb; % stepsize in A
0023 
0024 tune_start = gettune;
0025 stepsp('BEND',itot);
0026 fprintf('Dipole current (%f A) is changed by %f\n',getsp('BEND'), itot);
0027 pause(40);
0028 Idip(1) = getsp('BEND');
0029 % for ik1 = 1:100,
0030 %     temp(ik1) = getam('BEND'); pause(0.1)
0031 % end
0032 %Idip(1) = mean(temp);
0033 Rmn(1) = getrmn;
0034 tune(1,:) = gettune
0035 
0036 k1 = 2;
0037 for k = nb:-1:-nb+1,    
0038     stepsp('BEND',istep);    
0039     pause(30);
0040     Idip(k1) = getsp('BEND');
0041 %     for ik1 = 1:100,
0042 %         temp(ik1) = getam('BEND'); pause(0.1)
0043 %     end
0044 %    Idip(k1) = mean(temp);
0045     fprintf('Dipole current (%f A) is changed by %f A\n',Idip(k1), istep);
0046     tune(k1,:) = gettune
0047     Rmn(k1) = getrmn;
0048     k1 = k1 + 1;
0049 end
0050 
0051 stepsp('BEND',itot);
0052 fprintf('Dipole current (%f A) is changed back to nominal value by %f A\n',getsp('BEND'), itot);
0053 pause(40);
0054 
0055 tune_finish = gettune;
0056 
0057 fprintf('Tune variation \n')
0058 fprintf('begin %f %f\n',tune_start)
0059 fprintf('end %f %f\n',tune_finish)
0060 
0061 % BUG should accept a array
0062 E = [];
0063 
0064 for k = 1:length(Idip),
0065     E(k) = bend2gev(Idip(k));
0066 end
0067 
0068 E0 = 2.73913739373611;
0069 % E = (E-E0)./E0;
0070 % E = E';
0071 E = (Rmn-Rmn(5))./Rmn(5);
0072 E = E';
0073 
0074 %%
0075 p1 = polyfit(E,tune(:,1),1)
0076 p2 = polyfit(E,tune(:,2),1)
0077 
0078 fprintf('natural chromaticity xix = %4.1f xiz = %4.1f\n',p1(1),p2(1));
0079 
0080 %%
0081 figure;
0082 subplot(2,1,1)
0083 suptitle(sprintf('Natural chromaticity xix = %4.1f xiz = %4.1f\n',p1(1),p2(1)));
0084 plot(E*100,tune(:,1),'.-')
0085 hold on
0086 plot(E*100,polyval(p1,E), 'k')
0087 
0088 ylabel('nux')
0089 grid on
0090 subplot(2,1,2)
0091 plot(E*100,tune(:,2),'.-')
0092 hold on
0093 plot(E*100,polyval(p2,E), 'k')
0094 ylabel('nuz')
0095 xlabel('Energy deviation [%]');
0096 grid on
0097 
0098 xix = p1(1); xiz = p2(1);

Generated on Mon 21-May-2007 15:35:27 by m2html © 2003