ATSETRFCAVITY sets the RF Cavity with the passmethod RFCavityPass. RFCavityPass allows to change the energy of the beam changing the frequency of the cavity. newring = atSetRFCavity(ring, rfv, radflag, HarmNumber, DeltaFreq) sets the synchronous phase of the cavity, the voltage, the harmonic number and the PassMethod. All the N cavities will have a voltage rfv/N radflag says whether or not we want radiation on, which affects synchronous phase. If radflag is 0, the function calls atradoff, if it is 1, it calls atradon. Cavities in the ring must have the Class RFCavity. Normally DeltaFreq should be 0, it's different from 0 when you want to simulate a change of energy changing the RF frequency. DeltaFreq is in Hz. normal use: newring = atsetRFCavity( ring, 6e6, 1, 992, 0 ) for off-energy simulations: newring = atsetRFCavity( ring, 6e6, 1, 992, 100 ) see also: atsetcavity
0001 function newring = atsetRFCavity( ring, rfv, radflag, HarmNumber, DeltaFreq ) 0002 % ATSETRFCAVITY sets the RF Cavity with the passmethod RFCavityPass. 0003 % RFCavityPass allows to change the energy of the beam changing the 0004 % frequency of the cavity. 0005 % 0006 % newring = atSetRFCavity(ring, rfv, radflag, HarmNumber, DeltaFreq) 0007 % sets the synchronous phase of the cavity, the voltage, the harmonic 0008 % number and the PassMethod. All the N cavities will have a voltage rfv/N 0009 % radflag says whether or not we want radiation on, which affects 0010 % synchronous phase. If radflag is 0, the function calls atradoff, if it 0011 % is 1, it calls atradon. 0012 % Cavities in the ring must have the Class RFCavity. 0013 % Normally DeltaFreq should be 0, it's different from 0 when you want to 0014 % simulate a change of energy changing the RF frequency. DeltaFreq is in 0015 % Hz. 0016 % 0017 % normal use: 0018 % newring = atsetRFCavity( ring, 6e6, 1, 992, 0 ) 0019 % for off-energy simulations: 0020 % newring = atsetRFCavity( ring, 6e6, 1, 992, 100 ) 0021 % 0022 % see also: atsetcavity 0023 0024 clight=299792458 ; 0025 0026 newring = ring; 0027 indrfc=findcells(ring,'Class','RFCavity'); 0028 beta0=1; 0029 U0=atgetU0(ring); %% not ok if misaligned elem! 0030 0031 circ=findspos(ring,length(ring)+1); 0032 0033 newring=setcellstruct(newring,'PassMethod',indrfc,'RFCavityPass'); 0034 0035 freq0=(clight*beta0/circ)*HarmNumber; 0036 0037 freq=freq0+DeltaFreq; 0038 0039 %now set cavity frequencies, Harmonic Number and RF Voltage 0040 for j=indrfc 0041 newring{j}.Frequency=freq; 0042 newring{j}.HarmNumber=HarmNumber; 0043 newring{j}.Voltage=rfv/length(indrfc); 0044 end 0045 0046 %now set phaselags in cavities 0047 if radflag 0048 timelag= (circ/(2*pi*HarmNumber))*asin(U0/(rfv)); 0049 newring=atradon(newring,'RFCavityPass','auto','auto'); % set radiation on. nothing if radiation is already on 0050 newring=setcellstruct(newring,'PassMethod',indrfc,'RFCavityPass'); 0051 else 0052 newring=atradoff(newring,'RFCavityPass','auto','auto'); % set radiation off. nothing if radiation is already off 0053 newring=setcellstruct(newring,'PassMethod',indrfc,'RFCavityPass'); 0054 timelag=0; 0055 end 0056 newring=setcellstruct(newring,'TimeLag',indrfc,timelag); 0057 end