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"])


check==False
check==False

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


[ 0.3    0.35   0.4    0.45   0.5    0.55   0.6    0.65   0.7    0.75   0.8
  0.85   0.9    0.95   0.363  0.726  1.089  1.452  1.815  2.178  2.541
  2.904  3.267  3.63   3.993  4.356  4.719  5.082  5.445  5.808  6.171
  6.534  6.897]
[ 0.3    0.35   0.363  0.4    0.45   0.5    0.55   0.6    0.65   0.7    0.726
  0.75   0.8    0.85   0.9    0.95   1.089  1.452  1.815  2.178  2.541
  2.904  3.267  3.63   3.993  4.356  4.719  5.082  5.445  5.808  6.171
  6.534  6.897]
[ 0  1 14  2  3  4  5  6  7  8 15  9 10 11 12 13 16 17 18 19 20 21 22 23 24
 25 26 27 28 29 30 31 32]
(33, 10) (33, 10) (33,)

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]


[  6.16032400e-02   6.39837025e-02   6.59719225e-02   7.26572025e-02
   4.25390625e-02   3.02934025e-02   2.39940100e-02   1.99233225e-02
   1.63840000e-02   1.38415225e-02   1.25888400e-02   1.15777600e-02
   9.75156250e-03   8.32656250e-03   7.02244000e-03   6.02952250e-03
   3.96270250e-03   1.46689000e-03   6.12562500e-04   2.78890000e-04
   1.38062500e-04   7.22500000e-05   4.03225000e-05   2.30400000e-05
   1.40625000e-05   8.70250000e-06   5.76000000e-06   3.80250000e-06
   2.72250000e-06   1.82250000e-06   1.21000000e-06   1.00000000e-06
   7.22500000e-07]
[  2.08513600e-02   1.47379600e-02   1.30302225e-02   1.15940250e-03
   3.36400000e-05   7.02250000e-06   1.60000000e-07   1.21000000e-06
   1.22500000e-07   1.82250000e-06   1.10250000e-06   2.89000000e-06
   1.00000000e-06   5.76000000e-06   6.50250000e-06   4.62250000e-06
   4.00000000e-06   1.60000000e-07   2.50000000e-07   4.00000000e-08
   4.00000000e-08   2.25000000e-08   1.00000000e-08   2.25000000e-08
   2.25000000e-08   2.25000000e-08   1.00000000e-08   2.25000000e-08
   1.00000000e-08   1.00000000e-08   2.25000000e-08   1.00000000e-08
   1.00000000e-08]
[ 0.3    0.35   0.363  0.4    0.45   0.5    0.55   0.6    0.65   0.7    0.726
  0.75   0.8    0.85   0.9    0.95   1.089  1.452  1.815  2.178  2.541
  2.904  3.267  3.63   3.993  4.356  4.719  5.082  5.445  5.808  6.171
  6.534  6.897]
[3]

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]: