@@ -30,7 +30,7 @@ def init_all(self):
3030 self .n_kick_smooth = pp .n_segments
3131
3232 # define the machine
33- from LHC_custom import LHC
33+ from . LHC_custom import LHC
3434 self .machine = LHC (
3535 n_segments = pp .n_segments ,
3636 machine_configuration = pp .machine_configuration ,
@@ -181,10 +181,10 @@ def init_all(self):
181181 i_start_part , i_end_part = sharing .my_part (myid )
182182 self .mypart = self .machine .one_turn_map [i_start_part :i_end_part ]
183183 if self .ring_of_CPUs .I_am_a_worker :
184- print 'I am id=%d/%d (worker) and my part is %d long' % (myid , self .ring_of_CPUs .N_nodes , len (self .mypart ))
184+ print ( 'I am id=%d/%d (worker) and my part is %d long' % (myid , self .ring_of_CPUs .N_nodes , len (self .mypart ) ))
185185 elif self .ring_of_CPUs .I_am_the_master :
186186 self .non_parallel_part = self .machine .one_turn_map [i_end_parallel :]
187- print 'I am id=%d/%d (master) and my part is %d long' % (myid , self .ring_of_CPUs .N_nodes , len (self .mypart ))
187+ print ( 'I am id=%d/%d (master) and my part is %d long' % (myid , self .ring_of_CPUs .N_nodes , len (self .mypart ) ))
188188
189189 #install eclouds in my part
190190 my_new_part = []
@@ -248,7 +248,7 @@ def init_all(self):
248248 self .mypart = my_new_part
249249
250250 if pp .footprint_mode :
251- print 'Proc. %d computing maps' % myid
251+ print ( 'Proc. %d computing maps' % myid )
252252 # generate a bunch
253253 bunch_for_map = self .machine .generate_6D_Gaussian_bunch_matched (
254254 n_macroparticles = pp .n_macroparticles_for_footprint_map , intensity = pp .intensity ,
@@ -283,7 +283,7 @@ def init_all(self):
283283 else :
284284 for ss in slices_list_for_map :
285285 ele .track (ss )
286- print 'Proc. %d done with maps' % myid
286+ print ( 'Proc. %d done with maps' % myid )
287287
288288 with open ('measured_optics_%d.pkl' % myid , 'wb' ) as fid :
289289 pickle .dump ({
@@ -322,10 +322,10 @@ def init_master(self):
322322 elif SimSt .first_run :
323323
324324 if pp .bunch_from_file is not None :
325- print 'Loading bunch from file %s ...' % pp .bunch_from_file
325+ print ( 'Loading bunch from file %s ...' % pp .bunch_from_file )
326326 with h5py .File (pp .bunch_from_file , 'r' ) as fid :
327327 self .bunch = self .buffer_to_piece (np .array (fid ['bunch' ]).copy ())
328- print 'Bunch loaded from file.\n '
328+ print ( 'Bunch loaded from file.\n ' )
329329
330330 else :
331331 self .bunch = self .machine .generate_6D_Gaussian_bunch_matched (
@@ -344,12 +344,12 @@ def init_master(self):
344344 self .bunch .x += x_kick
345345 self .bunch .y += y_kick
346346
347- print 'Bunch initialized.'
347+ print ( 'Bunch initialized.' )
348348 else :
349- print 'Loading bunch from file...'
349+ print ( 'Loading bunch from file...' )
350350 with h5py .File ('bunch_status_part%02d.h5' % (SimSt .present_simulation_part - 1 ), 'r' ) as fid :
351351 self .bunch = self .buffer_to_piece (np .array (fid ['bunch' ]).copy ())
352- print 'Bunch loaded from file.'
352+ print ( 'Bunch loaded from file.' )
353353
354354 # initial slicing
355355 self .slicer = UniformBinSlicer (n_slices = pp .n_slices , z_cuts = (- pp .z_cut , pp .z_cut ))
@@ -371,7 +371,7 @@ def init_master(self):
371371
372372 pieces_to_be_treated = slice_obj_list
373373
374- print 'N_turns' , self .N_turns
374+ print ( 'N_turns' , self .N_turns )
375375
376376 if pp .footprint_mode :
377377 self .recorded_particles = ParticleTrajectories (pp .n_macroparticles_for_footprint_track , self .N_turns )
@@ -413,7 +413,7 @@ def finalize_turn_on_master(self, pieces_treated):
413413 if not pp .footprint_mode and self .bunch .macroparticlenumber < pp .sim_stop_frac * pp .n_macroparticles :
414414 orders_to_pass .append ('stop' )
415415 self .SimSt .check_for_resubmit = False
416- print 'Stop simulation due to beam losses.'
416+ print ( 'Stop simulation due to beam losses.' )
417417
418418 # 2. for the emittance growth
419419 if pp .flag_check_emittance_growth :
@@ -422,7 +422,7 @@ def finalize_turn_on_master(self, pieces_treated):
422422 if not pp .footprint_mode and (self .bunch .epsn_x () > epsn_x_max or self .bunch .epsn_y () > epsn_y_max ):
423423 orders_to_pass .append ('stop' )
424424 self .SimSt .check_for_resubmit = False
425- print 'Stop simulation due to emittance growth.'
425+ print ( 'Stop simulation due to emittance growth.' )
426426
427427 return orders_to_pass , new_pieces_to_be_treated
428428
@@ -438,13 +438,13 @@ def finalize_simulation(self):
438438 # Tunes
439439
440440 import NAFFlib
441- print 'NAFFlib spectral analysis...'
441+ print ( 'NAFFlib spectral analysis...' )
442442 qx_i = np .empty_like (self .recorded_particles .x_i [:,0 ])
443443 qy_i = np .empty_like (self .recorded_particles .x_i [:,0 ])
444444 for ii in range (len (qx_i )):
445445 qx_i [ii ] = NAFFlib .get_tune (self .recorded_particles .x_i [ii ] + 1j * self .recorded_particles .xp_i [ii ])
446446 qy_i [ii ] = NAFFlib .get_tune (self .recorded_particles .y_i [ii ] + 1j * self .recorded_particles .yp_i [ii ])
447- print 'NAFFlib spectral analysis done.'
447+ print ( 'NAFFlib spectral analysis done.' )
448448
449449 # Save
450450 import h5py
@@ -460,7 +460,7 @@ def finalize_simulation(self):
460460 'y_centroid' : np .mean (self .recorded_particles .y_i , axis = 1 )}
461461
462462 with h5py .File ('footprint.h5' , 'w' ) as fid :
463- for kk in dict_beam_status .keys ():
463+ for kk in list ( dict_beam_status .keys () ):
464464 fid [kk ] = dict_beam_status [kk ]
465465 else :
466466 #save data for multijob operation and launch new job
0 commit comments