2 % Copyright (C) 2018 Peter Rakyta, Ph.D
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.
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.
14 % You should have received a copy of the GNU General Public License
15 % along with
this program. If not, see http:
17 %> @addtogroup unit_tests Unit Tests
20 %> @brief Testfile to check functionalities of the classes developed
for steady-state Keldysh formalism.
22 %> EQuUs v4.9 or later
24 %> @brief Testfile to check functionalities of the classes developed
for steady-state Keldysh formalism.
27 filename = mfilename('fullpath');
28 [directory, fncname] = fileparts( filename );
33 % defining the width of the lead 1
34 param.Leads{1}.M = 10;
37 % energy value used in the calculations
40 % The temperature in Kelvins
46 % create an instance of class Lead_Keldysh 50 cLead_K.CreateHamiltonians(); 51 %cLead_K.CalcSpektrum('ka_min
', -1, 'ka_max
', 1, 'ka_num
', 100, 'toPlot
', true) 54 cLead_K.TrukkosSajatertekek(Energy); 56 % Calculate The grou velocity 57 cLead_K.Group_Velocity(); 59 % calculate the lesser Self energy 60 cLead_K.LesserSelfEnergy(); 64 %% test of class Ribbon_Keldysh, Transport_Interface_Keldysh 67 % chemical potentials in the leads 68 bias_leads = [0.0 0.0]; 70 % chemical potential in the central device 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); 76 % calculate the inverse of the retarded surface Green operator of the isolated scattering center 77 cRibbon_K.CalcFiniteGreensFunctionFromHamiltonian('onlyGinv
', true); 79 % calculate the lesser Green operator 80 lesserG = cRibbon_K.LesserGreenFunction(); 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)]); 86 checkpoint = norm( lesserG - occupation_number*(retardedG'-retardedG ) );
88 warning([
'EQuUs:Tests:', fncname,
':checkpoint failed with error ', num2str( checkpoint)]);
91 % set
new temperature value
93 cRibbon_K.setTemperature(
T );
95 % calculate the lesser Green
operator 96 lesserG = cRibbon_K.LesserGreenFunction();
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)]);
102 checkpoint = norm(
lesserG - occupation_number*(retardedG
'-retardedG ) ); 103 if checkpoint > 1e-10 104 warning(['EQuUs:Tests:
', fncname, ':checkpoint failed with error
', num2str( checkpoint)]); 108 % set new energy value 111 cRibbon_K.setEnergy( Energy ); 113 % calculate the inverse of the retarded surface Green operator of the isolated scattering center 114 cRibbon_K.CalcFiniteGreensFunctionFromHamiltonian('onlyGinv
', true); 116 % calculate the lesser Green operator 117 lesserG = cRibbon_K.LesserGreenFunction(); 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)]); 124 checkpoint = norm( lesserG - occupation_number*(retardedG'-retardedG ) );
125 if checkpoint > 1e-10
126 warning([
'EQuUs:Tests:', fncname,
':checkpoint failed with error ', num2str( checkpoint)]);
133 % create input structures for three-terminal setup 134 [Opt, param] = parseInput( 'Input_ThreeTerminal.xml
'); 136 % chemical potentials in the leads 137 bias_leads = [0.0 0.0 0.0]; 139 % chemical potential in the central device 142 % creating function handle for the custom Hamiltonians 143 hHamiltonians = @(varargin)ThreeTerminalHamiltonians(Opt, param, varargin{:}); 145 % set new temperature value 148 % Set the Energy value 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); 154 % calculate the inverse of the retarded surface Green operator of the isolated scattering center 155 cNTerminal_K.CalcFiniteGreensFunction('onlyGinv
', true); 157 % calculate the lesser Green operator 158 lesserG = cNTerminal_K.LesserGreenFunction(); 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)]); 165 checkpoint = norm( lesserG - occupation_number*(retardedG'-retardedG ) );
166 if checkpoint > 1e-10
167 warning([
'EQuUs:Tests:', fncname,
':checkpoint failed with error ', num2str( checkpoint)]);
176 % create input structures for three-terminal setup 177 [Opt, param] = parseInput( 'Input_ThreeTerminal.xml
'); 179 % chemical potentials in the leads 180 bias_leads = [0.0 0.0 0.1]; 182 % chemical potential in the central device 185 % creating function handle for the custom Hamiltonians 186 hHamiltonians = @(varargin)ThreeTerminalHamiltonians(Opt, param, varargin{:}); 188 % set new temperature value 191 % Set the Energy value 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); 197 % calculate the inverse of the retarded surface Green operator of the isolated scattering center 198 cNTerminal_K.CalcFiniteGreensFunction('onlyGinv
', true); 200 % calculate the lesser Green operator 201 [lesserG, junction_sites] = cNTerminal_K.LesserGreenFunction(); 203 % **** check the Dyson equation of Eq (6) of Eur. Phys. J. B 53, 537-549 (2006) **** 205 % Calculating the retarded and lesser Green operator of the uncoupled system 206 retardedg = zeros(size(lesserG)); 207 lesserg = zeros(size(lesserG)); 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; 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);
219 % Calculating the Green
operator of the leads
220 Leads = cNTerminal_K.FL_handles.
Read(
'Leads' );
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;
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;
231 offset = offset + size(gsurf,1);
235 % obtaining the coupling Hamiltonian
236 Hcoupling = zeros( size(
lesserG) );
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);
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);
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)]); 260 % **** checkpoint 3: check the Dyson equation of Eq (13) of PRB 57 7366 **** 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 ); 267 indexes = junction_sites.Leads{idx}.site_indexes; 268 retarded_self_energy( indexes, indexes ) = Leads{idx}.SelfEnergy(); 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)]); 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)]); 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.
Property T
The temperature in Kelvin.
Property Hanyadik_Lead
The id number of the current lead.
Structure Opt contains the basic computational parameters used in EQuUs.
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...
Property height
height (length) of the scattering region (number of unit cells)
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...
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)
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 ...
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...
Property bias
The bias on the lead in units of the energy unit in the elements of the Hamiltonian.
Property E
The energy used in the calculations.
function structures(name)