How to use the fbpic.lpa_utils.laser.GaussianLaser 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_particle_envelope.py View on Github external
zf : float
       The position of the focal plane

    a0 : float
       The initial a0 of the pulse

    m: int, optional
        The mode on which to imprint the 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:
        # 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_pml.py View on Github external
i_field = 0
    elif coord == 'y':
        i_field = 1
    else:
        raise ValueError("Unknown field: %s" %coord)
    # - Build the theoretical laser profile
    #  (same as the one that was used in order to initialize the simulation)
    if m == 0:
        # Build a radially-polarized pulse from 2 Laguerre-Gauss profiles
        profile = LaguerreGaussLaser( 0, 1, 0.5*a0, w0, tau, z0, zf=zf,
            lambda0=lambda0, theta_pol=0., theta0=0. ) \
                + LaguerreGaussLaser( 0, 1, 0.5*a0, w0, tau, z0, zf=zf,
            lambda0=lambda0, theta_pol=np.pi/2, theta0=np.pi/2 )
    elif m == 1:
        # Use a regular linearly-polarized pulse
        profile = GaussianLaser( a0=a0, waist=w0, tau=tau,
            lambda0=lambda0, z0=z0, zf=zf )
    # - Calculate profile
    r, z = np.meshgrid( info.r, info.z, indexing='ij' )
    if boundaries=='periodic':
        Lz = info.zmax - info.zmin + info.dz # Full length of the box
        n_shift = np.floor( c*t/Lz )
        E_th = profile.E_field( r, 0, z + (n_shift+1)*Lz, t )[i_field] \
             + profile.E_field( r, 0, z + n_shift*Lz, t )[i_field]
    else:
        E_th = profile.E_field( r, 0, z, t )[i_field]

    # Calculate the difference:
    E_diff = E_sim - E_th

    if show:
        import matplotlib.pyplot as plt
github fbpic / fbpic / tests / test_linear_wakefield_envelope.py View on Github external
show: bool
        Whether to have pop-up windows show the comparison between
        analytical and simulated results
    """
    # Automatically choose higher number of macroparticles along theta
    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 ) )
github fbpic / fbpic / tests / test_envelope_group_velocity.py View on Github external
a0 : float
       The initial a0 of the pulse

    m: int, optional
        The mode on which to imprint the profile
        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 / tests / test_laser_envelope.py View on Github external
a0 : float
       The initial a0 of the pulse

    m: int, optional
        The mode on which to imprint the profile
        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=w, tau=tau,
                    lambda0=lambda0, z0=z0, zf=zf )
    elif m == 1:
        profile = LaguerreGaussLaser( 0, 1, a0=a0, waist=w, tau=tau,
                    lambda0=lambda0, z0=z0, zf=zf )
    elif m == -1:
        profile = DonutLikeLaguerreGaussLaser( 0, -1, a0=a0/2**.5,
                    waist=w, tau=tau, lambda0=lambda0, z0=z0, zf=zf )

    # Add the profiles to the simulation
    add_laser_pulse( sim, profile, method = 'direct_envelope' )