Commit eda89981 authored by Simone Liuzzo's avatar Simone Liuzzo

qempanel updated

parent 0c16001a
......@@ -25,22 +25,24 @@ else
[rx,~]=qemdispderiv(mach,qemres.ct,@setk,1.e-3,...
[qemres.qcoridx],qemres.bpmidx); % h dispersion derivative resepct to quadrupoles
rx=rx./qemres.qcorl(:,ones(1,size(rx,1)))'; % as in semskewresp
qemres.quadhdispresponse = rx;
end
function elem=setk(elem,dk)
function elem=setk(elem,dk)
k=elem.PolynomB(2)+dk;
elem.K=k;
elem.PolynomB(2)=k;
end
% dispersion
disp('h dispersion derivative');
frh = qemres.frespx;
[frh0,frv0]=qemfresp(mach,qemres.ct,qemres.bpmidx,[],[],[]); %#ok<ASGLU>
dfrh = alpha_c * (qemres.bhscale*frh-frh0);
dfrh = (qemres.bhscale*frh-frh0); %alpha_c *
a1 = qemres.hdispRDTcorWeight;
if a1 > 1 | a1<0
......
......@@ -71,15 +71,15 @@ disp('ANALYTIC QEMPANEL Response AT2.0/errors_corrections')
if isfield(qemres,'quadhdispresponse')
% do not recomput if already available
dDx_dq=qemres.quadhdispresponse;
dDy_ds=qemres.skewvdispresponse;
else
disp('FIRST and only h.disp derivative with respect to quadrupoles');
disp('computation starts on lattice without errors/correctors');
[dDx_dq,dDy_ds]=qemdispderiv(qemres(1).at,qemres.ct,@setk,1.e-3,...
[dDx_dq,~]=qemdispderiv(qemres(1).at,qemres.ct,@setk,1.e-3,...
[varidx],qemres.bpmidx,dispfunc); % h dispersion derivative resepct to quadrupoles
dDx_dq=dDx_dq./qemres.qcorl(:,ones(1,size(dDx_dq,1)))'; % as in semskewresp
qemres.quadhdispresponse = dDx_dq;
qemres.skewvdispresponse = dDy_ds;
disp('finished. stored in qemres.quadhdispresponse')
end
function elem=setk(elem,dk)
......
......@@ -145,6 +145,7 @@ semres.respiax=[];
qemres.respiax=[];
qemplotresp(3,qemres.resph,qemres.respv,'response');
set(handles.pushbutton3,'Enable','On');
set(handles.pushbutton19,'Enable','On'); % dipole fit on
qemb(2)=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
if get(handles.ACRMcheckbox,'Value')
......@@ -353,8 +354,9 @@ global qemb qemres semres
qemb(2).kn=qemb(1).kn;
qemb(2).dipdelta=qemb(1).dipdelta;
qemb(2).dxs=qemb(1).dxs;
mach=atfittune(qemat(qemres,qemb(2),true),qemres.tunes,'QD2\w*','QF1\w*'); % retune the model
qemb(2).kn=getcellstruct(mach,'PolynomB',qemres.qpidx,2);
% mach=atfittune(qemat(qemres,qemb(2),true),qemres.tunes,'QD2\w*','QF1\w*'); % retune the model
mach = qemres(1).at;
qemb(2).kn=getcellstruct(mach,'PolynomB',qemres.qpidx,{1,2});
set(handles.qemdata.errdef,'Enable','On');
set(hObject,'Enable','Off');
qemb(2)=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
......@@ -412,7 +414,7 @@ set(handles.statustext,'String','computing correction');
fitproc={[],@qemcorrdt};
fitmethod=fitproc{get(handles.popupmenu1,'Value')};
if ~isempty(fitmethod)
qemb(2).cor(:,2)=fitmethod(qemres,qemb(2).kn,qemb(2).cor(:,end));
[qemb(2).cor(:,2),qemres]=fitmethod(qemres,qemb(2).kn,qemb(2).cor(:,end));
set(handles.qemdata.cordef,'Enable','On');
end
qemb(2)=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
......
......@@ -139,8 +139,8 @@ end
% disp('simulator (will be removed)');toc;
%%
if (isfield(handles,'compare') && handles.compare) || ...
(isfield(handles,'pushbutton13') && strcmpi(get(handles.pushbutton13,'Enable'),'Off'))
% if (isfield(handles,'compare') && handles.compare) || ...
% (isfield(handles,'pushbutton13') && strcmpi(get(handles.pushbutton13,'Enable'),'Off'))
if all(isfield(qemres,{'resph','respv','frespx'}))
diffh=qemb.atresph-qemres.resph; % Response H -> H in m/rad
diffv=qemb.atrespv-qemres.respv; % Response V -> V in m/rad
......@@ -155,7 +155,7 @@ if (isfield(handles,'compare') && handles.compare) || ...
[num2str(length(qemres.wrongbpms)) ' bpms not used: ' num2str(qemres.wrongbpms,'%d ')]];
qemplotresp(4,diffh,diffv,'deviation');
end
end
% end
disp('plot disp'); toc;
......
......@@ -104,7 +104,7 @@ qemres.dpp=syncorb(5,1);
qemres.fractunes=periods*tunes-fix(periods*tunes);
% qemres.dipidx=find(atgetcells(atmod.ring,'FamName','[DJ]L[12][AE]_3','DQ1[B]','DQ2C_1'))';%,'DQ1[BD]' atmod.get(0,'di');
qemres.dipidx=find(atgetcells(atmod.ring,'FamName','[DJ]L[12][AE]_[15]','ml_\w*'))';%,'DQ1[BD]' atmod.get(0,'di');
qemres.dipidx=find(atgetcells(atmod.ring,'FamName','[DJ]L[12][AE]_[15]','ml\w*'))';%,'DQ1[BD]' atmod.get(0,'di');
bang=atmod.getfieldvalue(qemres.dipidx,'BendingAngle');
qemres.dipidx=qemres.dipidx(bang>0.001);
%qemres.dipidx=qemres.dipidx(1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment