77#
88# This file is part of the code:
99#
10- # PyECLOUD Version 8.2 .0
10+ # PyECLOUD Version 8.4 .0
1111#
1212#
1313# Main author: Giovanni IADAROLA
5252
5353import numpy as np
5454from numpy .random import rand
55- import hist_for as histf
55+ from . import hist_for as histf
5656from scipy .constants import e , m_e
5757
5858
@@ -134,7 +134,7 @@ def __init__(self, N_mp_max, nel_mp_ref_0, fact_split, fact_clean,
134134
135135 def clean_small_MPs (self ):
136136
137- print "Cloud %s: Start clean. N_mp=%d Nel=%e" % (self .name , self .N_mp , np .sum (self .nel_mp [0 :self .N_mp ]))
137+ print ( "Cloud %s: Start clean. N_mp=%d Nel=%e" % (self .name , self .N_mp , np .sum (self .nel_mp [0 :self .N_mp ]) ))
138138
139139 flag_clean = (self .nel_mp < self .nel_mp_cl_th )
140140 flag_keep = ~ (flag_clean )
@@ -154,11 +154,11 @@ def clean_small_MPs(self):
154154 if self .flag_lifetime_hist :
155155 self .t_last_impact [0 :self .N_mp ] = np .array (self .t_last_impact [flag_keep ].copy ())
156156
157- print "Cloud %s: Done clean. N_mp=%d Nel=%e" % (self .name , self .N_mp , np .sum (self .nel_mp [0 :self .N_mp ]))
157+ print ( "Cloud %s: Done clean. N_mp=%d Nel=%e" % (self .name , self .N_mp , np .sum (self .nel_mp [0 :self .N_mp ]) ))
158158
159159 if self .N_mp == 0 :
160160 self .set_nel_mp_ref (self .nel_mp_ref_0 )
161- print ('Cloud %s: nel_mp_ref set to nel_mp_ref_0' % self .name )
161+ print (( 'Cloud %s: nel_mp_ref set to nel_mp_ref_0' % self .name ) )
162162
163163 def set_nel_mp_ref (self , val ):
164164 self .nel_mp_ref = val
@@ -176,7 +176,7 @@ def perform_soft_regeneration(self, target_N_mp):
176176 new_nel_mp_ref = self .nel_mp_ref_0
177177
178178 #if new_nel_mp_ref>self.nel_mp_ref_0:removed from version 3.16
179- print 'Cloud %s: Start SOFT regeneration. N_mp=%d Nel_tot=%1.2e En_tot=%1.2e' % (self .name , self .N_mp , chrg , erg )
179+ print ( 'Cloud %s: Start SOFT regeneration. N_mp=%d Nel_tot=%1.2e En_tot=%1.2e' % (self .name , self .N_mp , chrg , erg ) )
180180
181181 self .set_nel_mp_ref (new_nel_mp_ref )
182182
@@ -204,13 +204,13 @@ def perform_soft_regeneration(self, target_N_mp):
204204
205205 correct_fact = chrg_before / chrg_after
206206
207- print 'Cloud %s: Applied correction factor = %e' % (self .name , correct_fact )
207+ print ( 'Cloud %s: Applied correction factor = %e' % (self .name , correct_fact ) )
208208
209209 self .nel_mp [0 :self .N_mp ] = self .nel_mp [0 :self .N_mp ] * correct_fact
210210
211211 chrg = np .sum (self .nel_mp )
212212 erg = np .sum (0.5 / np .abs (self .charge / self .mass ) * self .nel_mp [0 :self .N_mp ] * (self .vx_mp [0 :self .N_mp ] * self .vx_mp [0 :self .N_mp ] + self .vy_mp [0 :self .N_mp ] * self .vy_mp [0 :self .N_mp ] + self .vz_mp [0 :self .N_mp ] * self .vz_mp [0 :self .N_mp ]))
213- print 'Cloud %s: Done SOFT regeneration. N_mp=%d Nel_tot=%1.2e En_tot=%1.2e' % (self .name , self .N_mp , chrg , erg )
213+ print ( 'Cloud %s: Done SOFT regeneration. N_mp=%d Nel_tot=%1.2e En_tot=%1.2e' % (self .name , self .N_mp , chrg , erg ) )
214214
215215 def check_for_soft_regeneration (self ):
216216
@@ -222,7 +222,7 @@ def check_for_async_regeneration(self):
222222
223223 if self .flag_async_regen :
224224 if self .N_mp > self .N_mp_async_regen :
225- print ('Cloud %s: Asynchronous clean and regeneration.' % self .name )
225+ print (( 'Cloud %s: Asynchronous clean and regeneration.' % self .name ) )
226226 self .clean_small_MPs ()
227227 if self .N_mp > self .N_mp_async_regen :
228228 self .perform_soft_regeneration (target_N_mp = self .N_mp_after_async_regen )
@@ -232,7 +232,7 @@ def check_for_regeneration(self):
232232 if (self .N_mp > self .N_mp_regen or (self .N_mp < self .N_mp_regen_low and self .nel_mp_ref > self .nel_mp_ref_0 )):
233233 chrg = np .sum (self .nel_mp )
234234 erg = np .sum (0.5 / np .abs (self .charge / self .mass ) * self .nel_mp [0 :self .N_mp ] * (self .vx_mp [0 :self .N_mp ] * self .vx_mp [0 :self .N_mp ] + self .vy_mp [0 :self .N_mp ] * self .vy_mp [0 :self .N_mp ] + self .vz_mp [0 :self .N_mp ] * self .vz_mp [0 :self .N_mp ]))
235- print 'Cloud %s: Start regeneration. N_mp=%d Nel_tot=%1.2e En_tot=%1.2e' % (self .name , self .N_mp , chrg , erg )
235+ print ( 'Cloud %s: Start regeneration. N_mp=%d Nel_tot=%1.2e En_tot=%1.2e' % (self .name , self .N_mp , chrg , erg ) )
236236
237237 new_nel_mp_ref = chrg / self .N_mp_after_regen
238238 if new_nel_mp_ref < self .nel_mp_ref_0 :
@@ -253,7 +253,7 @@ def check_for_regeneration(self):
253253
254254 x_max = (len (hist_vect ) - i_cut + 1 ) * self .Dx_hist_reg + self .bias_x_hist_reg
255255
256- print 'Cloud %s: x_max = %e' % (self .name , x_max )
256+ print ( 'Cloud %s: x_max = %e' % (self .name , x_max ) )
257257
258258 flag_clean = (abs (self .x_mp ) > x_max )
259259 flag_keep = ~ (flag_clean )
@@ -303,7 +303,7 @@ def check_for_regeneration(self):
303303 bias_vz = np .ceil (float (self .Nvz_reg ) / 2 )
304304 #Attention when trnslating to python
305305
306- print 'Cloud %s: particles_assigned_to grid' % (self .name )
306+ print ( 'Cloud %s: particles_assigned_to grid' % (self .name ) )
307307
308308 ##
309309 #% MATLAB-like indices
@@ -324,15 +324,15 @@ def check_for_regeneration(self):
324324 indices_nonzero_cells = np .array (list (set (indexes )))
325325 indices_nonzero_cells = np .sort (indices_nonzero_cells )
326326
327- vect_dens = dict (zip (indices_nonzero_cells , np .zeros (len (indices_nonzero_cells ))))
327+ vect_dens = dict (list ( zip (indices_nonzero_cells , np .zeros (len (indices_nonzero_cells ) ))))
328328 #lil_matrix((Nx_reg*Ny_reg*Nvx_reg*Nvy_reg*Nvz_reg,1));#allocate a sparse matrix
329329 #
330330
331331 for i_mp in range (0 , self .N_mp ):
332332 index_curr = indexes [i_mp ]
333333 vect_dens [index_curr ] = vect_dens [index_curr ] + self .nel_mp [i_mp ]
334334
335- nonzero_cells = np .array (map (vect_dens .get , indices_nonzero_cells ))
335+ nonzero_cells = np .array (list ( map (vect_dens .get , indices_nonzero_cells ) ))
336336
337337 #%% retrieve indices of nonempty cells
338338 #% NB use C-like indices
@@ -436,7 +436,7 @@ def check_for_regeneration(self):
436436
437437 chrg = np .sum (self .nel_mp )
438438 erg = np .sum (0.5 / np .abs (self .charge / self .mass ) * self .nel_mp [0 :self .N_mp ] * (self .vx_mp [0 :self .N_mp ] * self .vx_mp [0 :self .N_mp ] + self .vy_mp [0 :self .N_mp ] * self .vy_mp [0 :self .N_mp ] + self .vz_mp [0 :self .N_mp ] * self .vz_mp [0 :self .N_mp ]))
439- print 'Cloud %s: Done regeneration. N_mp=%d Nel_tot=%1.2e En_tot=%1.2e' % (self .name , self .N_mp , chrg , erg )
439+ print ( 'Cloud %s: Done regeneration. N_mp=%d Nel_tot=%1.2e En_tot=%1.2e' % (self .name , self .N_mp , chrg , erg ) )
440440
441441 def add_uniform_MP_distrib (self , DNel , E_init , x_max , x_min , y_max , y_min ):
442442
@@ -569,7 +569,7 @@ def add_from_file(self, filename_MPs):
569569 self .nel_mp [self .N_mp :self .N_mp + Nint_new_MP ] = np .squeeze (dict_MP_init ['nel_mp' ])
570570
571571 if self .flag_lifetime_hist :
572- if 't_last_impact' in dict_MP_init .keys ():
572+ if 't_last_impact' in list ( dict_MP_init .keys () ):
573573 self .t_last_impact [self .N_mp :self .N_mp + Nint_new_MP ] = np .squeeze (
574574 dict_MP_init ['t_last_impact' ])
575575 else :
0 commit comments