Skip to content

Commit

Permalink
change namelist to make simulation in nonlinear regime
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Massimo authored and Francesco Massimo committed Nov 30, 2023
1 parent cab53f5 commit 85b9d41
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 36 deletions.
18 changes: 9 additions & 9 deletions InputNamelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
######################### Simulation parameters

##### mesh resolution
dx = 0.095*um # longitudinal mesh resolution
dr = 0.5*um # transverse mesh resolution
dx = 0.1*um # longitudinal mesh resolution
dr = 0.35*um # transverse mesh resolution


dt = 0.9*dx/c_normalized # integration timestep

##### simulation window size
nx = 544 # number of mesh points in the longitudinal direction
nr = 56 # number of mesh points in the transverse direction
nx = 576 # number of mesh points in the longitudinal direction
nr = 80 # number of mesh points in the transverse direction
Lx = nx * dx # longitudinal size of the simulation window
Lr = nr * dr # transverse size of the simulation window

Expand Down Expand Up @@ -85,7 +85,7 @@
#laser_waist = 12*um # laser waist, conversion from um
#center_laser = Lx-1.7*laser_fwhm # laser position at the start of the simulation
#x_focus = (center_laser+0.1*laser_fwhm) # laser focal plane position
#a0 = 1.8 # laser peak field, normalized by E0 defined above
#a0 = 2.3 # laser peak field, normalized by E0 defined above

#### Define a Gaussian bunch with Gaussian temporal envelope
#LaserEnvelopeGaussianAM(
Expand All @@ -112,7 +112,7 @@
########################## Define the plasma
#
###### plasma parameters
#plasma_plateau_density_1_ov_cm3 = 1.3e18
#plasma_plateau_density_1_ov_cm3 = 1.e18
#n0 = plasma_plateau_density_1_ov_cm3*1e6/ncrit # plasma plateau density in units of critical density defined above
#Radius_plasma = 30.*um # Radius of plasma
#Lramp = 15*um # Plasma density upramp length
Expand All @@ -137,7 +137,7 @@
# position_initialization = "regular",
# momentum_initialization = "cold",
# particles_per_cell = 4,
# regular_number = [2,2,1],
# regular_number = [1,4,1],
# mass = 1.0,
# charge = -1.0,
# number_density = plasma_density,
Expand All @@ -155,12 +155,12 @@
######################## Define the electron bunch

###### electron bunch parameters
#Q_bunch = -15*pC # Total charge of the electron bunch
#Q_bunch = -60*pC # Total charge of the electron bunch
#sigma_x = 1.5*um # initial longitudinal rms size
#sigma_r = 2*um # initial transverse/radial rms size (cylindrical symmetry)
#bunch_energy_spread = 0.01 # initial rms energy spread / average energy (not in percent)
#bunch_normalized_emittance = 3.*mm_mrad # initial rms emittance, same emittance for both transverse planes
#delay_behind_laser = 18.5*um # distance between center_laser and center_bunch
#delay_behind_laser = 22.*um # distance between center_laser and center_bunch
#center_bunch = center_laser-delay_behind_laser # initial position of the electron bunch in the window
#gamma_bunch = 200. # initial relativistic Lorentz factor of the bunch

Expand Down
32 changes: 12 additions & 20 deletions Postprocessing_Scripts/Follow_electron_bunch_evolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,45 +150,37 @@ def print_bunch_params(x,y,z,px,py,pz,E,weights,conversion_factor):

######### Plot

fig = plt.figure()
fig = plt.figure(figsize=(12,4))
plt.title("Evolution of the Electron Bunch Parameters")
fig.set_facecolor('w')


plt.subplot(221)
plt.plot(Bunch_position/1e3,Sigma_y,c="b",label="y")
plt.plot(Bunch_position/1e3,Sigma_z,c="r",linestyle="--",label="z")
plt.subplot(131)
plt.plot(bunch_position/1e3,Sigma_y,c="b",label="y")
plt.plot(bunch_position/1e3,Sigma_z,c="r",linestyle="--",label="z")
plt.xlabel("Position [mm]")
plt.ylabel("Rms Transverse Size\n[um]")
plt.xticks([0.0,0.1,0.2,0.3,0.4,0.5])
plt.ylim(0,2.5)
plt.ylim(0.5,2.5)
plt.legend()

plt.subplot(222)
plt.plot(Bunch_position/1e3,Emittance_y,c="b",label="y")
plt.plot(Bunch_position/1e3,Emittance_z,c="r",linestyle="--",label="z")
plt.subplot(132)
plt.plot(bunch_position/1e3,Emittance_y,c="b",label="y")
plt.plot(bunch_position/1e3,Emittance_z,c="r",linestyle="--",label="z")
plt.xlabel("Position [mm]")
plt.ylabel("Normalized Emittance\n[mm-mrad]")
plt.xticks([0.0,0.1,0.2,0.3,0.4,0.5])
plt.ylim(2.5,3.5)
plt.ylim(2.8,3.2)
plt.legend()

plt.subplot(223)
plt.plot(Bunch_position/1e3,Energy,c="b")
plt.subplot(133)
plt.plot(bunch_position/1e3,Energy,c="b")
plt.xlabel("Position [mm]")
plt.ylabel("Energy\n[MeV]")
plt.xticks([0.0,0.1,0.2,0.3,0.4,0.5])

plt.subplot(224)
plt.plot(Bunch_position/1e3,Divergence_y/1e-3,c="b",label="y")
plt.plot(Bunch_position/1e3,Divergence_z/1e-3,c="r",linestyle="--",label="z")
plt.xlabel("Position [mm]")
plt.ylabel("Divergence \n[mrad]")
plt.xticks([0.0,0.1,0.2,0.3,0.4,0.5])
plt.legend()
#plt.ylim(0,7.0)

plt.subplots_adjust(hspace=0.4,wspace=0.4)
plt.subplots_adjust(hspace=2.,wspace=0.4)

plt.savefig('Electron_bunch_evolution.png', format='png')
plt.show()
14 changes: 7 additions & 7 deletions doc/source/exercises.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ If you do not specify a ``vmax`` value (the colorbar maximum) in the previous co
``happi`` will change it at each iteration. To better see the laser diffraction,
try to specify a colormap maximum with ``vmax``. For example::

S.Probe.Probe1("Env_E_abs",units=["um","fs","TV/m"]).slide( figure=3,vmax=0.2, xlabel="x [um]",ylabel="y [um]" )
S.Probe.Probe1("Env_E_abs",units=["um","fs","TV/m"]).slide( figure=3,vmax=0.3, xlabel="x [um]",ylabel="y [um]" )

.. _exercise5:
.. admonition:: Exercise 5
Expand Down Expand Up @@ -250,7 +250,7 @@ and electron plasma, as represented in :ref:`Fig. 5 <Schema_Simulation_2>`.
.. admonition:: Exercise 7

As you can see, the plasma density has a value
:math:`n_0 = 1.3\cdot10^{18} electrons/cm^{3}`.
:math:`n_0 = 1.\cdot10^{18} electrons/cm^{3}`.

What is the ratio between the plasma density and the critical density (computed for :ref:`Exercise 1 <exercise1>`)?

Expand Down Expand Up @@ -323,7 +323,7 @@ analytical solutions to the coupled Vlasov-Maxwell system of equations, and flui
.. _exercise10:
.. admonition:: Exercise 10

Launch a new simulation with ``a0=1.8``.
Launch a new simulation with ``a0=2.3``, i.e. its original value.
This simulation will be in the nonlinear regime (:math:`a_0>1`), so the plasma wave will not be sinusoidal.
You can visualize both the normalized absolute value of the envelope of the laser field and the electron number density by defining a transparency
for the parts where the latter field is lower than a threshold ``vmin``::
Expand Down Expand Up @@ -546,7 +546,7 @@ as well as their weight (from which their charge can be computed).
With the same simulation of :ref:`Exercise 13 <exercise13>`, use the script `Follow_electron_bunch_evolution.py <https://github.com/SmileiPIC/TP-M2-GI/blob/main/Postprocessing_Scripts/Follow_electron_bunch_evolution.py>`_ to see how the bunch has evolved during
the simulation (``%run Follow_electron_bunch_evolution.py``
in ``IPython``). The script reads the ``DiagTrackParticles`` output and
then computes some bunch quantities (`rms` size, emittance, energy, divergence)
then computes some bunch quantities (rms size, emittance, energy)
at each available output iteration.

Include the resulting image in your answers.
Expand All @@ -560,7 +560,7 @@ as well as their weight (from which their charge can be computed).
.. admonition:: Exercise 17

Create four new folders, ``sim1``, ``sim2``, ``sim3``, ``sim4``
where you will run four new simulation. In each simulation, the charge of the electron bunch will be changed to :math:`40, 60, 80,100 pC`, respectively.
where you will run four new simulation. In each simulation, the charge of the electron bunch will be changed to :math:`20, 40, 60, 100 pC`, respectively.

**Warning:** Do not forget the minus sign or the bunch will be made of positrons!

Expand All @@ -580,7 +580,7 @@ as well as their weight (from which their charge can be computed).
You can use Python or any other language for this simple plot. For example, using Python: ::

import matplotlib.pyplot as plt
bunch=[40,60,80,100]
bunch=[20,40,60,100]
energy=[...,...,...,...] #replace by the energy values you obtained
fig = plt.figure()
plt.plot(bunch, energy, 'ro', markersize=10)
Expand All @@ -598,7 +598,7 @@ as well as their weight (from which their charge can be computed).
where you will launch the simulation varying the bunch distance from the laser, changing the ``delay_behind_laser`` parameter (Set again the charge to :math:`20 pC` for all these simulations).
This parameter controls the distance between the electron bunch and the laser center, therefore its phase in the plasma wave behind the laser pulse.

For ``delay_behind_laser``, try the values :math:`16.5, 18.5, 20.5, 22.5 \mu m`.
For ``delay_behind_laser``, try the values :math:`20, 22, 24, 26. \mu m`.

What is the observed final energy for each of the four ``delay_behind_laser`` parameters?

Expand Down

0 comments on commit 85b9d41

Please sign in to comment.