%%bash
cat input.f90
%config InlineBackend.figure_format = 'retina'
from numba import jit,f8,u8
import numpy as np
import matplotlib.pyplot as plt
import math as mt
from scipy.fftpack import fft, ifft,fft2,fftshift
import time
import matplotlib as mpl
from IPython import display
plt.rcParams['font.size'] = 14
plt.rcParams['axes.linewidth'] = 1.5
nx=128
ny=128
nd=100
isav=10
dx=0.1; dy=0.1
dt=0.05
lx=nx*dx; ly=ny*dy
it=50
f =open('data/bz%05d.d' %(it) ,'rb')
bz =np.fromfile(f, dtype='float64').reshape(-1,nx)
plt.imshow(bz,origin='lower',cmap='jet',aspect='auto',extent=([0,lx,0,ly]))
plt.xlabel(r'$x/(c/\omega_{pe})$'); plt.ylabel(r'$x/(c/\omega_{pe})$')
plt.title('$B_z$')
plt.colorbar()
plt.axis('square')
plt.show()
The solid black line describes the theoretical curve of a numerical Cherenkov emission.
That is defined as follows:
$${k_y}\Delta y = 2\arcsin \left\{\pm {\frac{{\Delta y}}{{c\Delta t}}\sqrt {{{\tan }^2}\left( {\frac{{V{k_x}\Delta t}}{2}} \right) - {{\left( {\frac{{c\Delta t}}{{\Delta x}}\sin \left( {\frac{{{k_x}\Delta x}}{2}} \right)} \right)}^2} - \frac{1}{2}\frac{{\omega _{pe}^2}}{{V{k_x}}}\Delta t\tan \left( {\frac{{V{k_x}\Delta t}}{2}} \right)} } \right\}$$
kmin=2*mt.pi/(dx*nx)*(-nx/2); kmax=2*mt.pi/(dx*nx)*(nx/2)
kx=np.linspace(kmin,kmax,nx)
a1=np.tan(kx*dt/2)**2
a2=-(dt/dx*np.sin(kx*dx/2))**2
a3=-0.5/kx*dt*np.tan(kx*dt/2)
kym=2*np.arcsin(+dy/dt*np.sqrt(a1+a2+a3))/dy
kyp=2*np.arcsin(-dy/dt*np.sqrt(a1+a2+a3))/dy
fftbz=fftshift(fft2(bz))
plt.imshow(abs(fftbz),aspect='auto',extent=([kmin,kmax,kmin,kmax]),cmap='jet',norm=mpl.colors.LogNorm())
plt.xlabel('$k_x(c/\omega_{pe})$');plt.ylabel('$k_y(c/\omega_{pe})$')
plt.colorbar()
plt.clim(1e-2,1e3)
plt.plot(kx,kym,'-k')
plt.plot(kx,kyp,'-k')
plt.show()
tt=dt*np.arange(nd)
enbz=np.zeros((nd))
for it in range(nd):
f =open('data/bz%05d.d' %(it) ,'rb')
bz =np.fromfile(f, dtype='float64').reshape(-1,nx)
enbz[it]=np.mean(bz**2)
plt.plot(tt,enbz)
plt.xlabel(r'$t\omega_e$'); plt.ylabel('$B_z$ energy')
plt.yscale('log')
plt.show()