2 % Copyright (C) 2019 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 A
class for calculations on a structure made of two connected leds.
22 %> EQuUs v5.0.144 or later
26 %> @brief A
class for calculations on a structure made of two connected leds.
30 properties ( Access = public )
34 methods ( Access =
public )
35 %% Contructor of the
class 36 %> @brief Constructor of the
class.
38 %> @
param varargin Cell array of optional parameters. For details see #InputParsing.
39 %> @
return An instance of the
class 44 if strcmpi(
class(obj),
'Ribbon_Leads')
45 % processing the optional parameters
46 obj.InputParsing(varargin{:})
49 obj.display([
'EQuUs:Utils:',
class(obj),
':Ribbon_Leads: Creating a Ribbon object'])
51 % create the
shape of the scattering region
57 % exporting calculation parameters into an XML format
60 % create
class intances and initializing class attributes
74 %> @brief Custom Dyson
function for a general two terminal arrangement.
75 %> @
param varargin Cell array of optional parameters (https:
76 %> @
param 'gfininv' The inverse of the Greens
function of the scattering region. For
default the inverse of the attribute #G is used.
77 %> @
param 'constant_channels' Logical value. Set true (
default) to keep constant the number of the open channels in the leads
for each energy value, or
false otherwise.
78 %> @
param 'onlyGinverz' Logical value. Set
true to calculate only the inverse of the total Green
operator, or false (
default) to calculate #G as well.
79 %> @
param 'recalculateSurface' A vector of the identification numbers of the lead surfaces to be recalculated.
80 %> @
param 'decimate' Logical value. Set true (
default) to eliminate all inner
sites in the Greens
function and keep only the selected
sites. Set
false to omit the decimation procedure.
81 %> @
param 'kulso_szabfokok' Array of
sites to be kept after the decimation procedure. (Use parameter
'keep_sites' instead)
82 %> @
param 'selfEnergy' Logical value. Set
true to use the
self energies of the leads in the Dyson equation, or false (
default) to use the surface Green
function instead.
83 %> @
param 'keep_sites' Name of
sites to be kept in the resulted Green function (POssible values are:
'scatter',
'interface',
'lead').
84 %> @
return [1] The calculated Greens
function.
85 %> @
return [2] The inverse of the Green
operator.
86 %> @
return [3] An instance of structure #
junction_sites describing the
sites in the calculated Green
operator.
87 function [Gret, Ginverz,
junction_sites] = CustomDysonFunc( obj, varargin )
90 p.addParameter(
'gfininv', []);
91 p.addParameter(
'constant_channels',
true);
92 p.addParameter(
'onlyGinverz',
false );
93 p.addParameter(
'recalculateSurface', 1:length(obj.param.Leads) );
94 p.addParameter(
'decimate',
true );
95 p.addParameter(
'kulso_szabfokok', []); %The list of
sites to be left after the decimation procedure
96 p.addParameter(
'SelfEnergy',
false); %set
true to calculate the Dyson equation with the
self energy
97 p.addParameter(
'keep_sites',
'lead'); %identification of
sites to be kept (scatter, interface, lead)
99 gfininv = p.Results.gfininv;
100 constant_channels = p.Results.constant_channels;
101 onlyGinverz = p.Results.onlyGinverz;
102 recalculateSurface = p.Results.recalculateSurface;
103 decimate = p.Results.decimate;
105 useSelfEnergy = p.Results.SelfEnergy;
106 keep_sites = p.Results.keep_sites;
109 if ~isempty( obj.Ginv )
112 rcond_G = rcond(obj.G);
113 if isnan(rcond_G) || abs( rcond_G ) < 1e-15
114 gfininv = obj.inv_SVD( obj.G );
116 gfininv = inv(obj.G);
121 if ~isempty(recalculateSurface)
123 % creating interfaces for the Leads
125 shiftLeads = ones(length(obj.
param.Leads),1)*obj.E;
127 shiftLeads = ones(length(obj.
param.Leads),1)*0;
130 % creating objects describing the Leads
131 Leads = obj.FL_handles.LeadCalc('shiftLeads', shiftLeads, ...
132 'SelfEnergy', useSelfEnergy, 'SurfaceGreensFunction', ~useSelfEnergy, '
gauge_field', obj.
gauge_field, 'leads', recalculateSurface, 'q', obj.q, ...
133 'leadmodel', obj.leadmodel, 'CustomHamiltonian', obj.cCustom_Hamiltonians);
135 Leads = obj.FL_handles.Read( 'Leads' );
139 Neffs = obj.FL_handles.Get_Neff();
143 Ginverz = CalcGinverzwithSelfEnergy();
145 Ginverz = CalcGinverz();
151 GetSitesForDecimation();
152 Ginverz = obj.DecimationFunction( kulso_szabfokok, Ginverz);
162 if issparse( Ginverz )
163 err = MException(['EQuUs:Utils:', class(obj), ':CustomDysonFunc', 'Ginverz is sparse. Calculation of the inverse of a sparse matrix is not supported at this point']);
164 save('Error_Ribbon_CustomDysonFunc.mat');
168 rcond_Ginverz = rcond(Ginverz);
169 if isnan( rcond_Ginverz )
170 err = MException(['EQuUs:Utils:', class(obj), ':CustomDysonFunc'], 'NaN is the condition number for Ginverz');
171 save('Error_Ribbon_CustomDysonFunc.mat');
175 if abs( rcond_Ginverz ) < 1e-15
176 obj.display( ['EQuUs:Utils:', class(obj), ':CustomDysonFunc: Regularizing Ginverz by SVD'],1);
177 Gret = obj.inv_SVD( Ginverz );
179 Gret = inv( Ginverz );
184 %-------------------------------
185 %> calculate the inverse Greens function
186 function Ginverz = CalcGinverz()
188 Gsurfinverz = cell(length(Neffs),1);
189 for idx = 1:length(Neffs)
190 Gsurfinverz{idx} = Leads{idx}.Read(
'gsurfinv');
193 K_interface = cell(length(Neffs),1);
194 K1_sc = cell(length(Neffs),1);
195 K1adj_sc = cell(length(Neffs),1);
196 K1 = cell(length(Neffs),1);
197 K1adj = cell(length(Neffs),1);
198 for idx = 1:length(recalculateSurface)
199 obj.CreateInterface( recalculateSurface(idx) );
201 for idx = 1:length( obj.Interface_Regions )
202 [K_interface{idx}, K1{idx}, K1adj{idx}, K1_sc{idx}, K1adj_sc{idx}] = obj.Interface_Regions{idx}.Get_Effective_Hamiltonians();
206 %Ginverz = [Gsurfinverz{1}, -K1{1}; -K1adj{1}, Gsurfinverz{2}];
209 % leads and the
interface region
212 Ginverz_leads = [Gsurfinverz{1}, zeros(size(Gsurfinverz{1})); zeros(size(Gsurfinverz{1})), Gsurfinverz{2}];
215 Ginverz_interface = [-K_interface{1}, -K1adj{2}; -K1{2}, -K_interface{2}];
218 Ginverz_coupling = [ K1_sc{1}; K1_sc{2}];
219 Ginverz_coupling_adj = [ K1adj_sc{1}, K1adj_sc{2}];
221 Ginverz = [Ginverz_leads, Ginverz_coupling; Ginverz_coupling_adj, Ginverz_interface];
226 %-------------------------------
227 % calculate the inverse Greens
function with the
self energy
228 function Ginverz = CalcGinverzwithSelfEnergy()
230 error('Not developed yet')
235 % creating site indexes corresponding to the elements of the calculated Green operator
240 % determine the matrix sizes
241 size_K0_leads = zeros(length(Leads), 1);
242 size_K0_interface = zeros(length(Leads), 1);
243 for kdx = 1:length(Leads)
244 K0_lead = Leads{kdx}.Get_Effective_Hamiltonians();
245 size_K0_leads(kdx) = size(K0_lead,1);
247 K0_interface = obj.Interface_Regions{kdx}.Get_Effective_Hamiltonians();
248 size_K0_interface(kdx) = size(K0_interface,1);
251 % determine junction
sites corresponding to the scattering region
259 junction_sites.Scatter.site_indexes = sum(size_K0_leads) + sum(size_K0_interface) + (1:size(gfininv,1)); %including 2*
interface regions and 2 leads
262 % determine junction
sites corresponding to the interface
266 [~, coordinates_interface] = obj.getCoordinates();
267 for kdx = 1:length(Leads)
294 % Obtain the site indexes to be decimated out and removes the unnecesarry
sites from the structure
junction_sites according to the
295 % performed decimation
296 function GetSitesForDecimation()
298 if isempty(kulso_szabfokok)
299 if strcmpi(keep_sites, 'scatter')
300 kulso_szabfokok = get_scatter_sites();
306 elseif strcmpi(keep_sites, 'interface')
307 kulso_szabfokok = get_interface_sites();
317 elseif strcmpi(keep_sites,
'lead')
318 kulso_szabfokok = get_lead_sites();
328 error([
'EQuUs:Utils:',
class(obj),
':CustomDysonFunc'], [
'Undifined Sites: ', keep_sites]);
332 %
for custom given kulso_szabfokok
334 % determine
sites in the scattering center
338 % determine
sites in the
interface regions
344 % determine
sites in the
interface regions
352 %-------------------------------------------------------------
353 % an auxilary
function to select the
sites to be kept
354 function sites_ret = SelectSites(
sites )
356 start_index = find( min(site_indexes_tmp) <= kulso_szabfokok, 1,
'first');
357 end_index = find( max(site_indexes_tmp) >= kulso_szabfokok, 1,
'last');
359 if isempty(start_index)
367 % selecting site indexes
368 if isempty(end_index)
369 sites_ret.site_indexes = 1:length(kulso_szabfokok(start_index:end));
371 sites_ret.site_indexes = 1:length(kulso_szabfokok(start_index:end_index));
374 % selecting coordinate sof the
sites 376 for iidx = 1:length(names)
377 fieldname = names(iidx);
378 if strcmpi( fieldname,
'a') || strcmpi( fieldname,
'b')
382 field_tmp = sites_ret.coordinates.(fieldname);
384 if isempty(field_tmp)
388 if isempty(end_index)
389 field_tmp = field_tmp( kulso_szabfokok(start_index:end) - min(site_indexes_tmp) + 1 );
391 field_tmp = field_tmp( kulso_szabfokok(start_index:end_index) - min(site_indexes_tmp) + 1 );
393 sites_ret.coordinates.(fieldname) = field_tmp;
402 %-------------------------------
403 % determine the site indexes of the scattering region within Ginverz
404 function kulso_szabfokok = get_scatter_sites()
408 %-------------------------------
409 % determine the site indexes of the interface region within Ginverz
410 function kulso_szabfokok = get_interface_sites()
413 size_interface = size_interface + length(
junction_sites.Interface{idx}.site_indexes);
416 kulso_szabfokok = zeros( size_interface, 1);
419 indexes = size_interface + ( 1:length(
junction_sites.Interface{idx}.site_indexes) );
426 %-------------------------------
427 % determine the site indexes of the leads within Ginverz
428 function kulso_szabfokok = get_lead_sites()
432 size_leads = size_leads + length(
junction_sites.Leads{idx}.site_indexes);
435 kulso_szabfokok = zeros( size_leads, 1);
438 indexes = size_leads + ( 1:length(
junction_sites.Leads{idx}.site_indexes) );
446 % end nested functions
453 %> @brief Creates a clone of the present
object.
454 %> @
return Returns with the cloned
object.
455 function ret = CreateClone( obj )
458 'height', obj.height, ...
459 'filenameIn', obj.filenameIn, ...
460 'filenameOut', obj.filenameOut, ...
464 'silent', obj.silent, ...
465 'transversepotential', obj.transversepotential, ...
467 'param', obj.param, ...
469 'leadmodel', obj.leadmodel, ...
470 'interfacemodel', obj.interfacemodel);
473 ret.CreateH = obj.CreateH.CreateClone();
474 ret.FL_handles = obj.FL_handles.CreateClone();
475 ret.Scatter_UC = obj.Scatter_UC.CreateClone();
476 ret.Interface_Regions = cell(size(obj.Interface_Regions));
477 for idx = 1:length(obj.Interface_Regions)
478 ret.Interface_Regions{idx} = obj.Interface_Regions{idx}.CreateClone();
480 if ~isempty( obj.PeierlsTransform_Scatter )
481 ret.PeierlsTransform_Scatter = obj.PeierlsTransform_Scatter.CreateClone();
484 if ~isempty( obj.PeierlsTransform_Leads )
485 ret.PeierlsTransform_Leads = obj.PeierlsTransform_Leads.CreateClone();
495 methods (Access=protected)
499 %> @brief Parses the optional parameters for the class constructor.
500 %> @
param varargin Cell array of optional parameters (https:
501 %> @
param 'width' Integer. The number of the nonsingular atomic
sites in the cross section of the ribbon.
502 %> @
param 'height' Integer. The height of the ribbon in units of the lattice vector.
503 %> @
param 'filenameIn' The input filename containing the computational parameters. (Use parameters 'Op' and '
param' instead)
504 %> @
param 'filenameOut' The output filename to export the computational parameters.
505 %> @
param 'WorkingDir' The absolute path to the working directoy.
506 %> @
param 'E' The energy value used in the calculations (in the same units as the Hamiltonian).
507 %> @
param 'EF' The Fermi energy in the same units as the Hamiltonian. Attribute
#E is measured from this value. (Use for equilibrium calculations in the zero temperature limit. Overrides the one comming from the external source) 508 %> @
param 'silent' Set
true to suppress output messages.
512 %> @
param 'Opt' An instance of the structure #
Opt.
513 %> @
param 'param' An instance of the structure #
param.
514 %> @
param 'q' The transverse momentum quantum number.
515 function InputParsing( obj, varargin )
516 % calling the input parsing of the superclass
517 InputParsing@
Ribbon( obj, varargin{:});
521 end % methdos
protected Structure Opt contains the basic computational parameters used in EQuUs.
Structure shape contains data about the geometry of the scattering region.
Class to create and store Hamiltonian of the translational invariant leads.
A class for calculations on a ribbon of finite width for equilibrium calculations mostly in the zero ...
sites Interface
Structure sites describing the geometry of the interface regions.
function Transport(Energy, B)
Calculates the conductance at a given energy value.
A class to evaluate the Dyson equation and to calculate the scattering matrix for equilibrium process...
function Hamiltonians(varargin)
Function to create the custom Hamiltonians for the 1D chain.
function createOutput(filename, Opt, param)
This function creates an output file containing the running parameters.
function Landauy(x, y, eta_B)
Vector potential in the Landau gauge parallel to the y direction.
kulso_szabfokok
An array containing the site indexes connected to other parts.
A class describing the interface region between the scattering region and a lead.
A class to calculate the Green functions and self energies of a translational invariant lead The nota...
function InterfaceModel(Interface_Region)
Method to adjust the Hamiltonians of the interface regions.
Structure param contains data structures describing the physical parameters of the scattering center ...
site_indexes
An array containing the site indexes of the given system part.
Structure sites contains data to identify the individual sites in a matrix.
sites Leads
Structure sites describing the geometry of the leads.
function Landaux(x, y, eta_B, Aconst, height, lattice_constant)
Vector potential in the Landau gauge parallel to the x direction.
function SurfaceGreenFunctionCalculator(idx, varargin)
Calculates the surface Green's function or the self energy of a Lead.
function gauge_field(x, y, eta_B, Aconst, height, lattice_constant)
Scalar gauge field connecting Landaux and Landauy gauges.
coordinates
An instance of structure coordinates describing the geometry.
sites Scatter
Structure sites describing the geometry of the scattering region.
Structure containing the coordinates and other quantum number identifiers of the sites in the Hamilto...
function structures(name)
Structure junction_sites contains data to identify the individual sites of the leads,...