Eötvös Quantum Utilities  v4.8.128
Providing the Horsepowers in the Quantum Realm
SVDregularizationLead.m
Go to the documentation of this file.
1 %% Eotvos Quantum Transport Utilities - EigenProblemLead
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 obj = 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 Returns with the effective Hamiltonians K0_eff, K1_eff, K1adj_eff
121  function [K0_eff, K1_eff, K1adj_eff] = Get_Effective_Hamiltonians(obj)
122  if isempty(obj.next_SVD_cycle)
123  K0_eff = obj.K0;
124  K1_eff = obj.K1;
125  K1adj_eff = obj.K1adj;
126  elseif strcmpi( class(obj.next_SVD_cycle), 'SVDregularizationLead' )
127  [K0_eff, K1_eff, K1adj_eff] = obj.next_SVD_cycle.Get_Effective_Hamiltonians();
128  else
129  error('EQuUs:SVDregularizationLead:Get_Effective_Hamiltonians', 'Unrecognized type of attribute next_SVD_cycle');
130  end
131 
132  end
133 
134 %% Get_Effective_Overlaps
135 %> @brief Gets the effective Hamiltonians S0_eff, S1_eff, S1adj_eff according to Eq (48) of of PRB 78, 035407
136 %> @return Returns with the effective Hamiltonians S0_eff, S1_eff, S1adj_eff
137  function [S0_eff, S1_eff, S1adj_eff] = Get_Effective_Overlaps(obj)
138  if isempty(obj.next_SVD_cycle)
139  S0_eff = obj.S0;
140  S1_eff = obj.S1;
141  S1adj_eff = obj.S1adj;
142  elseif strcmpi( class(obj.next_SVD_cycle), 'SVDregularizationLead' )
143  [S0_eff, S1_eff, S1adj_eff] = obj.next_SVD_cycle.Get_Effective_Overlaps();
144  else
145  error('EQuUs:SVDregularizationLead:Get_Effective_Overlaps', 'Unrecognized type of attribute next_SVD_cycle');
146  end
147 
148  end
149 
150 %% SVD_transform
151 %> @brief Regularize the Hamiltonians of the lead by SVD regularization
152  function SVD_transform( obj )
153 
154  obj.SVDdecompozition();
155 
156  K0 = obj.K0;
157 
158  if ~isempty(obj.q) && ~obj.HamiltoniansDecimated
159  K0 = K0 + obj.K1_transverse*diag(exp(1i*obj.q)) + obj.K1_transverse'*diag(exp(-1i*obj.q));
160  end
161 
162  % Eqs (48) in PRB 78, 035407
163  % here we use diiferent transformation for the leads with diffferent orientation
164  if obj.Lead_Orientation == 1
165  U = obj.V;
166  elseif obj.Lead_Orientation == -1
167  U = obj.U;
168  end
169  K0 = U'*K0*U;
170  K1 = U'*obj.K1*U;
171  K1adj = U'*obj.K1adj*U;
172 
173  obj.Neff = size(obj.K0, 1);
174 
175  % determine singular values
176  S = abs(obj.S);
177  regular_sites_slab = transpose(find(S > obj.tolerance*max(S)));
178 
179  K = [K0, K1; K1adj, K0];
180 
181 
182  regular_sites = [regular_sites_slab, size(K0,1)+regular_sites_slab];
183 
184  CreateH = CreateHamiltonians(obj.Opt, obj.param);
185  CreateH.Write('Hscatter', K);
186  CreateH.Write('kulso_szabfokok', regular_sites);
187  CreateH.Write('HamiltoniansCreated', true);
188  CreateH.Write('HamiltoniansDecimated', false);
189 
190  Decimation_Procedure = Decimation(obj.Opt);
191  Decimation_Procedure.DecimationFunc(0, CreateH, 'Hscatter', 'kulso_szabfokok');
192 
193  K = CreateH.Read('Hscatter');
194  CreateH.Clear('Hscatter');
195 
196  Neff_new = length(regular_sites_slab);
197 
198  if obj.Lead_Orientation == 1
199  K0 = K(Neff_new+1:end, Neff_new+1:end);
200  elseif obj.Lead_Orientation == -1
201  K0 = K(1:Neff_new, 1:Neff_new);
202  end
203  K1 = K(1:Neff_new, Neff_new+1:end);
204  K1adj = K(Neff_new+1:end, 1:Neff_new);
205 
206 
207  obj.next_SVD_cycle = SVDregularizationLead(obj.Opt, obj.param, obj.varargin{:});
208  obj.next_SVD_cycle.Write('K0', K0);
209  obj.next_SVD_cycle.Write('K1', K1);
210  obj.next_SVD_cycle.Write('K1adj', K1adj);
211  obj.next_SVD_cycle.Write('OverlapApplied', true);
212  obj.next_SVD_cycle.Write('HamiltoniansDecimated', true);
213  obj.next_SVD_cycle.Write('Neff', Neff_new);
214 
215 
216  obj.is_SVD_transformed = true;
217  obj.HamiltoniansDecimated = true;
218 
219  if issparse(K1)
220  condition_num = 1/condest(K1);
221  else
222  condition_num = rcond(K1);
223  end
224 
225  if condition_num<obj.tolerance
226  obj.next_SVD_cycle.Calc_Effective_Hamiltonians( 0 );
227  end
228  end
229 
230 %% Decimate_Interface
231 %> @brief Decimates the Hamiltonians (if the singular sites are predefined).
232  function Decimate_Hamiltonians( obj )
233  if ~isempty(obj.q)
234  K0loc = obj.K0 + obj.K1_transverse*diag(exp(1i*obj.q)) + obj.K1_transverse'*diag(exp(-1i*obj.q));
235  else
236  K0loc = obj.K0;
237  end
238  K = [K0loc,obj.K1;obj.K1adj,K0loc];
239 
240  regular_sites_slab = obj.kulso_szabfokok;
241  regular_sites = [regular_sites_slab, size(obj.K0,1)+regular_sites_slab];
242 
243 
244  CreateH = CreateHamiltonians(obj.Opt, obj.param);
245  CreateH.Write('Hscatter', K);
246  CreateH.Write('kulso_szabfokok', regular_sites);
247  CreateH.Write('HamiltoniansCreated', true);
248  CreateH.Write('HamiltoniansDecimated', false);
249 
250  Decimation_Procedure = Decimation(obj.Opt);
251  Decimation_Procedure.DecimationFunc(0, CreateH, 'Hscatter', 'kulso_szabfokok');
252 
253  K = CreateH.Read('Hscatter');
254  CreateH.Clear('Hscatter');
255 
256  Neff_new = length(regular_sites_slab);
257 
258  K0 = K(Neff_new+1:end, Neff_new+1:end);
259  K1 = K(1:Neff_new, Neff_new+1:end);
260  K1adj = K(Neff_new+1:end, 1:Neff_new);
261 
262  obj.next_SVD_cycle = SVDregularizationLead(obj.Opt, obj.param, obj.varargin{:});
263  obj.next_SVD_cycle.Write('K0', K0);
264  obj.next_SVD_cycle.Write('K1', K1);
265  obj.next_SVD_cycle.Write('K1adj', K1adj);
266  obj.next_SVD_cycle.Write('OverlapApplied', true);
267  obj.next_SVD_cycle.Write('HamiltoniansDecimated', true);
268  obj.next_SVD_cycle.Write('Neff', Neff_new);
269 
270  obj.HamiltoniansDecimated = true;
271 
272 
273 % Decimation_Procedure_Lead = Decimation(obj.Opt, 'ForcedDecimation', obj.Opt.Decimation);
274 % kulso_szabfokok_tmp = obj.kulso_szabfokok;
275 % obj.kulso_szabfokok = [obj.kulso_szabfokok, obj.kulso_szabfokok+size(obj.H0,1)];
276 % Decimation_Procedure_Lead.DecimationFunc(0, obj, 'Hamiltonian2Dec', 'kulso_szabfokok');
277 % obj.kulso_szabfokok = kulso_szabfokok_tmp;
278 % obj.Neff = size(obj.K0,1);
279 
280  end
281 
282 %% Unitary_Transform
283 %> @brief Transforms the effective Hamiltonians by a unitary transformation
284 %> @param Umtx The matrix of the unitary transformation.
285  function Unitary_Transform(obj, Umtx)
286 
287  if isempty(obj.next_SVD_cycle)
288  if ~isempty(obj.K0)
289  obj.K0 = Umtx*obj.K0*Umtx';
290  end
291 
292  if ~isempty(obj.K1)
293  obj.K1 = Umtx*obj.K1*Umtx';
294  end
295 
296  if ~isempty(obj.K1adj)
297  obj.K1adj = Umtx*obj.K1adj*Umtx';
298  end
299 
300  elseif strcmpi( class(obj.next_SVD_cycle), 'SVDregularizationLead' )
301  obj.next_SVD_cycle.Unitary_Transform(Umtx);
302  else
303  error('EQuUs:SVDregularizationLead:Unitary_Transform', 'Unrecognized type of attribute next_SVD_cycle');
304  end
305 
306  end
307 
308 %% Get_Neff
309 %> @brief Gets the effective number of sites after the elimination of the singular values.
310 %> @return Returns with the effective number of sites
311  function Neff = Get_Neff(obj)
312  if isempty(obj.next_SVD_cycle)
313  Neff = obj.Neff;
314  elseif strcmpi( class(obj.next_SVD_cycle), 'SVDregularizationLead' )
315  Neff = obj.next_SVD_cycle.Get_Neff();
316  else
317  error('EQuUs:SVDregularizationLead:Get_Neff', 'Unrecognized type of attribute next_SVD_cycle');
318  end
319  end
320 
321 
322 
323 
324 %% Get_U
325 %> @brief Gets the total transformation U related to the SVD transformation
326 %> @return Returns with the total transformation U
327 function Vtot = Get_V(obj)
328  if isempty(obj.next_SVD_cycle)
329  Vtot = obj.V;
330  elseif strcmpi( class(obj.next_SVD_cycle), 'SVDregularizationLead' )
331  Vtot_tmp = obj.next_SVD_cycle.Get_V();
332  size_V = size(obj.V);
333  size_Vtmp = size(Vtot_tmp);
334  Vtot_tmp = [Vtot_tmp, zeros(size_Vtmp(1), size_V(2)-size_Vtmp(2));
335  zeros(size_V(1)-size_Vtmp(1), size_Vtmp(2)), eye(size_V(1)-size_Vtmp(1))];
336  Vtot = obj.V*Vtot_tmp;
337  else
338  error('EQuUs:SVDregularizationLead:Get_V', 'Unrecognized type of attribute next_SVD_cycle');
339  end
340 
341 end
342 
343 %% CreateClone
344 %> @brief Creates a clone of the present object.
345 %> @return Returns with the cloned object.
346 %> @param varargin Cell array of optional parameters:.
347  function ret = CreateClone( obj, varargin )
348 
349  p = inputParser;
350  p.addParameter('empty', false );
351 
352  p.parse(varargin{:});
353  empty = p.Results.empty;
354 
355  ret = SVDregularizationLead(obj.Opt, obj.param,...
356  'Hanyadik_Lead', obj.Hanyadik_Lead,...
357  'Lead_Orientation', obj.Lead_Orientation, ...
358  'q', obj.q);
359 
360  if empty
361  return
362  end
363 
364  meta_data = metaclass(obj);
365 
366  for idx = 1:length(meta_data.PropertyList)
367  prop_name = meta_data.PropertyList(idx).Name;
368  if strcmpi( prop_name, 'next_SVD_cycle' )
369  if ~isempty( obj.next_SVD_cycle )
370  ret.next_SVD_cycle = obj.next_SVD_cycle.CreateClone();
371  end
372  else
373  ret.Write( prop_name, obj.(prop_name));
374  end
375  end
376 
377  end
378 
379 
380 %% Reset
381 %> @brief Resets all elements in the object.
382  function Reset( obj )
383 
384  if strcmp( class(obj), 'SVDregularizationLead' )
385  meta_data = metaclass(obj);
386 
387  for idx = 1:length(meta_data.PropertyList)
388  prop_name = meta_data.PropertyList(idx).Name;
389  if strcmp(prop_name, 'Opt') || strcmp( prop_name, 'param') || strcmp(prop_name, 'varargin')
390  continue
391  end
392  obj.Clear( prop_name );
393  end
394  end
395 
396  obj.Initialize()
397 
398 
399  end
400 
401 
402 %% Write
403 %> @brief Sets the value of an attribute in the interface.
404 %> @param MemberName The name of the attribute to be set.
405 %> @param input The value to be set.
406  function Write(obj, MemberName, input)
407 
408 
409  if strcmp(MemberName, 'param') || strcmp(MemberName, 'params')
410  Write@CreateLeadHamiltonians( obj, MemberName, input );
411  return
412  else
413  try
414  obj.(MemberName) = input;
415  catch
416  error(['EQuUs:', class(obj), ':Read'], ['No property to write with name: ', MemberName]);
417  end
418  end
419 
420  end
421 %% Read
422 %> @brief Query for the value of an attribute in the interface.
423 %> @param MemberName The name of the attribute to be set.
424 %> @return Returns with the value of the attribute.
425  function ret = Read(obj, MemberName)
426 
427  if strcmp(MemberName, 'Hamiltonian2Dec')
428  ret = Read@CreateLeadHamiltonians( obj, MemberName );
429  return
430  else
431  try
432  ret = obj.(MemberName);
433  catch
434  error(['EQuUs:', class(obj), ':Read'], ['No property to read with name: ', MemberName]);
435  end
436  end
437 
438  end
439 %% Clear
440 %> @brief Clears the value of an attribute in the interface.
441 %> @param MemberName The name of the attribute to be cleared.
442  function Clear(obj, MemberName)
443 
444  try
445  obj.(MemberName) = [];
446  catch
447  error(['EQuUs:', class(obj), ':Clear'], ['No property to clear with name: ', MemberName]);
448  end
449 
450  end
451 
452 
453 end % methods public
454 
455 
456 
457 methods (Access=protected)
458 
459 
460 %% Extend_Wavefnc ---- DEVELOPMENT
461 %> @brief Extend a reduced wave function to the original basis before the SVD regularization (Eq (45) in PRB 78 035407
462 %> @param wavefnc_reduced The reduced wavefunction of the effective system
463 %> @param expk e^(i*k)
464  function wavefnc_extended = Extend_Wavefnc(obj, wavefnc_reduced, expk)
465 
466  if ~isempty(obj.next_SVD_cycle) && strcmpi( class(obj.next_SVD_cycle), 'SVDregularizationLead' )
467  wavefnc_reduced = obj.next_SVD_cycle.Extend_Wavefnc(wavefnc_reduced, expk);
468  elseif ~isempty(obj.next_SVD_cycle)
469  error('EQuUs:SVDregularizationLead:Extend_Wavefnc', 'Unrecognized type of attribute next_SVD_cycle');
470  end
471 
472  Fn = -obj.invD*(obj.K1adju/expk + obj.C);
473  wavefnc_extended = [wavefnc_reduced; Fn*wavefnc_reduced];
474  wavefnc_extended = obj.U*wavefnc_extended;
475 
476  end
477 
478 
479 
480 %% Initialize
481 %> @brief Initializes object properties.
482  function Initialize(obj)
483  Initialize@CreateLeadHamiltonians(obj);
484  obj.tolerance = 1e-12;
485  obj.is_SVD_transformed = false;
486  end
487 
488 
489 
490 
491 end % methods protected
492 
493 
494 
495 
496 
497 end
Structure Opt contains the basic computational parameters used in EQuUs.
Definition: structures.m:120
Class to create and store Hamiltonian of the translational invariant leads.
function Transport(Energy, B)
creating the Ribbon class representing the twoterminal setup
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 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:247
Class to solve the eigenproblem of a translational invariant leads and calculate the group velocities...
A class to create and store Hamiltonian of the scattering region.