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

    # Add diagnostics
    sim.diags = [
        FieldDiagnostic(dt_period / sim.dt, sim.fld, comm=sim.comm),
        ParticleDiagnostic(dt_period / sim.dt, {"electrons": elec},
                           select={
                               "ux": [0, None],
                               "uy": [0, None]
                           },
                           comm=sim.comm),
        ParticleDiagnostic(dt_period / sim.dt, {"beam": beam},
                           particle_data=[
                               "position", "momentum", "weighting", "E", "B",
                               "gamma"
                           ],
                           comm=sim.comm)
    ]
    # Add checkpoints
    if save_checkpoints:
        set_periodic_checkpoint(sim, 50000)

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

    ### Run the simulation
    sim.step(N_step)
    print('')
Ejemplo n.º 2
0
    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 from N": elec_from_N,
            "electrons": elec
        },
                           comm=sim.comm),
        # Since rho from `FieldDiagnostic` is 0 almost everywhere
        # (neutral plasma), it is useful to see the charge density
        # of individual particles
        ParticleChargeDensityDiagnostic(diag_period, sim, {"electrons": elec})
    ]
    # Add checkpoints
    if save_checkpoints:
        set_periodic_checkpoint(sim, checkpoint_period)

    ### Run the simulation
    sim.step(N_step)
Ejemplo n.º 3
0
         + LaguerreGaussLaser( 0, 1, 0.5*a0, w0, tau, z0, zf=zf,
            lambda0=lambda0, theta_pol=np.pi/2, theta0=np.pi/2 )
# - Mode 1: Use a regular linearly-polarized pulse
profile1 = GaussianLaser(a0=a0,
                         waist=w0,
                         tau=tau,
                         lambda0=lambda0,
                         z0=z0,
                         zf=zf)

if not restart:
    # Add the profiles to the simulation
    add_laser_pulse(sim, profile0)
    add_laser_pulse(sim, profile1)
else:
    restart_from_checkpoint(sim)

# Calculate the total number of steps
N_step = int(round(L_prop / (c * dt)))
diag_period = int(round(N_step / N_diag))

# Add openPMD diagnostics
sim.diags = [
    FieldDiagnostic(diag_period, sim.fld, fieldtypes=["E"], comm=sim.comm)
]

set_periodic_checkpoint(sim, N_step // 2)

# Do only half the steps
sim.step(N_step // 2 + 1)