How to use the fbpic.fields.cuda_methods.cuda.to_device function in fbpic

To help you get started, we’ve selected a few fbpic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fbpic / fbpic / fbpic / fields / spectral_grid.py View on Github external
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 )
github fbpic / fbpic / fbpic / fields / spectral_grid.py View on Github external
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 )
github fbpic / fbpic / fbpic / fields / spectral_grid.py View on Github external
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 )
github fbpic / fbpic / fbpic / fields / spectral_grid.py View on Github external
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 )
github fbpic / fbpic / fbpic / fields / spectral_grid.py View on Github external
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 )
github fbpic / fbpic / fbpic / fields / spectral_grid.py View on Github external
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 )
github fbpic / fbpic / fbpic / fields / spectral_grid.py View on Github external
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 )
github fbpic / fbpic / fbpic / fields / spectral_grid.py View on Github external
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 )
github fbpic / fbpic / fbpic / fields / spectral_grid.py View on Github external
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 )
github fbpic / fbpic / fbpic / fields / spectral_grid.py View on Github external
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 )