In [1]:
import numpy as np
import sqlite3
import matplotlib.pyplot as plt
import scipy.constants as ct
Ryd2eV=13.605692
bohr2nm=ct.physical_constants["Bohr radius"][0]*1e9
%matplotlib inline
plt.rcParams['figure.figsize'] = (14.0, 10.0)
In [2]:
def readSql(sqlname,ids):
sqlstatement = 'SELECT drX,drY,drZ from pairs where id={}'.format(ids)
con = sqlite3.connect(sqlname)
with con:
cur = con.cursor()
cur.execute(sqlstatement)
rows = cur.fetchall()
r=np.array([rows[0][0],rows[0][1],rows[0][2]],dtype=float)
return r
In [3]:
def readLogfile(lognames,sqlnames,num=9):
if type(lognames)==str:
lognames=[lognames]
Singlets=[]
Triplets=[]
R=[]
for logname,sqlname in zip(lognames,sqlnames):
with open(logname,"r") as f:
lines=f.readlines()
check=False
Ts=[]
Ss=[]
evalbool=False
for line in lines:
if "Evaluating pair" in line:
parts=line.split()
pairid=int(parts[7])
segids=(parts[8][1:-1]).split(":")
if check==True:
evalbool=False
Singlets.append(Ss)
Triplets.append(Ts)
R.append(readSql(sqlname,pairid-1))
if len(Ts)!=len(Ss):
print line, logname
Ts=[]
Ss=[]
else:
print "check==False"
evalbool=True
check=False
if " T = " in line:
if len(Ts)>num:
continue
Ts.append(float(line.split()[8]))
check=True
if " S = " in line:
if len(Ss)>num:
continue
Ss.append(float(line.split()[8]))
check=True
if "Next job: ID = - (none available)" in line and check==True:
Singlets.append(Ss)
Triplets.append(Ts)
R.append(readSql(sqlname,pairid))
return Triplets,Singlets,R
In [4]:
T,S,Rvec=readLogfile(["SPLITT_LOG.txt","SPLITT_long.txt"],["system_qm_splitt.sql","system_splitt_long.sql"])
#T,S,Rvec=readLogfile(["SPLITT_LOG.txt"],["system_qm_splitt.sql"])
#T,S,Rvec=readLogfile(["SPLITT_long.txt"],["system_splitt_long.sql"])
#Rvec=readSql(["system_qm_splitt.sql","system_splitt_long.sql"])
In [5]:
Ts=np.array(T)
Ss=np.array(S)
Rvec=np.array(Rvec)
#rint Rvec
Runsorted=np.sqrt(np.sum(Rvec**2,axis=1))
R=np.sort(Runsorted)
print Runsorted
print R
index=np.argsort(Runsorted)
print index
T=Ts[index]
S=Ss[index]
print S.shape, T.shape, R.shape
#print T
In [13]:
i=1
for t in T.T:
plt.plot(R[10:],t[10:],label="T={}".format(i),marker="x")
#if R.size>14:
# plt.scatter(R[14],t[14])
i+=1
if i>2:
break
plt.xlabel("distance [nm]")
plt.ylabel("Triplet Omega [eV]")
plt.legend()
plt.show()
In [7]:
i=1
for s in S.T:
plt.plot(R,s,label="S={}".format(i),marker="x")
if R.size>14:
plt.scatter(R[14],s[14])
i+=1
plt.xlabel("distance [nm]")
plt.ylabel("Singlet Omega [eV]")
plt.legend()
plt.show()
In [8]:
Js=(S[:,1]-S[:,0])/2.0
Jt=(T[:,1]-T[:,0])/2.0
print Js**2
print Jt**2
print R
print [np.where(np.diff(np.log(Js**2))>0)[0][-1]+1]
In [11]:
plt.plot(R,Js**2,label="singlets",marker="x")
plt.plot(R,Jt**2,label="triplets",marker="x")
plt.scatter(R[np.where(np.diff(np.log(Js**2))>0)[0][-1]+1],Js[np.where(np.diff(np.log(Js**2))>0)[0][-1]+1]**2)
plt.xlabel("distance [nm]")
plt.ylabel("J**2 [eV**2]")
plt.legend()
plt.yscale("log")
plt.savefig("coupling_split.png")
plt.show()
In [251]: