Commit 973a10c6 authored by Simone Liuzzo's avatar Simone Liuzzo

analytic dispersion derivative with DQ

parent 61bfa570
......@@ -10,35 +10,35 @@ function [rx,rz,N,S,bang,alldip,usedip]=qemdispderivAnalyticDQ(mach,varidx,bpmid
%RX: derivative of the horizontal response to frequency
%RZ: derivative of the vertical response to frequency
disp('Analytic');
disp('Analytic (DQ)');
nb=length(bpmidx);
alldip=find(atgetcells(mach,'BendingAngle'));
Ndip=numel(alldip);
dipsel=sort([1:Ndip]);
bndidx=sort(alldip(dipsel));% only long part
bang=atgetfieldvalues(mach,alldip,'BendingAngle');
alldip=alldip(bang>1e-9);
bang=bang(bang>1e-9);
% make sure order is as in qempanel vector.
[usedip,b]=ismember(varidx,alldip);
[~,b]=ismember(varidx,bndidx);
%% compute analytic response with all dipoles always.
[N,S,~,~]=dDxyDthetaDQ(mach,bpmidx,alldip,'magmodel','thick');
% negative sign, probably due to dipole sign convention
N_sort=-N(:,b);
N_sort=-N(:,dipsel(b));
% qempanel response in [m/Hz] instead of [m/%]
N_sort=N_sort/mcf(mach);
% in qempanel the response is for scaling factors, not deltas
N_sort=N_sort.*repmat(bang(b)',nb,1);
N_sort=N_sort.*repmat(bang(dipsel(b))',nb,1);
S_sort=S(:,b);
S_sort=S(:,dipsel(b));
% qempanel response in [m/Hz] instead of [m/%]
S_sort=S_sort/mcf(mach);
% in qempanel the response is for scaling factors, not deltas
S_sort=S_sort.*repmat(bang(b)',nb,1);
S_sort=S_sort.*repmat(bang(dipsel(b))',nb,1);
rx=N_sort;
......
......@@ -14,7 +14,7 @@ if isempty(okfit), okfit=true(size(qemres.dipidx)); end
qemres.brot,qemres.bhgain,qemres.bvgain); %#ok<ASGLU>
[frh0,frv0]=qemfresp(mach,qemres.ct,qemres.bpmidx,[],[],[]); %#ok<ASGLU>
dfrh=qemres.bhscale*frh-frh0;
[dipresponse,~]=qemdispderivAnalytic(mach,qemres.dipidx,qemres.bpmidx);
[dipresponse,~]=qemdispderivAnalyticDQ(mach,qemres.dipidx,qemres.bpmidx);
bok=isfinite(dfrh)&okbpm;
% [dipresponseN,~]=qemdispderiv(mach,qemres.ct,@setbendangle,1.e-3,...
% qemres.dipidx,qemres.bpmidx);
......
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