Eötvös Quantum Utilities  v4.9.146
Providing the Horsepowers in the Quantum Realm
CreateLeadHamiltonians.m
Go to the documentation of this file.
1 %% Eotvos Quantum Transport Utilities - CreateLeadHamiltonians
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 CreateLeadHamiltonians.m
20 %> @brief Class to create and store Hamiltonian of the translational invariant leads.
21 %> @}
22 %> @brief Class to create and store Hamiltonian of the translational invariant leads.
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  %> An instance of the structure param
34  param
35  %> The orientation of the lead. Set +1 is the "incoming" direction of the propagating states is defined in the +x or +y direction, and "-1" otherwise.
36  Lead_Orientation
37  %> The id number of the current lead.
38  Hanyadik_Lead
39  %> The number of the sites in the cross section.
40  M
41  %> An instance of the structure lead_param
42  params
43  %> The tranverse momentum for transverse computations.
44  q
45  %> List of sites in the unit cell that should be kept after decimation.
46  kulso_szabfokok
47  %> An instance of the structure coordinates.
48  coordinates
49  %> K0=H0-E*S0, see Eq (4) of PRB 78, 035407
50  K0
51  %> K1=H1-E*S1, see Eq (4) of PRB 78, 035407
52  K1
53  %> K1adj=H1adj-E*S1', see Eq (4) of PRB 78, 035407
54  K1adj
55  %> K1_transverse=H1_transverse-E*S1_transverse
56  K1_transverse
57  %> The Hamiltonian of a unit cell.
58  H0
59  %> The coupling Hamiltonian between the unit cells.
60  H1
61  %> The coupling Hamiltonian between the unit cells in the opposite direction as H1. (For complex energies they differ from each other.)
62  H1adj
63  %> Obsolete
64  H00
65  %> The transverse coupling between the slabs for transverse calculations.
66  H1_transverse
67  %> The skew upward (in the negative direction) coupling between Hamiltonians H0 for transverse calculations.
68  H1_skew_right
69  %> The skew coupling (in the positive direction) between Hamiltonians H0 for transverse calculations.
70  H1_skew_left
71  %> The overlap integrals of a unit cell.
72  S0
73  %> The overlap integrals between the unit cells.
74  S1
75  %> The adjungate of the overlap integrals between the unit cells.
76  S1adj
77  %> The overlap integrals between the slabs for transverse calculations.
78  S1_transverse
79  %> The matrix of the Peierls phases in the unit cell.
80  fazis_mtx_H0
81  %> The matrix of the Peierls phases in the coupling matrix between the unit cells.
82  fazis_mtx_H1
83  %> The matrix of the Peierls phases in the transverse coupling matrix between the unit cells.
84  fazis_mtx_H1t
85  %> A logical value. True if the Hamiltonians were created, false otherwise.
86  HamiltoniansCreated
87  %> A logical value. True if the Hamiltonians were decimated, false otherwise.
88  HamiltoniansDecimated
89  %> A logical value. True if the overlap integrals were applied, false otherwise.
90  OverlapApplied
91  %> A logical value. True if magnetic field was applied in the Hamiltonians, false otherwise.
92  MagneticFieldApplied
93  %> A logical value. True if a gauge transformation was incorporated into the Hamiltonians or false otherwise.
94  GaugeTransformationApplied
95  %> list of optional parameters (see http://www.mathworks.com/help/matlab/ref/varargin.html for details)
96  varargin
97  end
98 
99 
100 methods ( Access = public )
101 %% constructorof the class
102 %> @brief Constructor of the class.
103 %> @param Opt An instance of the structure Opt.
104 %> @param param An instance of structure param.
105 %> @param varargin Cell array of optional parameters. See #InputParsing for details.
106 %> @return An instance of the class
107  function obj = CreateLeadHamiltonians(Opt, param, varargin)
108  obj = obj@Messages( Opt );
109  obj.param = param;
110  obj.varargin = varargin;
111 
112 
113  obj.Initialize();
114 
115  end
116 
117 
118 
119 %% ApplyOverlapMatrices
120 %> @brief Applies the overlap matrices to the Hamiltonians: K = H-ES
121 %> @param E The energy value.
122  function ApplyOverlapMatrices(obj, E)
123 
124  if obj.OverlapApplied
125  obj.display('EQuUs:CreateLeadHamiltonians:ApplyOverlapMatrices: Overlap matrices were already applied.');
126  return;
127  end
128 
129  if ~isempty( obj.S0 )
130  obj.K0 = obj.H0 - E*obj.S0;
131 
132  else
133  obj.K0 = obj.H0 - speye(size(obj.H0))*E;
134  end
135 
136  if ~isempty( obj.S1 )
137  obj.K1 = obj.H1 - E*obj.S1;
138  obj.K1adj = obj.H1adj - E*obj.S1';
139  else
140  obj.K1 = obj.H1;
141  obj.K1adj = obj.H1adj;
142  end
143 
144 
145  if ~isempty( obj.S1_transverse )
146  obj.K1_transverse = obj.H1_transverse - E*obj.S1_transverse;
147  elseif ~isempty( obj.H1_transverse )
148  obj.K1_transverse = obj.H1_transverse;
149  end
150 
151  obj.OverlapApplied = true;
152  end
153 
154 
156 %> @brief Creates the Hamiltonians H_0 and H_1 of the lead. The created Hamiltonians are stored by within the object.
157 %> @param varargin Cell array of optional parameters (https://www.mathworks.com/help/matlab/ref/varargin.html):
158 %> @param 'toSave' Logical value. If true, the created Hamiltonians are saved into a file 'Hamiltoni_Lead_' + num2str(Hanyadik_Lead) + '.mat'.
159 %> @param 'CustomHamiltonian' An instance of class #Custom_Hamiltonians describing external source of Hamiltonians.
160  function CreateHamiltonians(obj, varargin )
161 
162  p = inputParser;
163  p.addParameter('toSave', 0);
164  p.addParameter('CustomHamiltonian', []);
165  p.parse(varargin{:});
166 
167  toSave = p.Results.toSave;
168  CustomHamiltonian = p.Results.CustomHamiltonian;
169 
170  obj.setM();
171 
172  if ~isempty( obj.Opt.custom_Hamiltonians )
173  if isempty( CustomHamiltonian )
174  CustomHamiltonian = Custom_Hamiltonians( obj.Opt, obj.param );
175  end
176 
177  if ~CustomHamiltonian.Read( 'Hamiltonians_loaded' )
178  CustomHamiltonian.LoadHamiltonians();
179  end
180 
181  obj.coordinates = CustomHamiltonian.Read( 'coordinates' );
182  obj.coordinates = obj.coordinates{obj.Hanyadik_Lead};
183  obj.H0 = CustomHamiltonian.Read( 'H0' );
184  obj.H0 = obj.H0{obj.Hanyadik_Lead};
185  obj.H1 = CustomHamiltonian.Read( 'H1' );
186  obj.H1 = obj.H1{obj.Hanyadik_Lead};
187  obj.H1adj = obj.H1';
188  obj.H1_transverse = CustomHamiltonian.Read( 'H1_transverse' );
189  obj.H1_transverse = obj.H1_transverse{obj.Hanyadik_Lead};
190  obj.S0 = CustomHamiltonian.Read( 'S0' );
191  if iscell( obj.S0 )
192  obj.S0 = obj.S0{obj.Hanyadik_Lead};
193  end
194  obj.S1 = CustomHamiltonian.Read( 'S1' );
195  if iscell( obj.S1 )
196  obj.S1 = obj.S1{obj.Hanyadik_Lead};
197  obj.S1adj = obj.S1';
198  end
199  obj.S1_transverse = CustomHamiltonian.Read( 'S1_transverse' );
200  if iscell( obj.S1_transverse )
201  obj.S1_transverse = obj.S1_transverse{obj.Hanyadik_Lead};
202  end
203  obj.M = size(obj.H0,1);
204  %obj.kulso_szabfokok = 1:obj.M;
205  elseif strcmpi(obj.Opt.Lattice_Type, 'Square')
206  createH = Square_Lead_Hamiltonians();
207  [obj.H0,obj.H1,obj.H1_transverse,obj.coordinates] = createH.SquareLattice_Lead_Hamiltonians(obj.params, obj.M );
208  obj.H1adj = obj.H1';
209  obj.kulso_szabfokok = 1:obj.M;
210  elseif strcmpi(obj.Opt.Lattice_Type, 'SSH')
211  createH = Square_Lead_Hamiltonians();
212  [obj.H0,obj.H1,obj.H1_transverse,obj.coordinates] = createH.SSH_Lead_Hamiltonians(obj.params );
213  obj.H1adj = obj.H1';
214  obj.kulso_szabfokok = 1;
215  elseif strcmp(obj.Opt.Lattice_Type, 'Lieb')
216  createH = Square_Lead_Hamiltonians();
217  [obj.H0,obj.H1,obj.H1_transverse,obj.coordinates] = createH.Lieb_Lead_Hamiltonians(obj.params, obj.M );
218  obj.H1adj = obj.H1';
219  obj.M = size(obj.H0,1);
220  obj.kulso_szabfokok = [];%1:3:3*obj.M-2;
221  elseif strcmp(obj.Opt.Lattice_Type, 'BiTeI')
222  createH = BiTeI_Lead_Hamiltonians();
223  [obj.H0,obj.H1,obj.H1_transverse,obj.coordinates] = createH.BiTeILattice_Lead_Hamiltonians(obj.params, obj.M );
224  obj.H1adj = obj.H1';
225  obj.M = size(obj.H0,1);
226  obj.kulso_szabfokok = [];%sort([1:4:2*obj.M-1, 2:4:2*obj.M], 'ascend');%[];
227  elseif strcmp(obj.Opt.Lattice_Type, 'Graphene') || strcmpi(obj.Opt.Lattice_Type, 'H')
228  createH = Hex_Lead_Hamiltonians();
229  [obj.H0,obj.H1,obj.H1_transverse,obj.coordinates] = createH.Graphene_Lead_Hamiltonians(obj.params, obj.M, obj.params.End_Type );
230  obj.H1adj = obj.H1';
231  obj.kulso_szabfokok = (1:obj.M);
232  elseif strcmpi(obj.Opt.Lattice_Type, 'Graphene_Bilayer')
233  createH = Hex_Lead_Hamiltonians();
234  [obj.H0,obj.H1,obj.H1_transverse,obj.coordinates] = createH.Graphene_Bilayer_Lead_Hamiltonians(obj.params, obj.M, obj.params.End_Type );
235  obj.H1adj = obj.H1';
236  obj.kulso_szabfokok = [1:obj.M, size(obj.H0,1)/2 + (1:obj.M)];
237  obj.M = 2*obj.M;
238  elseif strcmpi(obj.Opt.Lattice_Type, 'Graphene_Bilayer_2')
239  createH = Hex_Lead_Hamiltonians();
240  [obj.H0,obj.H1,obj.H1_transverse,obj.coordinates] = createH.Graphene_Bilayer_Lead_Hamiltonians2(obj.params, obj.M, obj.params.End_Type );
241  obj.H1adj = obj.H1';
242  obj.kulso_szabfokok = [1:obj.M, size(obj.H0,1)/2 + (1:obj.M)];
243  obj.M = 2*obj.M;
244  elseif strcmpi(obj.Opt.Lattice_Type, 'Graphene_Bilayer_3')
245  createH = Hex_Lead_Hamiltonians();
246  [obj.H0,obj.H1,obj.H1_transverse,obj.coordinates] = createH.Graphene_Bilayer_Lead_Hamiltonians3(obj.params, obj.M, obj.params.End_Type );
247  obj.H1adj = obj.H1';
248  obj.kulso_szabfokok = [1:obj.M+1, size(obj.H0,1)/2 + (1:obj.M+1)];
249  obj.M = 2*(obj.M+1);
250  elseif strcmpi(obj.Opt.Lattice_Type, 'Silicene')
251  createH = Hex_Lead_Hamiltonians();
252  [obj.H0,obj.H1,obj.H1_transverse,obj.coordinates] = createH.Silicene_Lead_Hamiltonians(obj.params, obj.M, obj.params.End_Type );
253  obj.H1adj = obj.H1';
254  obj.kulso_szabfokok = [1:obj.M, size(obj.H0,1)/2 + (1:obj.M)];
255  obj.M = 2*obj.M;
256  elseif strcmpi(obj.Opt.Lattice_Type, 'Triangle')
257  createH = Triangle_Lead_Hamiltonians();
258  [obj.H0, obj.H1 ,obj.H1_transverse, obj.H1_skew_left, obj.coordinates] = createH.Triangle_Hamiltonians(obj.params, obj.M );
259  obj.H1adj = obj.H1';
260  obj.kulso_szabfokok = [1:obj.M];
261  elseif strcmpi(obj.Opt.Lattice_Type, 'TMDC_Monolayer')
263  [obj.H0, obj.H1 ,obj.H1_transverse, obj.H1_skew_left, obj.coordinates] = createH.TMDC_Monolayer_Hamiltonians(obj.params, obj.M );
264  obj.H1adj = obj.H1';
265  obj.kulso_szabfokok = 1:size(obj.H0,1);
266  obj.M = size(obj.H0,1);
267  elseif strcmpi(obj.Opt.Lattice_Type, 'TMDC_Monolayer_SOC')
269  [obj.H0, obj.H1 ,obj.H1_transverse, obj.H1_skew_left, obj.coordinates] = createH.TMDC_Monolayer_SOC_Hamiltonians(obj.params, obj.M );
270  obj.H1adj = obj.H1';
271  obj.kulso_szabfokok = 1:size(obj.H0,1);
272  obj.M = size(obj.H0,1);
273  elseif strcmpi(obj.Opt.Lattice_Type, 'TMDC_Bilayer_SOC')
275  [obj.H0, obj.H1 ,obj.H1_transverse, obj.H1_skew_left, obj.coordinates] = createH.TMDC_Bilayer_SOC_Hamiltonians(obj.params, obj.M );
276  obj.H1adj = obj.H1';
277  obj.kulso_szabfokok = 1:size(obj.H0,1);
278  obj.M = size(obj.H0,1);
279  else
280  error(['EQuUs:', class(obj), ':CreateHamiltonians'], 'Unrecognized lattice type, or a valid custom source for the Hamiltonians was not set.')
281  end
282 
283  obj.Transform2Spin();
284  obj.Transform2BdG();
285 
286  if toSave
287  saveLeads();
288  end
289 
290  obj.HamiltoniansCreated = true;
291  obj.OverlapApplied = false;
292  obj.HamiltoniansDecimated = false;
293  obj.MagneticFieldApplied = false;
294  obj.GaugeTransformationApplied = false;
295 
296 
297  end
298 
299 %% Transform2Spin
300 %> @brief Transforms the Hamiltonians and the overlap matrices to include electron spin.
301  function Transform2Spin( obj )
302 
303  if isempty(obj.Opt.Spin) || ~obj.Opt.Spin
304  return
305  end
306 
307  if ~isempty( obj.coordinates.spinup )
308  % spin is also included in the model
309  return
310  end
311 
312  fnames = fieldnames( obj.coordinates );
313  for idx = 1:length(fnames)
314  fname = fnames{idx};
315  if strcmp(fname, 'a') || strcmp(fname, 'b')
316  continue
317  end
318  obj.coordinates.(fname) = [ obj.coordinates.(fname); obj.coordinates.(fname) ];
319  end
320 
321  obj.coordinates.spinup = [ true(size(obj.H0,1),1); false(size(obj.H0,1),1)];
322 
323  obj.kulso_szabfokok = [obj.kulso_szabfokok, obj.kulso_szabfokok+size(obj.H0,1)];
324 
325 
326  % transforming the Hamiltonians
327  obj.H0 = [obj.H0, sparse([],[],[], size(obj.H0,1), size(obj.H0,2)); sparse([],[],[], size(obj.H0,1), size(obj.H0,2)), obj.H0];
328  obj.H1 = [obj.H1, sparse([],[],[], size(obj.H1,1), size(obj.H1,2)); sparse([],[],[], size(obj.H1,1), size(obj.H1,2)), obj.H1];
329  obj.H1adj = [obj.H1adj, sparse([],[],[], size(obj.H1adj,1), size(obj.H1adj,2)); sparse([],[],[], size(obj.H1adj,1), size(obj.H1adj,2)), obj.H1adj];
330 
331  obj.H1_transverse = [obj.H1_transverse, sparse([],[],[], size(obj.H1_transverse,1), size(obj.H1_transverse,2)); ...
332  sparse([],[],[], size(obj.H1_transverse,1), size(obj.H1_transverse,2)), obj.H1_transverse];
333 
334  % transforming th eoverlap integrals
335  if ~isempty( obj.S0 )
336  obj.S0 = [obj.S0, sparse([], [], [], size(obj.S0,1), size(obj.S0,2)); ...
337  sparse([], [], [], size(obj.S0,1), size(obj.S0,2)), obj.S0];
338  end
339 
340  if ~isempty(obj.S1)
341  obj.S1 = [obj.S1, sparse([], [], [], size(obj.S1,1), size(obj.S1,2)); ...
342  sparse([], [], [], size(obj.S1,1), size(obj.S1,2)), obj.S1];
343  end
344 
345  if ~isempty( obj.S1_transverse )
346  obj.S1_transverse = [obj.S1_transverse, sparse([], [], [], size(obj.S1_transverse,1), size(obj.S1_transverse,2)); ...
347  sparse([], [], [], size(obj.S1_transverse,2), size(obj.S1_transverse,1)), obj.S1_transverse];
348  end
349 
350 
351  obj.M = 2*obj.M;
352 
353  end
354 
355 %% Transform2BdG
356 %> @brief Transforms the Hamiltonians and the overlap matrices into the BdG model in the Nambu space representation according to
357 %> <a href="http://iopscience.iop.org/article/10.1088/1367-2630/9/8/278/meta">New Journal of Physics 9 (2007) 278</a>.
358 %> It is assumed, that the Hamiltonian is already transfromed to the grand canonical operator: \f$ \hat{H} \rightarrow \hat{H} - E_F\hat{N}\f$
359  function Transform2BdG( obj )
360 
361  if isempty(obj.Opt.BdG) || ~obj.Opt.BdG
362  obj.display(['EQuUs:', class(obj), ':Transform2BdG: BdG option is not set to true in the computational parameters.'])
363  return
364  end
365 
366  if ~isempty( obj.coordinates.BdG_u )
367  % already transformed into BdG model
368  obj.display(['EQuUs:', class(obj), ':Transform2BdG: Hamiltonians already transformed intt the BdG model.'])
369  return
370  end
371 
372  % transforming the coordinates
373  obj.coordinates = obj.coordinates.Transform2BdG();
374  % checking the crated BdG array ---- this is necessary when the structure coordinates was nat filled in with informations, when the Hamiltonians were created
375  if isempty( obj.coordinates.BdG_u )
376  obj.coordinates.BdG_u = [ true(size(obj.H0,1),1); false(size(obj.H0,1),1)];
377  end
378 
379  obj.kulso_szabfokok = [obj.kulso_szabfokok, obj.kulso_szabfokok+size(obj.H0,1)];
380 
381  pair_potential = obj.params.pair_potential;
382 
383  % transforming the Hamiltonians
384  if isempty(obj.S0)
385  S0 = speye(size(obj.H0));
386  else
387  S0 = obj.S0;
388  end
389 
390  obj.H0 = [obj.H0, S0*pair_potential; S0*conj(pair_potential), -conj(obj.H0)];
391 
392  if isempty(obj.S1)
393  S1 = sparse([],[],[], size(obj.H1,1), size(obj.H1,2));
394  else
395  S1 = obj.S1;
396  end
397 
398  obj.H1 = [obj.H1, S1*pair_potential; S1*conj(pair_potential), -conj(obj.H1)];
399  obj.H1adj = [obj.H1adj, S1'*pair_potential; S1'*conj(pair_potential), -conj(obj.H1adj)];
400 
401  if isempty(obj.S1_transverse)
402  S1_transverse = sparse([],[],[], size(obj.H1_transverse,1), size(obj.H1_transverse,2));
403  else
404  S1_transverse = obj.S1_transverse;
405  end
406 
407  obj.H1_transverse = [obj.H1_transverse, S1_transverse*pair_potential; S1_transverse*conj(pair_potential), -conj(obj.H1_transverse)];
408 
409  % transforming the overlap integrals
410  if ~isempty( obj.S0 )
411  obj.S0 = [obj.S0, sparse([], [], [], size(obj.S0,1), size(obj.S0,2)); sparse([], [], [], size(obj.S0,1), size(obj.S0,2)), obj.S0];
412  end
413 
414  if ~isempty(obj.S1)
415  obj.S1 = [obj.S1, sparse([], [], [], size(obj.S1,1), size(obj.S1,2)); sparse([], [], [], size(obj.S1,1), size(obj.S1,2)), obj.S1];
416  obj.S1adj = obj.S1';
417  end
418 
419  if ~isempty( obj.S1_transverse )
420  obj.S1_transverse = [obj.S1_transverse, sparse([], [], [], size(obj.S1_transverse,1), size(obj.S1_transverse,2)); ...
421  sparse([], [], [], size(obj.S1_transverse,2), size(obj.S1_transverse,1)), obj.S1_transverse];
422  end
423 
424  % the number of sites in the cross section becomes twice as many as in the normal case
425  obj.M = 2*obj.M;
426 
427  end
428 
429 %% CalcSpektrum
430 %> @brief Calculates the band structure of the lead.
431 %> @param varargin Cell array of optional parameters:
432 %> @param 'toPlot' Set 1 in order to plot the calculated spectrum, 0 (default) otherwise
433 %> @param 'ka_min' The lower bound of the wave numbers. (Default is -pi.)
434 %> @param 'ka_max' The upper bound of the wave numbers. (Default is pi.)
435 %> @param 'ka_num' The number of wave number points involved in the calculations. (Default is 300.)
436 %> @param 'ka_vec' One dimensional array of the k-pints. (Overrides previous attributes related to the k-vector array.)
437 %> @param 'center' The calculated energy eigenvalues are centered around this value. (Default is 0.001.)
438 %> @param 'db' The number of the calculated eigenvalues.
439 %> @param 'offset' Offset value to shift the spectrum along the energy axis.
440 %> @param 'calcWaveFnc' Logical value. Set true to calculate also the wave functions, or false (default) otherwise.
441 %> @return [1] ka_num x 2 array of the calculated spactrum. In the first column are the k-points, whil ein the second columns are the calculated energy points.
442 %> @return [2] The calculated wave functions stored in a structure #WaveFnc.
443  function [spectrum, WaveFnc] = CalcSpektrum( obj, varargin )
444 
445  p = inputParser;
446  p.addParameter('toPlot', 0, @isscalar);
447  p.addParameter('ka_min', -pi, @isscalar);
448  p.addParameter('ka_max', pi, @isscalar);
449  p.addParameter('ka_num', 300, @isscalar);
450  p.addParameter('ka_vec', [] );
451  p.addParameter('center', 0.001);
452  p.addParameter('db', min([10,size(obj.H0,1)]), @isscalar);
453  p.addParameter('offset', mean(diag(obj.H0)) ); %Offset value to shift the spectrum along the energy axis
454  p.addParameter('calcWaveFnc', false ); %Logical value. Set true to calculate also the wave functions, or false (default) otherwise.
455 
456  p.parse(varargin{:});
457  toPlot = p.Results.toPlot;
458  ka_min = p.Results.ka_min;
459  ka_max = p.Results.ka_max;
460  ka_num = p.Results.ka_num;
461  ka_vec = p.Results.ka_vec;
462  center = p.Results.center;
463  db = p.Results.db;
464  offset = p.Results.offset;
465  calcWaveFnc = p.Results.calcWaveFnc;
466 
467 
468  % check wheter Hamiltonians are decimated or not
469  if obj.HamiltoniansDecimated
470  obj.display(['EQuUs:', class(obj), ':CalcSpektrum: Hamiltonians are decimated. Please recreate Hamiltonians to calculate spectrum.'], 1)
471  spectrum = NaN;
472  return
473  end
474 
475  % check the number of eigenvalues
476  db = min([ db, size(obj.H0,1)]);
477 
478 
479  obj.display('Calculating spectrum')
480 
481  % discrete increment of the wavenumber array
482  deltak = (ka_max-ka_min)/ka_num;
483 
484  % allocating temporary matricest;
485  S0_loc = obj.S0;
486  S1_loc = obj.S1;
487  S1_transverse_loc = obj.S1_transverse;
488 
489  tic
490  % creating the one-dimensional array for the wave numbers if not given
491  if isempty(ka_vec)
492  ka_vec = ka_min:deltak:ka_max;
493  end
494 
495  % allocating arrays for the results
496  spectrum = cell(length(ka_vec),1);
497  if calcWaveFnc
498  WaveFnc = structures('WaveFnc');
499  else
500  WaveFnc = [];
501  end
502 
503  % calculating the spectrum
504  for idx=1:length(ka_vec)
505  % obtaining the k-dependent effective Hamiltonian
506  H = obj.MomentumDependentHamiltonian( ka_vec(idx), obj.q );
507  H = H - eye(size(H))*offset;
508 
509  if isempty( S0_loc ) && isempty( S1_loc )
510  if calcWaveFnc
511  % calculations including the wavefunctions
512  if db < size(H,1)-1
513  [WaveFnc_tmp, E] = eigs(H, db, center);
514  else
515  [WaveFnc_tmp, E] = eig(H);
516  end
517  E = diag(E);
518  WaveFnc(idx).WaveFnc = WaveFnc_tmp;
519  WaveFnc(idx).E = E;
520  WaveFnc(idx).ka = ka_vec(idx);
521  else
522  % only eigenvalues are calculated
523  if db < size(H,1)-1
524  E = eigs(H, db, center);
525  else
526  E = eig(full(H));
527  end
528  end
529  else
530  % calculations including the overlap matrices
531  S = secular_H( S0_loc, S1_loc, S1_transverse_loc, ka_vec(idx));
532  if calcWaveFnc
533  % calculations including the wavefunctions
534  if db < size(H,1)-1
535  [WaveFnc_tmp, E] = eigs(H, S, db, center);
536  else
537  [WaveFnc_tmp, E] = eig(H, S);
538  end
539  E = diag(E);
540  WaveFnc.WaveFnc{idx} = WaveFnc_tmp;
541  WaveFnc.E{idx} = E;
542  WaveFnc.ka(idx) = ka_vec(idx);
543  else
544  % only eigenvalues are calculated
545  if db < size(H,1)-1
546  E = eigs(H, S, db, center);
547  else
548  E = eig(H, S);
549  end
550  end
551  end
552 
553  spectrum{idx} = [ones(length(E),1)*ka_vec(idx), E];
554 
555  end
556  % reorganize the calculated data
557  spectrum = cell2mat(spectrum);
558  toc
559 
560  obj.display('Spectrum calculated')
561 
562  % check whether to plot the spectrum
563  if ~toPlot
564  return
565  end
566 
567  % plot the calculated spectrum
568  figure1 = figure();
569  fontsize = 9;
570 
571  spectrum(:,2) = real(spectrum(:,2));
572  x_lim = [min(spectrum(:,1)) max(spectrum(:,1))];
573  y_lim = [min(spectrum(:,2)) max(spectrum(:,2))];
574 
575  Position = [0.5 0.58 0.33 0.4];
576  axes_spectrum = axes('Parent',figure1, 'Position', Position,...
577  'Visible', 'on',...
578  'FontSize', fontsize,...
579  'xlim', x_lim,...
580  'ylim', y_lim,... 'XTick', XTick,... 'YTick', YTick,...
581  'Box', 'on',...
582  'FontName','Times New Roman');
583  hold on;
584 
585  plot(spectrum(:,1), spectrum(:,2),'.', 'MarkerSize', 4, 'Parent', axes_spectrum )
586 
587  % Create xlabel
588  xlabel_position = [0 0 0];
589  xlabel('ka','FontSize', fontsize,'FontName','Times New Roman', 'Parent', axes_spectrum);
590  xlabel_handle = get(axes_spectrum,'XLabel');
591  set(xlabel_handle, 'Position', get(xlabel_handle, 'Position') + xlabel_position);
592 
593  % Create ylabel
594  ylabel_position = [0 0 0];
595  ylabel('E [eV]','FontSize', fontsize,'FontName','Times New Roman', 'Parent', axes_spectrum);
596  ylabel_handle = get(axes_spectrum,'YLabel');
597  set(ylabel_handle, 'Position', get(ylabel_handle, 'Position') + ylabel_position);
598 
599 
600  % --------------------------------------
601  % nested functions
602  % Hamiltonian for the secular equation
603  function H = secular_H(H0,H1, H1_transverse, k)
604 
605  if ~isempty(q) && ~obj.HamiltoniansDecimated
606  H0 = H0 + H1_transverse*diag(exp(-1i*q)) + H1_transverse'*diag(exp(1i*q));
607  end
608  H = H0 + H1*exp(1i*k) + H1'*exp(-1i*k);
609 
610  end
611 
612  % end nested functions
613 
614 
615  end
616 
617 %% saveLeads
618 %> @brief Save Lead Hamiltonians into a file 'Hamiltoni_Lead_' + num2str(Hanyadik_Lead) + '.mat'.
619  function saveLeads( obj )
620  save(['Hamiltoni_Lead_',num2str(obj.Hanyadik_Lead),'.mat'], 'H0', 'H1', 'kulso_szabfokok', 'Lead_Orientation', 'fazis_mtx_H0', 'fazis_mtx_H1', 'params');
621  end
622 
623 %% ShiftCoordinates
624 %> @brief Shifts the coordinates of the sites by an integer multiple of the lattice vector #Coordinates.a.
625 %> @param shift Integer by which the coordinates are shifted.
626  function ShiftCoordinates( obj, shift )
627  if isempty(shift) || shift == 0
628  return
629  end
630 
631  % shifting the coordinates along the translational invariant direction
632  obj.coordinates = obj.coordinates.Shift( shift*obj.coordinates.a );
633 
634  end
635 
636 
637 
638 %% ShiftLead
639 %> @brief Shifts the on-site energies in the leads by a given energy.
640 %> @param Energy The enrgy value.
641  function ShiftLead( obj, Energy )
642  obj.H0 = obj.H0 + sparse(1:size(obj.H0,1), 1:size(obj.H0,2),Energy,size(obj.H0,1),size(obj.H0,2));
643  obj.params.epsilon = obj.params.epsilon + Energy;
644 
645  obj.K0 = [];
646  obj.OverlapApplied = false;
647  end
648 
649 %% AddPotential
650 %> @brief Adds on-site potential to the Hamiltonian H0.
651 %> @param V The potential calculated on the sites.
652  function AddPotential( obj, V )
653 
654  if ( size(V,2) == 1 ) || ( size(V,1) == 1 )
655  if length(V) == size(obj.H0,1)
656  obj.H0 = obj.H0 + sparse(1:size(obj.H0,1), 1:size(obj.H0,2),V,size(obj.H0,1),size(obj.H0,2));
657  obj.K0 = [];
658  obj.OverlapApplied = false;
659  else
660  disp(' Wrong dimension of potential: 1')
661  return
662  end
663  elseif norm(size(V) - size(obj.H0)) < 1e-6
664  obj.H0 = obj.H0 + V;
665  obj.K0 = [];
666  obj.OverlapApplied = false;
667  else
668  disp(' Wrong dimension of potential: 2')
669  return
670  end
671 
672  obj.display(' Potential added to lead')
673  end
674 
675 %% isSuperconducting
676 %> @brief Test, whether the lead is in the superconducting phase or not.
677 %> @return True if the lead is superconducting, false otherwise.
678  function ret = isSuperconducting( obj )
679 
680  if ~obj.Opt.BdG
681  ret = false;
682  return;
683  end
684 
685  if abs(obj.params.pair_potential) >= 1e-10
686  ret = true;
687  else
688  ret = false;
689  end
690 
691  return
692 
693 
694  end
695 
696 
697 %% MomentumDependentHamiltonian
698 %> @brief Construct a momentum dependent (Fourier-transformed) Hamiltonian.
699 %> @param k The longitudinal momentum times the lattice constant.
700 %> @param q The transverse momentum times the lattice constant.
701 %> @return Return with the momentum dependent Hamiltonian.
702  function ret = MomentumDependentHamiltonian( obj, k, q )
703 
704  % check wheter Hamiltonians are decimated or not
705  if obj.HamiltoniansDecimated
706  obj.display(['EQuUs:', class(obj), ':MomentumDependentHamiltonian: Hamiltonians are decimated. Please recreate Hamiltonians to calculate spectrum.'], 1)
707  ret = NaN;
708  return
709  end
710 
711  ret = obj.H0;
712 
713  ret = ret + obj.H1*diag(exp(1i*k)) + obj.H1'*diag(exp(-1i*k));
714 
715  if ~isempty(obj.H1_transverse) && ~isempty(q)
716  ret = ret + obj.H1_transverse*diag(exp(1i*q)) + obj.H1_transverse'*diag(exp(-1i*q));
717  end
718 
719  if ~isempty(obj.H1_skew_right) && ~isempty(q)
720  ret = ret + obj.H1_skew_right*diag(exp(1i*(q-k))) + obj.H1_skew_right'*diag(exp(-1i*(q-k)));
721  end
722 
723  if ~isempty(obj.H1_skew_left) && ~isempty(q)
724  ret = ret + obj.H1_skew_left*diag(exp(1i*(q+k))) + obj.H1_skew_left'*diag(exp(-1i*(q+k)));
725  end
726 
727 
728  return
729 
730 
731  end
732 
733 %% CreateClone
734 %> @brief Creates a clone of the present class.
735 %> @return Returns with the cloned object.
736 %> @param varargin Cell array of optional parameters (https://www.mathworks.com/help/matlab/ref/varargin.html):
737 %> @param 'empty' Set true to create an empty clone, or false (default) to clone all atributes.
738  function ret = CreateClone( obj, varargin )
739 
740  p = inputParser;
741  p.addParameter('empty', false ); %Logical value. Set true for creating an empty class, or false (default) otherwise.
742 
743  p.parse(varargin{:});
744  empty = p.Results.empty;
745 
746  ret = CreateLeadHamiltonians(obj.Opt, obj.param,...
747  'Hanyadik_Lead', obj.Hanyadik_Lead,...
748  'Lead_Orientation', obj.Lead_Orientation, ...
749  'q', obj.q);
750  if empty
751  return
752  end
753 
754  meta_data = metaclass(obj);
755 
756  for idx = 1:length(meta_data.PropertyList)
757  prop_name = meta_data.PropertyList(idx).Name;
758  ret.Write( prop_name, obj.(prop_name));
759  end
760 
761  end
762 
763 %% Reset
764 %> @brief Resets all elements in the object.
765  function Reset( obj )
766 
767  if strcmpi( class(obj), 'CreateLeadHamiltonians' )
768  meta_data = metaclass(obj);
769 
770  for idx = 1:length(meta_data.PropertyList)
771  prop_name = meta_data.PropertyList(idx).Name;
772  if strcmp(prop_name, 'Opt') || strcmp( prop_name, 'param') || strcmp(prop_name, 'varargin')
773  continue
774  end
775  obj.Clear( prop_name );
776  end
777  end
778 
779  obj.Initialize();
780 
781 
782  end
783 
784 
785 
786 %% Write
787 %> @brief Sets the value of an attribute in the interface.
788 %> @param MemberName The name of the attribute to be set.
789 %> @param input The value to be set.
790  function Write(obj, MemberName, input)
791 
792  if strcmp(MemberName, 'param')
793  obj.param = input;
794  obj.Reset()
795  return
796  elseif strcmpi(MemberName, 'params')
797  obj.params = input;
798  if isempty(obj.Hanyadik_Lead)
799  obj.param.scatter = input;
800  else
801  obj.param.Leads{obj.Hanyadik_Lead} = input;
802  end
803  else
804  try
805  obj.(MemberName) = input;
806  catch
807  error(['EQuUs:', class(obj), ':Read'], ['No property to write with name: ', MemberName]);
808  end
809  end
810 
811  end
812 %% Read
813 %> @brief Query for the value of an attribute in the interface.
814 %> @param MemberName The name of the attribute to be set.
815 %> @return Returns with the value of the attribute.
816  function ret = Read(obj, MemberName)
817 
818  try
819  ret = obj.(MemberName);
820  catch
821  error(['EQuUs:', class(obj), ':Read'], ['No property to read with name: ', MemberName]);
822  end
823 
824  end
825 %% Clear
826 %> @brief Clears the value of an attribute in the interface.
827 %> @param MemberName The name of the attribute to be cleared.
828  function Clear(obj, MemberName)
829 
830  try
831  obj.(MemberName) = [];
832  catch
833  error(['EQuUs:', class(obj), ':Clear'], ['No property to clear with name: ', MemberName]);
834  end
835 
836  end
837 
838 end % public methods
839 
840 
841 methods ( Access = protected )
842 
843 %% setM
844 %> @brief Updates the number of sites in the cross section.
845  function setM( obj )
846  if isempty( obj.Hanyadik_Lead )
847  obj.M = obj.param.scatter.shape.width;
848  else
849  obj.M = obj.param.Leads{obj.Hanyadik_Lead}.M;
850  end
851  end
852 
853 
854 %% Initialize
855 %> @brief Initializes object properties.
856  function Initialize(obj)
857  obj.InputParsing( obj.varargin{:});
858 
859 
860  obj.HamiltoniansCreated = false;
861  obj.HamiltoniansDecimated = false;
862  obj.OverlapApplied = false;
863  obj.MagneticFieldApplied = false;
864  obj.GaugeTransformationApplied = false;
865 
866 
867 
868  obj.setM();
869 
870  if isempty( obj.Hanyadik_Lead )
871  obj.params = obj.param.scatter; %Lead parameters
872  else
873  obj.params = obj.param.Leads{obj.Hanyadik_Lead}; %Lead parameters
874  end
875 
876  end
877 
878 end % protected methods
879 
880 
881 methods (Access=protected)
882 
883 
884 %% InputParsing
885 %> @brief Parses the optional parameters for the class constructor.
886 %> @param varargin Cell array of optional parameters (https://www.mathworks.com/help/matlab/ref/varargin.html):
887 %> @param 'Hanyadik_Lead' The ID number of the current lead. Set to empty (default) for using parameters of the scatter region.
888 %> @param 'Lead_Orientation' Orientation of the lead. Set +1 (default) is the "incoming" direction of the propagating states is defined in the +x or +y direction, and "-1" otherwise.
889 %> @param 'q' The transverse momentum. Set to empty (default) for computations without transverse momentums.
890  function InputParsing( obj, varargin )
891  p = inputParser;
892  p.addParameter('Hanyadik_Lead', []);
893  p.addParameter('Lead_Orientation', 1);
894  p.addParameter('q', []);
895 
896  % keeping unmatched attributes that possibly comes from the derived classes
897  p.KeepUnmatched = true;
898 
899  p.parse(varargin{:});
900 
901  obj.Lead_Orientation = p.Results.Lead_Orientation;
902  obj.Hanyadik_Lead = p.Results.Hanyadik_Lead;
903  obj.q = p.Results.q;
904 
905 
906 
907 
908  end
909 
910 end % private methods
911 
912 
913 
914 
915 
916 end
Class to create the Hamiltonian of one unit cell in a translational invariant lead made of Triangle l...
A class containing methodes for displaying several standard messages.
Definition: Messages.m:24
Structure Opt contains the basic computational parameters used in EQuUs.
Definition: structures.m:60
E
Cell array containing the individual energies.
Definition: structures.m:222
Structure shape contains data about the geometry of the scattering region.
Definition: structures.m:106
Class to create and store Hamiltonian of the translational invariant leads.
Class to create the Hamiltonian of one unit cell in a translational invariant lead made of square lat...
function Transport(Energy, B)
Calculates the conductance at a given energy value.
WaveFnc
Cell array containing the individual wave functions.
Definition: structures.m:218
Class to create the Hamiltonian of one unit cell on a BiTeI lattice.
function Hamiltonians(varargin)
Function to create the custom Hamiltonians for the 1D chain.
A class to import custom Hamiltonians provided by other codes or created manually
function secular_H(H0, H1, k)
Hamiltonian for the secular equation.
Property H0
Cell array of Hamiltonians of one slab in the leads.
A class to calculate the Green functions and self energies of a translational invariant lead The nota...
Definition: Lead.m:29
function()
Class to create the Hamiltonian of one unit cell in a translational invariant lead made of TMDC_Monol...
Structure param contains data structures describing the physical parameters of the scattering center ...
Definition: structures.m:45
ka
Cell array containing the individual k-pints.
Definition: structures.m:220
Class to create the Hamiltonian of one unit cell in a translational invariant lead made of TMDC_Monol...
Structure sites contains data to identify the individual sites in a matrix.
Definition: structures.m:187
A class responsible for the Peierls and gauge transformations.
Definition: Peierls.m:24
Structure containg datat on the calculated eigenstate in a translational invariant lead.
Definition: structures.m:216
A class to create the Hamiltonian of one unit cell in a translational invariant lead made of hexagona...
function structures(name)
Class to create the Hamiltonian of one unit cell in a translational invariant lead made of TMDC bilay...
A class to create and store Hamiltonian of the scattering region.