Skip to content
Snippets Groups Projects
Commit 4c53c299 authored by Teresia Olsson's avatar Teresia Olsson
Browse files

Fix of bin length calculation with 1 slice for MPI and init_phasor.

parent 6a3e482b
Branches use-one-bin
No related tags found
2 merge requests!20Turn off quantum excitation,!19Draft: Use one bin in CavityResonator
......@@ -389,13 +389,14 @@ class CavityResonator():
# get shared bunch profile for current bunch
center = beam.mpi.tau_center[j]
profile = beam.mpi.tau_profile[j]
bin_length = center[1] - center[0]
bin_length = beam.mpi.tau_bin_length[j]
charge_per_mp = beam.mpi.charge_per_mp_all[j]
else:
if i == 0:
# get bunch profile for current bunch
(bins, sorted_index, profile,
center) = bunch.binning(n_bin=self.n_bin)
bin_length = bins[1] - bins[0]
if j == 0:
self.profile_save = np.zeros((
len(beam),
......@@ -405,13 +406,17 @@ class CavityResonator():
len(beam),
len(center),
))
self.bin_length_save = np.zeros(
(len(beam), len(bin_length)))
self.profile_save[j, :] = profile
self.center_save[j, :] = center
self.bin_length_save[j, :] = bin_length
else:
profile = self.profile_save[j, :]
center = self.center_save[j, :]
bin_length = self.bin_length_save[j, :]
bin_length = center[1] - center[0]
charge_per_mp = bunch.charge_per_mp
self.phasor_decay(center[0] - bin_length/2, ref_frame="rf")
......@@ -511,13 +516,14 @@ class CavityResonator():
if self.tracking is False:
self.init_tracking(beam)
N = self.n_bin - 1
N = self.n_bin
delta = (self.wr - self.m * self.ring.omega1)
n_turn = int(self.filling_time / self.ring.T0 * 10)
T = np.ones(self.ring.h) * self.ring.T1
bin_length = np.zeros(self.ring.h)
charge_per_mp = np.zeros(self.ring.h)
bins = np.zeros((N + 1, self.ring.h))
profile = np.zeros((N, self.ring.h))
center = np.zeros((N, self.ring.h))
......@@ -528,12 +534,12 @@ class CavityResonator():
beam.mpi.share_distributions(beam, n_bin=self.n_bin)
center[:, index] = beam.mpi.tau_center[j]
profile[:, index] = beam.mpi.tau_profile[j]
bin_length[index] = center[1, index] - center[0, index]
bin_length[index] = beam.mpi.bin_length[j]
charge_per_mp[index] = beam.mpi.charge_per_mp_all[j]
else:
(bins, sorted_index, profile[:, index],
(bins[:, index], sorted_index, profile[:, index],
center[:, index]) = bunch.binning(n_bin=self.n_bin)
bin_length[index] = center[1, index] - center[0, index]
bin_length[index] = bins[1, index] - bins[0, index]
charge_per_mp[index] = bunch.charge_per_mp
T[index] -= (center[-1, index] + bin_length[index] / 2)
if index != 0:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment