Skip to content

Commit 4ede264

Browse files
committed
Clean end simulation
1 parent 2248fe3 commit 4ede264

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

ring_of_CPUs_multiturn.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ def __init__(self, sim_content, N_pieces_per_transfer=1, force_serial = False, c
5757

5858
if hasattr(sim_content, 'N_parellel_rings'):
5959
self.N_parellel_rings = sim_content.N_parellel_rings
60+
61+
if int(np.mod(self.N_turns, self.N_parellel_rings)) != 0.:
62+
raise ValueError('Sorry! N_turns needs to be a multiple of N_parellel_rings!')
6063

6164
if hasattr(sim_content, 'verbose'):
6265
self.verbose = sim_content.verbose
@@ -222,11 +225,15 @@ def run(self):
222225

223226
self.sim_content.perform_bunch_operations_at_start_ring(next_bunch)
224227

228+
if next_bunch.slice_info['i_bunch'] == next_bunch.slice_info['N_bunches_tot_beam']-1:
229+
if int(next_bunch.slice_info['i_turn']) >= self.N_turns:
230+
orders_from_master.append('stop')
231+
if self.I_am_a_worker:
232+
raise ValueError('I cannot give orders to anybody :-(')
233+
225234
next_bunch.slice_info['i_turn']+=1
226-
self.slices_to_be_treated = self.sim_content.slice_bunch_at_start_ring(next_bunch)
227-
228-
if next_bunch.slice_info['i_turn'] > self.N_turns:
229-
orders_from_master.append('stop')
235+
if next_bunch.slice_info['i_turn'] <= self.N_turns:
236+
self.slices_to_be_treated = self.sim_content.slice_bunch_at_start_ring(next_bunch)
230237

231238
# Pop slices
232239
slice_group = []

0 commit comments

Comments
 (0)