2 % Copyright (C) 2016 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 utilities Utilities
20 %> @brief A
class to calculate the density of states along a one-dimensional energy array.
22 %> @brief A
class to calculate the density of states along a one-dimensional energy array.
24 %> EQuUs v4.9 or later
29 properties (Access =
public)
30 % A structure containing the calculated
DOS.
36 methods (Access=
public)
38 %% Contructor of the
class 39 %> @brief Constructor of the
class.
41 %> @
param varargin Cell array of optional parameters. For details see #InputParsing.
42 %> @
return An instance of the
class 43 function obj =
DOS(
Opt, varargin )
49 if strcmpi(
class(obj),
'DOS')
50 obj.InputParsing( obj.varargin{:} );
60 %> @brief Calculates the onsite desnity of states.
61 %> @
param Evec One-dimensional array of the energy points.
62 %> @
param varargin Cell array of optional parameters:
63 %> @
param 'JustScatter' Logical value. Set
true to omit the contacts from the system
64 function DOSCalc( obj, Evec, varargin )
67 p.addParameter(
'JustScatter',
false ); %logical value. True
if only an isolated scattering center should be considered in the calculations,
false otherwise.
70 JustScatter = p.Results.JustScatter;
72 obj.create_Hamiltonians(
'junction', obj.junction )
73 Hscatter = obj.junction.CreateH.Read(
'Hscatter');
76 obj.display([
'EQuUs:Utils:',
class(obj),
':DOSCalc: Calculating the DOS between Emin = ', num2str(min(Evec)),
' and Emax = ',num2str(max(Evec)),],1);
79 %> preallocate memory
for Densitysurf
80 DOSvec = complex(zeros( size(Evec) ));
82 % starting parallel pool
83 poolmanager =
Parallel( obj.junction.FL_handles.Read(
'Opt') );
86 %> creating
function handles
for parallel
for 87 hdisplay = @obj.display;
88 hSetEnergy = @obj.SetEnergy;
89 hcomplexSpectral = @obj.complexSpectral;
90 hcreate_scatter = @obj.create_scatter;
92 junction_loc = obj.junction;
94 %
for iidx = 1:length(Evec)
95 parfor (iidx = 1:length(Evec), poolmanager.NumWorkers)
97 %> setting the current energy
98 feval(hSetEnergy, Evec(iidx),
'junction', junction_loc );
100 %> creating the Hamiltonian of the scattering region
101 feval(hcreate_scatter,
'junction', junction_loc );
104 %> evaluating the energy resolved density
105 densityvec2int = feval(hcomplexSpectral, junction_loc, JustScatter);
107 feval(hdisplay, [
'EQuUs:Utils:',
class(obj),
':DOSCalc: Error at energy point E = ', num2str(Evec(iidx)),
' caused by:'], 1);
108 feval(hdisplay, errCause.identifier, 1 );
109 for jjjdx = 1:length(errCause.stack)
110 feval(hdisplay, errCause.stack(jjjdx), 1 );
112 feval(hdisplay, ['EQuUs:Utils:', class(obj), ':DOSCalc: Giving NaN for the calculated current at the given energy point.'], 1);
113 densityvec2int = NaN;
116 DOSvec( iidx ) = -imag( sum( densityvec2int(end-size(Hscatter,1)+1:end)) )/pi;
120 %> closing the parallel pool
121 poolmanager.closePool();
123 % setting the attribute values
124 obj.DOSdata.
DOS = DOSvec;
125 obj.DOSdata.Evec = Evec;
128 obj.display(['EQuUs:Utils:', class(obj), ':DOSCalc: Process finished.'], 1)
130 %reset the system for a new calculation
131 obj.InputParsing( obj.varargin );
144 %> @brief Calculates the local desnity of states for a given energy.
146 %> @
param varargin Cell array of optional parameters:
147 %> @
param 'JustScatter' Logical value. Set true to omit the contacts from the system
148 %> @return Returns with the calculated local
DOS. (An instance of structure
#LocalDOS) 149 function cLocalDOS = LocalDOSCalc( obj, Energy, varargin )
152 p.addParameter(
'JustScatter',
false ); %logical value. True
if only an isolated scattering center should be considered in the calculations,
false otherwise.
154 p.parse(varargin{:});
155 JustScatter = p.Results.JustScatter;
157 obj.create_Hamiltonians(
'junction', obj.junction )
158 Hscatter = obj.junction.CreateH.Read(
'Hscatter');
159 cCoordinates_scatter = obj.junction.CreateH.Read(
'coordinates');
162 obj.display([
'EQuUs:Utils:',
class(obj),
':LocalDOSCalc: Calculating the local DOS at energy E = ', num2str(Energy)],1);
165 junction_loc = obj.junction;
167 %> setting the current energy
168 obj.SetEnergy( Energy,
'junction', junction_loc );
170 %> creating the Hamiltonian of the scattering region
171 obj.create_scatter(
'junction', junction_loc );
174 %> evaluating the energy resolved density
175 densityvec2int = obj.complexSpectral( junction_loc, JustScatter);
177 obj.display( [
'EQuUs:Utils:',
class(obj),
':LocalDOSCalc: Error at energy point E = ', num2str(Evec(iidx)),
' caused by:'], 1);
178 feval(hdisplay, errCause.identifier, 1 );
179 for jjjdx = 1:length(errCause.stack)
180 obj.display( errCause.stack(jjjdx), 1 );
182 obj.display( ['EQuUs:Utils:', class(obj), ':LocalDOSCalc: Giving NaN for the calculated current at the given energy point.'], 1);
183 densityvec2int = NaN;
186 DOSvec = -imag( densityvec2int(end-size(Hscatter,1)+1:end) )/pi;
189 %> creating the data structure of the local density of states
192 cLocalDOS.Energy = Energy;
193 cLocalDOS.DOSvec = DOSvec;
194 cLocalDOS.coordinates = cCoordinates_scatter;
197 obj.display(['EQuUs:Utils:', class(obj), ':DOSCalc: Process finished.'], 1)
199 %reset the system for a new calculation
200 obj.InputParsing( obj.varargin{:} );
216 methods (Access=
protected)
220 %> @brief Calculates the spectral
function at a complex energy
221 %> @
param junction_loc An instance of
class NTerminal or its subclass representing the junction.
222 %> @
param JustScatter logical value. True
if only an isolated scattering center should be considered in the calculations,
false otherwise.
223 %> @
return spectral_function The calculted spectral
function and a data structure containing geometry data of the junction.
224 function [spectral_function,
junction_sites] = complexSpectral( obj, junction_loc, JustScatter )
226 % Obtaining the Hamiltonian of the scattering center
227 Hscatter = junction_loc.CreateH.Read(
'Hscatter');
229 % creating the inverse of the Green opertor related to the scattering center
230 gfininv = speye(size(Hscatter))*junction_loc.getEnergy()-Hscatter;
233 % in
case when just the scattering region is involved in the calculations
236 % Use Dyson equation to attach contacts to the scattering center
237 [~, Ginverz,
junction_sites] = junction_loc.CustomDysonFunc(
'UseHamiltonian',
true,
'onlyGinverz',
true, ...
238 'decimate',
false,
'gfininv', gfininv,
'constant_channels',
false, ...
239 'SelfEnergy', obj.useSelfEnergy,
'keep_sites',
'scatter');
242 spectral_function = obj.diagInv( Ginverz );
248 %% create_Hamiltonians
250 %> @
param varargin Cell array of optional parameters:.
251 function create_Hamiltonians( obj, varargin )
254 p.addParameter(
'junction', obj.junction); %
for parallel computations
255 p.parse(varargin{:});
256 junction_loc = p.Results.junction;
259 %> cerating Hamiltonian of the scattering region
260 obj.create_scatter(
'junction', obj.junction )
263 coordinates_shift = [-2, junction_loc.height+1] + junction_loc.shift;
264 junction_loc.FL_handles.LeadCalc(
'coordinates_shift', coordinates_shift,
'transversepotential', junction_loc.transversepotential, ...
265 'gauge_field', junction_loc.gauge_field,
'q', junction_loc.getTransverseMomentum(),
'leadmodel', junction_loc.leadmodel);
273 %> @brief Creates the Hamiltonian of the scattering center
274 %> @
param varargin Cell array of optional parameters:.
275 function create_scatter( obj, varargin )
278 p.addParameter(
'gauge_trans',
true); % logical:
true if want to perform gauge transformation on the Green
's function and Hamiltonians 279 p.addParameter('junction
', obj.junction); %for parallel computations 280 p.parse(varargin{:}); 281 gauge_trans = p.Results.gauge_trans; 282 junction_loc = p.Results.junction; 284 % create the unit cell of the scattering center 285 junction_loc.CreateScatter(); 287 % apply custom potential in the scattering center 288 if ~isempty(obj.scatterPotential) 289 junction_loc.ApplyPotentialInScatter( junction_loc.CreateH, obj.scatterPotential) 293 % gauge transformation of the calculated effective Hamiltonians 294 if gauge_trans && ~isempty( junction_loc.PeierlsTransform_Scatter ) 295 Hscatter = junction_loc.CreateH.Read('Hscatter
'); 296 coordinates_scatter = junction_loc.CreateH.Read('coordinates
'); 297 Hscatter = junction_loc.PeierlsTransform_Scatter.gaugeTransformation( Hscatter, coordinates_scatter, junction_loc.gauge_field ); 298 junction_loc.CreateH.Write('Hscatter
', Hscatter); 299 %ribbon_loc.PeierlsTransform_Scatter.gaugeTransformationOnLead( ribbon_loc.Scatter_UC, ribbon_loc.gauge_field ); 309 %> @brief Parses the optional parameters for the class constructor. 310 %> @param varargin Cell array of optional parameters: 311 %> @param 'T
' The absolute temperature in Kelvins. 312 %> @param 'scatterPotential
' A function handle y=f( #coordinates coords ) or y=f( #CreateHamiltonians CreateH, E ) of the potential across the junction. 313 %> @param 'useSelfEnergy
' Logical value. Set true (default) to solve the Dyson equation with the self energies of the leads, or false to use the surface Green operators. 314 %> @param 'gfininvfromHamiltonian
' Logical value. Set true calculate the surface Greens function of the scattering region from the Hamiltonaian of the scattering region, or false (default) to calculate it by the fast way (see Phys. Rev. B 90, 125428 (2014) for details). 315 %> @param 'junction
' An instance of a class #NTerminal or its subclass describing the junction. 316 function InputParsing( obj, varargin ) 319 p.addParameter('T
', obj.T); 320 p.addParameter('scatterPotential
', []); 321 p.addParameter('gfininvfromHamiltonian
', false); 322 p.addParameter('useSelfEnergy
', true); 323 p.addParameter('junction
', []); 325 p.parse(varargin{:}); 327 InputParsing@UtilsBase( obj, 'T
', p.Results.T, ... 328 'junction
', p.Results.junction, ... 329 'scatterPotential
', p.Results.scatterPotential, ... 330 'gfininvfromHamiltonian
', p.Results.gfininvfromHamiltonian, ... 331 'useSelfEnergy
', p.Results.useSelfEnergy); 338 end % protected methods A class describing an N-terminal geometry for equilibrium calculations mostly in the zero temperature...
A class for controlling the parallel pool for paralell computations.
Structure Opt contains the basic computational parameters used in EQuUs.
Structure containg the local density of states at a given energy point.
function Transport(Energy, B)
Calculates the conductance at a given energy value.
function Hamiltonians(varargin)
Function to create the custom Hamiltonians for the 1D chain.
Structure containg the energy resolved density of states.
A class to calculate the Green functions and self energies of a translational invariant lead The nota...
Structure param contains data structures describing the physical parameters of the scattering center ...
This class is a base class containing common properties and methods utilized in several other classes...
function structures(name)
function openPool()
Opens a parallel pool for parallel computations.
Structure junction_sites contains data to identify the individual sites of the leads,...