Commit 0bfbf1cd authored by beamdyn's avatar beamdyn

MDT modifications

parent 9128366e
......@@ -48,7 +48,7 @@ defaultNIterations=4;
defaultNoiseLevelEvaluation=false;
defaultFixedChrom=false;
expectedSextupoleGroups={'sextcor','Sext3Fams','SF2cor','Debug_2Var'};
expectedSextupoleGroups={'sextcor','Sext3Fams','SF2cor','SF2cor_fast','Debug_2Var'};
expectedSextupoleGroupsSave={'sextcor'};
expectedObjectives={'TLT','BLM','TLT_nonorm','BLM_nonorm'};
......@@ -87,7 +87,7 @@ switch TLTorBLM
% error('update averaging time and noiseval for NewBLM reading')
%averagingtime=5;
objfun=@(xx)objBLM_nonorm(xx,devopt,averagingtime);
noiseval=4000; % noise evaluated on 50 measurements with this averaging time.
noiseval=400; % noise evaluated on 50 measurements with this averaging time.
case 'TLT_nonorm'
%averagingtime=5;
objfun=@(xx)objTouLT_nonorm(xx,devopt,averagingtime);
......@@ -183,7 +183,7 @@ else
dmat = eye(Nvar);
end
step = 0.01;
step = 0.1;
g_cnt = 0;
[x1,f1,nf]=powellmain(objfun,x0,step,dmat,0,Nit,'noplot',1000*Nit);
......
......@@ -86,15 +86,16 @@ while it < maxIt
% set(0,'CurrentFigure',gcf);
% end
% if ~isempty(g_data)
[~,~,~] = process_scandata(g_data,Nvar,vrange,'plot');
% end
%direction with largest decrease
if (fm - f1)*(1) > del,
del=(fm - f1)*(1);
k=ii;
fprintf('iteration %d, var %d: del = %f updated\n',it, ii, del);
% if ~isempty(g_data)
[~,~,~] = process_scandata(g_data,Nvar,vrange,'plot');
% end
end
fm=f1;
......
......@@ -32,7 +32,7 @@ end
%% evaluate the objective function:
% get the current values. if the change is too large, do it in steps
pact=cellfun(@(d)gettangoval(d),attributenames(devopt))';
maxchange=0.1;
maxchange=2;
if max(abs(p-pact))>maxchange
......@@ -67,7 +67,7 @@ else
end
% wait power supply
pause(2);
pause(.5);
obj=getTotalLosses(averagingtime);
......
......@@ -2,13 +2,13 @@ function [names,vrange,cellnamerange]=attributenames(typedevice)
% [names,range]=attributenames(typedevice)
%
% list attribute names and possible ranges for typedevice:
% sextcor, SF2cor, skewcor,
% sextcor, SF2cor, skewcor,
%
%see also:
switch typedevice
case 'injsextcor'
case 'injsextcor'
% +/- 2 A
sxt = tango.Attribute('srmag/m-s/all/Strengths');
......@@ -30,7 +30,7 @@ switch typedevice
cellnamerange=magnames;
case 'sextcor'
% +/- 2 A
......@@ -51,36 +51,39 @@ switch typedevice
% +/- 2 A
sxt = tango.Attribute('srmag/m-s/all/Strengths');
names = sxt.device.MagnetNames.read;
names = sxt.device.MagnetNames.read;
K = sxt.value;
magnames={};
indsxt = 1:length(names);
for is = sort(indsxt([2:6:end,5:6:end]))
magnames = [magnames,{[names{is} '/Strength'];[-0.2 +0.2]+K(is)}];
magnames = [magnames,{[names{is} '/Strength'];[-0.3 +0.3]+K(is)}];
end
cellnamerange=magnames;
case 'Debug_2Var'
case 'Debug_2Var'
% +/- 2 A
sxt = tango.Attribute('srmag/m-s/all/Strengths');
names = sxt.device.MagnetNames.read;
names = sxt.device.MagnetNames.read;
K = sxt.value;
magnames={};
indsxt = 1:length(names);
for is = sort(indsxt([2,191]))
magnames = [magnames,{[names{is} '/Strength'];[-0.2 +0.2]+K(is)}];
magnames = [magnames,{[names{is} '/Strength'];[-0.5 +0.5]+K(is)}];
end
cellnamerange=magnames;
case 'Sext3Fams'
case 'SF2cor_fast'
load('/mntdirect/_machfs/MDT/2020/2020_06_28/SextupolesOptimizations/SF2cor_names.mat')
case 'Sext3Fams'
% +/- 2 A
......@@ -88,7 +91,7 @@ switch typedevice
'srmag/m-sf2/all/DeltaCorrectionStrength',...
'srmag/m-sd1bd/all/DeltaCorrectionStrength'};
K=zeros(size(names));
magnames={};
indsxt = 1:length(names);
......@@ -103,18 +106,18 @@ switch typedevice
case 'quadcor'
% +/- 2 A
% +/- 2 A
% +/- 2 A
sxt = tango.Attribute('srmag/m-q/all/Strengths');
names = sxt.device.MagnetNames.read;
names = sxt.device.MagnetNames.read;
K = sxt.value;
magnames={};
indsxt = 1:length(names);
for is = indsxt
if strcmp(names{is}(1:9),'srmag/m-q')
magnames = [magnames,{[names{is} '/Strength'];[0.98 1.02]*K(is)}];
magnames = [magnames,{[names{is} '/Strength'];[0.98 1.02]*K(is)}];
end
end
......@@ -127,7 +130,7 @@ switch typedevice
% +/- 2 A
sxt = tango.Attribute('srmag/m-q/all/Strengths');
names = sxt.device.MagnetNames.read;
names = sxt.device.MagnetNames.read;
K = sxt.value;
magnames={};
indsxt = 1:length(names);
......@@ -139,7 +142,7 @@ switch typedevice
cellnamerange=magnames;
case 'Quad7Fams'
case 'Quad7Fams'
% +/- 2 A
......@@ -152,29 +155,29 @@ switch typedevice
'srmag/m-qf8/all/DeltaCorrectionStrength'};
K=zeros(size(names));
magnames={};
indsxt = 1:length(names);
for is = sort(indsxt)
magnames = [magnames,{names{is};[-0.001 0.001]}];
magnames = [magnames,{names{is};[-0.001 0.001]}];
end
cellnamerange=magnames;
case 'quadres'
cellnamerange=resnames;
case 'skewres'
cellnamerange=resnames;
case 'sextres'
cellnamerange=resnames;
case 'skewcor'
......@@ -188,8 +191,8 @@ switch typedevice
for is = indsxt
if strcmp(names{is}(1:9),'srmag/sqp')
magnames = [magnames,{[names{is} '/Strength'];[-0.0004 0.0004]}];
magnames = [magnames,{[names{is} '/Strength'];[-0.0004 0.0004]}];
end
end
......@@ -208,14 +211,14 @@ switch typedevice
for is = indsxt
if strcmp(names{is}(1:9),'srmag/sqp')
magnames = [magnames,{[names{is} '/Strength'];[-0.0004 0.0004]}];
magnames = [magnames,{[names{is} '/Strength'];[-0.0004 0.0004]}];
end
end
cellnamerange=magnames;
case 'injcor'
injcorfamnames=[...
......@@ -246,7 +249,7 @@ switch typedevice
{'TL2/PS-C1/cv9';[-8,8]},...
];
cellnamerange=injcorfamnames;
case 'injcorlast'
[~,~,cellnamerange]=attributenames('injcor');
......@@ -325,7 +328,7 @@ switch typedevice
[~,~,cnr3]=attributenames('injsep');
cellnamerange=[cnr1 cnr2 cnr3];
case 'injXYXpYp'
[~,~,cnr1]=attributenames('injcorlast2V');
......
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