Eötvös Quantum Utilities  v4.9.146
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(end-size(Hscatter,1)+1:end)) )/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 %> @return Returns with the calculated local DOS. (An instance of structure #LocalDOS)
149  function cLocalDOS = LocalDOSCalc( obj, Energy, varargin )
150 
151  p = inputParser;
152  p.addParameter('JustScatter', false ); %logical value. True if only an isolated scattering center should be considered in the calculations, false otherwise.
153 
154  p.parse(varargin{:});
155  JustScatter = p.Results.JustScatter;
156 
157  obj.create_Hamiltonians( 'junction', obj.junction )
158  Hscatter = obj.junction.CreateH.Read('Hscatter');
159  cCoordinates_scatter = obj.junction.CreateH.Read('coordinates');
160 
161 
162  obj.display(['EQuUs:Utils:', class(obj), ':LocalDOSCalc: Calculating the local DOS at energy E = ', num2str(Energy)],1);
163 
164 
165  junction_loc = obj.junction;
166 
167  %> setting the current energy
168  obj.SetEnergy( Energy, 'junction', junction_loc );
169 
170  %> creating the Hamiltonian of the scattering region
171  obj.create_scatter( 'junction', junction_loc );
172 
173  try
174  %> evaluating the energy resolved density
175  densityvec2int = obj.complexSpectral( junction_loc, JustScatter);
176  catch errCause
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 );
181  end
182  obj.display( ['EQuUs:Utils:', class(obj), ':LocalDOSCalc: Giving NaN for the calculated current at the given energy point.'], 1);
183  densityvec2int = NaN;
184  end
185 
186  DOSvec = -imag( densityvec2int(end-size(Hscatter,1)+1:end) )/pi;
187 
188 
189  %> creating the data structure of the local density of states
190  cLocalDOS = structures( 'LocalDOS');
191 
192  cLocalDOS.Energy = Energy;
193  cLocalDOS.DOSvec = DOSvec;
194  cLocalDOS.coordinates = cCoordinates_scatter;
195 
196 
197  obj.display(['EQuUs:Utils:', class(obj), ':DOSCalc: Process finished.'], 1)
198 
199  %reset the system for a new calculation
200  obj.InputParsing( obj.varargin{:} );
201 
202 
203 
204 
205 
206 
207 
208 
209  end
210 
211 
212 
213  end % public methods
214 
215 
216  methods (Access=protected)
217 
218 
219 %% complexSpectral
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 )
225 
226  % Obtaining the Hamiltonian of the scattering center
227  Hscatter = junction_loc.CreateH.Read('Hscatter');
228 
229  % creating the inverse of the Green opertor related to the scattering center
230  gfininv = speye(size(Hscatter))*junction_loc.getEnergy()-Hscatter;
231 
232  if JustScatter
233  % in case when just the scattering region is involved in the calculations
234  Ginverz = gfininv;
235  else
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');
240  end
241 
242  spectral_function = obj.diagInv( Ginverz );
243 
244 
245  end
246 
247 
248 %% create_Hamiltonians
249 %> @brief Creates the Hamiltonians of the system
250 %> @param varargin Cell array of optional parameters:.
251  function create_Hamiltonians( obj, varargin )
252 
253  p = inputParser;
254  p.addParameter('junction', obj.junction); %for parallel computations
255  p.parse(varargin{:});
256  junction_loc = p.Results.junction;
257 
258 
259  %> cerating Hamiltonian of the scattering region
260  obj.create_scatter( 'junction', obj.junction )
261 
262  %> creating the Lead Hamiltonians
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);
266 
267 
268 
269  end
270 
271 
272 %% create_scatter
273 %> @brief Creates the Hamiltonian of the scattering center
274 %> @param varargin Cell array of optional parameters:.
275  function create_scatter( obj, varargin )
276 
277  p = inputParser;
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;
283 
284  % create the unit cell of the scattering center
285  junction_loc.CreateScatter();
286 
287  % apply custom potential in the scattering center
288  if ~isempty(obj.scatterPotential)
289  junction_loc.ApplyPotentialInScatter( junction_loc.CreateH, obj.scatterPotential)
290  end
291 
292 
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 );
300  end
301 
302 
303  end
304 
305 
306 
307 
308 %% InputParsing
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 )
317 
318  p = inputParser;
319  p.addParameter('T', obj.T);
320  p.addParameter('scatterPotential', []);
321  p.addParameter('gfininvfromHamiltonian', false);
322  p.addParameter('useSelfEnergy', true);
323  p.addParameter('junction', []);
324 
325  p.parse(varargin{:});
326 
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);
332 
333 
334 
335  end %
336 
337 
338 end % protected methods
339 end
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:205
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:196
A class to calculate the Green functions and self energies of a translational invariant lead The nota...
Definition: Lead.m:29
Structure param contains data structures describing the physical parameters of the scattering center ...
Definition: structures.m:45
This class is a base class containing common properties and methods utilized in several other classes...
Definition: UtilsBase.m:26
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