diff --git a/atmat/atphysics/LongitudinalDynamics/BunchLength.m b/atmat/atphysics/LongitudinalDynamics/BunchLength.m index dabdeee5a..fa9246bff 100755 --- a/atmat/atphysics/LongitudinalDynamics/BunchLength.m +++ b/atmat/atphysics/LongitudinalDynamics/BunchLength.m @@ -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); @@ -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 diff --git a/atmat/atphysics/LongitudinalDynamics/atBunchLength.m b/atmat/atphysics/LongitudinalDynamics/atBunchLength.m index 5a4f79cc0..d94e6fd70 100755 --- a/atmat/atphysics/LongitudinalDynamics/atBunchLength.m +++ b/atmat/atphysics/LongitudinalDynamics/atBunchLength.m @@ -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); +end end diff --git a/atmat/atphysics/LongitudinalDynamics/blgrowth.m b/atmat/atphysics/LongitudinalDynamics/blgrowth.m new file mode 100644 index 000000000..e9ee38c47 --- /dev/null +++ b/atmat/atphysics/LongitudinalDynamics/blgrowth.m @@ -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