Eötvös Quantum Utilities  v4.9.146
Providing the Horsepowers in the Quantum Realm
test_Keldysh.m
Go to the documentation of this file.
1 %% Eotvos Quantum Transport Utilities
2 % Copyright (C) 2018 Peter Rakyta, Ph.D
3 %
4 % This program is free software: you can redistribute it and/or modify
5 % it under the terms of the GNU General Public License as published by
6 % the Free Software Foundation, either version 3 of the License, or
7 % (at your option) any later version.
8 %
9 % This program is distributed in the hope that it will be useful,
10 % but WITHOUT ANY WARRANTY; without even the implied warranty of
11 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 % GNU General Public License for more details.
13 %
14 % You should have received a copy of the GNU General Public License
15 % along with this program. If not, see http://www.gnu.org/licenses/.
16 %
17 %> @addtogroup unit_tests Unit Tests
18 %> @{
19 %> @file test_Keldysh.m
20 %> @brief Testfile to check functionalities of the classes developed for steady-state Keldysh formalism.
21 %> @Available
22 %> EQuUs v4.9 or later
23 %> @}
24 %> @brief Testfile to check functionalities of the classes developed for steady-state Keldysh formalism.
25 function test_Keldysh()
26 
27 filename = mfilename('fullpath');
28 [directory, fncname] = fileparts( filename );
29 
30  % create input structures
31  [Opt, param] = parseInput( 'Input_Ribbon.xml');
32 
33  % defining the width of the lead 1
34  param.Leads{1}.M = 10;
35 
36 
37  % energy value used in the calculations
38  Energy = -0.01;
39 
40  % The temperature in Kelvins
41  T = 10;
42 
43  %% test of the class Lead_Keldysh
44  disp( '***** test of the class Lead_Keldysh *****' );
45 
46  % create an instance of class Lead_Keldysh
47  cLead_K = Lead_Keldysh(Opt, param, 'Hanyadik_Lead', 1, 'T', T, 'bias', 0.04);
48 
49  % create Hamiltonians
50  cLead_K.CreateHamiltonians();
51  %cLead_K.CalcSpektrum('ka_min', -1, 'ka_max', 1, 'ka_num', 100, 'toPlot', true)
52 
53  % Trukkos sajatertek
54  cLead_K.TrukkosSajatertekek(Energy);
55 
56  % Calculate The grou velocity
57  cLead_K.Group_Velocity();
58 
59  % calculate the lesser Self energy
60  cLead_K.LesserSelfEnergy();
61 
62 
63 
64  %% test of class Ribbon_Keldysh, Transport_Interface_Keldysh
65  disp( '***** test of class Ribbon_Keldysh, Transport_Interface_Keldysh *****' );
66 
67  % chemical potentials in the leads
68  bias_leads = [0.0 0.0];
69 
70  % chemical potential in the central device
71  EF = 0.05;
72 
73  % create an instance of class Lead_Keldysh
74  cRibbon_K = Ribbon_Keldysh('width', 10, 'height', 10, 'Opt', Opt, 'param', param, 'E', Energy, 'bias_leads', bias_leads, 'EF', EF, 'T', T);
75 
76  % calculate the inverse of the retarded surface Green operator of the isolated scattering center
77  cRibbon_K.CalcFiniteGreensFunctionFromHamiltonian('onlyGinv', true);
78 
79  % calculate the lesser Green operator
80  lesserG = cRibbon_K.LesserGreenFunction();
81 
82  retardedG = cRibbon_K.FL_handles.Read('G');
83  occupation_number = cRibbon_K.Fermi( Energy );
84  disp(['Occupation number = ', num2str( occupation_number ), ', Energy: ', num2str(Energy), ', temperature = ', num2str(T)]);
85 
86  checkpoint = norm( lesserG - occupation_number*(retardedG'-retardedG ) );
87  if checkpoint > 1e-10
88  warning(['EQuUs:Tests:', fncname, ':checkpoint failed with error ', num2str( checkpoint)]);
89  end
90 
91  % set new temperature value
92  T = 1000;
93  cRibbon_K.setTemperature( T );
94 
95  % calculate the lesser Green operator
96  lesserG = cRibbon_K.LesserGreenFunction();
97 
98  retardedG = cRibbon_K.FL_handles.Read('G');
99  occupation_number = cRibbon_K.Fermi( Energy );
100  disp(['Occupation number = ', num2str( occupation_number ), ', Energy: ', num2str(Energy), ', temperature = ', num2str(T)]);
101 
102  checkpoint = norm( lesserG - occupation_number*(retardedG'-retardedG ) );
103  if checkpoint > 1e-10
104  warning(['EQuUs:Tests:', fncname, ':checkpoint failed with error ', num2str( checkpoint)]);
105  end
106 
107 
108  % set new energy value
109  Energy = 0.15;
110 
111  cRibbon_K.setEnergy( Energy );
112 
113  % calculate the inverse of the retarded surface Green operator of the isolated scattering center
114  cRibbon_K.CalcFiniteGreensFunctionFromHamiltonian('onlyGinv', true);
115 
116  % calculate the lesser Green operator
117  lesserG = cRibbon_K.LesserGreenFunction();
118 
119  % check the equivalence with the equlibrium lesser Green operator
120  retardedG = cRibbon_K.FL_handles.Read('G');
121  occupation_number = cRibbon_K.Fermi( Energy );
122  disp(['Occupation number = ', num2str( occupation_number ), ', Energy: ', num2str(Energy), ', temperature = ', num2str(T)]);
123 
124  checkpoint = norm( lesserG - occupation_number*(retardedG'-retardedG ) );
125  if checkpoint > 1e-10
126  warning(['EQuUs:Tests:', fncname, ':checkpoint failed with error ', num2str( checkpoint)]);
127  end
128 
129 
131  disp( '***** test of class NTerminal_Keldysh, Transport_Interface_Keldysh *****' );
132 
133  % create input structures for three-terminal setup
134  [Opt, param] = parseInput( 'Input_ThreeTerminal.xml');
135 
136  % chemical potentials in the leads
137  bias_leads = [0.0 0.0 0.0];
138 
139  % chemical potential in the central device
140  EF = 0.05;
141 
142  % creating function handle for the custom Hamiltonians
143  hHamiltonians = @(varargin)ThreeTerminalHamiltonians(Opt, param, varargin{:});
144 
145  % set new temperature value
146  T = 1000;
147 
148  % Set the Energy value
149  Energy = 0.04;
150 
151  % create an instance of class Lead_Keldysh
152  cNTerminal_K = NTerminal_Keldysh('Opt', Opt, 'param', param, 'E', Energy, 'bias_leads', bias_leads, 'EF', EF, 'T', T, 'CustomHamiltoniansHandle', hHamiltonians);
153 
154  % calculate the inverse of the retarded surface Green operator of the isolated scattering center
155  cNTerminal_K.CalcFiniteGreensFunction('onlyGinv', true);
156 
157  % calculate the lesser Green operator
158  lesserG = cNTerminal_K.LesserGreenFunction();
159 
160  % check the equivalence with the equlibrium lesser Green operator
161  retardedG = cNTerminal_K.FL_handles.Read('G');
162  occupation_number = cNTerminal_K.Fermi( Energy );
163  disp(['Occupation number = ', num2str( occupation_number ), ', Energy: ', num2str(Energy), ', temperature = ', num2str(T)]);
164 
165  checkpoint = norm( lesserG - occupation_number*(retardedG'-retardedG ) );
166  if checkpoint > 1e-10
167  warning(['EQuUs:Tests:', fncname, ':checkpoint failed with error ', num2str( checkpoint)]);
168  end
169 
170 
171 
172 
173 %% test of class NTerminal_Keldysh for biased leads
174  disp( '***** test of class NTerminal_Keldysh, biased leads *****' );
175 
176  % create input structures for three-terminal setup
177  [Opt, param] = parseInput( 'Input_ThreeTerminal.xml');
178 
179  % chemical potentials in the leads
180  bias_leads = [0.0 0.0 0.1];
181 
182  % chemical potential in the central device
183  EF = 0.05;
184 
185  % creating function handle for the custom Hamiltonians
186  hHamiltonians = @(varargin)ThreeTerminalHamiltonians(Opt, param, varargin{:});
187 
188  % set new temperature value
189  T = 10;
190 
191  % Set the Energy value
192  Energy = 0.04;
193 
194  % create an instance of class Lead_Keldysh
195  cNTerminal_K = NTerminal_Keldysh('Opt', Opt, 'param', param, 'E', Energy, 'bias_leads', bias_leads, 'EF', EF, 'T', T, 'CustomHamiltoniansHandle', hHamiltonians);
196 
197  % calculate the inverse of the retarded surface Green operator of the isolated scattering center
198  cNTerminal_K.CalcFiniteGreensFunction('onlyGinv', true);
199 
200  % calculate the lesser Green operator
201  [lesserG, junction_sites] = cNTerminal_K.LesserGreenFunction();
202 
203  % **** check the Dyson equation of Eq (6) of Eur. Phys. J. B 53, 537-549 (2006) ****
204 
205  % Calculating the retarded and lesser Green operator of the uncoupled system
206  retardedg = zeros(size(lesserG));
207  lesserg = zeros(size(lesserG));
208 
209 
210  % Calculating the Green operator of the isolated scattering center
211  cNTerminal_K.CalcFiniteGreensFunctionFromHamiltonian();
212  gfin_central = cNTerminal_K.GetFiniteGreensFunction();
213  retardedg(end-size(gfin_central,1)+1:end, end-size(gfin_central,2)+1:end) = gfin_central;
214 
215  % calculating the occupation number of the central region
216  occupation_number = cNTerminal_K.Fermi( Energy );
217  lesserg(end-size(gfin_central,1)+1:end, end-size(gfin_central,2)+1:end) = occupation_number*(gfin_central'-gfin_central);
218 
219  % Calculating the Green operator of the leads
220  Leads = cNTerminal_K.FL_handles.Read( 'Leads' );
221  offset = 0;
222  for idx = 1:length(Leads)
223  Leads{idx}.SurfaceGreenFunction( 'CalcInverse', false );
224  gsurf = Leads{idx}.Read('gsurf');
225  retardedg( offset+(1:size(gsurf,1)), offset+(1:size(gsurf,2)) ) = gsurf;
226 
227  Leads{idx}.LesserSurfaceGreenFunction();
228  lesserg_tmp = Leads{idx}.Read('lessergsurf');
229  lesserg( offset+(1:size(gsurf,1)), offset+(1:size(gsurf,2)) ) = lesserg_tmp;
230 
231  offset = offset + size(gsurf,1);
232  end
233 
234 
235  % obtaining the coupling Hamiltonian
236  Hcoupling = zeros( size(lesserG) );
237  offset = 0;
238  offset_adj = 0;
239  for idx = 1:length(Leads)
240  cNTerminal_K.CreateInterface( idx );
241  tmp = cNTerminal_K.Interface_Regions{idx}.Read('Kcoupling');
242  Hcoupling( offset+(1:size(tmp,1)), end-size(tmp,2)+1:end ) = tmp;
243  offset = offset + size(tmp,1);
244 
245  tmp = cNTerminal_K.Interface_Regions{idx}.Read('Kcouplingadj');
246  Hcoupling( end-size(tmp,1)+1:end, offset_adj+(1:size(tmp,2)) ) = tmp;
247  offset_adj = offset_adj + size(tmp,2);
248 
249 
250  end
251 
252 
253  lesserG2 = lesserg + retardedG*Hcoupling*lesserg + lesserG*Hcoupling*retardedg';
254  checkpoint = norm( lesserG2 - lesserG );
255  if checkpoint > 1e-10
256  warning(['EQuUs:Tests:', fncname, ':checkpoint failed with error ', num2str( checkpoint)]);
257  end
258 
259 
260  % **** checkpoint 3: check the Dyson equation of Eq (13) of PRB 57 7366 ****
261 
262  % create a global matrix containing the retarded self-energies and obtaining the retarded self energies of the leads
263  retarded_self_energy = zeros( size(retardedG) );
264  Leads = cNTerminal_K.FL_handles.Read( 'Leads' );
265  leadnum = length( Leads );
266  for idx = 1:leadnum
267  indexes = junction_sites.Leads{idx}.site_indexes;
268  retarded_self_energy( indexes, indexes ) = Leads{idx}.SelfEnergy();
269  end
270 
271  lesserG3 = (eye(size(lesserG)) + retardedG*Hcoupling)*lesserg*(eye(size(lesserG)) + Hcoupling'*retardedG');
272  checkpoint = norm( lesserG3 - lesserG );
273  if checkpoint > 1e-10
274  warning(['EQuUs:Tests:', fncname, ':checkpoint failed with error ', num2str( checkpoint)]);
275  end
276 
277  % **** checkpoint 4: checking the Dyson equation of the retarded Green operator
278  retardedG_2 = retardedg + retardedg*Hcoupling*retardedG;
279  checkpoint = norm( retardedG_2 - retardedG );
280  if checkpoint > 1e-10
281  warning(['EQuUs:Tests:', fncname, ':checkpoint failed with error ', num2str( checkpoint)]);
282  end
283 
284 
285 
286 end
A class representing a two-terminal structure defined on a preprogrammed lattices for steady state no...
function test(arg1, arg2)
Brief description of the function.
Property G
Green operator of the scattering region.
Definition: NTerminal.m:49
Property T
The temperature in Kelvin.
Definition: FermiDirac.m:35
Property Hanyadik_Lead
The id number of the current lead.
Structure Opt contains the basic computational parameters used in EQuUs.
Definition: structures.m:60
function Transport(Energy, B)
Calculates the conductance at a given energy value.
Property lesserG
Lesser Green operator projected onto the scattering region.
A class to evaluate the Dyson equation derived from class Transport_Interface with specific modificat...
Property EF
The Fermi energy. Attribute E is measured from this value. (Use for equilibrium calculations in the z...
Definition: NTerminal.m:58
Property height
height (length) of the scattering region (number of unit cells)
Definition: Ribbon.m:51
Property bias_leads
An array containing the bias of the leads in the same unit as other energy scales in the Hamiltonians...
A class to calculate the Keldysh lesser and greater Green functions and self energies of a translatio...
Definition: Lead_Keldysh.m:29
function test_Keldysh()
Testfile to check functionalities of the classes developed for steady-state Keldysh formalism.
Property width
width of the scattering region (number of the nonsingular atomic sites in the cross section)
Definition: Ribbon.m:48
function Read(MemberName)
Query for the value of an attribute in the class.
Structure param contains data structures describing the physical parameters of the scattering center ...
Definition: structures.m:45
A class describing an N-terminal geometry for steady state non-equilibrium calculations.
Property CustomHamiltoniansHandle
Function handle to create custom Hamiltonians. Has the same inputs ans outputs as Custom_Hamiltonians...
Definition: NTerminal.m:64
Property bias
The bias on the lead in units of the energy unit in the elements of the Hamiltonian.
Definition: Lead_Keldysh.m:49
function parseInput(filename)
This function parses the input file containing the input parameters.
Property E
The energy used in the calculations.
Definition: NTerminal.m:55
function structures(name)