Commit 78e0b516 authored by Simone Liuzzo's avatar Simone Liuzzo
Browse files

optics matching modified to take in account sliced QF8D model for 2PW (sliced QF8D)

parent 83d5092b
function [rM, qpk,dqpk]=opticsmatching(r,varargin)
function [rM, qpk,dqpk,qf8dpk]=opticsmatching(r,varargin)
% match lattice optics for S28D ESRF-EBS
%
% OUTPUT:
......@@ -25,6 +25,7 @@ function [rM, qpk,dqpk]=opticsmatching(r,varargin)
% 'matchSB' : logical (true), match also SB cells (2,8,16,20,26,28,30,32)
% 'verbose' : logical (false), print out text information
% 'noDQ' : logical (false), excludes DQ quadrupoles for optics matching.
% 'noDQ1' : logical (false), excludes DQ1 quadrupoles for optics matching.
% bymid, bxid removed from objectives
%
% DESCRIPTION:
......@@ -75,6 +76,7 @@ addOptional(p,'match2PW',true,@islogical);
addOptional(p,'matchSB',true,@islogical);
addOptional(p,'verbose',false,@islogical);
addOptional(p,'noDQ',false,@islogical);
addOptional(p,'noDQ1',false,@islogical);
parse(p,r,varargin{:});
......@@ -93,11 +95,12 @@ match2PW = p.Results.match2PW;
matchSB = p.Results.matchSB;
verbose = p.Results.verbose;
noDQ = p.Results.noDQ;
noDQ1 = p.Results.noDQ1;
%% reduce lattice (remove pinholes)
r_input=r;
rmod = ebs.model(r,'reduce',true,'keep','ID\w*|Canting\w*');
rmod = ebs.model(r,'reduce',true,'keep','ID\w*|Canting\w*|CellCenter|\w*Dispersion\w*');
r = rmod.ring;
......@@ -118,9 +121,14 @@ splitdq=[false false false];
function [arc,splitsf]=splitmag(arc,splitsf,magfam)
ind=find(atgetcells(arc,'FamName',magfam))'; % get sf indexes
nel=1;
% do not split if already splitted
if strcmp(magfam,'S[FIJ]2\w*')
nel=2;
end
if strcmp(magfam,'DQ2\w*')
nel=2;
end
if length(ind)==nel % split
splitsf=true;
......@@ -130,7 +138,7 @@ splitdq=[false false false];
end
function [arc]=mergemag(arc,splitsf,magfam)
if splitsf % split
if splitsf % merge only if splitting took place previously in splitmag
if verbose, disp(['merging ' magfam ' ']); end
indsf=find(atgetcells(arc,'FamName',magfam))'; % get sf indexes
L=atgetfieldvalues(arc,indsf(1:2:end),'Length');
......@@ -217,6 +225,7 @@ ARCA_1=ebs.matching.arc(ARCA,...
DBind,...
mk_ids,...
noDQ,...
noDQ1,...
verbose);
%% assign quarupole strengths as in ARCA_1 to all other cells
......@@ -392,7 +401,7 @@ r0 = [ARCA_INJ_1;repmat(ARCA_1,30,1);ARCB_INJ_1]; % no canting no BM.
disp([ 'tot angle/2/pi no BM no canting angles: ' num2str(sum(atgetfieldvalues(rb,atgetcells(rb,'BendingAngle'),'BendingAngle'))/2/pi)]);
disp([ 'tot angle/2/pi inj-30xarc-inj: ' num2str(sum(atgetfieldvalues(r0,atgetcells(r0,'BendingAngle'),'BendingAngle'))/2/pi)]);
disp([ 'tot angle/2/pi : ' num2str(sum(atgetfieldvalues(r,atgetcells(r,'BendingAngle'),'BendingAngle'))/2/pi)]);
if matchCanting
for idnum=cantedid
% assign canted beamlines bending angles only up to present cell
......@@ -412,7 +421,7 @@ for idnum=cantedid
end
end
end
%% restore 2PW and DQ angles for BM
rb0=rb;
......@@ -578,7 +587,9 @@ end
% add back pinholes markers
rbmod = ebs.model(rb);
rM = rbmod.ring;
qpk = rbmod.getfieldvalue('qp','PolynomB',{1,2});
dqpk = rbmod.getfieldvalue('dq','PolynomB',{1,2});
qf8dpk = rbmod.getfieldvalue('qf8d','PolynomB',{1,2});
end
......
Supports Markdown
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