Eötvös Quantum Utilities  v4.9.146
Providing the Horsepowers in the Quantum Realm
SVDregularizationLead.m
Go to the documentation of this file.
1 %% Eotvos Quantum Transport Utilities - SVDregularizationLead
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 basic Basic Functionalities
18 %> @{
19 %> @file SVDregularizationLead.m
20 %> @brief Class to regulerize the H1 problem of the leads by SVD decompozition.
21 %> @}
22 %> @brief Class to regulerize the H1 problem of the leads by SVD decompozition.
23 %> The notations and the structure of the Hamiltonian is defined accroding to the following image:
24 %> @image html Lead_Hamiltonian.jpg
25 %> @image latex Lead_Hamiltonian.jpg
26 %> @Available
27 %> EQuUs v4.8 or later
28 %%
30 
31 
32 properties ( Access = protected )
33  %> true if the Hamiltonians were SVD transformed, false otherwise
34  is_SVD_transformed
35  %> U matrix from the SVD decompozition, see Eq (41) of PRB 78, 035407
36  U
37  %> S matrix from the SVD decompozition, see Eq (41) of PRB 78, 035407
38  S
39  %> V matrix from the SVD decompozition, see Eq (41) of PRB 78, 035407
40  V
41  %> SVD tolerance to identify singular values
42  tolerance
43  %> Somethimes it is needed to perform another SVD cycle to regularize the H1 matrix
44  next_SVD_cycle
45  %> Effective number of sites after the elimination of the singular values
46  Neff
47 
48 
49 end
50 
51 
52 
53 
54 
55 methods ( Access = public )
56 %% constructorof the class
57 %> @brief Constructor of the class.
58 %> @param Opt An instance of the structure #Opt.
59 %> @param param An instance of structure #param.
60 %> @param varargin Cell array of optional parameters identical to #CreateLeadHamiltonians.CreateLeadHamiltonians.
61 %> @return An instance of the class
62  function obj = SVDregularizationLead(Opt, param, varargin)
63  obj = obj@CreateLeadHamiltonians( Opt, param, varargin{:} );
64  end
65 
66 
67 
68 %% SVDdecompozition
69 %> @brief Calculates the SVD decomposition of the matrix H1.
70  function SVDdecompozition( obj )
71  if issparse(obj.K1)
72  [obj.U, obj.S, obj.V] = svd(full(obj.K1));
73  else
74  [obj.U, obj.S, obj.V] = svd(obj.K1);
75  end
76 
77  obj.U = sparse(obj.U);
78  obj.V = sparse(obj.V);
79 
80  obj.S = diag(obj.S);
81  end
82 
83 %% is_SVD_needed
84 %> @brief Decides whether SVD regularization is needed or not.
85 %> @return Returns with true if SVD regularization is needed, false otherwise
86  function ret = is_SVD_needed(obj)
87  if 1/condest(obj.H1)<obj.tolerance
88  ret = true;
89  else
90  ret = false;
91  end
92  end
93 
94 
95 %% Calc_Effective_Hamiltonians
96 %> @brief Calculates the effective Hamiltonians according to Eq (48) of of PRB 78, 035407
97 %> @param E The energy value
98  function Calc_Effective_Hamiltonians( obj, E )
99 
100  obj.ApplyOverlapMatrices(E);
101 
102  if ~isempty(obj.kulso_szabfokok) && length(obj.kulso_szabfokok) ~= size(obj.K0,1)
103  obj.Decimate_Hamiltonians();
104  return
105  elseif 1/condest(obj.K1)<obj.tolerance && isempty(obj.V)
106  obj.SVD_transform();
107  return
108  else
109  % in case no SVD regularization or simple decimation is needed
110  obj.Neff = size(obj.K0,1);
111  return
112  end
113 
114 
115  end
116 
117 
118 %% Get_Effective_Hamiltonians
119 %> @brief Gets the effective Hamiltonians K0_eff, K1_eff, K1adj_eff according to Eq (48) of of PRB 78, 035407
120 %> @return [1] The effective Hamiltonian of one unit cell
121 %> @return [2] The effective coupling between unit cells K1_eff
122 %> @return [3] The adjungate of the effective coupling between unit cells K1adj_eff
123  function [K0_eff, K1_eff, K1adj_eff] = Get_Effective_Hamiltonians(obj)
124  if isempty(obj.next_SVD_cycle)
125  K0_eff = obj.K0;
126  K1_eff = obj.K1;
127  K1adj_eff = obj.K1adj;
128  elseif strcmpi( class(obj.next_SVD_cycle), 'SVDregularizationLead' )
129  [K0_eff, K1_eff, K1adj_eff] = obj.next_SVD_cycle.Get_Effective_Hamiltonians();
130  else
131  error('EQuUs:SVDregularizationLead:Get_Effective_Hamiltonians', 'Unrecognized type of attribute next_SVD_cycle');
132  end
133 
134  end
135 
136 %% Get_Effective_Overlaps
137 %> @brief Gets the effective Hamiltonians S0_eff, S1_eff, S1adj_eff according to Eq (48) of of PRB 78, 035407
138 %> @return [1] The effective overlap matrix of one unit cell S0_eff
139 %> @return [2] The effective overlap matrix between unit cells S1_eff
140 %> @return [3] The adjungate of the effective overlap matrix between unit cells S1adj_eff
141  function [S0_eff, S1_eff, S1adj_eff] = Get_Effective_Overlaps(obj)
142  if isempty(obj.next_SVD_cycle)
143  S0_eff = obj.S0;
144  S1_eff = obj.S1;
145  S1adj_eff = obj.S1adj;
146  elseif strcmpi( class(obj.next_SVD_cycle), 'SVDregularizationLead' )
147  [S0_eff, S1_eff, S1adj_eff] = obj.next_SVD_cycle.Get_Effective_Overlaps();
148  else
149  error('EQuUs:SVDregularizationLead:Get_Effective_Overlaps', 'Unrecognized type of attribute next_SVD_cycle');
150  end
151 
152  end
153 
154 %% Get_Effective_Coordinates
155 %> @brief Gets the coordinates of the sites of the effective Hamiltonians. (Has sense if the singular sites were given directly)
156 %> @return [1] A class Coordinates containing the coordinates of the sites of the effective Hamiltonian
157  function coordinates = Get_Effective_Coordinates(obj)
158  if isempty(obj.next_SVD_cycle)
159  coordinates = obj.coordinates;
160  elseif strcmpi( class(obj.next_SVD_cycle), 'SVDregularizationLead' )
161  coordinates = obj.next_SVD_cycle.Get_Effective_Coordinates();
162  else
163  error('EQuUs:SVDregularizationLead:Get_Effective_Coordinates', 'Unrecognized type of attribute next_SVD_cycle');
164  end
165 
166  end
167 
168 
169 %% SVD_transform
170 %> @brief Regularize the Hamiltonians of the lead by SVD regularization
171  function SVD_transform( obj )
172 
173  obj.SVDdecompozition();
174 
175  K0 = obj.K0;
176 
177  if length(obj.q) < 2 && ~isempty(obj.q) && ~obj.HamiltoniansDecimated
178  K0 = K0 + obj.K1_transverse*diag(exp(1i*obj.q)) + obj.K1_transverse'*diag(exp(-1i*obj.q));
179  end
180 
181  % Eqs (48) in PRB 78, 035407
182  % here we use different transformation for the leads with different orientation
183  if obj.Lead_Orientation == 1
184  U = obj.V;
185  elseif obj.Lead_Orientation == -1
186  U = obj.U;
187  end
188  K0 = U'*K0*U;
189  K1 = U'*obj.K1*U;
190  K1adj = U'*obj.K1adj*U;
191 
192  obj.Neff = size(obj.K0, 1);
193 
194  % determine singular values
195  S = abs(obj.S);
196  regular_sites_slab = transpose(find(S > obj.tolerance*max(S)));
197 
198  K = [K0, K1; K1adj, K0];
199 
200 
201  regular_sites = [regular_sites_slab, size(K0,1)+regular_sites_slab];
202 
203  CreateH = CreateHamiltonians(obj.Opt, obj.param);
204  CreateH.Write('Hscatter', K);
205  CreateH.Write('kulso_szabfokok', regular_sites);
206  CreateH.Write('HamiltoniansCreated', true);
207  CreateH.Write('HamiltoniansDecimated', false);
208 
209  Decimation_Procedure = Decimation(obj.Opt);
210  Decimation_Procedure.DecimationFunc(0, CreateH, 'Hscatter', 'kulso_szabfokok');
211 
212  K = CreateH.Read('Hscatter');
213  CreateH.Clear('Hscatter');
214 
215  Neff_new = length(regular_sites_slab);
216 
217  if obj.Lead_Orientation == 1
218  K0 = K(Neff_new+1:end, Neff_new+1:end);
219  elseif obj.Lead_Orientation == -1
220  K0 = K(1:Neff_new, 1:Neff_new);
221  end
222  K1 = K(1:Neff_new, Neff_new+1:end);
223  K1adj = K(Neff_new+1:end, 1:Neff_new);
224 
225 
226  obj.next_SVD_cycle = SVDregularizationLead(obj.Opt, obj.param, obj.varargin{:});
227  obj.next_SVD_cycle.Write('K0', K0);
228  obj.next_SVD_cycle.Write('K1', K1);
229  obj.next_SVD_cycle.Write('K1adj', K1adj);
230  obj.next_SVD_cycle.Write('OverlapApplied', true);
231  obj.next_SVD_cycle.Write('HamiltoniansDecimated', true);
232  obj.next_SVD_cycle.Write('Neff', Neff_new);
233 
234 
235  obj.is_SVD_transformed = true;
236  obj.HamiltoniansDecimated = true;
237 
238  if issparse(K1)
239  condition_num = 1/condest(K1);
240  else
241  condition_num = rcond(K1);
242  end
243 
244  if condition_num<obj.tolerance
245  obj.next_SVD_cycle.Calc_Effective_Hamiltonians( 0 );
246  end
247  end
248 
249 %% Decimate_Hamiltonians
250 %> @brief Decimates the Hamiltonians (if the singular sites are predefined).
251  function Decimate_Hamiltonians( obj )
252  if ~isempty(obj.q)
253  K0loc = obj.K0 + obj.K1_transverse*diag(exp(1i*obj.q)) + obj.K1_transverse'*diag(exp(-1i*obj.q));
254  else
255  K0loc = obj.K0;
256  end
257  K = [K0loc,obj.K1;obj.K1adj,K0loc];
258 
259  regular_sites_slab = obj.kulso_szabfokok;
260  regular_sites = [regular_sites_slab, size(obj.K0,1)+regular_sites_slab];
261 
262 
263  CreateH = CreateHamiltonians(obj.Opt, obj.param);
264  CreateH.Write('Hscatter', K);
265  CreateH.Write('kulso_szabfokok', regular_sites);
266  CreateH.Write('HamiltoniansCreated', true);
267  CreateH.Write('HamiltoniansDecimated', false);
268 
269  Decimation_Procedure = Decimation(obj.Opt);
270  Decimation_Procedure.DecimationFunc(0, CreateH, 'Hscatter', 'kulso_szabfokok');
271 
272  K = CreateH.Read('Hscatter');
273  CreateH.Clear('Hscatter');
274  coordinates = CreateH.Read('coordinates');
275 
276  Neff_new = length(regular_sites_slab);
277 
278  K0 = K(Neff_new+1:end, Neff_new+1:end);
279  K1 = K(1:Neff_new, Neff_new+1:end);
280  K1adj = K(Neff_new+1:end, 1:Neff_new);
281 
282  obj.next_SVD_cycle = SVDregularizationLead(obj.Opt, obj.param, obj.varargin{:});
283  obj.next_SVD_cycle.Write('K0', K0);
284  obj.next_SVD_cycle.Write('K1', K1);
285  obj.next_SVD_cycle.Write('K1adj', K1adj);
286  obj.next_SVD_cycle.Write('OverlapApplied', true);
287  obj.next_SVD_cycle.Write('HamiltoniansDecimated', true);
288  obj.next_SVD_cycle.Write('Neff', Neff_new);
289 
290 
291  obj.HamiltoniansDecimated = true;
292 
293 
294  % determine the truncated coordinates
295  indexes2remove = true( size( obj.coordinates.x ) );
296  indexes2remove( regular_sites_slab ) = false;
297  coordinates = obj.coordinates.RemoveSites( indexes2remove );
298  obj.next_SVD_cycle.Write('coordinates', coordinates);
299 
300 
301 
302 % Decimation_Procedure_Lead = Decimation(obj.Opt, 'ForcedDecimation', obj.Opt.Decimation);
303 % kulso_szabfokok_tmp = obj.kulso_szabfokok;
304 % obj.kulso_szabfokok = [obj.kulso_szabfokok, obj.kulso_szabfokok+size(obj.H0,1)];
305 % Decimation_Procedure_Lead.DecimationFunc(0, obj, 'Hamiltonian2Dec', 'kulso_szabfokok');
306 % obj.kulso_szabfokok = kulso_szabfokok_tmp;
307 % obj.Neff = size(obj.K0,1);
308 
309  end
310 
311 %% Unitary_Transform
312 %> @brief Transforms the effective Hamiltonians by a unitary transformation
313 %> @param Umtx The matrix of the unitary transformation.
314  function Unitary_Transform(obj, Umtx)
315 
316  if isempty(obj.next_SVD_cycle)
317  if ~isempty(obj.K0)
318  obj.K0 = Umtx*obj.K0*Umtx';
319  end
320 
321  if ~isempty(obj.K1)
322  obj.K1 = Umtx*obj.K1*Umtx';
323  end
324 
325  if ~isempty(obj.K1adj)
326  obj.K1adj = Umtx*obj.K1adj*Umtx';
327  end
328 
329  elseif strcmpi( class(obj.next_SVD_cycle), 'SVDregularizationLead' )
330  obj.next_SVD_cycle.Unitary_Transform(Umtx);
331  else
332  error('EQuUs:SVDregularizationLead:Unitary_Transform', 'Unrecognized type of attribute next_SVD_cycle');
333  end
334 
335  end
336 
337 %% Get_Neff
338 %> @brief Gets the effective number of sites after the elimination of the singular values.
339 %> @return Returns with the effective number of sites
340  function Neff = Get_Neff(obj)
341  if isempty(obj.next_SVD_cycle)
342  Neff = obj.Neff;
343  elseif strcmpi( class(obj.next_SVD_cycle), 'SVDregularizationLead' )
344  Neff = obj.next_SVD_cycle.Get_Neff();
345  else
346  error('EQuUs:SVDregularizationLead:Get_Neff', 'Unrecognized type of attribute next_SVD_cycle');
347  end
348  end
349 
350 
351 
352 
353 %% Get_U
354 %> @brief Gets the total transformation U related to the SVD transformation
355 %> @return Returns with the total transformation U
356 function Vtot = Get_V(obj)
357  if isempty(obj.next_SVD_cycle)
358  Vtot = obj.V;
359  elseif strcmpi( class(obj.next_SVD_cycle), 'SVDregularizationLead' )
360  Vtot_tmp = obj.next_SVD_cycle.Get_V();
361  size_V = size(obj.V);
362  size_Vtmp = size(Vtot_tmp);
363  Vtot_tmp = [Vtot_tmp, zeros(size_Vtmp(1), size_V(2)-size_Vtmp(2));
364  zeros(size_V(1)-size_Vtmp(1), size_Vtmp(2)), eye(size_V(1)-size_Vtmp(1))];
365  Vtot = obj.V*Vtot_tmp;
366  else
367  error('EQuUs:SVDregularizationLead:Get_V', 'Unrecognized type of attribute next_SVD_cycle');
368  end
369 
370 end
371 
372 %% CreateClone
373 %> @brief Creates a clone of the present object.
374 %> @return Returns with the cloned object.
375 %> @param varargin Cell array of optional parameters:.
376  function ret = CreateClone( obj, varargin )
377 
378  p = inputParser;
379  p.addParameter('empty', false );
380 
381  p.parse(varargin{:});
382  empty = p.Results.empty;
383 
384  ret = SVDregularizationLead(obj.Opt, obj.param,...
385  'Hanyadik_Lead', obj.Hanyadik_Lead,...
386  'Lead_Orientation', obj.Lead_Orientation, ...
387  'q', obj.q);
388 
389  if empty
390  return
391  end
392 
393  meta_data = metaclass(obj);
394 
395  for idx = 1:length(meta_data.PropertyList)
396  prop_name = meta_data.PropertyList(idx).Name;
397  if strcmpi( prop_name, 'next_SVD_cycle' )
398  if ~isempty( obj.next_SVD_cycle )
399  ret.next_SVD_cycle = obj.next_SVD_cycle.CreateClone();
400  end
401  else
402  ret.Write( prop_name, obj.(prop_name));
403  end
404  end
405 
406  end
407 
408 
409 %% Reset
410 %> @brief Resets all elements in the object.
411  function Reset( obj )
412 
413  if strcmpi( class(obj), 'SVDregularizationLead' )
414  meta_data = metaclass(obj);
415 
416  for idx = 1:length(meta_data.PropertyList)
417  prop_name = meta_data.PropertyList(idx).Name;
418  if strcmp(prop_name, 'Opt') || strcmp( prop_name, 'param') || strcmp(prop_name, 'varargin')
419  continue
420  end
421  obj.Clear( prop_name );
422  end
423  end
424 
425  obj.Initialize()
426 
427 
428  end
429 
430 
431 %% Write
432 %> @brief Sets the value of an attribute in the interface.
433 %> @param MemberName The name of the attribute to be set.
434 %> @param input The value to be set.
435  function Write(obj, MemberName, input)
436 
437 
438  if strcmpi(MemberName, 'param') || strcmp(MemberName, 'params')
439  Write@CreateLeadHamiltonians( obj, MemberName, input );
440  return
441  else
442  try
443  obj.(MemberName) = input;
444  catch
445  error(['EQuUs:', class(obj), ':Read'], ['No property to write with name: ', MemberName]);
446  end
447  end
448 
449  end
450 %% Read
451 %> @brief Query for the value of an attribute in the interface.
452 %> @param MemberName The name of the attribute to be set.
453 %> @return Returns with the value of the attribute.
454  function ret = Read(obj, MemberName)
455 
456  if strcmpi(MemberName, 'Hamiltonian2Dec')
457  ret = Read@CreateLeadHamiltonians( obj, MemberName );
458  return
459  else
460  try
461  ret = obj.(MemberName);
462  catch
463  error(['EQuUs:', class(obj), ':Read'], ['No property to read with name: ', MemberName]);
464  end
465  end
466 
467  end
468 %% Clear
469 %> @brief Clears the value of an attribute in the interface.
470 %> @param MemberName The name of the attribute to be cleared.
471  function Clear(obj, MemberName)
472 
473  try
474  obj.(MemberName) = [];
475  catch
476  error(['EQuUs:', class(obj), ':Clear'], ['No property to clear with name: ', MemberName]);
477  end
478 
479  end
480 
481 
482 end % methods public
483 
484 
485 
486 methods (Access=protected)
487 
488 
489 %% Extend_Wavefnc ---- DEVELOPMENT
490 %> @brief Extend a reduced wave function to the original basis before the SVD regularization (Eq (45) in PRB 78 035407
491 %> @param wavefnc_reduced The reduced wavefunction of the effective system
492 %> @param expk e^(i*k)
493 %> @return A matrix conatining the extended wave functions.
494  function wavefnc_extended = Extend_Wavefnc(obj, wavefnc_reduced, expk)
495 
496  if ~isempty(obj.next_SVD_cycle) && strcmpi( class(obj.next_SVD_cycle), 'SVDregularizationLead' )
497  wavefnc_reduced = obj.next_SVD_cycle.Extend_Wavefnc(wavefnc_reduced, expk);
498  elseif ~isempty(obj.next_SVD_cycle)
499  error('EQuUs:SVDregularizationLead:Extend_Wavefnc', 'Unrecognized type of attribute next_SVD_cycle');
500  end
501 
502  Fn = -obj.invD*(obj.K1adju/expk + obj.C);
503  wavefnc_extended = [wavefnc_reduced; Fn*wavefnc_reduced];
504  wavefnc_extended = obj.U*wavefnc_extended;
505 
506  end
507 
508 
509 
510 %% Initialize
511 %> @brief Initializes class properties.
512  function Initialize(obj)
513  Initialize@CreateLeadHamiltonians(obj);
514  obj.tolerance = 1e-12;
515  obj.is_SVD_transformed = false;
516  end
517 
518 
519 
520 
521 end % methods protected
522 
523 
524 
525 
526 
527 end
Property next_SVD_cycle
Somethimes it is needed to perform another SVD cycle to regularize the H1 matrix.
Structure Opt contains the basic computational parameters used in EQuUs.
Definition: structures.m:60
Class to create and store Hamiltonian of the translational invariant leads.
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.
A class providing function handle to reduce the number of sites in the Hamiltonian via decimation pro...
Definition: Decimation.m:29
Class to regulerize the H1 problem of the leads by SVD decompozition.
function()
function CreateLeadHamiltonians(Opt, param, varargin)
Constructor of the class.
Structure param contains data structures describing the physical parameters of the scattering center ...
Definition: structures.m:45
Structure sites contains data to identify the individual sites in a matrix.
Definition: structures.m:187
Structure containing the coordinates and other quantum number identifiers of the sites in the Hamilto...
Definition: Coordinates.m:24
A class to create and store Hamiltonian of the scattering region.