Commit b4fe0b56 authored by Simone Liuzzo's avatar Simone Liuzzo

introduced closed bump kick option (As default), improved plots

parent 1ed035fb
......@@ -18,6 +18,10 @@ classdef DynamicAperture < RingControl %& GridScan
scraper_positions % positions to step scraper in [mm]
khdev % device name of hor. kicker to use for amplitue scan
kedev % device name of extraction. kicker to use to trigger injection bump
khdevCurr0 % initial Khdev Current, used only if kickmode = fullbump
kickmode % "fullbump" = full bump + reduce khdev, "singlekicker" = zero bump + increase khdev
tolhk % A
diithres % loss rate %
......@@ -62,7 +66,7 @@ classdef DynamicAperture < RingControl %& GridScan
obj.dfreq = 0; % on energy DA only by default
obj.scraper_positions = -[4:1:11]; % in [mm]
obj.scraper_positions = -[4:0.3:11]; % in [mm]
% measurement results
obj.x = NaN(length(obj.dfreq));
......@@ -71,6 +75,19 @@ classdef DynamicAperture < RingControl %& GridScan
obj.q = NaN(length(obj.dfreq),2);
obj.khdev = 'sr/ps-k1/1';
obj.kedev = 'sr/ps-ke/1';
obj.kickmode= 'fullbump'; % or 'singlekicker'
switch obj.kickmode
case 'fullbump'
obj.khdevCurr0 = tango.Attribute([obj.khdev '/Current']).value;
case 'singlekicker'
obj.khdevCurr0 = 0;
otherwise
error('not appropriate kickmode, either fullbump or singlekicker');
end
obj.tolhk=1; % A
obj.diithres=0.01; % loss rate %
......@@ -133,6 +150,8 @@ classdef DynamicAperture < RingControl %& GridScan
disp(['Scraper positions [mm]: ' num2str(obj.scraper_positions)]);
disp(['measurement type: ' obj.measurement_type]);
disp(['Kicker used: ' obj.khdev]);
disp(['Ext. Kicker: ' obj.kedev]);
disp(['Kick mode: ' obj.kickmode]);
disp(['Kicker amplitudes: ' num2str(obj.amplhk)]);
disp(['---- ---- ---- ---- ---- ----']);
......@@ -172,32 +191,58 @@ classdef DynamicAperture < RingControl %& GridScan
k1dev = tango.Device(obj.khdev);
kEdev = tango.Device('sy/ps-ke/1');
k1dev.Current=val(1);
kEdev = tango.Device(obj.kedev);
switch obj.kickmode
case 'fullbump'
k1dev.Current= obj.khdevCurr0 -val(1);
case 'singlekicker'
k1dev.Current = val(1);
otherwise
error('not appropriate kickmode, either fullbump or singlekicker');
end
k1dev.Standby();
pause(3);
InitCounterMode = kEdev.CounterMode;
kEdev.CounterMode=int16(nave);
for i=1:numel(val)
fprintf('Kicking with %.3f A\n',val(i));
k1dev.Current=val(i);
switch obj.kickmode
case 'fullbump'
fprintf('Kicking with %.3f A\n',obj.khdevCurr0 -val(i));
k1dev.Current= obj.khdevCurr0 -val(i);
case 'singlekicker'
fprintf('Kicking with %.3f A\n',val(i));
k1dev.Current=val(i);
otherwise
error('not appropriate kickmode, either fullbump or singlekicker');
end
pause(3);
r1=obj.stored_current(); % mA
kEdev.On()
pause(8+nave);
kEdev.On(); % trgger kickers
pause(8+nave);
r2=obj.stored_current(); % mA
deltai=(r2-r1)/nave/r1;
deltai=(r2-r1)/nave/r1; % average relative lost current per shot
r=-deltai*sum(1./(1+(0:nave-1)*deltai))/nave;
cur(i)=r2;
dii(i)=r;
set(hh,'YData',dii);
% stop if current reduced more than threshold (avoid kill)
if (r > 1.2*threshold) break; end
% stop if more than 90% of the initial current is lost
if (r2 < i0/10) break; end
end
% kEdev.CounterMode=int16(0);
% kEdev.CounterMode=InitCounterMode;
kEdev.Standby();
......@@ -369,12 +414,16 @@ classdef DynamicAperture < RingControl %& GridScan
disp(['Saved data in : ' [obj.dirname '/' 'scrappos' num2str(ip) '_df' num2str(ifreq) '.mat']])
f2=figure;
plot(curs,dii,'b');hold on;
plot([x1,x2],[y1,y2]*100,'k');
plot(curthres,obj.diithres,'ro');
xlabel('h kicker amplitude [A]')
plot(curs,dii*100,'.b--','LineWidth',2,'MarkerSize',12);hold on;
plot([x1,x2],[y1,y2]*100,'g--','LineWidth',2,'MarkerSize',12);
plot(curthres,obj.diithres*100,'ro','LineWidth',2,'MarkerSize',12);
xlabel('hor. kicker amplitude [A]')
ylabel('lost current on scraper [%]');
title(['Scraper at : ' num2str(scrappos) ' mm'])
grid on;
set(gcf,'color','white');
drawnow;
saveas(gca,fullfile(obj.dirname,['scrappos' num2str(ip) '.fig']));
......
......@@ -33,13 +33,13 @@ C2=polyfit(pi(sel2),hi(sel2),0);
figure;
%subplot(2,1,1);
plot(pi,hi,'b-'); hold on;
plot(dd.position,dd.HKval,'ro');
plot(pi,polyval(P1,pi),'m-');
plot(pi,polyval(C2,pi),'c-');
xlabel('Scraper position [mm]');
ylabel('Horizontal Kicker Amplitude [A]');
title('Horizontal Kicker Amplitude to lose 5% on the scraper');
plot(pi,hi,'b-','LineWidth',2,'MarkerSize',12); hold on;
plot(dd.position,dd.HKval,'ro','LineWidth',2,'MarkerSize',12);
plot(pi,polyval(P1,pi),'m--','LineWidth',2,'MarkerSize',12);
plot(pi,polyval(C2,pi),'c--','LineWidth',2,'MarkerSize',12);
xlabel({'','Scraper position [mm]'});
ylabel({'Horizontal Kicker Amplitude [A]',''});
title({'Horizontal Kicker Amplitude';'to loose 5% on the scraper'});
%subplot(2,1,2);
%plot(pi(1:end-1),diff(hi)./diff(pi)) ;%+(pi(2)-pi(1))/2
......@@ -51,7 +51,9 @@ m2=0; b2=C2;
xintersect = (b2-b1)/(m1-m2);
yintersect = m1*xintersect + b1;
plot(xintersect,yintersect,'ks');
plot(xintersect,yintersect,'ks','LineWidth',2,'MarkerSize',12);
grid on;
set(gcf,'color','white');
try
a=load('/operation/beamdyn/matlab/optics/sr/theory/alpha');
......
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