-
Notifications
You must be signed in to change notification settings - Fork 1
/
current.py
146 lines (119 loc) · 2.43 KB
/
current.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import math
import pygrace
import pygame,os,time,sys
WIDTH=400
HEIGHT=100
size = [WIDTH,HEIGHT]
flags=pygame.SRCALPHA|pygame.HWSURFACE|pygame.HWACCEL
os.environ['SDL_VIDEO_WINDOW_POS'] = '700,100'
screen = pygame.display.set_mode(size,flags)
pygame.display.set_caption("Transmission and reflection")
def xmgrace():
global pg
try:
import pygrace
except:
print 'damn'
return
pg = pygrace.grace()
pg.xlabel('V -->>')
pg.ylabel('dI/dV -->')
pg.title('Current')
#globals
m=1.0
k=1.38e-23
ev=1.6e-19
Ef=1e-3*ev
delta=20*ev
T=(1.0/11600)/100 #temperature in eV 1ev=11600k
z=1.0 #Barrier strength at the interface
#general form
def gamma2(u2):
return (u2+z*z*(2*u2-1) )**2
def u2(E):
return 0.5*(1+math.sqrt((E**2-delta**2)/(E**2)) )
def PA(E): #probability of andreev reflection
if E<delta:
t2=E*E + (delta*delta-E*E)*( (1+2*z*z)**2 )
return (delta*delta)/t2
else:
u=u2(E)
return u*(1-u)/gamma2(u)
def PB(E): #probability of ordinary reflection
if E<delta:
return 1-PA(E)
else:
u=u2(E)
return (2*u-1)*(2*u-1)*(1+z*z)*z*z/gamma2(u)
def PC(E): #probability of transmission sans branch crossing
if E<delta:
return 0
else:
u=u2(E)
return u*(2*u-1)*(1+z*z)/gamma2(u)
def PD(E): #probability of transmission with branch crossing
if E<delta:
return 0
else:
u=u2(E)
return (1-u)*(2*u-1)*(z*z)/gamma2(u)
def fermi_fn(E):
#print '(E-Ef)/(k*T) = ',(E-Ef)/(k*T)
return 1.0/(math.exp((E-Ef)/(k*T))+1)
def integ(E,V):
x=(fermi_fn(E-ev*V)-fermi_fn(E))*(1+PA(E)-PB(E))
print 'fermi_fn(E-ev*V) , E-ev*V = ',fermi_fn(E-ev*V),E-ev*V
return x
def current(V):
#integrate between reasonable limits ( not -inf to +inf )
dE=1e-3*ev
E=Ef
I=0
#print 'E,V =',E,V
for a in range(20):
I+=integ(E,V)*dE
E+=dE
return I
xmgrace()
pg.hold(1)
dump=open('TandR_Z0.txt','wt')
#XMGRACE PLOT FEATURES
# A=Black , B=red , C in green , D in Blue
def refresh(z):
pg.xlabel('E (Z = %2.2f) -->'%(z))
pg.clear()
pg.hold(1)
dump=open('I.txt','wt')
y=[]
x=[]
for V in range(0,300):
j=ev*V/(delta*10000.0)
g=current(V/10000.0)
if(j):
#print j,g
x.append(j)
y.append(g)
dump.write('%f %f\n'%(j,g) )
pg.plot(x,y)
dump.write('\n')
dump.close()
ll=0
refresh(z)
run=True
while run:
event=pygame.event.wait()
if event.type == pygame.QUIT:
try:
pg.exit()
run=False
except:
sys.exit()
ll=0
try:
ll=event.button
if(ll==4):z+=0.1
elif (ll==5): z-=0.1
if z<0: z=0
except:
continue
if(ll):refresh(z)