Statistiques
| Révision :

root / ase / transport / stm.py @ 1

Historique | Voir | Annoter | Télécharger (7,29 ko)

1
import numpy as np
2
from ase.transport.tools import dagger
3
from ase.transport.selfenergy import LeadSelfEnergy
4
from ase.transport.greenfunction import GreenFunction
5
import time
6
from gpaw.mpi import world
7

    
8

    
9
class STM:
10
    def __init__(self, h1, s1, h2, s2 ,h10, s10, h20, s20, eta1, eta2, w=0.5, pdos=[], logfile = None):
11
        """XXX
12
        
13
        1. Tip
14
        2. Surface
15
        
16
        h1: ndarray
17
            Hamiltonian and overlap matrix for the isolated tip
18
            calculation.  Note, h1 should contain (at least) one
19
            principal layer.
20

21
        h2: ndarray
22
            Same as h1 but for the surface.
23

24
        h10: ndarray
25
            periodic part of the tip. must include two and only
26
            two principal layers.
27

28
        h20: ndarray
29
            same as h10, but for the surface
30

31
        The s* are the corresponding overlap matrices.  eta1, and eta
32
        2 are (finite) infinitesimals.  """
33
        
34
        self.pl1 = len(h10) // 2 #principal layer size for the tip
35
        self.pl2 = len(h20) // 2 #principal layer size for the surface
36
        self.h1 = h1 
37
        self.s1 = s1
38
        self.h2 = h2
39
        self.s2 = s2
40
        self.h10 = h10 
41
        self.s10 = s10 
42
        self.h20 = h20 
43
        self.s20 = s20
44
        self.eta1 = eta1
45
        self.eta2 = eta2
46
        self.w = w #asymmetry of the applied bias (0.5=>symmetric)
47
        self.pdos = []
48
        self.log = logfile
49

    
50
    def initialize(self, energies, bias=0):
51
        """
52
            energies: list of energies 
53
            for which the transmission function should be evaluated.
54
            bias.
55
            Will precalculate the surface greenfunctions of the tip and
56
            surface.
57
        """
58
        self.bias = bias
59
        self.energies = energies
60
        nenergies = len(energies)
61
        pl1, pl2 = self.pl1, self.pl2
62
        nbf1, nbf2 = len(self.h1), len(self.h2)
63
      
64
        #periodic part of the tip
65
        hs1_dii = self.h10[:pl1, :pl1], self.s10[:pl1, :pl1]
66
        hs1_dij = self.h10[:pl1, pl1:2*pl1], self.s10[:pl1, pl1:2*pl1]
67
        #coupling betwen per. and non. per part of the tip
68
        h1_im = np.zeros((pl1, nbf1), complex) 
69
        s1_im = np.zeros((pl1, nbf1), complex)
70
        h1_im[:pl1, :pl1], s1_im[:pl1, :pl1] = hs1_dij
71
        hs1_dim = [h1_im, s1_im]
72

    
73
        #periodic part the surface 
74
        hs2_dii = self.h20[:pl2, :pl2], self.s20[:pl2, :pl2]
75
        hs2_dij = self.h20[pl2:2*pl2, :pl2], self.s20[pl2:2*pl2, :pl2]
76
        #coupling betwen per. and non. per part of the surface
77
        h2_im = np.zeros((pl2, nbf2), complex)
78
        s2_im = np.zeros((pl2, nbf2), complex) 
79
        h2_im[-pl2:, -pl2:], s2_im[-pl2:, -pl2:] = hs2_dij
80
        hs2_dim = [h2_im, s2_im]
81

    
82
        #tip and surface greenfunction 
83
        self.selfenergy1 = LeadSelfEnergy(hs1_dii, hs1_dij, hs1_dim, self.eta1)
84
        self.selfenergy2 = LeadSelfEnergy(hs2_dii, hs2_dij, hs2_dim, self.eta2)
85
        self.greenfunction1 = GreenFunction(self.h1-self.bias*self.w*self.s1, self.s1, 
86
                                            [self.selfenergy1], self.eta1)
87
        self.greenfunction2 = GreenFunction(self.h2-self.bias*(self.w-1)*self.s2, self.s2, 
88
                                            [self.selfenergy2], self.eta2)
89
        
90
        #Shift the bands due to the bias.
91
        bias_shift1 = -bias * self.w
92
        bias_shift2 = -bias * (self.w - 1)
93
        self.selfenergy1.set_bias(bias_shift1)
94
        self.selfenergy2.set_bias(bias_shift2)
95
        
96
        #tip and surface greenfunction matrices.
97
        nbf1_small = nbf1 #XXX Change this for efficiency in the future
98
        nbf2_small = nbf2 #XXX -||-
99
        coupling_list1 = range(nbf1_small)# XXX -||-
100
        coupling_list2 = range(nbf2_small)# XXX -||-
101
        self.gft1_emm = np.zeros((nenergies, nbf1_small, nbf1_small), complex) 
102
        self.gft2_emm = np.zeros((nenergies, nbf2_small, nbf2_small), complex)
103
 
104
        for e, energy in enumerate(self.energies):
105
            if self.log != None: # and world.rank == 0:
106
                    T = time.localtime()
107
                    self.log.write(' %d:%02d:%02d, ' % (T[3], T[4], T[5]) +
108
                                   '%d, %d, %02f\n' % (world.rank, e, energy))
109
            gft1_mm = self.greenfunction1.retarded(energy)[coupling_list1]
110
            gft1_mm = np.take(gft1_mm, coupling_list1, axis=1)
111

    
112
            gft2_mm = self.greenfunction2.retarded(energy)[coupling_list2]
113
            gft2_mm = np.take(gft2_mm, coupling_list2, axis=1)
114
 
115
            self.gft1_emm[e] = gft1_mm
116
            self.gft2_emm[e] = gft2_mm
117

    
118
            if self.log != None and world.rank == 0:
119
                self.log.flush()
120

    
121
    def get_transmission(self, v_12, v_11_2=None, v_22_1=None):
122
        """XXX
123

124
        v_12:
125
            coupling between tip and surface 
126
        v_11_2:
127
            correction to "on-site" tip elements due to the 
128
            surface (eq.16). Is only included to first order.
129
        v_22_1:
130
            corretion to "on-site" surface elements due to he
131
            tip (eq.17). Is only included to first order.
132
        """
133

    
134
        dim0 = v_12.shape[0]
135
        dim1 = v_12.shape[1]
136

    
137
        nenergies = len(self.energies)
138
        T_e = np.empty(nenergies,float)
139
        v_21 = dagger(v_12)
140
        for e, energy in enumerate(self.energies):
141
            gft1 = self.gft1_emm[e]
142
            if v_11_2!=None:
143
                gf1 = np.dot(v_11_2, np.dot(gft1, v_11_2)) 
144
                gf1 += gft1 #eq. 16
145
            else:
146
                gf1 = gft1
147
            
148
            gft2 = self.gft2_emm[e]
149
            if v_22_1!=None:
150
                gf2 = np.dot(v_22_1,np.dot(gft2, v_22_1))
151
                gf2 += gft2 #eq. 17
152
            else:
153
                gf2 = gft2
154
            
155
            a1 = (gf1 - dagger(gf1))
156
            a2 = (gf2 - dagger(gf2))
157
            self.v_12 = v_12
158
            self.a2 = a2
159
            self.v_21 = v_21
160
            self.a1 = a1
161
            v12_a2 = np.dot(v_12, a2[:dim1])
162
            v21_a1 = np.dot(v_21, a1[-dim0:])
163
            self.v12_a2 = v12_a2
164
            self.v21_a1 = v21_a1
165
            T = -np.trace(np.dot(v12_a2[:,:dim1], v21_a1[:,-dim0:])) #eq. 11
166
            T_e[e] = T
167
            self.T_e = T_e
168
        return T_e
169

    
170

    
171
    def get_current(self, bias, v_12, v_11_2=None, v_22_1=None):
172
        """Very simple function to calculate the current.
173
        
174
        Asummes zero temperature.
175

176
        bias: type? XXX
177
            bias voltage (V)
178
            
179
        v_12: XXX
180
            coupling between tip and surface.
181
            
182
        v_11_2:
183
            correction to onsite elements of the tip
184
            due to the potential of the surface.
185
        v_22_1:
186
            correction to onsite elements of the surface
187
            due to the potential of the tip.
188
        """
189
        energies = self.energies
190
        T_e = self.get_transmission(v_12, v_11_2, v_22_1)
191
        bias_window = -np.array([bias * self.w, bias * (self.w - 1)])
192
        bias_window.sort()
193
        self.bias_window = bias_window
194
        #print 'bias window', np.around(bias_window,3)
195
        #print 'Shift of tip lead do to the bias:', self.selfenergy1.bias
196
        #print 'Shift of surface lead do to the bias:', self.selfenergy2.bias
197
        i1 = sum(energies < bias_window[0]) 
198
        i2 = sum(energies < bias_window[1])
199
        step = 1 
200
        if i2 < i1:
201
            step = -1
202
        
203
        return np.sign(bias)*np.trapz(x=energies[i1:i2:step], y=T_e[i1:i2:step])
204

    
205

    
206

    
207

    
208

    
209