Eötvös Quantum Utilities  v5.0.144
Providing the Horsepowers in the Quantum Realm
DOS.m
Go to the documentation of this file.
1 %% Eotvos Quantum Transport Utilities - DOS
2 % Copyright (C) 2016 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 utilities Utilities
18 %> @{
19 %> @file DOS.m
20 %> @brief A class to calculate the density of states along a one-dimensional energy array.
21 %> @}
22 %> @brief A class to calculate the density of states along a one-dimensional energy array.
23 %> @Available
24 %> EQuUs v4.9 or later
25 %%
26 classdef DOS < UtilsBase
27 
28 
29  properties (Access = public)
30  % A structure containing the calculated DOS.
31  DOSdata
32 
33  end
34 
35 
36 methods (Access=public)
37 
38 %% Contructor of the class
39 %> @brief Constructor of the class.
40 %> @param Opt An instance of structure #Opt.
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 )
44 
45  obj = obj@UtilsBase( Opt, varargin{:} );
46 
47  obj.DOSdata = structures('DOS');
48 
49  if strcmpi(class(obj), 'DOS')
50  obj.InputParsing( obj.varargin{:} );
51  end
52 
53 
54  end
55 
56 
57 
58 
59 %% DOSCalc
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 )
65 
66  p = inputParser;
67  p.addParameter('JustScatter', false ); %logical value. True if only an isolated scattering center should be considered in the calculations, false otherwise.
68 
69  p.parse(varargin{:});
70  JustScatter = p.Results.JustScatter;
71 
72  obj.create_Hamiltonians( 'junction', obj.junction )
73  Hscatter = obj.junction.CreateH.Read('Hscatter');
74 
75 
76  obj.display(['EQuUs:Utils:', class(obj), ':DOSCalc: Calculating the DOS between Emin = ', num2str(min(Evec)),' and Emax = ',num2str(max(Evec)),],1);
77 
78 
79  %> preallocate memory for Densitysurf
80  DOSvec = complex(zeros( size(Evec) ));
81 
82  % starting parallel pool
83  poolmanager = Parallel( obj.junction.FL_handles.Read('Opt') );
84  poolmanager.openPool();
85 
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;
91 
92  junction_loc = obj.junction;
93 
94  %for iidx = 1:length(Evec)
95  parfor (iidx = 1:length(Evec), poolmanager.NumWorkers)
96 
97  %> setting the current energy
98  feval(hSetEnergy, Evec(iidx), 'junction', junction_loc );
99 
100  %> creating the Hamiltonian of the scattering region
101  feval(hcreate_scatter, 'junction', junction_loc );
102 
103  try
104  %> evaluating the energy resolved density
105  densityvec2int = feval(hcomplexSpectral, junction_loc, JustScatter);
106  catch errCause
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 );
111  end
112  feval(hdisplay, ['EQuUs:Utils:', class(obj), ':DOSCalc: Giving NaN for the calculated current at the given energy point.'], 1);
113  densityvec2int = NaN;
114  end
115 
116  DOSvec( iidx ) = -imag( sum( densityvec2int ) )/pi;
117 
118  end
119 
120  %> closing the parallel pool
121  poolmanager.closePool();
122 
123  % setting the attribute values
124  obj.DOSdata.DOS = DOSvec;
125  obj.DOSdata.Evec = Evec;
126 
127 
128  obj.display(['EQuUs:Utils:', class(obj), ':DOSCalc: Process finished.'], 1)
129 
130  %reset the system for a new calculation
131  obj.InputParsing( obj.varargin{:} );
132 
133 
134 
135 
136 
137 
138 
139 
140  end
141 
142 
143 %% LocalDOSCalc
144 %> @brief Calculates the local desnity of states for a given energy.
145 %> @param Energy The energy value in the units of the Hamiltonians
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 )
151 
152  p = inputParser;
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', [] );
155 
156  p.parse(varargin{:});
157  JustScatter = p.Results.JustScatter;
158  ChoseSites = p.Results.ChoseSites;
159 
160  obj.create_Hamiltonians( 'junction', obj.junction )
161  Hscatter = obj.junction.CreateH.Read('Hscatter');
162  cCoordinates_scatter = obj.junction.CreateH.Read('coordinates');
163 
164 
165  obj.display(['EQuUs:Utils:', class(obj), ':LocalDOSCalc: Calculating the local DOS at energy E = ', num2str(Energy)],1);
166 
167 
168  junction_loc = obj.junction;
169 
170  % setting the current energy
171  obj.SetEnergy( Energy, 'junction', junction_loc );
172 
173  % creating the Hamiltonian of the scattering region
174  obj.create_scatter( 'junction', junction_loc );
175 
176  % setting the function handle for displaying the message
177  hdisplay = @obj.display;
178 
179  try
180  % evaluating the energy resolved density
181  densityvec2int = obj.complexSpectral( junction_loc, JustScatter, 'ChoseSites', ChoseSites);
182  catch errCause
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 );
187  end
188  obj.display( ['EQuUs:Utils:', class(obj), ':LocalDOSCalc: Giving NaN for the calculated current at the given energy point.'], 1);
189  densityvec2int = NaN;
190  end
191 
192  DOSvec = -imag( densityvec2int )/pi;
193 
194 
195  % creating the data structure of the local density of states
196  cLocalDOS = structures( 'LocalDOS');
197 
198  cLocalDOS.Energy = Energy;
199  cLocalDOS.DOSvec = DOSvec;
200 
201  if ~isempty( ChoseSites )
202  cCoordinates_scatter = cCoordinates_scatter.KeepSites( ChoseSites( cCoordinates_scatter ) );
203  end
204  cLocalDOS.coordinates = cCoordinates_scatter;
205 
206  obj.display(['EQuUs:Utils:', class(obj), ':DOSCalc: Process finished.'], 1)
207 
208  %reset the system for a new calculation
209  obj.InputParsing( obj.varargin{:} );
210 
211 
212 
213 
214 
215 
216 
217 
218  end
219 
220 
221 
222  end % public methods
223 
224 
225  methods (Access=protected)
226 
227 
228 %% complexSpectral
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 )
236 
237  p = inputParser;
238  p.addParameter('ChoseSites', [] );
239 
240  p.parse(varargin{:});
241  ChoseSites = p.Results.ChoseSites;
242 
243  % Obtaining the Hamiltonian of the scattering center
244  Hscatter = junction_loc.CreateH.Read('Hscatter');
245  Hscatter_transverse = junction_loc.CreateH.Read('Hscatter_transverse');
246 
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));
250  end
251 
252  % creating the inverse of the Green opertor related to the scattering center
253  gfininv = speye(size(Hscatter))*junction_loc.getEnergy()-Hscatter;
254 
255 
256 
257  if JustScatter
258  % in case when just the scattering region is involved in the calculations
259  Ginverz = gfininv;
260  else
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');
265  end
266 
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);
272  else
273 
274  % deterirmine sites in the scattering region to be calculated
275  cCoordinates_scatter = junction_loc.CreateH.Read('coordinates');
276  ChosenSites_scatter = ChoseSites( cCoordinates_scatter );
277 
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;
281 
282  Ginverz = [ Ginverz( ~indexes2calc, ~indexes2calc) , Ginverz(~indexes2calc, indexes2calc);
283  Ginverz(indexes2calc, ~indexes2calc), Ginverz(indexes2calc, indexes2calc)];
284 
285  try
286  spectral_function = obj.partialInv( Ginverz, length(cCoordinates_scatter.x(ChosenSites_scatter)) );
287  spectral_function = diag(spectral_function);
288  catch
289  spectral_function = NaN(length(cCoordinates_scatter.x(ChosenSites_scatter)), 1);
290  end
291  end
292 
293 
294  end
295 
296 
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 )
301 
302  p = inputParser;
303  p.addParameter('junction', obj.junction); %for parallel computations
304  p.parse(varargin{:});
305  junction_loc = p.Results.junction;
306 
307 
308  % cerating Hamiltonian of the scattering region
309  obj.create_scatter( 'junction', obj.junction )
310 
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);
317  else
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);
319  end
320 
321 
322 
323 
324  end
325 
326 
327 %% create_scatter
328 %> @brief Creates the Hamiltonian of the scattering center
329 %> @param varargin Cell array of optional parameters:.
330  function create_scatter( obj, varargin )
331 
332  p = inputParser;
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;
338 
339  % create the unit cell of the scattering center
340  junction_loc.CreateScatter();
341 
342  % apply custom potential in the scattering center
343  if ~isempty(obj.scatterPotential)
344  junction_loc.ApplyPotentialInScatter( junction_loc.CreateH, obj.scatterPotential)
345  end
346 
347 
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 );
355  end
356 
357 
358  end
359 
360 
361 
362 
363 %% InputParsing
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.
371  function InputParsing( obj, varargin )
372 
373  p = inputParser;
374  p.addParameter('T', obj.T);
375  p.addParameter('scatterPotential', []);
376  p.addParameter('gfininvfromHamiltonian', false);
377  p.addParameter('useSelfEnergy', true);
378  p.addParameter('junction', []);
379 
380  p.parse(varargin{:});
381 
382  InputParsing@UtilsBase( obj, 'T', p.Results.T, ...
383  'junction', p.Results.junction, ...
384  'scatterPotential', p.Results.scatterPotential, ...
385  'gfininvfromHamiltonian', p.Results.gfininvfromHamiltonian, ...
386  'useSelfEnergy', p.Results.useSelfEnergy);
387 
388 
389 
390  end %
391 
392 
393 end % protected methods
394 end
Property y
A vector containing the $y$ coordinates of the sites in units of the lattice constant.
Definition: Coordinates.m:33
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...
Definition: NTerminal.m:38
A class for controlling the parallel pool for paralell computations.
Definition: Parallel.m:26
Structure Opt contains the basic computational parameters used in EQuUs.
Definition: structures.m:60
Structure containg the local density of states at a given energy point.
Definition: structures.m:207
A class for calculations on a ribbon of finite width for equilibrium calculations mostly in the zero ...
Definition: Ribbon.m:34
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.
Definition: structures.m:198
Structure param contains data structures describing the physical parameters of the scattering center ...
Definition: structures.m:45
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.
Definition: structures.m:187
This class is a base class containing common properties and methods utilized in several other classes...
Definition: UtilsBase.m:26
Property a
The lattice vector of the translational invariant lead in units of the lattice constant.
Definition: Coordinates.m:39
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...
Definition: Coordinates.m:24
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,...
Definition: structures.m:176