Title: BB-Diagnostics: Computer Class (Matlab/AT)
1BB-Diagnostics Computer Class (Matlab/AT)
Using Accelerator Tracking Code AT, Middle Layer
Software, and Response Matrix Fitting
- Christoph Steier with help from James Safranek
- Monday Intro to the Middle Layer and AT
- Orbit errors
- Tuesday
- Beam measurements using SPEAR 3
- Beta function, phase advance, beam based
alignment - Wednesday Gradient errors, LOCO
- Thursday Detuning with amplitude, decoherence,
resonances - Friday TBD
2Starting Matlab
- Start Matlab 2008a (7.6) (AT and LOCO require at
least Matlab version 7.x) - Matlab 7.6 is the
latest version. - Matlab middle layer is installed on the computers
in the first 3 rows in the computer room - I already have preset c\bbdiag\acceleratorcontrol
\mml on the Matlab path, this directory contains
many routines, including the ones that set up
memory structures and Matlab path for different
accelerators - setpathals
- setpathspear3
- setpathxray
- setpathvuv
- And many others
- cd c\bbdiag here we will put all the examples
of this class you can get the example file for
the day from http//als.lbl.gov/als_physics/csteie
r/uspas08/computerclass.html - Note When in doubt, setpathals (or spear3, )
will also restore the default lattice.
3Tuesday Gradient Errors
Add the perturbed beta to figure(1) figure(1)
subplot(2,2,1) hold on plot(MuX0, BetaX1,
'r') subplot(2,2,3) hold on plot(MuY0,
BetaY1, 'r') subplot(2,2,2) hold on
plot(MuX0, MuX1/(2pi) , 'r') subplot(2,2,4)
hold on plot(MuY0, MuY1/(2pi) , 'r') Plot
beta beat figure(2) subplot(2,2,1) plot(s,
BetaX1./BetaX0) xlabel('s m') title('Beta
Beat from the Nominal Model') subplot(2,2,2)
plot(s, BetaY1./BetaY0) xlabel('s
m') subplot(2,2,3) plot(MuX0,
BetaX1./BetaX0) xlabel('\mu_x
2\pi') subplot(2,2,4) plot(MuY0,
BetaY1./BetaY0) xlabel('\mu_y 2\pi')
Restore the lattice setsp('QF', qf, 7 1)
- Plot the beta function and phase advance for
the - nominal model and a model with a gradient
error - setpv('BPMx','Status',1,1 76 2)
- setpv('BPMy','Status',1,1 76 2)
- Get beta phase at all elements in the AT
model (Middle Layer) - Tune0 gettune
- BetaX0, BetaY0, s modeltwiss('Beta')
- MuX0, MuY0 modeltwiss('Phase')
- Plot beta vs. position
- figure(1) clf
- subplot(2,2,1) plot(MuX0, BetaX0, 'b')
ylabel('Beta X') - subplot(2,2,3) plot(MuY0, BetaY0, 'b')
ylabel('Beta Y') - subplot(2,2,2) plot(MuX0, MuX0/(2pi) , 'b')
ylabel('Phase X') - subplot(2,2,4) plot(MuY0, MuY0/(2pi) , 'b')
ylabel('Phase Y') - Perturb the lattice at 1 quadrupole, QF(7,1)
4Tuesday FFT Analyze
- Simulate a phase advance measurement
- Get the orbit, beta, and phase at all elements
in the AT model (Middle Layer) - Tune0 gettune
- BetaX0, BetaY0, s modeltwiss('Beta',
'BPMx') - MuX0, MuY0 modeltwiss('Phase', 'BPMx')
- Starting condition or tracking (0.1mm)
- X0 0.0001 0 0.0001 0 0 0
- Track for 1024 turns
- global THERING
- X1 ringpass(THERING, X0, 1024)
- size(X1)
- Track coordinates for every turn along the
ring (to all BPMs) - BPMindex findcells(THERING, 'FamName', 'BPM')
- BPM findorbit4(THERING, 0.0, BPMindex)
- X2 linepass(THERING, X1, BPMindex)
- size(X2)
- Recover matrix structure (turns x BPM)
5Tuesday FFT Analyze
- Calculate fractional tunes (interpolating FFT,
sine window) - nux, nuy, ax, ay findfreq(BPMx, BPMy)
- Calculate phase at every BPM
- (integral convolution with sine and cosine
trajectories) - MuX, MuY calcphase(nux, nuy, BPMx, BPMy)
- Calcphase asks for a frequency, typically just
accepting - the precalculated result is fine.
- Compare the 'measured' phase advance with the
computed nominal one. - DeltaMuX MuX()-MuX0/(2pi)
- DeltaMuY MuY()-MuY0/(2pi)
- figure(2)
- subplot(2,1,1)
- plot(MuX0, DeltaMuX-DeltaMuX(1), '.-b')
- subplot(2,1,2)
- plot(MuY0, DeltaMuY-DeltaMuY(1), '.-b')
6Tuessday FFT Analyze
- Add noise to the BPM data and recalculation the
phase - BPMxNoise BPMx 5e-6randn(size(BPMx))
- BPMyNoise BPMy 5e-6randn(size(BPMy))
- Calculate fractional tunes (interpolating FFT,
sine window) - nux, nuy, ax, ay findfreq(BPMxNoise ,
BPMyNoise) - Calculate phase at every BPM
- (integral convolution with sine and cosine
trajectories) - MuXnoise, MuYnoise calcphase(nux, nuy,
BPMxNoise, BPMyNoise) - Calcphase asks for a frequency, typically just
accepting - the precalculated result is fine.
- Compare the 'measured' phase advance with the
computed nominal one. - DeltaMuX MuXnoise()-MuX0/(2pi)
- DeltaMuY MuYnoise()-MuY0/(2pi)
- figure(2)
- subplot(2,1,1) hold on
7Tuessday FFT Analyze
- Now put a quadrupole error in the lattice and
repeat - steppv('QF',1,6 1)
- Track for 1024 turns
- X1 ringpass(THERING, X0, 1024)
- Track coordinates for every turn along the
ring (to all BPMs) - X2 linepass(THERING, X1, BPMindex)
- Recover matrix structure (turns x BPM)
- BPMx reshape(X2(1,), 1024, 122)
- BPMy reshape(X2(3,), 1024, 122)
- Add noise to the BPM data and recalculation the
phase - BPMxNoise BPMx 5e-6randn(size(BPMx))
- BPMyNoise BPMy 5e-6randn(size(BPMy))
- Calculate fractional tunes (interpolating FFT,
sine window) - nux, nuy, ax, ay findfreq(BPMxNoise ,
BPMyNoise) - Calculate phase at every BPM
- (integral convolution with sine and cosine
trajectories) - MuXnoise, MuYnoise calcphase(nux, nuy,
BPMxNoise, BPMyNoise) - Calcphase asks for a frequency, typically just
accepting - the precalculated result is fine.
8Tuesday Quadrupole Centers
- Beam based measurement of quadrupole centers
- quadcenter
- ? QF
- ? QF(7,1)
- ? Vertical only
- Note your data got put in c\bbdiag\accelerator
control\machine\ALS\StorageRingData\TopOff\QMS - quadplot