source: MML/trunk/mml/at/modeltune.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: 1.7 KB
Line 
1function [FractionalTune, IntegerTune] = modeltune
2%MODELTUNE - Returns the model tune (2x1 vector)
3%  [FractionalTune, IntegerTune] = modeltune
4%
5%  Also see, modelbeta, modeltune, modeldisp, modeltwiss
6%
7%  Written by Greg Portmann
8
9
10global THERING
11if isempty(THERING)
12    error('Simulator variable is not setup properly.');
13end
14
15
16% Fractional tune (Johan's method)
17% NOTE: TUNECHROM takes dp as an arguement and computes optics with findorbit44, m44
18%       In order to compute off-frequency tune, use m66 eigenvalue technique
19%       Cavity must be on.
20[CavityState, PassMethod, iCavity] = getcavity;
21
22try
23    if ~isempty(CavityState)
24        setcavity On;
25        m66 = findm66(THERING);
26
27        % Restore the cavity state
28        setcavity(PassMethod);
29
30        % Johan's method to resolve above or below half integer
31        FractionalTune = getnusympmat(m66);
32
33        %tunex = angle(eig(m66(1:2,1:2)))/(2*pi);
34        %tuney = angle(eig(m66(3:4,3:4)))/(2*pi);
35        %tunes = angle(eig(m66(5:6,5:6)))/(2*pi);
36        %FractionalTune = [tunex(1); tuney(1); tunes(1)];
37        %FractionalTune = FractionalTune(DeviceIndex);
38    else
39        FractionalTune = [NaN;NaN];
40    end
41catch
42    FractionalTune = [NaN;NaN];
43
44    % Restore the cavity state
45    setcavity(PassMethod);
46end
47
48
49if any(isnan(FractionalTune))
50    fprintf('   RF cavity missing or findm66 failed, trying findm44 (via twissring).\n');
51    [TD, Tune1] = twissring(THERING,0,1:length(THERING)+1);
52    FractionalTune = Tune1';
53    FractionalTune = rem(FractionalTune,1);
54end
55
56
57% Integer part
58if nargout >= 2
59    [TD, Tune] = twissring(THERING,0,1:length(THERING)+1);
60    Tune = Tune(:);
61    IntegerTune = fix(Tune);
62end
63
Note: See TracBrowser for help on using the repository browser.