In [2]:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import h5py
import cmath
print(mpl.__version__)
cmap = plt.get_cmap('rainbow')
c1 = "blue"#cmap(20)
c2 = "green"#cmap(150)
floc = "../../build/res.h5"
file = h5py.File(floc)
from matplotlib import rc
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
## for Palatino and other serif fonts use:
#rc('font',**{'family':'serif','serif':['Palatino']})
rc('text', usetex=True)
plt.rc('font', family='serif')
plt.rc('xtick', labelsize=30)
plt.rc('ytick', labelsize=30)
fig = plt.figure()
ax = fig.add_subplot(111)
t=49001
dstr = "/dset"+str(t)
r = "real"
im = "img"
#e = (dstr+r) in file
#print(e)
dsetr = np.array(file[dstr+r])
dseti = np.array(file[dstr+im])
param = np.array(file["/params"])
nx = param[4]
x = np.linspace(param[1],param[0],param[4])
#ax.plot(x, dsetr, label = "$\mathrm{Re}\{ \psi_n \} \ numerical $",linewidth=3,c="purple")
#ax.plot(x, dseti, label = "$\mathrm{Im}\{ \psi_n \} \ numerical $",linewidth=2,c="red")
ax.plot(x, dseti**2+dsetr**2, label=r"$|\psi_n|^2$ disturbed", linewidth=2)
plt.legend(loc="best",prop={'size':30},frameon=False)
#ax.plot(x, dsetr**2+dseti**2, label = "$|\psi(x)|^2 \ numerical$")
i = 0
dstr = "/dset"+str(i)
dsetr2 = np.array(file[dstr+r])
dseti2 = np.array(file[dstr+im])
E = param[-1]
#E = -1.0
dt = (param[2] - param[3])/param[5]
psi = dsetr2 + 1j * dseti2
i = 0
#i = np.int32(np.pi/(dt*E))
print(t*dt)
print(i)
t -= 1
i = t
U = np.exp( -1j* E * i * dt)
#U = -np.sin(E*t*dt)
#ax.plot(x,psi.real, label = "$\mathrm{Re}\{\psi_{n}\} \ analytical$")
print(U)
#ax.plot(x, psi.imag, label = "$\mathrm{Im}\{ \psi_n \} \ initial $")
psi = psi*U
print(param)
#ax.plot(x, np.abs(psi.imag-dseti), "o",label = " $\Delta \mathfrak{Im}\{\psi_n\}$")
#ax.plot(x,psi.real, label = "$\mathrm{Re}\{\psi_{n}\} \ undisturbed$",linewidth=1, c="blue")
#ax.plot(x, psi.imag, label = "$\mathrm{Im}\{ \psi_n \} \ undisturbed $",linewidth=2, color="green")
ax.plot(x, psi.real**2+psi.imag**2, linewidth=2, label="$|\psi_n|^2, undisturbed$")
#label=r"$|\psi_n|^2 \, undisturbed$",
ax.set_xlabel(r"$x \ (a.u)$", size = 30)
ax.set_ylabel(r"$\psi_n(x)$", size = 30)
#ax.set_title(r"Numerical result at $t_j = t_{"+str(i)+"}$ with $ \Delta t ="+str(dt)+"$",
# size = 40, y = 1.05)
ax.text(13.1673, 0.143, "$t_j = t_{"+str(i)+"}$", size=30)
ax.legend(loc="best",prop={'size':30},frameon=False)
#plt.tight_layout()
print(dt)
plt.show()
file.close()
In [2]:
file.close()
15000*1e6*8/1024**2
Out[2]:
In [51]:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import h5py
import cmath
from matplotlib import rc
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
## for Palatino and other serif fonts use:
#rc('font',**{'family':'serif','serif':['Palatino']})
rc('text', usetex=True)
plt.rc('font', family='serif')
plt.rc('xtick', labelsize=30)
plt.rc('ytick', labelsize=30)
cmap = plt.get_cmap('jet_r')
c1 = "red"#cmap(0)
c2 = cmap(130)
mpl.rcParams["mathtext.fontset"] = "stix"
#%matplotlib inline
fig = plt.figure(figsize=(15,8))
ax = fig.add_subplot(221)
floc = "../../build/instability_origin.h5"
file = h5py.File(floc)
t=1
dstr = "/dset"+str(t)
r = "real"
im = "img"
#e = (dstr+r) in file
#print(e)
dsetr = np.array(file[dstr+r])
dseti = np.array(file[dstr+im])
param = np.array(file["/params"])
nx = param[4]
x = np.linspace(param[1],param[0],param[4])
#ax.plot(x, dsetr, label = "$\mathrm{Re}\{ \psi_n \} \ numerical $",linewidth=3,c=c1)
#ax.plot(x, dseti, label = "$\mathrm{Im}\{ \psi_n \} \ numerical $",linewidth=3,c=c2)
#plt.legend(loc="best",prop={'size':18},frameon=False)
#ax.plot(x, dsetr**2+dseti**2, label = "$|\psi(x)|^2 \ numerical$")
i = 0
dstr = "/dset"+str(i)
dsetr2 = np.array(file[dstr+r])
dseti2 = np.array(file[dstr+im])
E = param[-1]
#E = -1.0
dt = (param[2] - param[3])/param[5]
psi = dsetr2 + 1j * dseti2
i = 0
#i = np.int32(np.pi/(dt*E))
print(i)
t -= 1
i = t
U = np.exp( -1j* E * i * dt)
#U = -np.sin(E*t*dt)
#ax.plot(x,psi.real, label = "$\mathrm{Re}\{\psi_{n}\} \ analytical$")
print(U)
#ax.plot(x, psi.imag, label = "$\mathrm{Im}\{ \psi_n \} \ initial $")
psi = psi*U
print(param)
#ax.plot(x, np.abs(psi.imag-dseti), "o",label = " $\Delta \mathfrak{Im}\{\psi_n\}$")
#ax.plot(x,psi.real, label = "$\mathrm{Re}\{\psi_{n}\} \ analytical$",linewidth=1, c="red")
#ax.plot(x, psi.imag, label = "$\mathrm{Im}\{ \psi_n \} \ analytical $",linewidth=1, c="purple")
#ax.plot(x, psi.real**2+psi.imag**2, label="$|\psi_n|^2 \ analytical$")
ax.plot(x, dseti,label="$\mathrm{Im}\{\psi_{num}\}$",
linewidth=3, c="red")
ax.plot(x, psi.imag,label="$\mathrm{Im}\{\psi_{an}\}$"
,linewidth=3,c=cmap(178))
#ax.set_xlabel("$x \ (a.u)$", size = 30)
ax.set_ylabel("$ \psi_n(x)$", size = 30)
ax.text(9.28,0.009,"a) $t_j = t_{"+str(i)+"}$",size = 30)
plt.legend(loc='best',frameon=False, prop={'size':30})
ax = fig.add_subplot(222)
t=1001
dstr = "/dset"+str(t)
r = "real"
im = "img"
#e = (dstr+r) in file
#print(e)
dsetr = np.array(file[dstr+r])
dseti = np.array(file[dstr+im])
param = np.array(file["/params"])
nx = param[4]
x = np.linspace(param[1],param[0],param[4])
#ax.plot(x, dsetr, label = "$\mathrm{Re}\{ \psi_n \} \ numerical $",linewidth=3,c=c1)
#ax.plot(x, dseti, label = "$\mathrm{Im}\{ \psi_n \} \ numerical $",linewidth=3,c=c2)
#plt.legend(loc="best",prop={'size':18},frameon=False)
#ax.plot(x, dsetr**2+dseti**2, label = "$|\psi(x)|^2 \ numerical$")
i = 0
dstr = "/dset"+str(i)
dsetr2 = np.array(file[dstr+r])
dseti2 = np.array(file[dstr+im])
E = param[-1]
#E = -1.0
dt = (param[2] - param[3])/param[5]
psi = dsetr2 + 1j * dseti2
i = 0
#i = np.int32(np.pi/(dt*E))
print(i)
t -= 1
i = t
U = np.exp( -1j* E * i * dt)
#U = -np.sin(E*t*dt)
#ax.plot(x,psi.real, label = "$\mathrm{Re}\{\psi_{n}\} \ analytical$")
print(U)
#ax.plot(x, psi.imag, label = "$\mathrm{Im}\{ \psi_n \} \ initial $")
psi = psi*U
print(param)
#ax.plot(x, np.abs(psi.imag-dseti), "o",label = " $\Delta \mathfrak{Im}\{\psi_n\}$")
#ax.plot(x,psi.real, label = "$\mathrm{Re}\{\psi_{n}\} \ analytical$",linewidth=1, c="red")
#ax.plot(x, psi.imag, label = "$\mathrm{Im}\{ \psi_n \} \ analytical $",linewidth=1, c="purple")
#ax.plot(x, psi.real**2+psi.imag**2, label="$|\psi_n|^2 \ analytical$")
ax.plot(x, dseti,label="$\mathrm{Im}\{\psi_{num}\}$",
linewidth=3, c="red")
ax.plot(x, psi.imag,label="$\mathrm{Im}\{\psi_{an}\}$"
,linewidth=3,c=cmap(178))
ax.text(9.23,0.3,"b) $t_j = t_{"+str(i)+"}$",size = 30)
#ax.set_xlabel("$x \ (a.u)$", size = 18)
#ax.set_ylabel("$\Delta \psi_n(x)$", size = 18)
#ax.set_title("Norm of errors at $t_j = t_{"+str(i)+"}$ with $ \Delta t ="+str(dt)+"$",
# size = 15, y = 1.05)
plt.legend(loc='best',frameon=False, prop={'size':30})
ax = fig.add_subplot(223)
t=1501
dstr = "/dset"+str(t)
r = "real"
im = "img"
#e = (dstr+r) in file
#print(e)
dsetr = np.array(file[dstr+r])
dseti = np.array(file[dstr+im])
param = np.array(file["/params"])
nx = param[4]
x = np.linspace(param[1],param[0],param[4])
#ax.plot(x, dsetr, label = "$\mathrm{Re}\{ \psi_n \} \ numerical $",linewidth=3,c=c1)
#ax.plot(x, dseti, label = "$\mathrm{Im}\{ \psi_n \} \ numerical $",linewidth=3,c=c2)
#plt.legend(loc="best",prop={'size':18},frameon=False)
#ax.plot(x, dsetr**2+dseti**2, label = "$|\psi(x)|^2 \ numerical$")
i = 0
dstr = "/dset"+str(i)
dsetr2 = np.array(file[dstr+r])
dseti2 = np.array(file[dstr+im])
E = param[-1]
#E = -1.0
dt = (param[2] - param[3])/param[5]
psi = dsetr2 + 1j * dseti2
i = 0
#i = np.int32(np.pi/(dt*E))
print(i)
t -= 1
i = t
U = np.exp( -1j* E * i * dt)
#U = -np.sin(E*t*dt)
#ax.plot(x,psi.real, label = "$\mathrm{Re}\{\psi_{n}\} \ analytical$")
print(U)
#ax.plot(x, psi.imag, label = "$\mathrm{Im}\{ \psi_n \} \ initial $")
psi = psi*U
print(param)
#ax.plot(x, np.abs(psi.imag-dseti), "o",label = " $\Delta \mathfrak{Im}\{\psi_n\}$")
#ax.plot(x,psi.real, label = "$\mathrm{Re}\{\psi_{n}\} \ analytical$",linewidth=1, c="red")
#ax.plot(x, psi.imag, label = "$\mathrm{Im}\{ \psi_n \} \ analytical $",linewidth=1, c="purple")
#ax.plot(x, psi.real**2+psi.imag**2, label="$|\psi_n|^2 \ analytical$")
ax.plot(x, dseti,label="$\mathrm{Im}\{\psi_{num}\}$",
linewidth=3, c="red")
ax.plot(x, psi.imag,label="$\mathrm{Im}\{\psi_{an}\}$"
,linewidth=3,c=cmap(178))
ax.set_xlabel("$x \ (a.u)$", size = 30)
ax.set_ylabel("$\psi_n(x)$", size = 30)
ax.text(9.25,0.3,"c) $t_j = t_{"+str(i)+"}$",size = 30)
#ax.set_title("Norm of errors at $t_j = t_{"+str(i)+"}$ with $ \Delta t ="+str(dt)+"$",
# size = 15, y = 1.05)
plt.legend(loc='best',frameon=False, prop={'size':30})
ax = fig.add_subplot(224)
t=2001
dstr = "/dset"+str(t)
r = "real"
im = "img"
#e = (dstr+r) in file
#print(e)
dsetr = np.array(file[dstr+r])
dseti = np.array(file[dstr+im])
param = np.array(file["/params"])
nx = param[4]
x = np.linspace(param[1],param[0],param[4])
#ax.plot(x, dsetr, label = "$\mathrm{Re}\{ \psi_n \} \ numerical $",linewidth=3,c=c1)
#ax.plot(x, dseti, label = "$\mathrm{Im}\{ \psi_n \} \ numerical $",linewidth=3,c=c2)
#plt.legend(loc="best",prop={'size':18},frameon=False)
#ax.plot(x, dsetr**2+dseti**2, label = "$|\psi(x)|^2 \ numerical$")
i = 0
dstr = "/dset"+str(i)
dsetr2 = np.array(file[dstr+r])
dseti2 = np.array(file[dstr+im])
E = param[-1]
#E = -1.0
dt = (param[2] - param[3])/param[5]
psi = dsetr2 + 1j * dseti2
i = 0
#i = np.int32(np.pi/(dt*E))
print(i)
t -= 1
i = t
U = np.exp( -1j* E * i * dt)
#U = -np.sin(E*t*dt)
#ax.plot(x,psi.real, label = "$\mathrm{Re}\{\psi_{n}\} \ analytical$")
print(U)
#ax.plot(x, psi.imag, label = "$\mathrm{Im}\{ \psi_n \} \ initial $")
psi = psi*U
print(param)
#ax.plot(x, np.abs(psi.imag-dseti), "o",label = " $\Delta \mathfrak{Im}\{\psi_n\}$")
#ax.plot(x,psi.real, label = "$\mathrm{Re}\{\psi_{n}\} \ analytical$",linewidth=1, c="red")
#ax.plot(x, psi.imag, label = "$\mathrm{Im}\{ \psi_n \} \ analytical $",linewidth=1, c="purple")
#ax.plot(x, psi.real**2+psi.imag**2, label="$|\psi_n|^2 \ analytical$")
ax.plot(x, dseti,label="$\mathrm{Im}\{\psi_{num}\}$",
linewidth=3, c="red")
ax.plot(x, psi.imag,label="$\mathrm{Im}\{\psi_{an}\}$"
,linewidth=3,c=cmap(178))
ax.text(9.25,0.24,"d) $t_j = t_{"+str(i)+"}$",size = 30)
ax.set_xlabel("$x \ (a.u)$", size = 30)
#ax.set_ylabel("$\Delta \psi_n(x)$", size = 18)
#ax.set_title("Norm of errors at $t_j = t_{"+str(i)+"}$ with $ \Delta t ="+str(dt)+"$",
# size = 15, y = 1.05)
print(dt)
plt.legend(loc='best',frameon=False, prop={'size':30})
#plt.tight_layout()
plt.show()
In [47]:
from matplotlib import rc
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
## for Palatino and other serif fonts use:
#rc('font',**{'family':'serif','serif':['Palatino']})
rc('text', usetex=True)
plt.rc('font', family='serif')
plt.rc('xtick', labelsize='xx-large')
plt.rc('ytick', labelsize='xx-large')
t = np.linspace(0,3000,10000)
x1 = 1000*np.sin(7*np.pi/3000*t-np.pi)*np.exp(-(t-1500)**2*2.2e-6)
#x1 = np.sin(3*(t-5))/(3*(t-5))
plt.plot(t,x1,label="Time disturbance",linewidth=2)
plt.xlabel("$t \ (a.u.)$",size=30)
plt.ylabel("$E(t) (a.u.)$",size=30)
plt.legend(frameon=False,prop={'size':30})
plt.show()
In [2]:
import matplotlib.pyplot as plt
import numpy as np
In [1]:
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import rc
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
## for Palatino and other serif fonts use:
#rc('font',**{'family':'serif','serif':['Palatino']})
rc('text', usetex=True)
plt.rc('font', family='serif')
plt.rc('xtick', labelsize=30)
plt.rc('ytick', labelsize=30)
a = np.log(2)/(1500-2500)**2
print("a = "+str(a))
b = np.log(2)/(10)**2
print("b = "+ str(b))
#t = np.linspace(0, 1000, 1e3)
x = np.linspace(-30, 30, 1e3)
t0 = 2500
x0 = 0
I = 1
k = 2*np.pi/(10000)
w = k*137
print("w = "+str(w))
t1 = 2500
st = np.sin(w*t1-k*x)*np.exp(-b*x**2)
et = np.exp(-a*(t1-t0)**2)
plt.xlabel(r"$x \ (a.u.)$", size=40)
plt.ylabel(r"$V(x,t) \ (a.u.)$", size=40)
wave = st#*et
p = plt.plot(x, wave, label="disturbance $V_1(x)$",c="b",linewidth=2)
plt.ylim([-0.5,1.1])
dt = 1
t1 = 1000
for i in range(0, 1000):
if t1 >= 700:
dt = 1
if t1 >= 3000:
dt = 1
t1+=dt
plt.title("Laser field at t = \ $"+str(t1)+" \ (a.u.)$",size=40)
et = np.sin(w*t1-k*x)*np.exp(-b*x**2)*np.exp(-a*(t1-t0)**2)
plt.setp(p[0], ydata=et)
plt.draw()
plt.pause(0.01)
plt.legend(frameon=False,loc='best',prop={'size':40})
plt.show()
In [2]:
print(2*np.pi/w)
In [ ]: