1 | function sweepenergy(PercentChangeInEnergy) |
---|
2 | %SWEEPENERGY - Energy sweep of the storage ring |
---|
3 | % sweepenergy(PercentChangeInEnergy) |
---|
4 | % sweepenergy( .1: .2: 1.1) ramps up .1 to 1.1 percent in .002 GeV steps |
---|
5 | % sweepenergy(-.1:-.2:-1.1) ramps down .1 to 1.1 percent in -.002 GeV steps |
---|
6 | % |
---|
7 | % This function starts at the present online lattice and |
---|
8 | % leaves the lattice at the last energy step. |
---|
9 | % |
---|
10 | |
---|
11 | % |
---|
12 | % Written by Gregory J. Portmann |
---|
13 | |
---|
14 | % PercentChangeInEnergy = .1:.2:1.1; |
---|
15 | |
---|
16 | |
---|
17 | % Get starting lattice |
---|
18 | SPstruct = getmachineconfig; |
---|
19 | SPcell = field2cell(SPstruct); |
---|
20 | |
---|
21 | SP = SPcell; |
---|
22 | |
---|
23 | % Set to simulator |
---|
24 | setmachineconfig(SPstruct, 'Simulator'); |
---|
25 | |
---|
26 | Energy0 = getsp('BEND', [1 1], 'Physics'); |
---|
27 | |
---|
28 | for i = 1:length(PercentChangeInEnergy) |
---|
29 | NewEnergy = Energy0 * (1 + PercentChangeInEnergy(i)/100); |
---|
30 | |
---|
31 | % Make the setpoint change w/o a WaitFlag |
---|
32 | for k = 1:length(SPcell) |
---|
33 | try |
---|
34 | if ismemberof(SPcell{k},'Magnet') |
---|
35 | SPcell{k}.Data = (1 + PercentChangeInEnergy(i)/100) * SP{k}.Data; |
---|
36 | setpv(SPcell{k}, 0); |
---|
37 | end |
---|
38 | catch |
---|
39 | fprintf(' Trouble with setsp(%s), hence ignored (sweepenergy)\n', SPcell{k}.FamilyName); |
---|
40 | %lasterr |
---|
41 | end |
---|
42 | end |
---|
43 | |
---|
44 | BEND = getsp('BEND', [1 1]); |
---|
45 | fprintf(' Changing energy to %f GeV (BEND=%f)\n', NewEnergy(1), BEND); |
---|
46 | |
---|
47 | % % Make the setpoint change with a WaitFlag |
---|
48 | % for k = 1:length(SPcell) |
---|
49 | % try |
---|
50 | % % Set with waiting |
---|
51 | % setpv(SPcell{k}, -1); |
---|
52 | % end |
---|
53 | % end |
---|
54 | |
---|
55 | fprintf(' Energy change to %f GeV complete\n', NewEnergy(1)); |
---|
56 | fprintf(' Hit return to continue (Ctrl-C to stop)\n\n'); |
---|
57 | pause |
---|
58 | end |
---|
59 | |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | |
---|
64 | % % Change the energy of the simulator |
---|
65 | % setsp('BEND', NewEnergy(1), 'Physics', 'Simulator'); |
---|
66 | % BENDsim = getsp('BEND', [1 1], 'Simulator', 'Hardware'); |
---|
67 | % |
---|
68 | % fprintf(' Changing energy to %f GeV (BEND=%f)\n', NewEnergy(1), BENDsim); |
---|
69 | % |
---|
70 | % % Get the simluator lattice at the new energy |
---|
71 | % SP = getmachineconfig('Simulator'); |
---|
72 | % |
---|
73 | % % Set to online accelerator |
---|
74 | % setmachineconfig(SP, 'Online'); |
---|