# ____________________________________________________________________________
#
# This script validates the relativist pushers in 1d by analyzing
# the trajectory of a particle in a circular Gaussian plane wave.
#
# _____________________________________________________________________________

import os, re, numpy as np, h5py
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])
Example #2
0
from Smilei import *
import numpy as np
import matplotlib.pyplot as plt
from scipy.special import erf as erf

plt.ion()

path = "Maxwellianization1"

sim = Smilei(path)
coulomb_log = np.double(sim.namelist.Collisions[0].coulomb_log)
dt = np.double(sim.namelist.Main.timestep) / (2 * np.pi)

re_ = 2.8179403267e-15  # meters
wavelength = 1e-6  # meters
c = 3e8

times = sim.ParticleDiagnostic(0).getAvailableTimesteps()
electrons = sim.ParticleDiagnostic(0, slice={"x": "all"}).get()
vx = electrons["vx"]

fig = None
fig = plt.figure(1)
if fig: fig.clf()
if fig: ax = fig.add_subplot(1, 1, 1)
for i, t in enumerate(times):
    if i % 3 > 0: continue
    A = electrons["data"][i]
    if fig:
        #ax.cla()
        ax.plot(vx, A, 'b')
Example #3
0
import numpy as np
from matplotlib.colors import LogNorm
from mpl_toolkits.mplot3d import Axes3D
import math as m

mpl.rcParams['font.size'] = 20
mpl.rcParams['legend.fontsize'] = 20
mpl.rcParams['figure.facecolor'] = 'white'

# ________________________________________________
# Functions

# ________________________________________________
# Open results

res = Smilei("./tst1d_cir_plane_wave_rela", verbose=False)

# ________________________________________________
# Parameters

#a0 = res_Boris.namelist.LaserGaussian3D[0].a0
a0 = 5.
step = 10

# ____________________________________________
# Fields

if False:

    Ey = res_Boris.Field(0, "Ey", timesteps=1300, slice={"z": [5.]}).get()
Example #4
0
import math as m
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.rcParams['text.usetex'] = True
plt.matplotlib.rcParams.update({
    'font.family': 'serif',
    'font.serif': 'Times',
    'font.size': 20
})
mpl.rcParams['xtick.major.size'] = 10
mpl.rcParams['ytick.major.size'] = 10
mpl.rcParams['xtick.minor.size'] = 5
mpl.rcParams['ytick.minor.size'] = 5

S = Smilei('/Users/mica/RESULTS/SMILEI/thermalPlasmaNoDrift/')
T = S.namelist.Te
mu = 1. / T
v0 = S.namelist.v0
g0 = 1. / m.sqrt(1. - v0**2)

# read gamma-distribution fct
fg = np.array(S.ParticleDiagnostic(0).getData())[0]
g = np.array(S.ParticleDiagnostic(0).get()['gamma'])
print 'int over all g:', (g[1] - g[0]) * np.sum(fg)

# compute theoretical distribution fct
fth = np.zeros(g.shape)
fth = g * np.sqrt(g**2 - 1.) * np.exp(-mu * g)
itg = (g[1] - g[0]) * np.sum(fth)
fth = fth / itg
Example #5
0
from Smilei import *

import numpy as np
import matplotlib.pyplot as plt
ln = np.log
plt.ion()

D = []
colors = ["k", "r", "g", "b", "m"]
for elm in ["C", "Al", "Zn", "Sn", "Au"]:
	S1=Smilei("ionization_multiple"+elm+"1")
	S2=Smilei("ionization_multiple"+elm+"2")
	
	color = colors.pop()
	
	timestep1 = np.round(np.double(S1.namelist.Main.timestep), decimals=1)
	D.append( S1.ParticleDiagnostic(0,slice={"ekin":[0,1]},
		linestyle="-", color=color,
		label=elm) )
	
	timestep2 = int(np.double(S2.namelist.Main.timestep))
	D.append( S2.ParticleDiagnostic(0,slice={"ekin":[0,1]},
		linestyle="", marker=".", color=color ) )


# Plot simulation result
plt.figure(1, figsize=(6,3.5))
multiPlot(*D)
fig =plt.gcf()
ax = plt.gca()
# Make nicer plot
import numpy as np
from matplotlib.colors import LogNorm
from mpl_toolkits.mplot3d import Axes3D
import math as m

mpl.rcParams['font.size'] = 20
mpl.rcParams['legend.fontsize'] = 20
mpl.rcParams['figure.facecolor'] = 'white'

# ________________________________________________
# Functions

# ________________________________________________
# Open results

res = Smilei("./tst1d_cir_plane_wave_clas", verbose=False)

# ________________________________________________
# Parameters

#a0 = res_Boris.namelist.LaserGaussian3D[0].a0
a0 = 0.1
step = 2

# ____________________________________________
# Fields

if False:

    Ey = res_Boris.Field(0, "Ey", timesteps=1300, slice={"z": [5.]}).get()
Example #7
0
     [17.475316, 0.014570], [20.565161, 0.012829], [24.201327, 0.011297],
     [28.480411, 0.009954], [33.516088, 0.008778], [39.442133, 0.007751],
     [46.415973, 0.006855], [54.622872, 0.006075], [64.280848, 0.005398],
     [75.646470, 0.004811], [89.021670, 0.004303], [104.761764, 0.003865],
     [123.284896, 0.003488], [145.083138, 0.003164], [170.735570, 0.002888],
     [200.923659, 0.002653], [236.449362, 0.002454], [278.256434, 0.002288],
     [327.455496, 0.002149], [385.353540, 0.002035], [453.488650, 0.001944],
     [533.670861, 0.001871], [628.030244, 0.001815], [739.073494, 0.001774],
     [869.750518, 0.001746], [1023.532800, 0.001730], [1204.505627, 0.001723],
     [1417.476611, 0.001725], [1668.103410, 0.001735], [1963.044021, 0.001751],
     [2310.133656, 0.001772], [2718.592885, 0.001798], [3199.272585, 0.001827],
     [3764.942199, 0.001860], [4430.628958, 0.001895], [5214.017089, 0.001932],
     [6135.917601, 0.001971], [7220.821137, 0.002012], [8497.548578, 0.002053],
     [10000.016685, 0.002096]])

S1 = Smilei("ionization_rate1")
S2 = Smilei("ionization_rate2")
S3 = Smilei("ionization_rate3")

# get electron velocity
ve = np.double(S1.namelist.Species["electron1"].mean_velocity[0])
Ee = (1. / np.sqrt(1. - ve**2) - 1.) * 511.  # energy
cse = np.interp(np.log(Ee), np.log(cs[:, 0]),
                cs[:, 1])  # interpolate cross section

# get density
ne = np.double(S1.namelist.Species["electron1"].charge_density)

# get ion charge
q0 = np.double(S1.namelist.Species["ion1"].charge)
        11.91873264, 13.84057796, 16.11965772, 18.80418339, 21.9305915,
        25.51153958, 29.52473287, 33.90815976, 38.56573939, 43.38130946,
        48.23275232, 52.99823957, 57.55375982, 61.76990959, 65.52021161,
        68.70651127, 71.28856372, 73.29422978, 74.80222575, 75.91222479,
        76.72040917, 77.30714207
    ]),
}

colors = ["b", "k", "r", "g"]

fig = plt.figure(3, figsize=(6, 3.5))

for element in ["H", "Al", "Zn", "Au"]:
    print "Analyzing " + element

    S = Smilei("ionization_equilibrium" + element)

    npoints = S.namelist.npoints
    every = S.namelist.DiagParticles[0].every
    ts = int(t0 * S.namelist.Main.referenceAngularFrequency_SI /
             S.namelist.Main.timestep / every)  # timestep at 1ps

    Z = []
    Zfinal = []
    T = []
    Tfinal = []
    for i in range(npoints):
        D = S.ParticleDiagnostic("#" + str(4 * i + 2) + "/#" + str(4 * i + 3),
                                 slice={"x": "all"},
                                 units=["ps"],
                                 marker=".")
Example #9
0
    g = E / 511. + 1.
    v2 = 1. - g**-2
    I0 = (9.76 * Z + 58.8 * Z**-0.19) / 1000.
    return 2.55e-25 * Z / (1. - g**-2) * (ln(
        (g + 1.) / 2. * (E / I0)**2) + (1. - (2. * g - 1.) * ln(2.) +
                                        (g - 1.)**2 / 8.) / g**2)


plt.figure(1, figsize=(8, 3.5))

# First, slowing down for a few examples
########################################
D = []
sims = ["2", "3", "4"]
for sim in sims:
    S = Smilei("ionization_stopping_power" + sim)

    D.append(
        S.ParticleDiagnostic("#0/#1",
                             slice={"x": "all"},
                             units=["fs"],
                             linestyle="None",
                             marker='o',
                             markersize=4,
                             markeredgewidth=0.,
                             skipAnimation=True))
multiPlot(*D)
fig = plt.gcf()
ax = plt.gca()
ax.xaxis.labelpad = 0
ax.yaxis.labelpad = 0
import numpy as np
from matplotlib.colors import LogNorm
from mpl_toolkits.mplot3d import Axes3D
import math as m

mpl.rcParams['font.size'] = 20
mpl.rcParams['legend.fontsize'] = 20
mpl.rcParams['figure.facecolor'] = 'white'

# ________________________________________________
# Functions

# ________________________________________________
# Open results

res_Boris = Smilei("./tst3d_cir_plane_wave_Boris")
res_Vay = Smilei("./tst3d_cir_plane_wave_Vay")
res_HC = Smilei("./tst3d_cir_plane_wave_HC")

# ________________________________________________
# Parameters

#a0 = res_Boris.namelist.LaserGaussian3D[0].a0
a0 = 2.

# _________________________________________
# Scalar

Ukin = res_Boris.Scalar("Ukin").get()
Ukin_Vay = res_Vay.Scalar("Ukin").get()
Ukin_HC = res_HC.Scalar("Ukin").get()