Ejemplo n.º 1
0
if False:

    Ey = res_Boris.Field(0, "Ey", timesteps=1300, slice={"z": [5.]}).get()

    Ey["data"] = np.array(Ey["data"][0].T)

    fig = plt.figure(figsize=(12, 6))
    gs = gridspec.GridSpec(2, 2)
    ax = plt.subplot(gs[:, :])

    ax.plot(Ey["x"], Ey["data"])

# ____________________________________________
# Track

Track_Boris = res.TrackParticles("electron_norm", axes=["x", "px", "py",
                                                        "pz"]).get()
Track_Vay = res.TrackParticles("electron_vay", axes=["x", "px", "py",
                                                     "pz"]).get()
Track_HC = res.TrackParticles("electron_higueracary",
                              axes=["x", "px", "py", "pz"]).get()

#gamma_Boris = m.sqrt(1 + np.array(Track['px'][:,0])**2 + np.array(Track['py'][:,0])**2 + np.array(Track['px'][:,0])**2)

# Momentum

x_Boris = np.array(Track_Boris['x'][::step, 0])
px_Boris = np.array(Track_Boris['px'][::step, 0])
py_Boris = np.array(Track_Boris['py'][::step, 0])
pz_Boris = np.array(Track_Boris['pz'][::step, 0])
portho_Boris = np.sqrt(py_Boris**2 + pz_Boris**2)
gf_Boris = np.sqrt(1. + px_Boris**2 + py_Boris**2 + pz_Boris**2)
from Smilei import *

S = Smilei(".", verbose=False)

# Step represents the step between trajectory points what we consider
# This enables to reduce the size of the array
step = 2

# List of relativistic pushers
pusher_list = ["borisnr", "norm", "vay", "higueracary"]

# We load successively the particle track associated to each pusher
for pusher in pusher_list:

    # Data from the Track diagnostic
    Track = S.TrackParticles("electron_" + pusher,
                             axes=["x", "px", "py", "pz"]).get()

    # We extract x,px,py,pz from the first particle
    x = np.array(Track['x'][::step, 0])
    px = np.array(Track['px'][::step, 0])
    py = np.array(Track['py'][::step, 0])
    pz = np.array(Track['pz'][::step, 0])

    # We determine p_\perp, p_\parallel and gamma
    p_perp = np.sqrt(py**2 + pz**2)
    gamma = np.sqrt(1. + px**2 + py**2 + pz**2)

    # Validation of p_\perp, p_\parallel and gamma
    Validate("Electron p_perp for pusher: " + pusher, p_perp, 1e-7)
    Validate("Electron p_x for pusher: " + pusher, px, 1e-7)
    Validate("Electron gamma for pusher: " + pusher, gamma, 1e-7)
    Ey["data"] = np.array(Ey["data"][0].T)

    fig = plt.figure(figsize=(12, 6))
    gs = gridspec.GridSpec(2, 2)
    ax = plt.subplot(gs[:, :])

    im = ax.pcolormesh(Ey["x"], Ey["y"], Ey['data'], shading='None')
    cb = plt.colorbar(im, format='%.2E')

    #Ey.plot()

# ____________________________________________
# Track

Track = res_Boris.TrackParticles("electron",
                                 axes=["x", "y", "z", "px", "py", "pz"]).get()
Track_Vay = res_Vay.TrackParticles("electron",
                                   axes=["x", "y", "z", "px", "py",
                                         "pz"]).get()
Track_HC = res_HC.TrackParticles("electron",
                                 axes=["x", "y", "z", "px", "py", "pz"]).get()

#gamma_Boris = m.sqrt(1 + np.array(Track['px'][:,0])**2 + np.array(Track['py'][:,0])**2 + np.array(Track['px'][:,0])**2)

# 3D figure
if False:
    fig = plt.figure(figsize=(12, 6))
    ax = fig.gca(projection='3d')

    ax.plot(Track['x'][:, 0],
            Track['y'][:, 0],