@@ -353,13 +353,18 @@ def get_particle_x(self, level=0, copy_to_host=False):
353353 List of arrays
354354 The requested particle x position
355355 '''
356- xp , cupy_status = load_cupy ()
356+ if copy_to_host :
357+ # Use the numpy version of cosine
358+ xp = np
359+ else :
360+ xp , cupy_status = load_cupy ()
357361
358362 structs = self .get_particle_structs (level , copy_to_host )
359363 if libwarpx .geometry_dim == '3d' or libwarpx .geometry_dim == '2d' :
360364 return [struct ['x' ] for struct in structs ]
361365 elif libwarpx .geometry_dim == 'rz' :
362- return [struct ['x' ]* xp .cos (theta ) for struct , theta in zip (structs , self .get_particle_theta ())]
366+ theta = self .get_particle_theta (level , copy_to_host )
367+ return [struct ['x' ]* xp .cos (theta ) for struct , theta in zip (structs , theta )]
363368 elif libwarpx .geometry_dim == '1d' :
364369 raise Exception ('get_particle_x: There is no x coordinate with 1D Cartesian' )
365370 xp = property (get_particle_x )
@@ -385,13 +390,18 @@ def get_particle_y(self, level=0, copy_to_host=False):
385390 List of arrays
386391 The requested particle y position
387392 '''
388- xp , cupy_status = load_cupy ()
393+ if copy_to_host :
394+ # Use the numpy version of sine
395+ xp = np
396+ else :
397+ xp , cupy_status = load_cupy ()
389398
390399 structs = self .get_particle_structs (level , copy_to_host )
391400 if libwarpx .geometry_dim == '3d' :
392401 return [struct ['y' ] for struct in structs ]
393402 elif libwarpx .geometry_dim == 'rz' :
394- return [struct ['x' ]* xp .sin (theta ) for struct , theta in zip (structs , self .get_particle_theta ())]
403+ theta = self .get_particle_theta (level , copy_to_host )
404+ return [struct ['x' ]* xp .sin (theta ) for struct , theta in zip (structs , theta )]
395405 elif libwarpx .geometry_dim == '1d' or libwarpx .geometry_dim == '2d' :
396406 raise Exception ('get_particle_y: There is no y coordinate with 1D or 2D Cartesian' )
397407 yp = property (get_particle_y )
0 commit comments