Home > lattice > element_creation > atrbend.m

atrbend

PURPOSE ^

ATRBEND creates a rectangular bending magnet element with class 'Bend'

SYNOPSIS ^

function elem=atrbend(fname,varargin)

DESCRIPTION ^

 ATRBEND creates a rectangular bending magnet element with class 'Bend'

  Two calling methods (that can be combined)
  ATRBEND(FAMNAME,LENGTH,BENDINGANGLE,K,PASSMETHOD)
  INPUTS
     1. fname            family name 
     2. LENGTH             length of the arc for an on-energy particle
                         [m], default to 0
     3. BENDINGANGLE    total bending angle [rad], defaults to 0 
     4. K                focusing strength, defaults to 0
     5. PASSMETHOD      tracking function, defaults to 'BendLinearPass'

  ATRBEND(FAMNAME,LENGTH,BENDINGANGLE,K,PASSMETHOD,'FIELDNAME1',VALUE1,...)
  Each pair {'FIELDNAME',VALUE} is added to the element

  OUTPUTS
      1. elem - Structure with the AT element

  NOTES
      1. Fieldname can be called by calling the passmethod
         [req opt] = BndMPoleSymplectic4Pass
                     where req are mandatory field and opt are optional
                     fields

  See also: ATDRIFT, ATQUADRUPOLE, ATSEXTUPOLE, ATSBEND
          ATMULTIPOLE, ATTHINMULTIPOLE, ATMARKER, ATCORRECTOR

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function elem=atrbend(fname,varargin)
0002 % ATRBEND creates a rectangular bending magnet element with class 'Bend'
0003 %
0004 %  Two calling methods (that can be combined)
0005 %  ATRBEND(FAMNAME,LENGTH,BENDINGANGLE,K,PASSMETHOD)
0006 %  INPUTS
0007 %     1. fname            family name
0008 %     2. LENGTH             length of the arc for an on-energy particle
0009 %                         [m], default to 0
0010 %     3. BENDINGANGLE    total bending angle [rad], defaults to 0
0011 %     4. K                focusing strength, defaults to 0
0012 %     5. PASSMETHOD      tracking function, defaults to 'BendLinearPass'
0013 %
0014 %  ATRBEND(FAMNAME,LENGTH,BENDINGANGLE,K,PASSMETHOD,'FIELDNAME1',VALUE1,...)
0015 %  Each pair {'FIELDNAME',VALUE} is added to the element
0016 %
0017 %  OUTPUTS
0018 %      1. elem - Structure with the AT element
0019 %
0020 %  NOTES
0021 %      1. Fieldname can be called by calling the passmethod
0022 %         [req opt] = BndMPoleSymplectic4Pass
0023 %                     where req are mandatory field and opt are optional
0024 %                     fields
0025 %
0026 %  See also: ATDRIFT, ATQUADRUPOLE, ATSEXTUPOLE, ATSBEND
0027 %          ATMULTIPOLE, ATTHINMULTIPOLE, ATMARKER, ATCORRECTOR
0028 
0029 % Input parser for option
0030 [rsrc,L,A,K,method]  = decodeatargs({0,0,[],'BendLinearPass'},varargin);
0031 [L,rsrc]             = getoption(rsrc,'Length',L);
0032 [A,rsrc]             = getoption(rsrc,'BendingAngle',A);
0033 [K,rsrc]             = getoption(rsrc,'K',K);
0034 [method,rsrc]        = getoption(rsrc,'PassMethod',method);
0035 [PolynomB,rsrc]      = getoption(rsrc,'PolynomB',[0 0]);
0036 [cl,rsrc]            = getoption(rsrc,'Class','Bend');
0037 [EntranceAngle,rsrc] = getoption(rsrc,'EntranceAngle',0.5*A);
0038 [ExitAngle,rsrc]     = getoption(rsrc,'ExitAngle',0.5*A);
0039 
0040 % Gradient setting if not specified explicitly
0041 if ~isempty(K), PolynomB(2) = K; end
0042 
0043 % Build the element
0044 elem = atbaselem(fname,method,'Class',cl,'Length',L,...
0045     'BendingAngle',A,'EntranceAngle',EntranceAngle,'ExitAngle',ExitAngle,...
0046     'K',PolynomB(2),'PolynomB',PolynomB,rsrc{:});
0047 end

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