How to use the fbpic.lpa_utils.laser.add_laser_pulse 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 / tests / test_flattenedgauss_laser.py View on Github external
def test_laser_periodic(show=False):
    """
    Function that is run by py.test, when doing `python setup.py test`
    Test the propagation of a laser in a periodic box.
    """
    # Propagate the pulse in a single step
    dt = Lprop*1./c

    # Initialize the simulation object
    sim = Simulation( Nz, zmax, Nr, rmax, Nm, dt,
                n_order=n_order, zmin=zmin, boundaries='periodic' )

    # Initialize the laser fields
    profile = FlattenedGaussianLaser(a0=a0, w0=w0, N=N, 
                                     tau=ctau/c, z0=0, zf=zfoc)
    add_laser_pulse( sim, profile )

    # Propagate the pulse
    sim.step(1)

    # Check the validity of the transverse field profile
    # (Take the RMS field in order to suppress the laser oscillations)
    trans_profile = np.sqrt( np.average(sim.fld.interp[1].Er.real**2, axis=0) )
    # Calculate the theortical profile out-of-focus
    Zr = k0*w0**2/2
    w_th = w0*(Lprop-zfoc)/Zr
    r = sim.fld.interp[1].r
    th_profile = trans_profile[0]*flat_gauss( r/w_th, N )
    # Plot the profile, if requested by the user
    if show:
        import matplotlib.pyplot as plt
        plt.plot( 1.e6*r, trans_profile, label='Simulated' )
github fbpic / fbpic / tests / test_laser.py View on Github external
lambda0 = 2*np.pi/k0
    # Create the relevant laser profile
    if m == 0:
        # Build a radially-polarized pulse from 2 Laguerre-Gauss profiles
        profile = LaguerreGaussLaser( 0, 1, 0.5*a0, w, tau, z0, zf=zf,
                    lambda0=lambda0, theta_pol=0., theta0=0. ) \
                + LaguerreGaussLaser( 0, 1, 0.5*a0, w, tau, z0, zf=zf,
                    lambda0=lambda0, theta_pol=np.pi/2, theta0=np.pi/2 )
    elif m == 1:
        profile = GaussianLaser( a0=a0, waist=w, tau=tau,
                    lambda0=lambda0, z0=z0, zf=zf )
    elif m == 2:
        profile = LaguerreGaussLaser( 0, 1, a0=a0, waist=w, tau=tau,
                    lambda0=lambda0, z0=z0, zf=zf )
    # Add the profiles to the simulation
    add_laser_pulse( sim, profile )
github fbpic / fbpic / tests / test_linear_wakefield_envelope.py View on Github external
p_nt = 2*Nm
    # Initialize the simulation object
    sim = Simulation( Nz, zmax, Nr, rmax, Nm, dt,
                      p_zmin, p_zmax, p_rmin, p_rmax, p_nz, p_nr, p_nt, n_e,
                      use_cuda=use_cuda, boundaries='open', use_envelope=True,
                      v_comoving=0.99*c, use_galilean=True,
                      initialize_ions=True)

    # Create the relevant laser profile
    if Nm == 1:
        profile = GaussianLaser(a0=a0, waist=w0, tau=tau, z0=z0,
                                      theta_pol=np.pi/2 )
    elif Nm == 3:
        profile = LaguerreGaussLaser(0, 1, a0=a0, waist=w0, tau=tau, z0=z0,
                                      theta_pol=np.pi/2)
    add_laser_pulse( sim, profile, method = 'direct_envelope' )

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

    # Add diagnostics
    if write_fields:
        sim.diags.append( FieldDiagnostic(diag_period, sim.fld, sim.comm,
                                fieldtypes=["rho", "E", "B", "J","a"]) )
    if write_particles:
        sim.diags.append( ParticleDiagnostic(diag_period,
                        {'electrons': sim.ptcl[0]}, sim.comm ) )

    # Prevent current correction for MPI simulation
    if sim.comm.size > 1:
        correct_currents=False
    else:
github fbpic / fbpic / tests / test_particle_envelope.py View on Github external
"""
    # Initialize the fields
    tau = ctau/c
    lambda0 = 2*np.pi/k0
    # Create the relevant laser profile
    if m == 0:
        profile = GaussianLaser( a0=a0, waist=w0, tau=tau,
                    lambda0=lambda0, z0=z0, zf=zf )
    elif m == 1:
        # Put the peak of the Laguerre-Gauss at pi/4 to check that the
        # angular dependency is correctly captured
        profile = LaguerreGaussLaser( 0, 1, a0, w0, tau,
                    z0, lambda0=lambda0, zf=zf, theta0=np.pi/4 )

    # Add the profiles to the simulation
    add_laser_pulse( sim, profile, method = 'direct_envelope' )
github fbpic / fbpic / tests / test_fewcycle_laser.py View on Github external
def test_laser_periodic(show=False):
    """
    Function that is run by py.test, when doing `python setup.py test`
    Test the propagation of a laser in a periodic box.
    """
    # Propagate the pulse in a single step
    dt = zfoc*1./c

    # Initialize the simulation object
    sim = Simulation( Nz, zmax, Nr, rmax, Nm, dt,
                      zmin=zmin, boundaries='periodic' )

    # Initialize the laser fields
    profile = FewCycleLaser(a0=a0, waist=w0, tau_fwhm=tau_fwhm, z0=0, zf=zfoc)
    add_laser_pulse( sim, profile )

    # Propagate the pulse
    compare_fields(sim.fld.interp[1], sim.time, profile, show)
    sim.step(1)
    compare_fields(sim.fld.interp[1], sim.time, profile, show)
github fbpic / fbpic / tests / test_envelope_group_velocity.py View on Github external
For m = 0 : gaussian profile, linearly polarized beam
        For m = 1 : annular profile
    """
    # Initialize the fields
    tau = ctau/c
    lambda0 = 2*np.pi/k0
    # Create the relevant laser profile

    if m == 0:
        profile = GaussianLaser( a0=a0, waist=w0, tau=tau,
                    lambda0=lambda0, z0=z0, zf=zf )
    elif m == 1:
        profile = LaguerreGaussLaser( 0, 1, a0, w0, tau,
                    z0, lambda0=lambda0, zf=zf )
    # Add the profiles to the simulation
    add_laser_pulse( sim, profile, method = 'direct_envelope' )
github fbpic / fbpic / fbpic / picmi / simulation.py View on Github external
assert (laser.zeta is None) or (laser.zeta == 0)
            assert (laser.beta is None) or (laser.beta == 0)
            phi2_chirp = laser.phi2
            if phi2_chirp is None:
                phi2_chirp = 0
            polarization_angle = np.arctan2(laser.polarization_direction[1],
                                            laser.polarization_direction[0])
            laser_profile = GaussianLaser( a0=laser.a0, waist=laser.waist,
                z0=laser.centroid_position[-1], zf=laser.focal_position[-1],
                tau=laser.duration, theta_pol=polarization_angle,
                phi2_chirp=phi2_chirp )
        else:
            raise ValueError('Unknown laser profile: %s' %type(injection_method))

        # Inject the laser
        add_laser_pulse( self.fbpic_sim, laser_profile, method='antenna',
            z0_antenna=injection_method.position[-1] )