Atsummary was very slow when calling ElementRadiation.
The main reason is the call of the function atgetfieldvalues for the full ring.
It is very slow if the full ring is used instead of the indices where the required field is present.
This a quick fix
% SLOW when elements do not have the 'BendingAngle'
% angle=atgetfieldvalues(ring,'BendingAngle');
% isdipole=isfinite(angle) & (angle~=0);
% Much faster with indices
dipoleIdx=findcells(ring,'BendingAngle');
angle=atgetfieldvalues(ring, dipoleIdx, 'BendingAngle');
isdipole = atgetcells(ring,'BendingAngle');
isdipole(dipoleIdx) = isfinite(angle) & (angle~=0);
This could be maybe improved evermore.
A a SOLEIL II lattice the gain to run atsummary is a factor 10 (1.5 s instead of 15 s).
The 2 main modifications are when calling atgetfieldvalues for dipoles and quadrupole.
key: using atgetfieldvalues with indices
Atsummary was very slow when calling ElementRadiation.
The main reason is the call of the function atgetfieldvalues for the full ring. It is very slow if the full ring is used instead of the indices where the required field is present.
This a quick fix % SLOW when elements do not have the 'BendingAngle' % angle=atgetfieldvalues(ring,'BendingAngle'); % isdipole=isfinite(angle) & (angle~=0);
% Much faster with indices dipoleIdx=findcells(ring,'BendingAngle'); angle=atgetfieldvalues(ring, dipoleIdx, 'BendingAngle'); isdipole = atgetcells(ring,'BendingAngle'); isdipole(dipoleIdx) = isfinite(angle) & (angle~=0);
This could be maybe improved evermore. A a SOLEIL II lattice the gain to run atsummary is a factor 10 (1.5 s instead of 15 s).
The 2 main modifications are when calling atgetfieldvalues for dipoles and quadrupole.
The rest of the modifications are only style.