Home > pubtools > LatticeTuningFunctions > correction > correction_chain > DisplayCorrectionEffect.m

DisplayCorrectionEffect

PURPOSE ^

[d0,de,dc]=DisplayCorrectionEffect(...

SYNOPSIS ^

function [d0,de,dc]=DisplayCorrectionEffect(r0,rerr,rcor,inCODe,inCODc,refpts,indHCor,indVCor,indQCor,indSCor)

DESCRIPTION ^

 [d0,de,dc]=DisplayCorrectionEffect(...
     r0,...        1) reference lattice
     rerr,...      2) lattice with errors
     rcor,...      3) corrected lattice
     inCODe,...    4) initial COD guess for rerr
     inCODc,...    5) initial COD guess for rcor
     refpts,...    6) reference points for computation
     indHCor,...   7) hor. steerers indexes
     indVCor,...   8) ver. steerers indexes 
     indQCor,...   9) normal quad. correctors indexes
     indSCor)     10) skew quad. correctors indexes

 dispaly correction effect.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [d0,de,dc]=DisplayCorrectionEffect(...
0002     r0,...
0003     rerr,...
0004     rcor,...
0005     inCODe,...
0006     inCODc,...
0007     refpts,...
0008     indHCor,...
0009     indVCor,...
0010     indQCor,...
0011     indSCor)
0012 % [d0,de,dc]=DisplayCorrectionEffect(...
0013 %     r0,...        1) reference lattice
0014 %     rerr,...      2) lattice with errors
0015 %     rcor,...      3) corrected lattice
0016 %     inCODe,...    4) initial COD guess for rerr
0017 %     inCODc,...    5) initial COD guess for rcor
0018 %     refpts,...    6) reference points for computation
0019 %     indHCor,...   7) hor. steerers indexes
0020 %     indVCor,...   8) ver. steerers indexes
0021 %     indQCor,...   9) normal quad. correctors indexes
0022 %     indSCor)     10) skew quad. correctors indexes
0023 %
0024 % dispaly correction effect.
0025 %
0026 
0027 compute_emittances=true;
0028 
0029 disp(' --- model lattice data --- ')
0030 
0031 d0=getdatalattice(r0,inCODe*0,refpts,indHCor,indVCor,indQCor,indSCor,compute_emittances);
0032 
0033 disp(' --- errors lattice data --- ')
0034 de=getdatalattice(rerr,inCODe,refpts,indHCor,indVCor,indQCor,indSCor,compute_emittances);
0035 
0036 disp(' --- corrected lattice data --- ')
0037 dc=getdatalattice(rcor,inCODc,refpts,indHCor,indVCor,indQCor,indSCor,compute_emittances);
0038 
0039 
0040 % print out correction effect
0041 oudataforma='%3.2e';
0042 oudataformatune='%2.3f';
0043 oudataformaemit='%3.3f';
0044 oudataformabeta='%2.1f';
0045 
0046 %
0047 disp('--------------------------------------------------');
0048 disp('------ total std corrector values applyed --------')
0049 disp('------                                    --------');
0050 disp(['       HK (' num2str(length(d0.ch)) ') [1/m]: ' num2str(std(de.ch),oudataforma) ' -> '  num2str(std(dc.ch),oudataforma) ]);
0051 disp(['       VK (' num2str(length(d0.cv)) ') [1/m]: ' num2str(std(de.cv),oudataforma) ' -> '  num2str(std(dc.cv),oudataforma) ]);
0052 disp(['       SK (' num2str(length(d0.cs)) ') [1/m2]: ' num2str(std(de.cs),oudataforma) ' -> '  num2str(std(dc.cs),oudataforma) ]);
0053 disp(['       QK (' num2str(length(d0.cq)) ') [1/m2]: ' num2str(std(de.cq-d0.cq),oudataforma) ' -> '  num2str(std(dc.cq-d0.cq),oudataforma) ]);
0054 if nargin==8
0055     ch=dc.ch.*d0.Lh;
0056     cv=dc.cv.*d0.Lv;
0057     cq=dc.cq.*d0.Lq;
0058     cs=dc.cs.*d0.Ls;
0059     che=de.ch.*d0.Lh;
0060     cve=de.cv.*d0.Lv;
0061     cqe=de.cq.*d0.Lq;
0062     cse=de.cs.*d0.Ls;
0063     disp(['       HKL (' num2str(length(ch)) ') [rad]: ' num2str(std(che),oudataforma) ' -> '  num2str(std(ch),oudataforma) ]);
0064     disp(['       VKL (' num2str(length(cv)) ') [rad]: ' num2str(std(cve),oudataforma) ' -> '  num2str(std(cv),oudataforma) ]);
0065     disp(['       SKL (' num2str(length(cs)) ') [1/m]: ' num2str(std(cse),oudataforma) ' -> '  num2str(std(cs),oudataforma) ]);
0066     disp(['       QKL (' num2str(length(cq)) ') [1/m]: ' num2str(std(cqe-d0.cq),oudataforma) ' -> '  num2str(std(cq-d0.cq),oudataforma) ]);
0067     
0068     Brho=getBrho(r0);
0069     
0070     ch=dc.ch.*d0.Lh.*Brho;
0071     cv=dc.cv.*d0.Lv.*Brho;
0072     cq=dc.cq.*d0.Lq.*Brho;
0073     cs=dc.cs.*d0.Ls.*Brho;
0074     che=de.ch.*d0.Lh.*Brho;
0075     cve=de.cv.*d0.Lv.*Brho;
0076     cqe=de.cq.*d0.Lq.*Brho;
0077     cse=de.cs.*d0.Ls.*Brho;
0078     disp(['       HKLBrho (' num2str(length(ch)) ') [Tm]: ' num2str(std(che),oudataforma) ' -> '  num2str(std(ch),oudataforma) ]);
0079     disp(['       VKLBrho (' num2str(length(cv)) ') [Tm]: ' num2str(std(cve),oudataforma) ' -> '  num2str(std(cv),oudataforma) ]);
0080     disp(['       SKLBrho (' num2str(length(cs)) ') [T]: ' num2str(std(cse),oudataforma) ' -> '  num2str(std(cs),oudataforma) ]);
0081     disp(['       QKLBrho (' num2str(length(cq)) ') [T]: ' num2str(std(cqe-d0.cq),oudataforma) ' -> '  num2str(std(cq-d0.cq),oudataforma) ]);
0082 end
0083 disp('------                                    --------');
0084 disp('------    residual orbit and dispersion   --------')
0085 disp('------                                    --------');
0086 disp(['       OH (' num2str(length(d0.monh)) ') [m]: ' num2str(std(de.monh),oudataforma) ' -> '  num2str(std(dc.monh),oudataforma) ]);
0087 disp(['       OV (' num2str(length(d0.monv)) ') [m]: ' num2str(std(de.monv),oudataforma) ' -> '  num2str(std(dc.monv),oudataforma) ]);
0088 disp(['       DH (' num2str(length(d0.dish)) ') [m]: ' num2str(std(de.dish-d0.dish),oudataforma) ' -> '  num2str(std(dc.dish-d0.dish),oudataforma) ]);
0089 disp(['       DV (' num2str(length(d0.disv)) ') [m]:' num2str(std(de.disv),oudataforma) ' -> '  num2str(std(dc.disv),oudataforma) ]);
0090 disp(['       BBH (' num2str(length(d0.bbh)) ') %: ' num2str(std((de.bbh-d0.bbh)./d0.bbh)*100,oudataformabeta) ' -> '  num2str(std((dc.bbh-d0.bbh)./d0.bbh)*100,oudataformabeta) ]);
0091 disp(['       BBV (' num2str(length(d0.bbv)) ') %: ' num2str(std((de.bbv-d0.bbv)./d0.bbv)*100,oudataformabeta) ' -> '  num2str(std((dc.bbv-d0.bbv)./d0.bbv)*100,oudataformabeta) ]);
0092 disp(['       PhH (' num2str(length(d0.mh)) ') : ' num2str(std((de.mh-d0.mh)),oudataforma) ' -> '  num2str(std((dc.mh-d0.mh)),oudataforma) ]);
0093 disp(['       PhV (' num2str(length(d0.mv)) ') : ' num2str(std((de.mv-d0.mv)),oudataforma) ' -> '  num2str(std((dc.mv-d0.mv)),oudataforma) ]);
0094 disp('------                                    --------');
0095 disp('------        tune and emittance          --------')
0096 disp('------                                    --------');
0097 disp(['       Qx [' num2str(d0.tune(1),oudataformatune) ']: ' num2str(de.tune(1),oudataformatune) ' -> '  num2str(dc.tune(1),oudataformatune) ]);
0098 disp(['       Qy [' num2str(d0.tune(2),oudataformatune) ']: ' num2str(de.tune(2),oudataformatune) ' -> '  num2str(dc.tune(2),oudataformatune) ]);
0099 disp(['       Cx [' num2str(d0.crom(1),oudataformatune) ']: ' num2str(de.crom(1),oudataformatune) ' -> '  num2str(dc.crom(1),oudataformatune) ]);
0100 disp(['       Cy [' num2str(d0.crom(2),oudataformatune) ']: ' num2str(de.crom(2),oudataformatune) ' -> '  num2str(dc.crom(2),oudataformatune) ]);
0101 if compute_emittances
0102     disp(['       EX [' num2str(d0.modemittance(1)*1e12,oudataformaemit) ' pm]: ' num2str(de.modemittance(1)*1e12,oudataformaemit) ' -> '  num2str(dc.modemittance(1)*1e12,oudataformaemit) ]);
0103     disp(['       EY [' num2str(d0.modemittance(2)*1e12,oudataformaemit) 'pm]: ' num2str(de.modemittance(2)*1e12,oudataformaemit) ' -> '  num2str(dc.modemittance(2)*1e12,oudataformaemit) ]);
0104 end
0105 disp('------                                    --------');
0106 disp('--------------------------------------------------');
0107 
0108 
0109 return
0110 
0111 
0112 function a=getdatalattice(r0,inCOD,refpts,indHCor,indVCor,indCorQuads,indSCor,emitok)
0113 
0114 warning('off','all'); % mcf,atx, findorbit6,... generates warnings
0115 
0116 alpha=mcf(r0);
0117 indrfc=find(atgetcells(r0,'Frequency'));
0118             
0119 % get initial orbit
0120 o=findorbit6Err(r0,refpts,inCOD);
0121 a.monh=o(1,:);
0122 a.monv=o(3,:);
0123 d=finddispersion6Err(r0,refpts,indrfc,alpha,1e-4,inCOD);
0124 a.dish=d(1,:);
0125 a.disv=d(3,:);
0126 
0127 if emitok
0128     try
0129         [~,b0]=atx(r0,0,1:length(r0));
0130     catch exc
0131         getReport(exc,'extended');
0132         warning('atx failed');
0133         b0.modemittance=[NaN NaN];
0134         b0.fulltunes=[NaN NaN];
0135     end
0136     
0137     a.tune=b0.fulltunes;
0138     a.modemittance= b0.modemittance;
0139 end
0140 
0141 [l,t,a.crom]=atlinopt(r0,0,refpts);
0142 
0143 if ~emitok
0144     a.tune=t;
0145 end
0146 
0147 a.bbh=arrayfun(@(s)s.beta(1),l);
0148 a.bbv=arrayfun(@(s)s.beta(2),l);
0149 a.mh=arrayfun(@(s)s.mu(1),l);
0150 a.mv=arrayfun(@(s)s.mu(2),l);
0151 
0152 a.Lh=getcellstruct(r0,'Length',indHCor);
0153 a.Lv=getcellstruct(r0,'Length',indVCor);
0154 a.Lq=getcellstruct(r0,'Length',indCorQuads);
0155 a.Ls=getcellstruct(r0,'Length',indSCor);
0156 a.ch=getcellstruct(r0,'PolynomB',indHCor,1,1);
0157 a.cv=getcellstruct(r0,'PolynomA',indVCor,1,1);
0158 a.cq=getcellstruct(r0,'PolynomB',indCorQuads,1,2);
0159 a.cs=getcellstruct(r0,'PolynomA',indSCor,1,2);
0160 
0161 warning('on','all');
0162 
0163 return

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