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

qemrdtresp_mod

PURPOSE ^

QEMRDTRESP compute resonance driving terms at BPM locations

SYNOPSIS ^

function [fx,fz,qcor]=qemrdtresp_mod(mach,bpmidx,qcoridx)

DESCRIPTION ^

QEMRDTRESP  compute resonance driving terms at BPM locations

[fx,fz,qcor]=semrdtresp_mod(mach,bpmidx,qcoridx)

 mach    : AT lattice
 bpmindx : BPM indexes
 qcoridx : skew quadrupole indexes
 
 fx    : f2000 RDT 
 fx    : f0020 RDT
 qcor  : qcor.beta, qcor.phase beta and phase at the quad index (averaged) 
 
 to obtain rdt for a given set of skewidx strengths (KL)
 
 f1001=f1.*k1.*Lquad
 f1010=f2.*k1.*Lquad
 
 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 [fx,fz,qcor]=qemrdtresp_mod(mach,bpmidx,qcoridx)
0002 %QEMRDTRESP  compute resonance driving terms at BPM locations
0003 %
0004 %[fx,fz,qcor]=semrdtresp_mod(mach,bpmidx,qcoridx)
0005 %
0006 % mach    : AT lattice
0007 % bpmindx : BPM indexes
0008 % qcoridx : skew quadrupole indexes
0009 %
0010 % fx    : f2000 RDT
0011 % fx    : f0020 RDT
0012 % qcor  : qcor.beta, qcor.phase beta and phase at the quad index (averaged)
0013 %
0014 % to obtain rdt for a given set of skewidx strengths (KL)
0015 %
0016 % f1001=f1.*k1.*Lquad
0017 % f1010=f2.*k1.*Lquad
0018 %
0019 % this function is an exact copy of semrdtresp by L.Farvacque
0020 %
0021 %see also: atavedata_mod
0022 
0023 nbpm=length(bpmidx);
0024 nqcor=length(qcoridx);
0025 
0026 % Compute optics
0027 
0028 [refpts,~,kl]=unique([qcoridx bpmidx length(mach)+1]);
0029 jcor=kl(1:nqcor);
0030 jbpm=kl(nqcor+(1:nbpm));
0031 jend=kl(end);
0032 [vdata,avebeta,avemu]=atavedata_mod(mach,0,refpts);
0033 mtx=vdata(jend).mu(1);
0034 mtz=vdata(jend).mu(2);
0035 
0036 % Extract parameters
0037 if nargout >= 3
0038     qcor.beta=avebeta(jcor,:);
0039     qcor.phase=avemu(jcor,:);
0040 end
0041 
0042 % Compute terms
0043 
0044 dphix=dphase(avemu(jbpm,1),avemu(jcor,1),mtx);
0045 dphiz=dphase(avemu(jbpm,2),avemu(jcor,2),mtz);
0046 
0047 fx=-avebeta(jcor,ones(1,nbpm))'.*complex(cos(2*dphix),sin(2*dphix))./...
0048     (1-complex(cos(2*mtx),sin(2*mtx)))/8;
0049 
0050 fz= avebeta(jcor,2*ones(1,nbpm))'.*complex(cos(2*dphiz),sin(2*dphiz))./...
0051     (1-complex(cos(2*mtz),sin(2*mtz)))/8;
0052 
0053     function dph=dphase(phib,phik,mtune)
0054         nb=length(phib);
0055         nk=length(phik);
0056         dph=phik(:,ones(nb,1))'-phib(:,ones(1,nk));
0057         neg=(dph < 0);
0058         dph(neg)=dph(neg)+mtune;
0059     end
0060 
0061 end

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