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 ) )/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 %> @
param 'ChoseSites' Function
handle ret = ChoseSites( #
Coordinates ) returning an array of logical values. The local
DOS is calculated
for those
sites in the scattering region, which are labeled with
true in the array ret. (ret should be the same size as the x,y,z arrays in the input
class #
Coordinates.)
149 %> @
return Returns with the calculated local
DOS. (An instance of structure #
LocalDOS)
150 function cLocalDOS = LocalDOSCalc( obj, Energy, varargin )
153 p.addParameter(
'JustScatter',
false ); %logical value. True
if only an isolated scattering center should be considered in the calculations,
false otherwise.
154 p.addParameter(
'ChoseSites', [] );
156 p.parse(varargin{:});
157 JustScatter = p.Results.JustScatter;
158 ChoseSites = p.Results.ChoseSites;
161 Hscatter = obj.junction.CreateH.Read(
'Hscatter');
162 cCoordinates_scatter = obj.junction.CreateH.Read(
'coordinates');
165 obj.display([
'EQuUs:Utils:',
class(obj),
':LocalDOSCalc: Calculating the local DOS at energy E = ', num2str(Energy)],1);
168 junction_loc = obj.junction;
170 % setting the current energy
171 obj.SetEnergy( Energy,
'junction', junction_loc );
173 % creating the Hamiltonian of the scattering region
174 obj.create_scatter(
'junction', junction_loc );
176 % setting the
function handle for displaying the message
177 hdisplay = @obj.display;
180 % evaluating the energy resolved density
181 densityvec2int = obj.complexSpectral( junction_loc, JustScatter,
'ChoseSites', ChoseSites);
183 obj.display( [
'EQuUs:Utils:',
class(obj),
':LocalDOSCalc: Error at energy point E = ', num2str(Energy),
' caused by:'], 1);
184 feval(hdisplay, errCause.identifier, 1 );
185 for jjjdx = 1:length(errCause.stack)
186 obj.display( errCause.stack(jjjdx), 1 );
188 obj.display( ['EQuUs:Utils:', class(obj), ':LocalDOSCalc: Giving NaN for the calculated current at the given energy point.'], 1);
189 densityvec2int = NaN;
192 DOSvec = -imag( densityvec2int )/pi;
195 % creating the data structure of the local density of states
198 cLocalDOS.Energy = Energy;
199 cLocalDOS.DOSvec = DOSvec;
201 if ~isempty( ChoseSites )
202 cCoordinates_scatter = cCoordinates_scatter.
KeepSites( ChoseSites( cCoordinates_scatter ) );
204 cLocalDOS.coordinates = cCoordinates_scatter;
206 obj.display(['EQuUs:Utils:', class(obj), ':DOSCalc: Process finished.'], 1)
208 %reset the system for
a new calculation
209 obj.InputParsing( obj.varargin{:} );
225 methods (Access=
protected)
229 %> @brief Calculates the spectral
function at
a complex energy
230 %> @
param junction_loc An instance of
class NTerminal or its subclass representing the junction.
231 %> @
param JustScatter logical value. True
if only an isolated scattering center should be considered in the calculations,
false otherwise.
232 %> @
param varargin Cell array of optional parameters:
233 %> @
param 'ChoseSites' Function
handle ret = ChoseSites( #
Coordinates ) returning an array of logical values. The local
DOS is calculated
for those
sites in the scattering region, which are labeled with
true in the array ret. (ret should be the same size as the x,y,z arrays in the input
class #
Coordinates.)
234 %> @
return spectral_function The calculted spectral
function and
a data structure containing geometry data of the junction.
235 function [spectral_function,
junction_sites] = complexSpectral( obj, junction_loc, JustScatter, varargin )
238 p.addParameter(
'ChoseSites', [] );
240 p.parse(varargin{:});
241 ChoseSites = p.Results.ChoseSites;
243 % Obtaining the Hamiltonian of the scattering center
244 Hscatter = junction_loc.CreateH.Read(
'Hscatter');
245 Hscatter_transverse = junction_loc.CreateH.Read(
'Hscatter_transverse');
247 q = junction_loc.CreateH.Read(
'q');
248 if ~isempty( q ) && ~junction_loc.CreateH.Read(
'HamiltoniansDecimated')
249 Hscatter = Hscatter + Hscatter_transverse*diag(exp(1i*q)) + Hscatter_transverse
'*diag(exp(-1i*q)); 252 % creating the inverse of the Green opertor related to the scattering center 253 gfininv = speye(size(Hscatter))*junction_loc.getEnergy()-Hscatter; 258 % in case when just the scattering region is involved in the calculations 261 % Use Dyson equation to attach contacts to the scattering center 262 [~, Ginverz, junction_sites] = junction_loc.CustomDysonFunc( 'UseHamiltonian
', true, 'onlyGinverz
', true, ... 263 'decimate
', false, 'gfininv
', gfininv, 'constant_channels
', false, ... 264 'SelfEnergy
', obj.useSelfEnergy, 'keep_sites
', 'scatter
'); 267 if isempty( ChoseSites ) 268 % if no geometrical constriction on the sites of the scatter 269 % region, then all the sites are kept in the calculations 270 spectral_function = obj.diagInv( Ginverz ); 271 spectral_function = spectral_function(end-size(Hscatter,1)+1:end); 274 % deterirmine sites in the scattering region to be calculated 275 cCoordinates_scatter = junction_loc.CreateH.Read('coordinates
'); 276 ChosenSites_scatter = ChoseSites( cCoordinates_scatter ); 278 % determine sites to be calculated in the full system 279 indexes2calc = false( size(Ginverz,1), 1 ); 280 indexes2calc( end-size(Hscatter,1)+1:end) = ChosenSites_scatter; 282 Ginverz = [ Ginverz( ~indexes2calc, ~indexes2calc) , Ginverz(~indexes2calc, indexes2calc); 283 Ginverz(indexes2calc, ~indexes2calc), Ginverz(indexes2calc, indexes2calc)]; 286 spectral_function = obj.partialInv( Ginverz, length(cCoordinates_scatter.x(ChosenSites_scatter)) ); 287 spectral_function = diag(spectral_function); 289 spectral_function = NaN(length(cCoordinates_scatter.x(ChosenSites_scatter)), 1); 297 %% create_Hamiltonians 298 %> @brief Creates the Hamiltonians of the system 299 %> @param varargin Cell array of optional parameters:. 300 function create_Hamiltonians( obj, varargin ) 303 p.addParameter('junction
', obj.junction); %for parallel computations 304 p.parse(varargin{:}); 305 junction_loc = p.Results.junction; 308 % cerating Hamiltonian of the scattering region 309 obj.create_scatter( 'junction
', obj.junction ) 311 % creating the Lead Hamiltonians 312 supClasses = superclasses(obj.junction); 313 if sum( strcmp( supClasses, 'Ribbon' ) ) > 0 314 coordinates_shift = [-2, junction_loc.height+1] + junction_loc.shift; 315 junction_loc.FL_handles.LeadCalc('coordinates_shift
', coordinates_shift, 'transversepotential
', junction_loc.transversepotential, ... 316 'gauge_field', junction_loc.gauge_field, 'q
', junction_loc.getTransverseMomentum(), 'leadmodel
', junction_loc.leadmodel); 318 junction_loc.FL_handles.LeadCalc( 'CustomHamiltonian
', junction_loc.cCustom_Hamiltonians , 'gauge_field', junction_loc.gauge_field, 'q
', junction_loc.getTransverseMomentum(), 'leadmodel
', junction_loc.leadmodel); 328 %> @brief Creates the Hamiltonian of the scattering center 329 %> @param varargin Cell array of optional parameters:. 330 function create_scatter( obj, varargin ) 333 p.addParameter('gauge_trans
', true); % logical: true if want to perform gauge transformation on the Green's
function and
Hamiltonians 334 p.addParameter(
'junction', obj.junction); %
for parallel computations
335 p.parse(varargin{:});
336 gauge_trans = p.Results.gauge_trans;
337 junction_loc = p.Results.junction;
339 % create the unit cell of the scattering center
340 junction_loc.CreateScatter();
342 % apply custom potential in the scattering center
343 if ~isempty(obj.scatterPotential)
344 junction_loc.ApplyPotentialInScatter( junction_loc.CreateH, obj.scatterPotential)
348 % gauge transformation of the calculated effective
Hamiltonians 349 if gauge_trans && ~isempty( junction_loc.PeierlsTransform_Scatter )
350 Hscatter = junction_loc.CreateH.Read('Hscatter');
351 coordinates_scatter = junction_loc.CreateH.Read('coordinates');
352 Hscatter = junction_loc.PeierlsTransform_Scatter.gaugeTransformation( Hscatter, coordinates_scatter, junction_loc.
gauge_field );
353 junction_loc.CreateH.Write('Hscatter', Hscatter);
354 %ribbon_loc.PeierlsTransform_Scatter.gaugeTransformationOnLead( ribbon_loc.Scatter_UC, ribbon_loc.
gauge_field );
364 %> @brief Parses the optional parameters for the class constructor.
365 %> @
param varargin Cell array of optional parameters:
366 %> @
param 'T' The absolute temperature in Kelvins.
367 %> @
param 'scatterPotential' A function
handle y=f(
#coordinates coords ) or y=f( #CreateHamiltonians CreateH, E ) of the potential across the junction. 368 %> @
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.
369 %> @
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).
370 %> @
param 'junction' An instance of
a class #
NTerminal or its subclass describing the junction.
374 p.addParameter(
'T', obj.T);
375 p.addParameter(
'scatterPotential', []);
376 p.addParameter(
'gfininvfromHamiltonian',
false);
377 p.addParameter(
'useSelfEnergy',
true);
378 p.addParameter(
'junction', []);
380 p.parse(varargin{:});
383 'junction', p.Results.junction, ...
384 'scatterPotential', p.Results.scatterPotential, ...
385 'gfininvfromHamiltonian', p.Results.gfininvfromHamiltonian, ...
386 'useSelfEnergy', p.Results.useSelfEnergy);
393 end %
protected methods
Property y
A vector containing the $y$ coordinates of the sites in units of the lattice constant.
function create_Hamiltonians(varargin)
Creates the Hamiltonians of the system.
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.
A class for calculations on a ribbon of finite width for equilibrium calculations mostly in the zero ...
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.
Structure param contains data structures describing the physical parameters of the scattering center ...
function KeepSites(indexes)
Keep only sites in the structure defined by the input parameter #indexes.
Structure sites contains data to identify the individual sites in a matrix.
This class is a base class containing common properties and methods utilized in several other classes...
Property a
The lattice vector of the translational invariant lead in units of the lattice constant.
function gauge_field(x, y, eta_B, Aconst, height, lattice_constant)
Scalar gauge field connecting Landaux and Landauy gauges.
function InputParsing(varargin)
Parses the optional parameters for the class constructor.
Structure containing the coordinates and other quantum number identifiers of the sites in the Hamilto...
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,...