Home > lattice > atguessclass.m

atguessclass

PURPOSE ^

ATCLASS=ATGUESSCLASS(ATELEM) Tries to determine the class of an element

SYNOPSIS ^

function atclass = atguessclass(elem, varargin)

DESCRIPTION ^

ATCLASS=ATGUESSCLASS(ATELEM) Tries to determine the class of an element
   ELEM    AT element

ATCLASS=ATGUESSCLASS(ATELEM,'UseClass')
   By default, ATGUESSCLASS will default "useless" elements (PolynopmB==0)
   to 'Drift' or 'Marker', depending on 'Length'. When specifying
   'UseClass', it it will preserve the 'Class' field for those elements.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function atclass = atguessclass(elem, varargin)
0002 %ATCLASS=ATGUESSCLASS(ATELEM) Tries to determine the class of an element
0003 %   ELEM    AT element
0004 %
0005 %ATCLASS=ATGUESSCLASS(ATELEM,'UseClass')
0006 %   By default, ATGUESSCLASS will default "useless" elements (PolynopmB==0)
0007 %   to 'Drift' or 'Marker', depending on 'Length'. When specifying
0008 %   'UseClass', it it will preserve the 'Class' field for those elements.
0009 %
0010 
0011 useclass=any(strcmpi(varargin,'UseClass'));
0012 
0013 if isfield(elem,'BendingAngle')
0014     atclass='Bend';
0015 elseif isfield(elem,'Frequency')
0016     atclass='RFCavity';
0017 elseif isfield(elem,'KickAngle')
0018     atclass='Corrector';
0019 elseif isfield(elem,'Periodicity')
0020     atclass='RingParam';
0021 elseif isfield(elem,'Limits')
0022     atclass='Aperture';
0023 elseif isfield(elem,'PolynomB')
0024     if useclass && isfield(elem,'Class')
0025         atclass=elem.Class;
0026     elseif isfield(elem,'Length') && elem.Length~=0
0027         loworder=find(abs(elem.PolynomB(2:end))~=0,1);
0028         if isempty(loworder)
0029             atclass='Drift';
0030         elseif loworder==1
0031             atclass='Quadrupole';
0032         elseif loworder==2
0033             atclass='Sextupole';
0034         else
0035             atclass='Multipole';
0036         end
0037     else
0038         atclass='ThinMultipole';
0039     end
0040 elseif isfield(elem,'Lmatp')
0041     atclass='QuantDiff';
0042 elseif isfield(elem,'M66')
0043     if isfield(elem,'Tijk')
0044         atclass='MatrixTijkPass';
0045     else
0046         atclass='Matrix66';
0047     end
0048 elseif isfield(elem,'Length') && elem.Length~=0
0049     atclass='Drift';
0050 else
0051     if useclass && isfield(elem,'Class')
0052         atclass=elem.Class;
0053     else
0054         atclass='Marker';
0055     end
0056 end
0057 
0058 end

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