Commit 600a8b91 authored by Simone Liuzzo's avatar Simone Liuzzo
Browse files

removed pass method switching method

parent c75046e3
function ring=PassMethodSwitch(ring,varargin)
% ring=PassMethodSwitch(ring,'mode',value)
%
% assigns pass methods to classes.
%
% type 'at2devel'
% drift: DriftPass
% dipole : BndMPoleSymplectic4Pass
% quadrupole: StrMPoleSymplectic4Pass
% sextupole : StrMPoleSymplectic4Pass
% octupole : StrMPoleSymplectic4Pass
%
% type 'AT1.4'
% drift: DriftPass
% dipole : BndMPoleSymplectic4FrgFPass
% quadrupole: QuadMPoleFringePass
% sextupole : StrMPoleSymplectic4Pass
% octupole : StrMPoleSymplectic4Pass
%
% modified 25-Jul-2017
expectedmodes={'AT1.4','at2devel'};
p=inputParser;
addRequired(p,'ring',@iscell);
addParameter(p,'mode',expectedmodes{1},@(x)any(validatestring(x,expectedmodes)));
parse(p,ring,varargin{:});
type=p.Results.mode;
% find drift
inddr=atgetcells(ring,'Class','Drift');
% find dipole
indbn=atgetcells(ring,'Class','Bend','Dipole');
% find quad
indqd=atgetcells(ring,'Class','Quadrupole');
% find sextupole
indsx=atgetcells(ring,'Class','Sextupole');
% find octupole
indoc=atgetcells(ring,'Class','Octupole');
disp(['Passmethods mode: ' type]);
disp('Initial PassMethods: ');
disp(unique(cellfun(@(a)a.PassMethod,ring,'un',0)));
switch type
case 'at2devel'
ring=AssignPassMethods(ring,...
inddr,'DriftPass',...
indbn,'BndMPoleSymplectic4Pass',...
indqd,'StrMPoleSymplectic4Pass',...
indsx,'StrMPoleSymplectic4Pass',...
indoc,'StrMPoleSymplectic4Pass'...
);
ring=atsetfieldvalues(ring,indbn,'FringeQuadEntrance',1);
ring=atsetfieldvalues(ring,indbn,'FringeQuadExit',1);
ring=atsetfieldvalues(ring,indqd,'FringeQuadEntrance',1);
ring=atsetfieldvalues(ring,indqd,'FringeQuadExit',1);
case 'AT1.4'
ring=AssignPassMethods(ring,...
inddr,'DriftPass',...
indbn,'BndMPoleSymplectic4FrgFPass',...
indqd,'QuadMPoleFringePass',...
indsx,'StrMPoleSymplectic4Pass',...
indoc,'StrMPoleSymplectic4Pass'...
);
end
disp('Final PassMethods: ');
disp(unique(cellfun(@(a)a.PassMethod,ring,'un',0)));
return
function ring=AssignPassMethods(ring,...
idr,drmeth,...
ibn,bnmeth,...
iqd,qdmeth,...
isx,sxmeth,...
ioc,ocmeth)
% function ring=AssignPassMethods(ring,drmeth,bnmeth,qdmeth,sxmeth,ioc,ocmeth)
%
% Assign PassMethods drmeth,bnmeth,qdmeth,sxmeth,ocmeth to ring.
%
ring=atsetfieldvalues(ring,idr,'PassMethod',drmeth);
ring=atsetfieldvalues(ring,ibn,'PassMethod',bnmeth);
ring=atsetfieldvalues(ring,iqd,'PassMethod',qdmeth);
ring=atsetfieldvalues(ring,isx,'PassMethod',sxmeth);
ring=atsetfieldvalues(ring,ioc,'PassMethod',ocmeth);
return
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