%matplotlib inline
import qutip
import numpy as np
import scipy
import matplotlib as mpl
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from IPython import display
import sys
import pickle
alpha_const_args = [(2, 200), (2,220), (2,240), (2,260), (2,280)]#, (2,300)]
T_const_args = [(2.,200), (2.2,200), (2.4,200), (2.6,200)]#, (2.8,200), (3.,200)]
both_args = [(2.,200), (2.2,220), (2.4,240), (2.6,260)]#, (2.8,280), (3.,300)]
T_const_res = []
for a,T in T_const_args:
with open("results_three_circles_phase_gate_one_dances_sym_init_state_%0.3f_%d"%(a,T), "rb") as f:
T_const_res.append(pickle.load(f))
alpha_const_res = []
for a,T in alpha_const_args:
with open("results_three_circles_phase_gate_one_dances_sym_init_state_%0.3f_%d"%(a,T), "rb") as f:
alpha_const_res.append(pickle.load(f))
both_res = []
for a,T in both_args:
with open("results_three_circles_phase_gate_one_dances_sym_init_state_%0.3f_%d"%(a,T), "rb") as f:
both_res.append(pickle.load(f))
T_const_pur = [(_[-1]**2).tr() for _ in T_const_res]
alpha_const_pur = [(_[-1]**2).tr() for _ in alpha_const_res]
both_pur = [(_[-1]**2).tr() for _ in both_res]
plt.plot([a for a,T in T_const_args], T_const_pur)
plt.xlabel(r'$\alpha_0$')
plt.title(r'Purity-vs-$\alpha_0$ for $T=200$');
plt.plot([T for a,T in alpha_const_args], alpha_const_pur)
plt.xlabel(r'$T$')
plt.title(r'Purity-vs-$T$ for $\alpha_0=2$');
plt.plot(np.log([T for a,T in alpha_const_args]), np.log(1-np.array(alpha_const_pur)))
plt.xlabel(r'$T$')
plt.title(r'loglog Purity-vs-$T$ for $\alpha_0=2$');
A = np.array([np.log([T for a,T in alpha_const_args]),[1]*5]).T
B = np.log(1-np.array(alpha_const_pur))
x = np.linalg.lstsq(A, B)[0]
plt.plot(np.log([T for a,T in alpha_const_args]), np.log(1-np.array(alpha_const_pur)))
plt.plot(np.log([T for a,T in alpha_const_args]), A.dot(x), 'r', alpha=0.4,linewidth=7)
plt.xlabel(r'$T$')
plt.title(r'loglog Purity vs $T$ for $\alpha_0=2$'+'\n'+r'fit: $1-P\propto T^{%.3f}$'%x[0], fontsize=18)
plt.legend(['input','fit']);
A = np.concatenate([np.log(alpha_const_args+T_const_args+both_args).T,[[1]*13]]).T
B = np.log(1-np.array(alpha_const_pur+T_const_pur+both_pur))
x = np.linalg.lstsq(A, B)[0]
f = plt.figure(figsize=(12,8))
s = f.add_subplot(1,1,1,projection='3d')
s.set_xlabel(r'$\log{(\alpha)}$', fontsize=22)
s.set_ylabel(r'$\log{(T)}$', fontsize=22)
s.set_zlabel(r'$\log{(1-P)}$', fontsize=22)
s.set_title(r'log-log $1-P$ vs $\alpha$ and $T$'+'\n'+r'fit: $1-P\propto\alpha^{%.3f}T^{%.3f}$'%(x[0],x[1]),fontsize=24)
s.plot3D(xs=A[:,0],ys=A[:,1],zs=B,label='input',linewidth=1,marker='o')
am,tm = np.meshgrid(np.log(np.linspace(2,3)),np.log(np.linspace(200,300)))
am = am.flatten()
tm = tm.flatten()
res = np.array([am,tm,np.ones_like(am)]).T.dot(x)
s.plot_wireframe(am,tm,res,color='r',label='fit',alpha=0.4,linewidth=1)
for (a, t, _), p in zip(A,B):
s.plot3D([a,a],[t,t],zs=[-9.5,p],color='k',alpha=0.1,linewidth=2)
#s.set_zlim3d(-5.3)
s.legend(fontsize=22)
s.view_init(elev=None,azim=None);
f = plt.figure(figsize=(12,8))
s = f.add_subplot(1,1,1,projection='3d')
s.set_xlabel(r'$\log{(\alpha)}$', fontsize=22)
s.set_ylabel(r'$\log{(T)}$', fontsize=22)
s.set_zlabel(r'$\log{(\Delta)}$', fontsize=22)
s.set_title(r'log-log $\Delta$ vs $\alpha$ and $T$'+'\n'+r'fit: $\Delta\propto\alpha^{%.3f}T^{%.3f}$'%(x[0],x[1]),fontsize=24)
s.plot3D(xs=A[:,0],ys=A[:,1],zs=B,label='input',linewidth=1,marker='o')
am,tm = np.meshgrid(np.log(np.linspace(2,3)),np.log(np.linspace(200,300)))
am = am.flatten()
tm = tm.flatten()
res = np.array([am,tm,np.ones_like(am)]).T.dot(x)
s.plot_wireframe(am,tm,res,color='r',label='fit',alpha=0.4,linewidth=1)
for (a, t, _), p in zip(A,B):
s.plot3D([a,a],[t,t],zs=[-9.5,p],color='k',alpha=0.1,linewidth=2)
#s.set_zlim3d(-5.3)
s.legend(fontsize=22)
s.view_init(elev=None,azim=None);