InitEbsSimulator.m 4.2 KB
Newer Older
1
function InitEbsSimulator(obj)
Simone Liuzzo's avatar
Simone Liuzzo committed
2
3
4
5
6
7
8
9
10
11
12
13
%SWITCHTOEBSSIMULATOR turns parameters of First2Turns class to EBS
%simulator
%
% 
%
%see also: First2Turns


TANGO_HOST='tango://ebs-simu:10000/';

%ft = First2Turns;

Simone Liuzzo's avatar
Simone Liuzzo committed
14
obj.MeasurementFolder = pwd;
Simone Liuzzo's avatar
Simone Liuzzo committed
15
16
obj.first_turn_index = 1;

Simone Liuzzo's avatar
Simone Liuzzo committed
17
18
19
20
21
22
23
24
25
26
27
28
%% moovable objects
obj.ke      = moovable(''); % moovable('sy/ps-ke/1'); 
obj.gun     = moovable(''); % 'elin/beam/run';%% missing
obj.rips    = moovable('');
obj.scraper = moovable('');
obj.s12     = moovable('');
obj.s3      = moovable('');
obj.cv8     = moovable('');
obj.cv9     = moovable('');
obj.sh      = moovable([TANGO_HOST 'srmag/hst/all/Strengths'],'absolute',true,'limits',[-3e-4 3e-4]);
obj.sv      = moovable([TANGO_HOST 'srmag/vst/all/Strengths'],'absolute',true,'limits',[-3e-4 3e-4]);
obj.rf      = moovable([TANGO_HOST 'srrf/master-oscillator/1/Frequency'],'absolute',false,'limits',[0.99 1.01]);
29
30
31
obj.quad    = moovable([TANGO_HOST 'srmag/m-q/all/CorrectionStrengths']);
obj.sext    = moovable([TANGO_HOST 'srmag/m-s/all/CorrectionStrengths']);
obj.octu    = moovable([TANGO_HOST 'srmag/m-o/all/CorrectionStrengths']);
Simone Liuzzo's avatar
Simone Liuzzo committed
32

Simone Liuzzo's avatar
Simone Liuzzo committed
33
34
35
%% diagnostics
obj.stored_current = [TANGO_HOST 'srdiag/beam-current/total/Current'];

Simone Liuzzo's avatar
Simone Liuzzo committed
36
37
obj.hor_bpm_TBT = [TANGO_HOST 'srdiag/beam-position/all/TBT_HPositions'];
obj.ver_bpm_TBT = [TANGO_HOST 'srdiag/beam-position/all/TBT_VPositions'];
38
obj.initial_coordinates = [TANGO_HOST 'sys/ringsimulator/ebs/TbT_InCoord'];
Simone Liuzzo's avatar
Simone Liuzzo committed
39
40
obj.sum_bpm_TBT = [];

Simone Liuzzo's avatar
Simone Liuzzo committed
41
42
obj.hor_bpm_SA = [TANGO_HOST 'srdiag/beam-position/all/SA_HPositions'];
obj.ver_bpm_SA = [TANGO_HOST 'srdiag/beam-position/all/SA_VPositions'];
Simone Liuzzo's avatar
Simone Liuzzo committed
43
44
obj.sum_bpm_SA = [];

45
46
obj.bpm_trigger_counter = 'sys/ringsimulator/ebs/Counter';

Simone Liuzzo's avatar
Simone Liuzzo committed
47
48
49
50
51
52
53
obj.status_bpm ='srdiag/beam-position/all/All_Status'; % BPM status (0 means no error, so ok)
obj.state_hst ='srmag/hst/all/CorrectorStates'; % H steerer status (ON OFF FAULT,...)
obj.state_vst ='srmag/vst/all/CorrectorStates'; % V steerer status (ON OFF FAULT,...)
obj.orbit_cor_disabled_bpm ='sr/beam-orbitcor/svd-h/DisabledBPMsIndex'; % H steerer not in orbit correction
obj.orbit_cor_disabled_hst ='sr/beam-orbitcor/svd-h/DisabledActuatorsIndex'; % H steerer not in orbit correction
obj.orbit_cor_disabled_vst ='sr/beam-orbitcor/svd-v/DisabledActuatorsIndex'; % V steerer not in orbit correction

54
55
56
57
%load reference sum signal
obj.sum_signal_beam = ones(1,320); % sum signal with beam (sensitivity of each BPM)
obj.sum_signal_background = zeros(1,320);

58
59
60
61
62
63
obj.h_tune = [TANGO_HOST 'srdiag/beam-tune/1/Tune_h'];
obj.v_tune = [TANGO_HOST 'srdiag/beam-tune/1/Tune_v'];
obj.h_emittance = [TANGO_HOST 'srdiag/emittance/id07/Emittance_h'];
obj.v_emittance = [TANGO_HOST 'srdiag/emittance/id07/Emittance_v'];
obj.lifetime = [TANGO_HOST 'srdiag/beam-current/total/Lifetime'];

Simone Liuzzo's avatar
Simone Liuzzo committed
64
%% lattice related informations
Simone Liuzzo's avatar
Simone Liuzzo committed
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
kick = [...
    0.000489845903684   0.000426168812966   0.000426168820758   0.000489845969593;... -1 mm
    0.002451840946955   0.002131227999229   0.002131228196820   0.002451842601757;... -5 mm
    0.004910225944962   0.004263696516143   0.004263697305621   0.004910232596004;... -10 mm
    0.007375181085586   0.006397873450655   0.006397875223752   0.007375196110139]; % -15 mm

% - 10mm kickers bump
K3 = 0.0;% kick(3,3);
K4 = 0.0;% kick(3,4);

obj.kick = kick;
obj.K3 = K3;
obj.K4 = K4;
obj.injoff = -0.0060; % set simulator TbT input to [injoff, 0,0,0,0,0]

80
mod = ebs.model('reduce',true,'keep','QF8D');
81
ring = mod.ring;
82
83
84
obj.indBPM = mod.get(0,'bpm')';
obj.indHst = sort([mod.get(0,'steerh'); mod.get(0,'dq')])';
obj.indVst = mod.get(0,'steerv')';
85

86
87
88
89
90
91
92
% mae sure steerers have KickAngle.
ring = atsetfieldvalues(ring,obj.indHst,'KickAngle',{1,1},0);
ring = atsetfieldvalues(ring,obj.indHst,'KickAngle',{1,2},0);
ring = atsetfieldvalues(ring,obj.indVst,'KickAngle',{1,1},0);
ring = atsetfieldvalues(ring,obj.indVst,'KickAngle',{1,2},0);

% quadrupole indexes (BAD FOR QF8D of 2PW cells)
93
94
qpind = mod.get(0,'qp');
qf8dind = mod.get(0,'qf8d');
95
obj.indQuad=sort([qpind; qf8dind(1:50:end)])';
96

97
98
99
obj.indSext = mod.get(0,'sx');
obj.indOctu = mod.get(0,'oc');

Simone Liuzzo's avatar
Simone Liuzzo committed
100
obj.rmodel = ring;
Simone Liuzzo's avatar
Simone Liuzzo committed
101

Simone Liuzzo's avatar
Simone Liuzzo committed
102
103
104
105
106

obj.tl2model ={};

try
    %% set up simulator
107
    attr = tango.Attribute(obj.initial_coordinates);    attr.set = [obj.injoff, 0,0,0,0,0];
Simone Liuzzo's avatar
Simone Liuzzo committed
108
109
110
111
112
113
catch err
    disp(err)
    error('Impossible to set off axis injection in simulator. Is Tango Available? (raki, CTRM)')
end

end