diff --git a/mbtrack2/instability/instabilities.py b/mbtrack2/instability/instabilities.py index 275faa687e92b7076ed78209ca60435ab31a59f8..c67bc2205ce9b1de9642ed7c18f4210d128be374 100644 --- a/mbtrack2/instability/instabilities.py +++ b/mbtrack2/instability/instabilities.py @@ -456,7 +456,7 @@ def rwmbi_threshold(ring, beff, rho_material, plane='x'): return Ith -def transverse_space_charge_tune_shift(ring, bunch_current, **kwargs): +def transverse_gaussian_space_charge_tune_shift(ring, bunch_current, **kwargs): """ Return the (maximum) transverse space charge tune shift for a Gaussian bunch in the linear approximation, see Eq.(1) of [1]. @@ -480,6 +480,9 @@ def transverse_space_charge_tune_shift(ring, bunch_current, **kwargs): If True, use beta fonctions along the lattice. If False, local values of beta fonctions are used. Default is ring.optics.use_local_values. + n_points : int, optional + Number of points in the lattice to be considered if use_lattice == + True. Default is 1000. sigma_delta : float, optional Relative energy spread. Default is ring.sigma_delta. @@ -505,15 +508,15 @@ def transverse_space_charge_tune_shift(ring, bunch_current, **kwargs): use_lattice = kwargs.get('use_lattice', not ring.optics.use_local_values) sigma_delta = kwargs.get('sigma_delta', ring.sigma_delta) gamma = kwargs.get('gamma', ring.gamma) - - q = np.abs(ring.particle.charge) + n_points = kwargs.get('n_points', 1000) + q = ring.particle.charge m = ring.particle.mass r_0 = 1 / (4*pi*epsilon_0) * q**2 / (m * c**2) - N = bunch_current / ring.f0 / q + N = np.abs(bunch_current / ring.f0 / q) sigma_z = sigma_s * c if use_lattice: - s = np.linspace(0, ring.L, 1000) + s = np.linspace(0, ring.L, n_points) beta = ring.optics.beta(s) sig_x = (emit_x * beta[0] + ring.optics.dispersion(s)[0]**2 * sigma_delta**2)**0.5