Skip to content

Commit 2f725f2

Browse files
Merge branch 'release/0.25.16'
2 parents 7cfefa9 + 434d2d8 commit 2f725f2

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

xfields/config_tools/spacecharge_config_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def install_spacecharge_frozen(line=None, _buffer=None,
125125
exclude_types_starting_with='SpaceCh')
126126

127127
line_sc_off.build_tracker()
128-
tw_at_sc = line_sc_off.twiss(particle_ref=particle_ref, at_elements=sc_names, method='4d')
128+
tw_at_sc = line_sc_off.twiss4d(particle_ref=particle_ref).rows[sc_names]
129129

130130
# Configure lenses
131131
for ii, sc in enumerate(sc_elements):

xfields/ibs/_analytical.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,10 @@ def coulomb_log(
351351
# and can be skewed by some very high peaks in the optics
352352
with warnings.catch_warnings(): # Catch and ignore the scipy.integrate.IntegrationWarning
353353
warnings.simplefilter("ignore", category=UserWarning)
354-
_bx_bar = quad(_bxb, self._twiss.s[0], self._twiss.s[-1])[0] / self._twiss.circumference
355-
_by_bar = quad(_byb, self._twiss.s[0], self._twiss.s[-1])[0] / self._twiss.circumference
356-
_dx_bar = quad(_dxb, self._twiss.s[0], self._twiss.s[-1])[0] / self._twiss.circumference
357-
_dy_bar = quad(_dyb, self._twiss.s[0], self._twiss.s[-1])[0] / self._twiss.circumference
354+
_bx_bar = quad(_bxb, self._twiss.s[0], self._twiss.s[-1])[0] / self._twiss.line_length
355+
_by_bar = quad(_byb, self._twiss.s[0], self._twiss.s[-1])[0] / self._twiss.line_length
356+
_dx_bar = quad(_dxb, self._twiss.s[0], self._twiss.s[-1])[0] / self._twiss.line_length
357+
_dy_bar = quad(_dyb, self._twiss.s[0], self._twiss.s[-1])[0] / self._twiss.line_length
358358
# ----------------------------------------------------------------------------------------------
359359
# Calculate transverse temperature as 2*P*X, i.e. assume the transverse energy is temperature/2
360360
# We need the total energy and the particle mass in GeV hence the 1e-9 below
@@ -373,7 +373,7 @@ def coulomb_log(
373373
if bunched is True: # bunched beam
374374
volume = 8.0 * np.sqrt(np.pi**3) * sigma_x_cm * sigma_y_cm * sigma_t_cm
375375
else: # coasting beam
376-
volume = 4.0 * np.pi * sigma_x_cm * sigma_y_cm * 100 * self._twiss.circumference
376+
volume = 4.0 * np.pi * sigma_x_cm * sigma_y_cm * 100 * self._twiss.line_length
377377
density = total_beam_intensity / volume
378378
debye_length = 743.4 * np.sqrt(TempeV / density) / abs(self._particle.q0)
379379
# ----------------------------------------------------------------------------------------------
@@ -610,9 +610,9 @@ def integrals(
610610
Sxp: ArrayLike = 3 * self._twiss.gamma0**2 * phix**2 * ax * (R3 - R2) / sqrt_term
611611
# ----------------------------------------------------------------------------------------------
612612
# These are the integrands of the integrals in Eq (30-32) in Nagaitsev paper
613-
Ix_integrand = self._twiss.betx / (self._twiss.circumference * sigx * sigy) * (Sx + Sp * (self._twiss.dx**2 / self._twiss.betx**2 + phix**2) + Sxp)
614-
Iy_integrand = self._twiss.bety / (self._twiss.circumference * sigx * sigy) * (R2 + R3 - 2 * R1)
615-
Iz_integrand = Sp / (self._twiss.circumference * sigx * sigy)
613+
Ix_integrand = self._twiss.betx / (self._twiss.line_length * sigx * sigy) * (Sx + Sp * (self._twiss.dx**2 / self._twiss.betx**2 + phix**2) + Sxp)
614+
Iy_integrand = self._twiss.bety / (self._twiss.line_length * sigx * sigy) * (R2 + R3 - 2 * R1)
615+
Iz_integrand = Sp / (self._twiss.line_length * sigx * sigy)
616616
# fmt: on
617617
# ----------------------------------------------------------------------------------------------
618618
# Integrating the integrands above accross the ring to get the desired results
@@ -739,7 +739,7 @@ class instead.
739739
"Using 'bunched=False' in this formalism makes the approximation of bunch length = C/(2*pi). "
740740
"Please use the Bjorken-Mtingwa formalism for a correct handling of Dy."
741741
)
742-
bunch_length: float = self._twiss.circumference / (2 * np.pi)
742+
bunch_length: float = self._twiss.line_length / (2 * np.pi)
743743
# ----------------------------------------------------------------------------------------------
744744
# Ensure we update the integrals have been computed beforehand
745745
_ = self.integrals(gemitt_x=gemitt_x, gemitt_y=gemitt_y, sigma_delta=sigma_delta)
@@ -869,7 +869,7 @@ def _Gamma(
869869
* gemitt_x
870870
* gemitt_y
871871
* sigma_delta
872-
* self._twiss.circumference
872+
* self._twiss.line_length
873873
)
874874

875875
def _a(self, gemitt_x: float, gemitt_y: float, sigma_delta: float) -> ArrayLike:
@@ -1666,9 +1666,9 @@ def calculate_integral_vectorized(func: Callable) -> ArrayLike:
16661666
LOGGER.debug("Getting average growth rates over the lattice")
16671667
with warnings.catch_warnings(): # Catch and ignore the scipy.integrate.IntegrationWarning
16681668
warnings.simplefilter("ignore", category=UserWarning)
1669-
Kx: float = float(quad(_kx, self._twiss.s[0], self._twiss.s[-1])[0] / self._twiss.circumference)
1670-
Ky: float = float(quad(_ky, self._twiss.s[0], self._twiss.s[-1])[0] / self._twiss.circumference)
1671-
Kz: float = float(quad(_kz, self._twiss.s[0], self._twiss.s[-1])[0] / self._twiss.circumference)
1669+
Kx: float = float(quad(_kx, self._twiss.s[0], self._twiss.s[-1])[0] / self._twiss.line_length)
1670+
Ky: float = float(quad(_ky, self._twiss.s[0], self._twiss.s[-1])[0] / self._twiss.line_length)
1671+
Kz: float = float(quad(_kz, self._twiss.s[0], self._twiss.s[-1])[0] / self._twiss.line_length)
16721672
emittance_rates = IBSEmittanceGrowthRates(Kx, Ky, Kz)
16731673
# ----------------------------------------------------------------------------------------------
16741674
# Important: the calculations of B&M yield emittance growth rates (this is what one gets in MAD-X

xfields/ibs/_equilibrium.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def get_ibs_and_synrad_emittance_evolution(
432432
# Initialize values for the iterative process (first time step is revolution period)
433433
iterations: float = 0
434434
tolerance: float = np.inf
435-
time_step: float = twiss.T_rev0
435+
time_step: float = twiss.t_rev0
436436
# Structures for iterative results (time, IBS growth rates, computed emittances)
437437
time_deltas: list[float] = [] # stores the deltas (!), we do a cumsum at the end
438438
K_x: list[float] = []

xfields/ibs/_kicks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def compute_kick_coefficients(self, particles: xt.Particles, **kwargs) -> IBSKic
386386
# (the particles.delta in Xsuite), we multiply by beta0**2 to adapt
387387
LOGGER.debug("Computing simple kick coefficients")
388388
beta0 = self._twiss.beta0
389-
revolution_frequency: float = 1 / self._twiss.T_rev0
389+
revolution_frequency: float = 1 / self._twiss.t_rev0
390390
Kx = float(sigma_px_normalized * np.sqrt(2 * scaling_factor * Tx / revolution_frequency))
391391
Ky = float(sigma_py_normalized * np.sqrt(2 * scaling_factor * Ty / revolution_frequency))
392392
Kz = float(sigma_delta * np.sqrt(2 * scaling_factor * Tz / revolution_frequency) * beta0**2)
@@ -578,7 +578,7 @@ def compute_kinetic_coefficients(
578578
beta0: float = self._twiss.beta0
579579
gamma0: float = self._twiss.gamma0
580580
radius: float = self._twiss.particle_on_co.get_classical_particle_radius0()
581-
circumference: float = self._twiss.circumference
581+
circumference: float = self._twiss.line_length
582582
betx = self._twiss.betx
583583
bety = self._twiss.bety
584584
dx = self._twiss.dx
@@ -680,7 +680,7 @@ def track(self, particles: xt.Particles) -> None:
680680
nplike = particles._context.nplike_lib
681681
# ----------------------------------------------------------------------------------------------
682682
# Compute delta_t for the turn and the line density (rho(z) term in Eq (19) of reference)
683-
dt: float = self._twiss.T_rev0
683+
dt: float = self._twiss.t_rev0
684684
rho_z: ArrayLike = line_density(particles, self.num_slices) # on context
685685
# ----------------------------------------------------------------------------------------------
686686
# TODO: Michalis wrote rho(z) in the paper but the way he had implemented it, it is actually

0 commit comments

Comments
 (0)