@@ -395,8 +395,14 @@ def particles_to_mesh(self, *mp_coords, **kwargs):
395395 Return the charge distribution on the mesh (which is
396396 mesh_charges = rho*volume).
397397 '''
398- charge = kwargs .get ("charge" , e )
399398 dtype = kwargs .get ("dtype" , np .float32 )
399+ charge = kwargs .get ("charge" , e )
400+ try :
401+ charge = charge .get ()
402+ except AttributeError :
403+ pass
404+ # ensure returning a dtype np.float64 in particles_to_mesh:
405+ charge = float (charge )
400406
401407 n_macroparticles = len (mp_coords [0 ])
402408 self .kernel_call_config ['p2m' ]['grid' ] = (
@@ -423,7 +429,7 @@ def particles_to_mesh(self, *mp_coords, **kwargs):
423429 self ._p2m_inclmeshing_32atomics_kernel .prepared_call (
424430 grid , block , * args )
425431 elif dtype == np .float64 :
426- self ._p2m_inclmeshing_32atomics_kernel .prepared_call (
432+ self ._p2m_inclmeshing_64atomics_kernel .prepared_call (
427433 grid , block , * args )
428434 else :
429435 raise ValueError ("PyPIC: particles_to_mesh() got unknown dtype "
@@ -453,7 +459,8 @@ def particles_to_mesh(self, *mp_coords, **kwargs):
453459 "argument, expected either np.float32 or "
454460 "np.float64!" )
455461 self ._context .synchronize ()
456- mesh_charges = mesh_count * charge
462+ mesh_charges = mesh_count * charge
463+ # because charge is double precision, mesh_charges will be as well!
457464 return mesh_charges
458465
459466 def sorted_particles_to_mesh (self , * mp_coords , ** kwargs ):
0 commit comments