Home > pubtools > LatticeTuningFunctions > correction > RDT > semrdtresp_mod.m

semrdtresp_mod

PURPOSE ^

SEMRDT compute resonance driving terms at BPM locations

SYNOPSIS ^

function [f1,f2,skew]=semrdtresp_mod(mach,bpmidx,skewidx)

DESCRIPTION ^

SEMRDT compute resonance driving terms at BPM locations

[f1,f2,skew]=semrdtresp_mod(mach,bpmidx,skewidx)

 mach    : AT lattice
 bpmindx : BPM indexes
 skewidx : skew quadrupole indexes
 
 f1    : f1001 RDT 
 f2    : f1010 RDT
 skew  : skew.beta skew.phase beta and phase at the skew index (averaged) 
 
 to obtain rdt for a given set of skewidx strengths (KL)
 
 f1001=f1.*k1s.*Lskew
 f1010=f2.*k1s.*Lskew
 
 this function is an exact copy of semrdtresp by L.Farvacque
 
see also: atavedata_mod

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [f1,f2,skew]=semrdtresp_mod(mach,bpmidx,skewidx)
0002 %SEMRDT compute resonance driving terms at BPM locations
0003 %
0004 %[f1,f2,skew]=semrdtresp_mod(mach,bpmidx,skewidx)
0005 %
0006 % mach    : AT lattice
0007 % bpmindx : BPM indexes
0008 % skewidx : skew quadrupole indexes
0009 %
0010 % f1    : f1001 RDT
0011 % f2    : f1010 RDT
0012 % skew  : skew.beta skew.phase beta and phase at the skew index (averaged)
0013 %
0014 % to obtain rdt for a given set of skewidx strengths (KL)
0015 %
0016 % f1001=f1.*k1s.*Lskew
0017 % f1010=f2.*k1s.*Lskew
0018 %
0019 % this function is an exact copy of semrdtresp by L.Farvacque
0020 %
0021 %see also: atavedata_mod
0022 
0023 nb=length(bpmidx);
0024 ns=length(skewidx);
0025 
0026 % Compute optics
0027 
0028 [refpts,ii,kl]=unique([skewidx bpmidx length(mach)+1]);
0029 jsk=kl(1:ns);
0030 jbpm=kl(ns+(1:nb));
0031 jend=kl(end);
0032 [vdata,avebeta,avemu]=atavedata_mod(mach,0,refpts);
0033 mtunes=vdata(jend).mu;
0034 if ~isempty(find(avebeta<0))
0035     bx=arrayfun(@(a)a.beta(1),vdata);
0036     by=arrayfun(@(a)a.beta(2),vdata);
0037     avebeta=[bx,by];
0038     warning('on','all');
0039     warning('negative data in AVEBETA! using beta at entrance!')
0040     save('failingavebetalattice.mat','mach','bpmidx','skewidx')
0041     warning('off','all');
0042 end
0043 % Extract parameters
0044 
0045 bpm.phase=cat(1,vdata(jbpm).mu);
0046 
0047 skew.beta=avebeta(jsk,:);
0048 skew.phase=avemu(jsk,:);
0049 
0050 % Compute terms
0051 
0052 jsqb=real(sqrt(skew.beta(:,1).*skew.beta(:,2)));
0053 [dphix,dphiz]=dphase(bpm.phase,skew.phase',mtunes);
0054 
0055 re1=jsqb(:,ones(1,nb))'.*cos(dphix-dphiz);
0056 im1=jsqb(:,ones(1,nb))'.*sin(dphix-dphiz);
0057 t1=mtunes(1)-mtunes(2);
0058 
0059 denom1=4*(1-complex(cos(t1),sin(t1)));
0060 f1=complex(re1,im1)/denom1;
0061 
0062 re2=jsqb(:,ones(1,nb))'.*cos(dphix+dphiz);
0063 im2=jsqb(:,ones(1,nb))'.*sin(dphix+dphiz);
0064 t2=mtunes(1)+mtunes(2);
0065 denom2=4*(1-complex(cos(t2),sin(t2)));
0066 f2=complex(re2,im2)/denom2;
0067 
0068 end
0069 
0070 function [dphix,dphiz]=dphase(phib,phik,mtune)
0071 nb=length(phib);
0072 nk=length(phik);
0073 dphix=phik(  ones(nb,1),:)-phib(:,  ones(1,nk));
0074 neg=(dphix < 0);
0075 dphix(neg)=dphix(neg)+mtune(1);
0076 dphiz=phik(2*ones(nb,1),:)-phib(:,2*ones(1,nk));
0077 neg=(dphiz < 0);
0078 dphiz(neg)=dphiz(neg)+mtune(2);
0079 end

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