Home > atphysics > LongitudinalDynamics > cavityon.m

cavityon

PURPOSE ^

CAVITYON turns Cavities ON

SYNOPSIS ^

function varargout = cavityon(varargin)

DESCRIPTION ^

CAVITYON turns Cavities ON

 CAVITYON looks for elements that have field Frequency
    and sets PassMethod for them to ThinCavityPass
 CAVITYON(ENERGY)
    In addition sets the E0 field of the global variable GLOBVAL
    to energy - design energy [eV]
    If GLOBVAL does not exist CAVITYON creates it

 See also CAVITYOFF, RADIATIONON, RADIATIONOFF, SETCAVITY

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = cavityon(varargin)
0002 %CAVITYON turns Cavities ON
0003 %
0004 % CAVITYON looks for elements that have field Frequency
0005 %    and sets PassMethod for them to ThinCavityPass
0006 % CAVITYON(ENERGY)
0007 %    In addition sets the E0 field of the global variable GLOBVAL
0008 %    to energy - design energy [eV]
0009 %    If GLOBVAL does not exist CAVITYON creates it
0010 %
0011 % See also CAVITYOFF, RADIATIONON, RADIATIONOFF, SETCAVITY
0012 
0013 if  ~evalin('base','~isempty(whos(''global'',''THERING''))')
0014    error('Global variable THERING could not be found');
0015 end
0016 
0017 if ~exist('THERING')
0018     global THERING
0019 end
0020 
0021 global GLOBVAL
0022 if ~exist('GLOBVAL') || ~evalin('base','~isempty(whos(''global'',''GLOBVAL''))')
0023     if nargin==0
0024         error('global variable GLOBVAL does not exist. To create it, use CAVITYON(ENERGY)')
0025     else
0026         evalin('base','global GLOBVAL');
0027         GLOBVAL.E0 = varargin{1};
0028         disp('Global variable GLOBVAL was created');
0029     end
0030 else
0031     if nargin==1
0032         GLOBVAL.E0 = varargin{1};
0033     end
0034     
0035 end
0036 
0037 localcavindex = findcells(THERING,'Frequency');
0038 
0039 if isempty(localcavindex)
0040    error('No cavities were found in the lattice');
0041 end
0042 
0043 THERING = setcellstruct(THERING,'PassMethod',localcavindex, 'CavityPass');
0044 
0045 disp(strcat('Cavities located at index  [',num2str(localcavindex),  ']  were turned ON'))     
0046 if nargout
0047     varargout{1}=localcavindex;
0048 end

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