Code Monkey home page Code Monkey logo

Comments (5)

Zhengjle1 avatar Zhengjle1 commented on July 19, 2024

FBPIC (0.25.0)

Running on GPU

Initializing laser pulse on the mesh...
Done.

Total time taken (with compilation): 0:00:00
Average time per iteration (with compilation): 0 ms
here is the result, it the picture cant be read

from fbpic.

RemiLehe avatar RemiLehe commented on July 19, 2024

Thanks for reporting this issue.

Could you share the FBPIC input script that you were using when observing this? This would help us reproduce the issue and understand what was wrong.

from fbpic.

Zhengjle1 avatar Zhengjle1 commented on July 19, 2024

My code reports this warning: Failed to detect UUID of GPU 0 (invalid UUID length: 18). But even I run it on the CPU, it exists the problem above.

Here is my input script:

import numpy as np
from scipy.constants import c, e, m_e
from fbpic.main import Simulation
from fbpic.lpa_utils.laser import add_laser_pulse
from fbpic.lpa_utils.laser.laser_profiles import Lightbullet
from fbpic.openpmd_diag import FieldDiagnostic, ParticleDiagnostic, \
     set_periodic_checkpoint, restart_from_checkpoint

use_cuda = True
n_order = -1


Nz = 2000         # Number of gridpoints along z
zmax = -20.e-6   # Right end of the simulation box (meters)
zmin = 20.e-6   # Left end of the simulation box (meters)
Nr = 50        # Number of gridpoints along r
rmax = 100.e-6  # Length of the box along r (meters)
Nm = 2           # Number of modes used


dt = (zmax-zmin)/Nz/c   # Timestep (seconds)


p_zmin = 30.e-3  # Position of the beginning of the plasma (meters)
p_zmax = 500.e-3 # Position of the end of the plasma (meters)
p_rmax = 10.e-3  # Maximal radial position of the plasma (meters)
n_e = 4.e18*1.e6 # Density (electrons.meters^-3)
p_nz = 2         # Number of particles per cell along z
p_nr = 2         # Number of particles per cell along r
p_nt = 4         # Number of particles per cell along theta


a0 = 0.07      # Laser amplitude
w0 = 2.e-3     # Laser waist
tau = 30.e-15     # Laser duration
z0 = 0.e-6        # Laser centroid
belta = 0/180 * np.pi # Laser tilt
alpha = 0/180 * np.pi #Rotation of axis
upordown_1 =-1        # up = -1 , down = +1
upordown_2 =+1
x0 = 0    #Laser centroid in r direction

v_window = c       # Speed of the window


diag_period = 50         # Period of the diagnostics in number of timesteps
save_checkpoints = False # Whether to write checkpoint files
checkpoint_period = 100  # Period for writing the checkpoints
use_restart = False      # Whether to restart from a previous checkpoint
track_electrons = False  # Whether to track and write particle ids
def dens_func( z, r ) :
    """Returns relative density at position z and r"""
    # Allocate relative density
    n = np.ones_like(z)
    # Make linear ramp
    # n = np.where( z<ramp_start+ramp_length, (z-ramp_start)/ramp_length, n )
    # # Supress density before the ramp
    # n = np.where( z<ramp_start, 0., n )
    return(n)


L_interact = 50.e-6 # increase to simulate longer distance!
T_interact = ( L_interact + (zmax-zmin) ) / v_window

if __name__ == '__main__':
        sim = Simulation( Nz, zmax, Nr, rmax, Nm, dt, zmin=zmin,
        n_order=n_order, use_cuda=use_cuda,
        boundaries={'z':'open', 'r':'reflective'})
  
    elec = sim.add_new_species( q=-e, m=m_e, n=n_e,
        dens_func=dens_func, p_zmin=p_zmin, p_zmax=p_zmax, p_rmax=p_rmax,
        p_nz=p_nz, p_nr=p_nr, p_nt=p_nt )

    # Load initial fields
    # Create a Gaussian laser profile
    up_field = Lightbullet (a0, w0, tau, z0 , belta , alpha , upordown_1 , x0=x0)
    # down_field =  Lightbullet (a0, w0, tau, z0 , belta , alpha , upordown_2,x0=-x0)
    # laser_profile =  down_field
    # up_field = Lightbullet (a0, w0, tau, z0 , belta , alpha , upordown_1 , x0=x0)
    laser_profile = up_field
    # Add the laser to the fields of the simulation
    add_laser_pulse( sim, laser_profile)

    if use_restart is False:
        # Track electrons if required (species 0 correspond to the electrons)
        if track_electrons:
            elec.track( sim.comm )
    else:
        # Load the fields and particles from the latest checkpoint file
        restart_from_checkpoint( sim )

    # Configure the moving window
    sim.set_moving_window( v=v_window )

    # Add diagnostics
    sim.diags = [ FieldDiagnostic( diag_period, sim.fld, comm=sim.comm ),
                  ParticleDiagnostic( diag_period, {"electrons" : elec},
                    select={"uz" : [1., None ]}, comm=sim.comm ) ]

    # Add checkpoints
    if save_checkpoints:
        set_periodic_checkpoint( sim, checkpoint_period )

    # Number of iterations to perform
    N_step = int(T_interact/sim.dt)

    ### Run the simulation
    sim.step( N_step )
    print('')

Here I create a new optic field called Lightbullet, which is correctly set because I obtained data before.

from fbpic.

dinkarm avatar dinkarm commented on July 19, 2024

belta = 0/180 * np.pi # Laser tilt
alpha = 0/180 * np.pi #Rotation of axis

I cannot understand the above two lines, I think it will definitely reproduce zero. and you have used the above two lines in your pulse profile as well. and since I don't have the lightbullet profile I cannot reproduce the same on my HPC or even CPU

from fbpic.

Zhengjle1 avatar Zhengjle1 commented on July 19, 2024

I have settled the problem which is very trivial. Anyway thanks for attention!!!!

from fbpic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.