Home > mml > at > modelchro.m

modelchro

PURPOSE ^

MODELCHRO - Returns the AT model chromaticity

SYNOPSIS ^

function [Chro, Tune] = modelchro(varargin)

DESCRIPTION ^

MODELCHRO - Returns the AT model chromaticity
  [Chromaticity, Tune] = modelchro(DeltaRF)

  INPUTS
  1. DeltaRF - Change in RF used to compute the chromaticity [Hz]  {Default: .1 Hz}
  2. 'Hardware' returns chromaticity in hardware units (Tune/MHz (usually))
     'Physics'  returns chromaticity in physics  units (Tune/(dp/p))

  OUTPUTS
  1. Chromaticity vector (2x1)
  1. Tune vector (2x1)

  Also see, modelbeta, modeltune, modeldisp, modeltwiss

  Written by Greg Portmann

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [Chro, Tune] = modelchro(varargin)
0002 %MODELCHRO - Returns the AT model chromaticity
0003 %  [Chromaticity, Tune] = modelchro(DeltaRF)
0004 %
0005 %  INPUTS
0006 %  1. DeltaRF - Change in RF used to compute the chromaticity [Hz]  {Default: .1 Hz}
0007 %  2. 'Hardware' returns chromaticity in hardware units (Tune/MHz (usually))
0008 %     'Physics'  returns chromaticity in physics  units (Tune/(dp/p))
0009 %
0010 %  OUTPUTS
0011 %  1. Chromaticity vector (2x1)
0012 %  1. Tune vector (2x1)
0013 %
0014 %  Also see, modelbeta, modeltune, modeldisp, modeltwiss
0015 %
0016 %  Written by Greg Portmann
0017 
0018 
0019 UnitsFlag = getunits('TUNE');
0020 if isempty(UnitsFlag)
0021     UnitsFlag = 'Hardware';
0022 end
0023 
0024 MCF = [];
0025 
0026 % Look if 'struct' or 'numeric' in on the input line
0027 for i = length(varargin):-1:1
0028     if strcmpi(varargin{i},'Physics')
0029         UnitsFlag = 'Physics';
0030         varargin(i) = [];
0031         %if length(varargin) >= i
0032         %    if isnumeric(varargin{i})
0033         %        MCF = varargin{i};
0034         %        varargin(i) = [];
0035         %    end
0036         %end
0037     elseif strcmpi(varargin{i},'Hardware')
0038         UnitsFlag = 'Hardware';
0039         varargin(i) = [];
0040         %if length(varargin) >= i
0041         %    if isnumeric(varargin{i})
0042         %        MCF = varargin{i};
0043         %        varargin(i) = [];
0044         %    end
0045         %end
0046     end        
0047 end
0048 
0049 
0050 DeltaRF = [];
0051 if length(varargin) >= 1
0052     if isnumeric(varargin{1})
0053         DeltaRF = varargin{1};  % Hz
0054     end
0055 end
0056 if  isempty(DeltaRF)   
0057     DeltaRF = .1;  % Hz
0058 end
0059 
0060 
0061 global THERING
0062 if isempty(THERING)
0063     error('Simulator variable is not setup properly.');
0064 end
0065 
0066 
0067 % tunechrom does not take into account the present RF frequency
0068 % [Tune, Chro] = tunechrom(THERING, 0, 'chrom');
0069 % Tune = Tune(:);
0070 % Chro = Chro(:);
0071 
0072 
0073 [CavityState, PassMethod, iCavity] = getcavity;
0074 if isempty(CavityState)
0075     error('The model does not have a cavity, hence the chromaticity cannot be determined.');
0076 else
0077     if any(strcmpi(CavityState(1,:),'Off'))
0078         % Turn on the cavities
0079         setcavity('On');
0080     end
0081 end
0082 
0083 
0084 % If the integer tune in needed
0085 %[TD, Tune] = twissring(THERING,0,1:length(THERING)+1);
0086 %IntTune = fix(Tune(:));
0087 
0088 
0089 % Get tune (Johan's method)
0090 M66 = findm66(THERING);
0091 FracTune0 = getnusympmat(M66);
0092 %Tune = fix(IntTune) + FracTune0;
0093 
0094 
0095 % Small change in the RF and remeasure the tune
0096 RF0 = THERING{iCavity(1)}.Frequency;
0097 for i = 1:length(iCavity)
0098     THERING{iCavity(i)}.Frequency = RF0 + DeltaRF;
0099 end
0100 
0101 % Get tune (Johan's method)
0102 M66 = findm66(THERING);
0103 FracTune1 = getnusympmat(M66);
0104 
0105 
0106 % Reset the RF
0107 for i = 1:length(iCavity)
0108     THERING{iCavity(i)}.Frequency = RF0;
0109 end
0110 
0111 
0112 % Chromaticity in hardware units (DeltaTune / DeltaRF)
0113 DeltaRF = physics2hw('RF', 'Setpoint', DeltaRF, [1 1], 'Model');
0114 Chro = (FracTune1 - FracTune0) / DeltaRF;
0115 
0116 
0117 if strcmpi(UnitsFlag,'Physics')
0118     % Change to Physics units
0119     MCF = mcf(THERING);
0120     RF0 = physics2hw('RF', 'Setpoint', RF0, [1 1], 'Model');
0121     Chro = (-MCF * RF0) * Chro;
0122 end
0123 
0124 
0125 % if strcmpi(UnitsFlag,'Hardware')
0126 %     % Change to Hardware units
0127 %     MCF = mcf(THERING);
0128 %     CavityFrequency  = THERING{iCavity(1)}.Frequency;
0129 %     Chro = Chro / (-MCF * RF0);
0130 % end
0131 
0132 
0133 
0134 % Reset cavity PassMethod
0135 setcavity(PassMethod);
0136 
0137 
0138

Generated on Mon 21-May-2007 15:29:18 by m2html © 2003