Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def send_fields_to_gpu( self ):
"""
Copy the fields to the GPU.
After this function is called, the array attributes
point to GPU arrays.
"""
self.Ep = cuda.to_device( self.Ep )
self.Em = cuda.to_device( self.Em )
self.Ez = cuda.to_device( self.Ez )
self.Bp = cuda.to_device( self.Bp )
self.Bm = cuda.to_device( self.Bm )
self.Bz = cuda.to_device( self.Bz )
self.Jp = cuda.to_device( self.Jp )
self.Jm = cuda.to_device( self.Jm )
self.Jz = cuda.to_device( self.Jz )
self.rho_prev = cuda.to_device( self.rho_prev )
self.rho_next = cuda.to_device( self.rho_next )
if self.use_pml:
self.Ep_pml = cuda.to_device( self.Ep_pml )
self.Em_pml = cuda.to_device( self.Em_pml )
self.Bp_pml = cuda.to_device( self.Bp_pml )
self.Bm_pml = cuda.to_device( self.Bm_pml )
# Only when using the cross-deposition
if hasattr( self, 'rho_next_z' ):
self.rho_next_z = cuda.to_device( self.rho_next_z )
self.Bm = cuda.to_device( self.Bm )
self.Bz = cuda.to_device( self.Bz )
self.Jp = cuda.to_device( self.Jp )
self.Jm = cuda.to_device( self.Jm )
self.Jz = cuda.to_device( self.Jz )
self.rho_prev = cuda.to_device( self.rho_prev )
self.rho_next = cuda.to_device( self.rho_next )
if self.use_pml:
self.Ep_pml = cuda.to_device( self.Ep_pml )
self.Em_pml = cuda.to_device( self.Em_pml )
self.Bp_pml = cuda.to_device( self.Bp_pml )
self.Bm_pml = cuda.to_device( self.Bm_pml )
# Only when using the cross-deposition
if hasattr( self, 'rho_next_z' ):
self.rho_next_z = cuda.to_device( self.rho_next_z )
self.rho_next_xy = cuda.to_device( self.rho_next_xy )
1., self.kz**2 + self.kr**2 )
self.inv_k2[ ( self.kz == 0 ) & (self.kr == 0) ] = 0.
# Register shift factor used for shifting the fields
# in the spectral domain when using a moving window
self.field_shift = np.exp(1.j*kz_true*dz)
# Check whether to use the GPU
self.use_cuda = use_cuda
# Transfer the auxiliary arrays on the GPU
if self.use_cuda :
self.d_filter_array_z = cuda.to_device( self.filter_array_z )
self.d_filter_array_r = cuda.to_device( self.filter_array_r )
self.d_kz = cuda.to_device( self.kz )
self.d_kr = cuda.to_device( self.kr )
self.d_field_shift = cuda.to_device( self.field_shift )
if current_correction == 'curl-free':
self.d_inv_k2 = cuda.to_device( self.inv_k2 )
self.inv_k2[ ( self.kz == 0 ) & (self.kr == 0) ] = 0.
# Register shift factor used for shifting the fields
# in the spectral domain when using a moving window
self.field_shift = np.exp(1.j*kz_true*dz)
# Check whether to use the GPU
self.use_cuda = use_cuda
# Transfer the auxiliary arrays on the GPU
if self.use_cuda :
self.d_filter_array_z = cuda.to_device( self.filter_array_z )
self.d_filter_array_r = cuda.to_device( self.filter_array_r )
self.d_kz = cuda.to_device( self.kz )
self.d_kr = cuda.to_device( self.kr )
self.d_field_shift = cuda.to_device( self.field_shift )
if current_correction == 'curl-free':
self.d_inv_k2 = cuda.to_device( self.inv_k2 )
def send_fields_to_gpu( self ):
"""
Copy the fields to the GPU.
After this function is called, the array attributes
point to GPU arrays.
"""
self.Ep = cuda.to_device( self.Ep )
self.Em = cuda.to_device( self.Em )
self.Ez = cuda.to_device( self.Ez )
self.Bp = cuda.to_device( self.Bp )
self.Bm = cuda.to_device( self.Bm )
self.Bz = cuda.to_device( self.Bz )
self.Jp = cuda.to_device( self.Jp )
self.Jm = cuda.to_device( self.Jm )
self.Jz = cuda.to_device( self.Jz )
self.rho_prev = cuda.to_device( self.rho_prev )
self.rho_next = cuda.to_device( self.rho_next )
if self.use_pml:
self.Ep_pml = cuda.to_device( self.Ep_pml )
self.Em_pml = cuda.to_device( self.Em_pml )
self.Bp_pml = cuda.to_device( self.Bp_pml )
self.Bm_pml = cuda.to_device( self.Bm_pml )
# Only when using the cross-deposition
if hasattr( self, 'rho_next_z' ):
self.rho_next_z = cuda.to_device( self.rho_next_z )
self.rho_next_xy = cuda.to_device( self.rho_next_xy )
def send_fields_to_gpu( self ):
"""
Copy the fields to the GPU.
After this function is called, the array attributes
point to GPU arrays.
"""
self.Ep = cuda.to_device( self.Ep )
self.Em = cuda.to_device( self.Em )
self.Ez = cuda.to_device( self.Ez )
self.Bp = cuda.to_device( self.Bp )
self.Bm = cuda.to_device( self.Bm )
self.Bz = cuda.to_device( self.Bz )
self.Jp = cuda.to_device( self.Jp )
self.Jm = cuda.to_device( self.Jm )
self.Jz = cuda.to_device( self.Jz )
self.rho_prev = cuda.to_device( self.rho_prev )
self.rho_next = cuda.to_device( self.rho_next )
if self.use_pml:
self.Ep_pml = cuda.to_device( self.Ep_pml )
self.Em_pml = cuda.to_device( self.Em_pml )
self.Bp_pml = cuda.to_device( self.Bp_pml )
self.Bm_pml = cuda.to_device( self.Bm_pml )
# Only when using the cross-deposition
if hasattr( self, 'rho_next_z' ):
self.rho_next_z = cuda.to_device( self.rho_next_z )
self.rho_next_xy = cuda.to_device( self.rho_next_xy )
After this function is called, the array attributes
point to GPU arrays.
"""
self.Ep = cuda.to_device( self.Ep )
self.Em = cuda.to_device( self.Em )
self.Ez = cuda.to_device( self.Ez )
self.Bp = cuda.to_device( self.Bp )
self.Bm = cuda.to_device( self.Bm )
self.Bz = cuda.to_device( self.Bz )
self.Jp = cuda.to_device( self.Jp )
self.Jm = cuda.to_device( self.Jm )
self.Jz = cuda.to_device( self.Jz )
self.rho_prev = cuda.to_device( self.rho_prev )
self.rho_next = cuda.to_device( self.rho_next )
if self.use_pml:
self.Ep_pml = cuda.to_device( self.Ep_pml )
self.Em_pml = cuda.to_device( self.Em_pml )
self.Bp_pml = cuda.to_device( self.Bp_pml )
self.Bm_pml = cuda.to_device( self.Bm_pml )
# Only when using the cross-deposition
if hasattr( self, 'rho_next_z' ):
self.rho_next_z = cuda.to_device( self.rho_next_z )
self.rho_next_xy = cuda.to_device( self.rho_next_xy )
self.Bp = cuda.to_device( self.Bp )
self.Bm = cuda.to_device( self.Bm )
self.Bz = cuda.to_device( self.Bz )
self.Jp = cuda.to_device( self.Jp )
self.Jm = cuda.to_device( self.Jm )
self.Jz = cuda.to_device( self.Jz )
self.rho_prev = cuda.to_device( self.rho_prev )
self.rho_next = cuda.to_device( self.rho_next )
if self.use_pml:
self.Ep_pml = cuda.to_device( self.Ep_pml )
self.Em_pml = cuda.to_device( self.Em_pml )
self.Bp_pml = cuda.to_device( self.Bp_pml )
self.Bm_pml = cuda.to_device( self.Bm_pml )
# Only when using the cross-deposition
if hasattr( self, 'rho_next_z' ):
self.rho_next_z = cuda.to_device( self.rho_next_z )
self.rho_next_xy = cuda.to_device( self.rho_next_xy )
def send_fields_to_gpu( self ):
"""
Copy the fields to the GPU.
After this function is called, the array attributes
point to GPU arrays.
"""
self.Ep = cuda.to_device( self.Ep )
self.Em = cuda.to_device( self.Em )
self.Ez = cuda.to_device( self.Ez )
self.Bp = cuda.to_device( self.Bp )
self.Bm = cuda.to_device( self.Bm )
self.Bz = cuda.to_device( self.Bz )
self.Jp = cuda.to_device( self.Jp )
self.Jm = cuda.to_device( self.Jm )
self.Jz = cuda.to_device( self.Jz )
self.rho_prev = cuda.to_device( self.rho_prev )
self.rho_next = cuda.to_device( self.rho_next )
if self.use_pml:
self.Ep_pml = cuda.to_device( self.Ep_pml )
self.Em_pml = cuda.to_device( self.Em_pml )
self.Bp_pml = cuda.to_device( self.Bp_pml )
self.Bm_pml = cuda.to_device( self.Bm_pml )
# Only when using the cross-deposition
if hasattr( self, 'rho_next_z' ):
self.rho_next_z = cuda.to_device( self.rho_next_z )
self.rho_next_xy = cuda.to_device( self.rho_next_xy )
if current_correction == 'curl-free':
self.inv_k2 = 1./np.where( ( self.kz == 0 ) & (self.kr == 0),
1., self.kz**2 + self.kr**2 )
self.inv_k2[ ( self.kz == 0 ) & (self.kr == 0) ] = 0.
# Register shift factor used for shifting the fields
# in the spectral domain when using a moving window
self.field_shift = np.exp(1.j*kz_true*dz)
# Check whether to use the GPU
self.use_cuda = use_cuda
# Transfer the auxiliary arrays on the GPU
if self.use_cuda :
self.d_filter_array_z = cuda.to_device( self.filter_array_z )
self.d_filter_array_r = cuda.to_device( self.filter_array_r )
self.d_kz = cuda.to_device( self.kz )
self.d_kr = cuda.to_device( self.kr )
self.d_field_shift = cuda.to_device( self.field_shift )
if current_correction == 'curl-free':
self.d_inv_k2 = cuda.to_device( self.inv_k2 )