Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 1 addition & 23 deletions atmat/atphysics/LongitudinalDynamics/BunchLength.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
% sigmadelta is the energy spread
% circ is the ring circumference
%
% see also: atBunchLength
% see also: atBunchLength, blgrowth

blg = abs(blgrowth(Ib,Zn,Vrf,U0,E0,h,alpha,sigdelta));
phi=pi - asin(U0./Vrf);
Expand All @@ -24,26 +24,4 @@
BL = zcBL .* blg;
end

function blg = blgrowth(Ib,Zn,Vrf,U0,E0,h,alpha,sigdelta)
% bunch lengthening factor due to the potential well effect

% Ib is the bunch current [A] (it may be a vector for multiple values)
% Zn is the longitudinal broadband impedance [Ohms]
% Vrf is the RF voltage [V] (it may be a vector for multiple values)
% U0 is the energy loss around the ring [eV]
% h is the harmonic number
% alpha is the momentum compaction factor
% sigmadelta is the energy spread

phi=pi - asin(U0./Vrf);
nus= sqrt(-(Vrf/E0).*(h * alpha)/(2*pi) .* cos(phi));

Delta = -(2*pi*Ib*Zn)./(Vrf*h.*cos(phi).*(alpha*sigdelta./nus).^3);
Q=Delta/(4*sqrt(pi));



blg = (2/3)^(1/3)./(9*Q + sqrt(3)*sqrt(-4+27*Q.^2)).^(1/3)...
+ (9*Q + sqrt(3)*sqrt(-4+27*Q.^2)).^(1/3)./(2^(1/3)*3^(2/3));
end

28 changes: 20 additions & 8 deletions atmat/atphysics/LongitudinalDynamics/atBunchLength.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,29 @@
%
% Ib is the bunch current [A] (it may be a vector for multiple values)
% Zn is the longitudinal broadband impedance [Ohms]
% ring is the at ring without radiation
% ring is the at lattice (4D or 6D)
%
% BL is the bunch length in metres
%
% see also: BunchLength
% see also: BunchLength, blgrowth

rp=ringpara(ring);
[E0,~,Vrf,h,U0]=atenergy(ring);
alpha=rp.alphac;
sigdelta=rp.sigma_E;
is6d=check_6d(ring);
circ=findspos(ring,length(ring)+1);

BL = BunchLength(Ib,Zn,Vrf,U0,E0,h,alpha,sigdelta,circ);

if ~is6d
[E0,~,Vrf,h,U0]=atenergy(ring);
rp=ringpara(ring);
alpha=rp.alphac;
sigdelta=rp.sigma_E;
BL = BunchLength(Ib,Zn,Vrf,U0,E0,h,alpha,sigdelta,circ);
else
[~,ringdata]=atx(ring,1);
[~,~,Vrf,h]=atenergy(ring);
alpha = ringdata.alpha;
E0 = ringdata.energy;
U0 = ringdata.eloss;
sigdelta = ringdata.espread;
bl0 = ringdata.blength;
BL = bl0 * blgrowth(Ib,Zn,Vrf,U0,E0,h,alpha,sigdelta);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some possible optimizations here:
alpha -> mcf(disable_6d(ring))
energy, vrf, h -> atGetRingProperties
sigdelta, bl0 -> ohmi_envelope
U0 -> atgetU0(ring, 'method', 'tracking')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On top of @swhite2401 proposal:

is6d and alpha are also available through atGetRingProperties. Asking for is6d, Vrf, E0, h, alpha and circ in one call (before the if test) minimises the number of passes through the lattice. Be careful to use the "single cell" attributes: cell_rf_voltage, cell_harmnumber, cell_length.

You could also get both bl0 and sigdelta from ringpara and completely forget BunchLength.

end
end
27 changes: 27 additions & 0 deletions atmat/atphysics/LongitudinalDynamics/blgrowth.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function blg = blgrowth(Ib,Zn,Vrf,U0,E0,h,alpha,sigdelta)
% blg = blgrowth(Ib,Zn,Vrf,U0,E0,h,alpha,sigdelta)
%
% bunch lengthening factor due to the potential well effect
%
% Ib is the bunch current [A] (it may be a vector for multiple values)
% Zn is the longitudinal broadband impedance [Ohms]
% Vrf is the RF voltage [V] (it may be a vector for multiple values)
% U0 is the energy loss around the ring [eV]
% h is the harmonic number
% alpha is the momentum compaction factor
% sigmadelta is the energy spread
%
% see also: atBunchLength, BunchLength
%

phi=pi - asin(U0./Vrf);
nus= sqrt(-(Vrf/E0).*(h * alpha)/(2*pi) .* cos(phi));

Delta = -(2*pi*Ib*Zn)./(Vrf*h.*cos(phi).*(alpha*sigdelta./nus).^3);
Q=Delta/(4*sqrt(pi));



blg = (2/3)^(1/3)./(9*Q + sqrt(3)*sqrt(-4+27*Q.^2)).^(1/3)...
+ (9*Q + sqrt(3)*sqrt(-4+27*Q.^2)).^(1/3)./(2^(1/3)*3^(2/3));
end