We show an example of the electron beam instability. The main calculation has been done by 2D electron-PIC simulation written in FORTRAN. The electron-PIC simulation means that only electrons are solved and ions are fixed in a simulation box.
%%bash
cat input.f90
%config InlineBackend.figure_format = 'retina'
from numba import jit,f8,u8
import numpy as np
import math as mt
import matplotlib.pyplot as plt
import math as mt
from scipy.fftpack import fft, ifft,fft2,fftshift
import time
from IPython import display
import matplotlib.animation as animation
plt.rcParams['font.size'] = 14
plt.rcParams['axes.linewidth'] = 1.5
nx=512
ny=512
nd=512
isav=2
dx=0.05; dy=0.05
dt=0.05*isav
lx=nx*dx; ly=ny*dy
tmax=dt*nd
exhstx=np.zeros((nd,nx));eyhstx=np.zeros((nd,nx));ezhstx=np.zeros((nd,nx))
bxhstx=np.zeros((nd,nx));byhstx=np.zeros((nd,nx));bzhstx=np.zeros((nd,nx))
exhsty=np.zeros((nd,ny));eyhsty=np.zeros((nd,ny));ezhsty=np.zeros((nd,ny))
bxhsty=np.zeros((nd,ny));byhsty=np.zeros((nd,ny));bzhsty=np.zeros((nd,ny))
for it in range(nd):
f1 =open('data/ex%05d.d' %(it) ,'rb')
f2 =open('data/ey%05d.d' %(it) ,'rb')
f3 =open('data/ez%05d.d' %(it) ,'rb')
f4 =open('data/bx%05d.d' %(it) ,'rb')
f5 =open('data/by%05d.d' %(it) ,'rb')
f6 =open('data/bz%05d.d' %(it) ,'rb')
f7 =open('data/rho%05d.d'%(it) ,'rb')
f8 =open('data/jx%05d.d' %(it) ,'rb')
f9 =open('data/jy%05d.d' %(it) ,'rb')
f10=open('data/jz%05d.d' %(it) ,'rb')
ex =np.fromfile(f1, dtype='float64' ).reshape(-1,nx)
ey =np.fromfile(f2, dtype='float64' ).reshape(-1,nx)
ez =np.fromfile(f3, dtype='float64' ).reshape(-1,nx)
bx =np.fromfile(f4, dtype='float64' ).reshape(-1,nx)
by =np.fromfile(f5, dtype='float64' ).reshape(-1,nx)
bz =np.fromfile(f6, dtype='float64' ).reshape(-1,nx)
rho=np.fromfile(f7, dtype='float64' ).reshape(-1,nx)
jx =np.fromfile(f8, dtype='float64' ).reshape(-1,nx)
jy =np.fromfile(f9, dtype='float64' ).reshape(-1,nx)
jz =np.fromfile(f10,dtype='float64' ).reshape(-1,nx)
exhstx[it,:]=np.mean(ex,axis=0);eyhstx[it,:]=np.mean(ey,axis=0);ezhstx[it,:]=np.mean(ez,axis=0)
bxhstx[it,:]=np.mean(bx,axis=0);byhstx[it,:]=np.mean(by,axis=0);bzhstx[it,:]=np.mean(bz,axis=0)
exhsty[it,:]=np.mean(ex,axis=1);eyhsty[it,:]=np.mean(ey,axis=1);ezhsty[it,:]=np.mean(ez,axis=1)
bxhsty[it,:]=np.mean(bx,axis=1);byhsty[it,:]=np.mean(by,axis=1);bzhsty[it,:]=np.mean(bz,axis=1)
kmin=2*mt.pi/(dx*nx)*(-nx/2); kmax=2*mt.pi/(dx*nx)*(nx/2)
wmin=2*mt.pi/(dt*nd)*(-nd/2); wmax=2*mt.pi/(dt*nd)*(nd/2)
kaxis=np.linspace(kmin,kmax,nx); waxis=np.linspace(wmin,wmax,nd)
fftex=fftshift(fft2(exhstx[:,::-1]))
fftey=fftshift(fft2(eyhstx[:,::-1]))
fftez=fftshift(fft2(ezhstx[:,::-1]))
fftbx=fftshift(fft2(bxhstx[:,::-1]))
fftby=fftshift(fft2(byhstx[:,::-1]))
fftbz=fftshift(fft2(bzhstx[:,::-1]))
fig, ((ax1,ax2,ax3,ax4),(ax5,ax6,ax7,ax8),(ax9,ax10,ax11,ax12))=plt.subplots(3,4,figsize=(25,15))
ax1. imshow(exhstx,origin='lower',cmap='bwr',aspect='auto',extent=[0,lx,0,tmax]);ax1 .set_xlabel(r'$x/(c/\omega_{pe})$');ax1 .set_ylabel(r'$t\omega_{pe}$')
ax5. imshow(eyhstx,origin='lower',cmap='bwr',aspect='auto',extent=[0,lx,0,tmax]);ax5 .set_xlabel(r'$x/(c/\omega_{pe})$');ax5 .set_ylabel(r'$t\omega_{pe}$')
ax9. imshow(ezhstx,origin='lower',cmap='bwr',aspect='auto',extent=[0,lx,0,tmax]);ax9 .set_xlabel(r'$x/(c/\omega_{pe})$');ax9 .set_ylabel(r'$t\omega_{pe}$')
ax3. imshow(bxhstx,origin='lower',cmap='bwr',aspect='auto',extent=[0,lx,0,tmax]);ax3 .set_xlabel(r'$x/(c/\omega_{pe})$');ax3 .set_ylabel(r'$t\omega_{pe}$')
ax7. imshow(byhstx,origin='lower',cmap='bwr',aspect='auto',extent=[0,lx,0,tmax]);ax7 .set_xlabel(r'$x/(c/\omega_{pe})$');ax7 .set_ylabel(r'$t\omega_{pe}$')
ax11.imshow(bzhstx,origin='lower',cmap='bwr',aspect='auto',extent=[0,lx,0,tmax]);ax11.set_xlabel(r'$x/(c/\omega_{pe})$');ax11.set_ylabel(r'$t\omega_{pe}$')
ax2. imshow(abs(fftex),origin='lower',aspect='auto',extent=([kmin,kmax,wmin,wmax]),clim=(0,.5));ax2 .set_xlabel(r'$kc/\omega_{pe}$');ax2 .set_ylabel(r'$\omega/\omega_{pe}$')
ax6. imshow(abs(fftey),origin='lower',aspect='auto',extent=([kmin,kmax,wmin,wmax]),clim=(0,.5));ax6 .set_xlabel(r'$kc/\omega_{pe}$');ax6 .set_ylabel(r'$\omega/\omega_{pe}$')
ax10.imshow(abs(fftez),origin='lower',aspect='auto',extent=([kmin,kmax,wmin,wmax]),clim=(0,.5));ax10.set_xlabel(r'$kc/\omega_{pe}$');ax10.set_ylabel(r'$\omega/\omega_{pe}$')
ax4. imshow(abs(fftbx),origin='lower',aspect='auto',extent=([kmin,kmax,wmin,wmax]),clim=(0,.5));ax4 .set_xlabel(r'$kc/\omega_{pe}$');ax4 .set_ylabel(r'$\omega/\omega_{pe}$')
ax8. imshow(abs(fftby),origin='lower',aspect='auto',extent=([kmin,kmax,wmin,wmax]),clim=(0,.5));ax8 .set_xlabel(r'$kc/\omega_{pe}$');ax8 .set_ylabel(r'$\omega/\omega_{pe}$')
ax12.imshow(abs(fftbz),origin='lower',aspect='auto',extent=([kmin,kmax,wmin,wmax]),clim=(0,.5));ax12.set_xlabel(r'$kc/\omega_{pe}$');ax12.set_ylabel(r'$\omega/\omega_{pe}$')
ax2 .axis([0,kmax/4,0,wmax/4])
ax6 .axis([0,kmax/4,0,wmax/4])
ax10.axis([0,kmax/4,0,wmax/4])
ax4 .axis([0,kmax/4,0,wmax/4])
ax8 .axis([0,kmax/4,0,wmax/4])
ax12.axis([0,kmax/4,0,wmax/4])
plt.show()
kmin=2*mt.pi/(dx*nx)*(-nx/2); kmax=2*mt.pi/(dx*nx)*(nx/2)
wmin=2*mt.pi/(dt*nd)*(-nd/2); wmax=2*mt.pi/(dt*nd)*(nd/2)
kaxis=np.linspace(kmin,kmax,nx); waxis=np.linspace(wmin,wmax,nd)
fftex=fftshift(fft2(exhsty[:,::-1]))
fftey=fftshift(fft2(eyhsty[:,::-1]))
fftez=fftshift(fft2(ezhsty[:,::-1]))
fftbx=fftshift(fft2(bxhsty[:,::-1]))
fftby=fftshift(fft2(byhsty[:,::-1]))
fftbz=fftshift(fft2(bzhsty[:,::-1]))
fig, ((ax1,ax2,ax3,ax4),(ax5,ax6,ax7,ax8),(ax9,ax10,ax11,ax12))=plt.subplots(3,4,figsize=(25,15))
ax1. imshow(exhsty,origin='lower',cmap='bwr',aspect='auto',extent=[0,lx,0,tmax]);ax1 .set_xlabel(r'$x/(c/\omega_{pe})$');ax1 .set_ylabel(r'$t\omega_{pe}$')
ax5. imshow(eyhsty,origin='lower',cmap='bwr',aspect='auto',extent=[0,lx,0,tmax]);ax5 .set_xlabel(r'$x/(c/\omega_{pe})$');ax5 .set_ylabel(r'$t\omega_{pe}$')
ax9. imshow(ezhsty,origin='lower',cmap='bwr',aspect='auto',extent=[0,lx,0,tmax]);ax9 .set_xlabel(r'$x/(c/\omega_{pe})$');ax9 .set_ylabel(r'$t\omega_{pe}$')
ax3. imshow(bxhsty,origin='lower',cmap='bwr',aspect='auto',extent=[0,lx,0,tmax]);ax3 .set_xlabel(r'$x/(c/\omega_{pe})$');ax3 .set_ylabel(r'$t\omega_{pe}$')
ax7. imshow(byhsty,origin='lower',cmap='bwr',aspect='auto',extent=[0,lx,0,tmax]);ax7 .set_xlabel(r'$x/(c/\omega_{pe})$');ax7 .set_ylabel(r'$t\omega_{pe}$')
ax11.imshow(bzhsty,origin='lower',cmap='bwr',aspect='auto',extent=[0,lx,0,tmax]);ax11.set_xlabel(r'$x/(c/\omega_{pe})$');ax11.set_ylabel(r'$t\omega_{pe}$')
ax2. imshow(abs(fftex),origin='lower',aspect='auto',extent=([kmin,kmax,wmin,wmax]),clim=(0,.5));ax2 .set_xlabel(r'$kc/\omega_{pe}$');ax2 .set_ylabel(r'$\omega/\omega_{pe}$')
ax6. imshow(abs(fftey),origin='lower',aspect='auto',extent=([kmin,kmax,wmin,wmax]),clim=(0,.5));ax6 .set_xlabel(r'$kc/\omega_{pe}$');ax6 .set_ylabel(r'$\omega/\omega_{pe}$')
ax10.imshow(abs(fftez),origin='lower',aspect='auto',extent=([kmin,kmax,wmin,wmax]),clim=(0,.5));ax10.set_xlabel(r'$kc/\omega_{pe}$');ax10.set_ylabel(r'$\omega/\omega_{pe}$')
ax4. imshow(abs(fftbx),origin='lower',aspect='auto',extent=([kmin,kmax,wmin,wmax]),clim=(0,.5));ax4 .set_xlabel(r'$kc/\omega_{pe}$');ax4 .set_ylabel(r'$\omega/\omega_{pe}$')
ax8. imshow(abs(fftby),origin='lower',aspect='auto',extent=([kmin,kmax,wmin,wmax]),clim=(0,.5));ax8 .set_xlabel(r'$kc/\omega_{pe}$');ax8 .set_ylabel(r'$\omega/\omega_{pe}$')
ax12.imshow(abs(fftbz),origin='lower',aspect='auto',extent=([kmin,kmax,wmin,wmax]),clim=(0,.5));ax12.set_xlabel(r'$kc/\omega_{pe}$');ax12.set_ylabel(r'$\omega/\omega_{pe}$')
ax2 .axis([0,kmax/4,0,wmax/4])
ax6 .axis([0,kmax/4,0,wmax/4])
ax10.axis([0,kmax/4,0,wmax/4])
ax4 .axis([0,kmax/4,0,wmax/4])
ax8 .axis([0,kmax/4,0,wmax/4])
ax12.axis([0,kmax/4,0,wmax/4])
plt.show()