


ATRADON switches RF and radiation on
[RING2,RADINDEX,CAVINDEX,ENERGY] = ATRADON(RING,CAVIPASS,BENDPASS,QUADPASS)
Changes passmethods to get RF cavity acceleration and radiation
damping. ATRADON also sets the "Energy" field on the modified elements,
looking for the machine energy in:
1) 1st 'RingParam' element
2) 1st 'RFCavity' element
3) field "E0" of the global variable "GLOBVAL"
INPUTS
1. RING initial AT structure
2. CAVIPASS pass method for cavities (default CavityPass)
'' makes no change,
3. BENDPASS pass method for bending magnets. Special values:
'' makes no change,
'auto' will substitute 'Pass' with 'RadPass' in any method
(default: 'auto')
4. QUADPASS pass method for quadrupoles
'' makes no change,
'auto' will substitute 'Pass' with 'RadPass' in any method
(default: '')
OUPUTS
1. RING2 Output ring
2. RADINDEX Indices of elements with radiation
3. CAVINDEX Indices of cavities
See also ATRADOFF, ATCAVITYON, ATCAVITYOFF


0001 function [ring,radelemIndex,cavitiesIndex,energy]=atradon(ring1,varargin) 0002 %ATRADON switches RF and radiation on 0003 % 0004 % [RING2,RADINDEX,CAVINDEX,ENERGY] = ATRADON(RING,CAVIPASS,BENDPASS,QUADPASS) 0005 % Changes passmethods to get RF cavity acceleration and radiation 0006 % damping. ATRADON also sets the "Energy" field on the modified elements, 0007 % looking for the machine energy in: 0008 % 1) 1st 'RingParam' element 0009 % 2) 1st 'RFCavity' element 0010 % 3) field "E0" of the global variable "GLOBVAL" 0011 % 0012 % INPUTS 0013 % 1. RING initial AT structure 0014 % 2. CAVIPASS pass method for cavities (default CavityPass) 0015 % '' makes no change, 0016 % 3. BENDPASS pass method for bending magnets. Special values: 0017 % '' makes no change, 0018 % 'auto' will substitute 'Pass' with 'RadPass' in any method 0019 % (default: 'auto') 0020 % 4. QUADPASS pass method for quadrupoles 0021 % '' makes no change, 0022 % 'auto' will substitute 'Pass' with 'RadPass' in any method 0023 % (default: '') 0024 % 0025 % OUPUTS 0026 % 1. RING2 Output ring 0027 % 2. RADINDEX Indices of elements with radiation 0028 % 3. CAVINDEX Indices of cavities 0029 % 0030 % See also ATRADOFF, ATCAVITYON, ATCAVITYOFF 0031 0032 0033 [cavipass,bendpass,quadpass]=parseargs({'CavityPass','auto',''},varargin); 0034 0035 ring=ring1; 0036 0037 energy=atenergy(ring); 0038 if ~isempty(cavipass) 0039 cavitiesIndex=atgetcells(ring,'Frequency'); 0040 if any(cavitiesIndex) 0041 ring(cavitiesIndex)=changepass(ring(cavitiesIndex),cavipass,energy); 0042 end 0043 else 0044 cavitiesIndex=false(size(ring)); 0045 end 0046 0047 if ~isempty(bendpass) 0048 isdipole=@(elem,bangle) bangle~=0; 0049 dipoles=atgetcells(ring,'BendingAngle',isdipole); 0050 if any(dipoles) > 0 0051 ring(dipoles)=changepass(ring(dipoles),bendpass,energy); 0052 end 0053 else 0054 dipoles=false(size(ring)); 0055 end 0056 0057 if ~isempty(quadpass) 0058 isquadrupole=@(elem,polyb) length(polyb) >= 2 && polyb(2)~=0; 0059 quadrupoles=atgetcells(ring,'PolynomB',isquadrupole) & ~dipoles; 0060 if any(quadrupoles) > 0 0061 ring(quadrupoles)=changepass(ring(quadrupoles),quadpass,energy); 0062 end 0063 else 0064 quadrupoles=false(size(ring)); 0065 end 0066 0067 radelemIndex=dipoles|quadrupoles; 0068 0069 if any(cavitiesIndex) 0070 atdisplay(1,['Cavities located at position ' num2str(find(cavitiesIndex)')]); 0071 else 0072 atdisplay(1,'No cavity'); 0073 end 0074 atdisplay(1,[num2str(sum(radelemIndex)) ' elements switched to include radiation']); 0075 0076 function newline=changepass(line,newpass,nrj) 0077 if strcmp(newpass,'auto') 0078 passlist=atgetfieldvalues(line,'PassMethod'); 0079 ok=cellfun(@(psm) isempty(strfind(psm,'RadPass')),passlist); 0080 passlist(ok)=strrep(passlist(ok),'Pass','RadPass'); 0081 else 0082 passlist=repmat({newpass},size(line)); 0083 end 0084 newline=cellfun(@newelem,line,passlist,'UniformOutput',false); 0085 0086 function elem=newelem(elem,newpass) 0087 elem.PassMethod=newpass; 0088 elem.Energy=nrj; 0089 end 0090 end 0091 0092 end