source: MML/trunk/mml/finddispquad.m @ 4

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

Initial import--MML version from SOLEIL@2013

File size: 1.1 KB
Line 
1function QuadSP = finddispquad
2%FINDDISPQUAD - Find the optimal setting for the dispersion correction quadrupole family
3%  QuadSP = finddispquad
4%
5%  This function is under development
6
7
8disp('This function is under construction (Greg Portmann).  ');
9return
10
11QuadSP0 = getsp('QFA');
12
13% Get Dispersion
14%[Dx,Dy] = getdisp;
15
16
17i = 0;
18for qfa=[0 .2 .4 .6 .8 1 1.2 1.4 1.6 1.8 2]
19  i = i+1;
20  QFAnew = QuadSP0+qfa
21  qfaam=setsp('QFA', QFAnew);
22  sleep(2);
23  [Dx(:,i),Dy(:,i)]=getdisp;
24  x(:,i) = getx(1,BPMelem1278);
25  QFA(:,i) = getsp('QFA');
26  save qfaout x QFA Dx Dy
27end
28
29
30% Set QFA back to starting point
31setsp('QFA', QuadSP0);
32
33
34% Find LS fit to the line
35%y=Dxmat;
36%X = [ones(max(size()),1) QFA'];
37%b = inv(X'*X)*X'*y;
38%QuadSP = -b(1)/b(2);
39
40%QFA1 = linspace(QFA(1),QFA(max(size(QFA))),100);
41%yfit = b(1) + b(2)*QFA1;
42
43%figure
44%plot(QFA1,yfit, QFA,y,'o'); grid on
45%xlabel('RF Frequency [MHz]');
46%ylabel('Dot product of Dx and Hor. Orbit');
47
48%fprintf('\n\n                             Zero crossing of QFAF = %f [MHz]\n', rf0);
49
50save qfadata
51
52figure;
53plot(QFA,Dx(BPMelem1278,:)); grid on
54xlabel('QFA [Amps]');
55ylabel('Dispersion');
56
Note: See TracBrowser for help on using the repository browser.