Home > atphysics > NonLinearDynamics > atnuampl.m

atnuampl

PURPOSE ^

ATNUAMPL computes tune shift with amplitude

SYNOPSIS ^

function varargout=atnuampl(ring,ampl,xz,varargin)

DESCRIPTION ^

ATNUAMPL    computes tune shift with amplitude
[NUX,NUZ]=ATNUAMPL(RING,AMPLITUDE)
[NUX,NUZ]=ATNUAMPL(RING,AMPLITUDE,1)

    Computes tunes for the specified horizontal amplitudes

[NUX,NUZ]=ATNUAMPL(RING,AMPLITUDE,3)

    Computes tunes for the specified vertical amplitudes

ATNUAMPL(...)
   Plots the computed tunes in the current axes

ATNUAMPL(...,Name,Value)
   Uses additional options specified by one or more Name,Value pairs.
   Possible values are:
       nturns: specify the number of turns for tracking (default 256)
       method: specify the method for tune determination
               1: Highest peak in fft
               2: Interpolation on fft results
               3: Windowing + interpolation (default)
               4: NAFF
   Other options are transmitted to the plot function

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout=atnuampl(ring,ampl,xz,varargin)
0002 %ATNUAMPL    computes tune shift with amplitude
0003 %[NUX,NUZ]=ATNUAMPL(RING,AMPLITUDE)
0004 %[NUX,NUZ]=ATNUAMPL(RING,AMPLITUDE,1)
0005 %
0006 %    Computes tunes for the specified horizontal amplitudes
0007 %
0008 %[NUX,NUZ]=ATNUAMPL(RING,AMPLITUDE,3)
0009 %
0010 %    Computes tunes for the specified vertical amplitudes
0011 %
0012 %ATNUAMPL(...)
0013 %   Plots the computed tunes in the current axes
0014 %
0015 %ATNUAMPL(...,Name,Value)
0016 %   Uses additional options specified by one or more Name,Value pairs.
0017 %   Possible values are:
0018 %       nturns: specify the number of turns for tracking (default 256)
0019 %       method: specify the method for tune determination
0020 %               1: Highest peak in fft
0021 %               2: Interpolation on fft results
0022 %               3: Windowing + interpolation (default)
0023 %               4: NAFF
0024 %   Other options are transmitted to the plot function
0025 
0026 
0027 lab={'x^2','p_x^2','z^2','p_z^2'};
0028 if nargin < 3, xz=1; end
0029 if ~isempty(varargin) && isnumeric(varargin{1})
0030     orbit=varargin{1};
0031     varargin(1)=[];
0032 else
0033     warning off MATLAB:singularMatrix
0034     orbit=findorbit6(ring);
0035     warning on MATLAB:singularMatrix
0036     if ~all(isfinite(orbit))
0037         orbit=zeros(6,1);
0038         orbit(1:5)=findsyncorbit(ring,0);
0039     end
0040 end
0041 [nturns,varargin]=getoption(varargin,'nturns',256);
0042 [method,varargin]=getoption(varargin,'method',3);
0043 
0044 [~,nbper]=atenergy(ring);
0045 [lindata,fractune0]=atlinopt(ring,0,1:length(ring)+1);
0046 tune0=nbper*lindata(end).mu/2/pi;
0047 offs=[nbper -nbper];
0048 siza=size(ampl);
0049 nampl=prod(siza);
0050 p0=repmat(0.00003*[1;0;1;0;0;0], 1,nampl); % 30 microns minimum amplitude
0051 p0(xz,:)=max(p0(xz,:),ampl(:)');
0052 p0=p0+orbit(:,ones(1,nampl));
0053 p1=ringpass(ring,p0,nturns)-orbit(:,ones(1,nampl*nturns));
0054 tunetrack=[findtune(reshape(p1(1,:),nampl,nturns)',method);...
0055     findtune(reshape(p1(3,:),nampl,nturns)',method)]';
0056 [~,k]=min([fractune0-tunetrack(1,:); 1-fractune0-tunetrack(1,:)]);
0057 np=offs(k);
0058 offset=round(tune0-np.*tunetrack(1,:));
0059 tunetrack=np(ones(nampl,1),:).*tunetrack + offset(ones(nampl,1),:);
0060 if nargout > 0
0061     varargout={reshape(tunetrack(:,1),siza),reshape(tunetrack(:,2),siza)};
0062 else
0063     inttunes=floor(tune0);
0064     plot((ampl.*ampl)',tunetrack-inttunes(ones(nampl,1),:),'o-',varargin{:});
0065     legend('\nu_x','\nu_z');
0066     xlabel(lab{xz});
0067     ylabel('\nu');
0068     grid on
0069 end

Generated on Thu 24-Aug-2017 18:47:33 by m2html © 2005