Eötvös Quantum Utilities  v4.9.146
Providing the Horsepowers in the Quantum Realm
CreateHamiltonians.m
Go to the documentation of this file.
1 %% Eotvos Quantum Transport Utilities - CreateHamiltonians
2 % Copyright (C) 2009-2015 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 CreateHamiltonians.m
20 %> @brief A class to create and store Hamiltonian of the scattering region
21 %> @}
22 %> @brief A class to create and store Hamiltonian of the scattering region
23 %%
25 
26  properties ( Access = protected )
27  %> An instance of structure param
28  param
29  %> A list of the sites to be kept after decimation.
30  kulso_szabfokok
31  %> Hscatter - E*Sscatter
32  Kscatter
33  %> Hscatter_transverse - E*Sscatter_transverse
34  Kscatter_transverse
35  %> The matrix of the Hamiltonian.
36  Hscatter
37  %> The matrix of the Hamiltonian corresponding to the transverse coupling.
38  Hscatter_transverse
39  %> The matrix of the overlap integrals in the Hamiltonian.
40  Sscatter
41  %> The matrix of the overlap integrals for the transverse coupling.
42  Sscatter_transverse
43  %> The matrix of the Peierls phases.
44  fazis_mtx_scatter
45  %> The matrix of the Peierls phases for the transverse coupling.
46  fazis_mtx_scatter_t
47  %> An instance of the structure coordinates.
48  coordinates
49  %> The length of the scattering region in units of the lattice contant.
50  height
51  %> The number of sites in the cross section.
52  width
53  %> The number of sites in one unit cell.
54  M
55  %> A logical value. True if the Hamiltonian was created, false otherwise.
56  HamiltoniansCreated
57  %> A logical value. True if the Hamiltonian was decimated, or false otherwise.
58  HamiltoniansDecimated
59  %> A logical value. True if the overlap integrals were applied, false otherwise.
60  OverlapApplied
61  %> A logical value. True if the vector potential was incorporated into the Hamiltonian or false otherwise.
62  MagneticFieldApplied
63  %> A logical value. True if a gauge transformation was applied on the Hamiltonians, or false otherwise.
64  GaugeTransformationApplied
65  %> A transverse momentum.
66  q
67  %> list of optional parameters (see http://www.mathworks.com/help/matlab/ref/varargin.html for details)
68  varargin
69 
70  end
71 
72 
73 methods ( Access = public )
74 %% constructorof the class
75 %> @brief Constructor of the class.
76 %> @param Opt An instance of the structure Opt.
77 %> @param param An instance of structure param.
78 %> @param varargin Cell array of optional parameters. For details see #InputParsing.
79 %> @return An instance of the class
80 function obj = CreateHamiltonians(Opt, param, varargin)
81  obj = obj@Messages( Opt );
82  obj.Opt = Opt;
83  obj.param = param;
84  obj.varargin = varargin;
85 
86  obj.Initialize();
87 
88 end
89 
90 %% CreateScatterH
91 %> @brief Creates a Hamiltonian of a rectangle shaped area. The created Hamiltonian and coordinates are stored within the object.
92 %> @param varargin Cell array of optional parameters:
93 %> @param 'Scatter_UC' An instance of class #CreateLeadHamiltonians or its subclass
94 %> @param 'CustomHamiltonian' An instance of class #Custom_Hamiltonians for external Hamiltonian source.
95 function CreateScatterH( obj, varargin )
96  p = inputParser;
97  p.addParameter('Scatter_UC', []);
98  p.addParameter('CustomHamiltonian', []);
99  p.parse(varargin{:});
100  Scatter_UC = p.Results.Scatter_UC;
101  CustomHamiltonian = p.Results.CustomHamiltonian;
102 
103  shape = obj.param.scatter.shape;
104 
105  obj.width = shape.width;
106  obj.height = shape.height; % number of unit cells!!!!!!!!
107 
108  if isempty(Scatter_UC)
109 
110  if ~isempty( obj.Opt.custom_Hamiltonians )
111  obj.queryHamiltonians( CustomHamiltonian );
112  return
113  elseif strcmpi(obj.Opt.Lattice_Type, 'Square')
114  createH = Square_Lead_Hamiltonians();
115  [H0,H1,H1_transverse,coordinates_unitcell] = createH.SquareLattice_Lead_Hamiltonians(obj.param.scatter, obj.width);
116  elseif strcmpi(obj.Opt.Lattice_Type, 'SSH')
117  createH = Square_Lead_Hamiltonians();
118  [H0,H1,H1_transverse,coordinates_unitcell] = createH.SSH_Lead_Hamiltonians(obj.param.scatter);
119  elseif strcmp(obj.Opt.Lattice_Type, 'Lieb')
120  createH = Square_Lead_Hamiltonians();
121  [obj.H0,obj.H1,obj.H1_transverse,obj.coordinates] = createH.Lieb_Lead_Hamiltonians(obj.params, obj.width);
122  obj.H1adj = obj.H1';
123  elseif strcmpi(obj.Opt.Lattice_Type, 'Graphene')
124  End_Type = obj.param.scatter.End_Type;
125  createH = Hex_Lead_Hamiltonians();
126  [H0,H1,H1_transverse,coordinates_unitcell] = createH.Graphene_Lead_Hamiltonians(obj.param.scatter, obj.width, End_Type);
127  elseif strcmpi(obj.Opt.Lattice_Type, 'Silicene')
128  End_Type = obj.param.scatter.End_Type;
129  createH = Hex_Lead_Hamiltonians();
130  [H0,H1,H1_transverse,coordinates_unitcell] = createH.Silicene_Lead_Hamiltonians(obj.param.scatter, obj.width, End_Type);
131  elseif strcmpi(obj.Opt.Lattice_Type, 'Graphene_Bilayer')
132  End_Type = obj.param.scatter.End_Type;
133  createH = Hex_Lead_Hamiltonians();
134  [H0,H1,H1_transverse,coordinates_unitcell] = createH.Graphene_Bilayer_Lead_Hamiltonians(obj.param.scatter, obj.width, End_Type);
135  elseif strcmpi(obj.Opt.Lattice_Type, 'Graphene_Bilayer_2')
136  End_Type = obj.param.scatter.End_Type;
137  createH = Hex_Lead_Hamiltonians();
138  [H0,H1,H1_transverse,coordinates_unitcell] = createH.Graphene_Bilayer_Lead_Hamiltonians2(obj.param.scatter, obj.width, End_Type);
139  elseif strcmpi(obj.Opt.Lattice_Type, 'Graphene_Bilayer_3')
140  End_Type = obj.param.scatter.End_Type;
141  createH = Hex_Lead_Hamiltonians();
142  [H0,H1,H1_transverse,coordinates_unitcell] = createH.Graphene_Bilayer_Lead_Hamiltonians3(obj.param.scatter, obj.width, End_Type);
143  elseif strcmpi(obj.Opt.Lattice_Type, 'Triangle')
144  createH = Triangle_Lead_Hamiltonians();
145  [H0,H1,H1_transverse,coordinates_unitcell] = createH.Triangle_Hamiltonians(obj.param.scatter, obj.width);
146  elseif strcmpi(obj.Opt.Lattice_Type, 'TMDC_Monolayer')
148  [H0,H1,H1_transverse,coordinates_unitcell] = createH.TMDC_Monolayer_Hamiltonians(obj.param.scatter, obj.width);
149  elseif strcmpi(obj.Opt.Lattice_Type, 'TMDC_Monolayer_SOC')
151  [H0,H1,H1_transverse,coordinates_unitcell] = createH.TMDC_Monolayer_SOC_Hamiltonians(obj.param.scatter, obj.width);
152  elseif strcmpi(obj.Opt.Lattice_Type, 'TMDC_Bilayer_SOC')
154  [H0,H1,H1_transverse,coordinates_unitcell] = createH.TMDC_Monolayer_SOC_Hamiltonians(obj.param.scatter, obj.width);
155  else
156  error(['EQuUs:', class(obj), ':CreateScatterH:'], 'Unrecognized lattice type, or the claculation options are not set to use outher DFT source.')
157  end
158  else
159  H0 = Scatter_UC.Read( 'H0' );
160  H1 = Scatter_UC.Read( 'H1' );
161  H1_transverse = Scatter_UC.Read( 'H1_transverse' );
162  coordinates_unitcell = Scatter_UC.Read( 'coordinates' );
163  obj.MagneticFieldApplied = Scatter_UC.Read( 'MagneticFieldApplied' );
164  obj.GaugeTransformationApplied = Scatter_UC.Read( 'GaugeTransformationApplied' );
165  obj.width = size(H0, 1);
166  end
167 
168  H1adj = H1';
169  obj.M = size(H0,1);
170 
171  height = obj.height;
173  coordinates.a = coordinates_unitcell.a;
174  coordinates.b = coordinates_unitcell.b;
175 
176  HCell = repmat({H1}, 1, height-1);
177  H1_big = blkdiag(HCell{:});
178  HCell = repmat({H1adj}, 1, height-1);
179  H1adj_big = blkdiag(HCell{:});
180  HCell = repmat({H0}, 1, height);
181  Hscatter = blkdiag(HCell{:});
182 
183  H1_big = [[sparse([],[],[], size(H1_big,1), size(H1,2)), H1_big]; sparse([],[],[], size(H1,1), size(H1_big,2)+size(H1,2))];
184  H1adj_big = [sparse([],[],[], size(H1,1), size(H1adj_big,1)+size(H1,2)); [H1adj_big, sparse([],[],[], size(H1adj_big,1), size(H1,2))]];
185 
186  Hscatter = Hscatter + H1_big + H1adj_big;
187 
188  if ~isempty(obj.q)
189  HCell = repmat({H1_transverse}, 1, height);
190  Hscatter_transverse = blkdiag(HCell{:});
191  else
192  Hscatter_transverse = [];
193  end
194  HCell = [];
195  coordfieldnames = fieldnames( coordinates_unitcell );
196  for idx = 1:length( coordfieldnames )
197  coordfieldname = coordfieldnames{idx};
198  if strcmpi( coordfieldname, 'a') || strcmpi( coordfieldname, 'b')
199  continue
200  elseif strcmpi( coordfieldname, 'x')
201  tmp = ones(size(coordinates_unitcell.x))*(coordinates_unitcell.a(1)*(0:height-1));
202  tmp = reshape(tmp, numel(tmp), 1);
203  coordinates.x = repmat(coordinates_unitcell.x, height, 1) + tmp;
204  elseif strcmpi( coordfieldname, 'y')
205  tmp = ones(size(coordinates_unitcell.y))*(coordinates_unitcell.a(2)*(0:height-1));
206  tmp = reshape(tmp, numel(tmp), 1);
207  coordinates.y = repmat(coordinates_unitcell.y, height, 1) + tmp;
208  elseif ~isempty(coordinates_unitcell.(coordfieldname))
209  coordinates.(coordfieldname) = repmat(coordinates_unitcell.(coordfieldname), height, 1);
210  end
211  end
212 
213 
214  obj.coordinates = coordinates;
215  obj.Hscatter = Hscatter;
217 
218  obj.HamiltoniansCreated = true;
219  obj.MagneticFieldApplied = false;
220  obj.GaugeTransformationApplied = false;
221  obj.OverlapApplied = false;
222  obj.HamiltoniansDecimated = false;
223 
224 
225 end
226 
227 
228 %% ApplyOverlapMatrices
229 %> @brief Applies the overlap matrices to the Hamiltonians: K = H-ES
230 %> @param E The energy value.
231  function ApplyOverlapMatrices(obj, E)
232 
233  if obj.OverlapApplied
234  obj.display(['EQuUs:', class(obj), ':ApplyOverlapMatrices: Overlap matrices were already applied.']);
235  return;
236  end
237 
238  if ~isempty( obj.Sscatter )
239  obj.Kscatter = obj.Hscatter - E*obj.Sscatter;
240  obj.OverlapApplied = true;
241  else
242  obj.Kscatter = obj.Hscatter - eye(size(obj.H0))*E;
243  end
244 
245 
246  if ~isempty( obj.Sscatter_transverse )
247  obj.Kscatter_transverse = obj.Hscatter_transverse - E*obj.Sscatter_transverse;
248  elseif ~isempty( obj.H1_transverse )
249  obj.Kscatter_transverse = obj.Hscatter_transverse;
250  end
251 
252  end
253 
254 %% shiftFermiEnergy
255 %> @brief Shifts the on-site energies in the Scattering region by a given energy.
256 %> @param Energy The energy value to be used.
257  function shiftFermiEnergy( obj, Energy )
258  if isempty( obj.Sscatter )
259  energyshift = speye( size( obj.Hscatter ) )*Energy;
260  else
261  energyshift = obj.Sscatter*Energy;
262  end
263 
264  obj.Hscatter = obj.Hscatter - energyshift;
265  if ~isempty( obj.param.scatter) && ~isempty( obj.param.scatter.epsilon )
266  obj.param.scatter.epsilon = obj.param.scatter.epsilon + Energy;
267  end
268  end
269 
270 %% projectHamiltonian2Spin
271 %> @brief Projects the Hamiltonian to a spin states of $s=\pm1$
272 %> @param s The quantum index of the spin (\pm1)
273  function projectHamiltonian2Spin( obj, s )
274  if s == 1
275  obj.coordinates.x = obj.coordinates.x(obj.coordinates.spinup);
276  obj.coordinates.y = obj.coordinates.y(obj.coordinates.spinup);
277  obj.Hscatter = obj.Hscatter( obj.coordinates.spinup, obj.coordinates.spinup);
278  if ~isempty(obj.q)
279  obj.Hscatter_transverse = obj.Hscatter_transverse( obj.coordinates.spinup, obj.coordinates.spinup);
280  end
281  elseif s == -1
282  obj.coordinates.x = obj.coordinates.x(~obj.coordinates.spinup);
283  obj.coordinates.y =obj. coordinates.y(~obj.coordinates.spinup);
284  obj.Hscatter = obj.Hscatter( ~obj.coordinates.spinup, ~obj.coordinates.spinup);
285  if ~isempty(obj.q)
286  obj.Hscatter_transverse = obj.Hscatter_transverse( ~obj.coordinates.spinup, ~obj.coordinates.spinup);
287  end
288  else
289  display(['EQuUs:', class(obj), ':projectHamiltonian2Spin: spin should be +/-1'], 1)
290  end
291 
292  obj.coordinates.spinup = [];
293  obj.M = obj.M/2;
294 
295 
296  end
297 
298 %% Reset
299 %> @brief Resets all elements in the class.
300  function Reset(obj)
301 
302  if strcmpi( class(obj), 'CreateHamiltonians' )
303  meta_data = metaclass(obj);
304 
305  for idx = 1:length(meta_data.PropertyList)
306  prop_name = meta_data.PropertyList(idx).Name;
307  if strcmp(prop_name, 'Opt') || strcmp( prop_name, 'param') || strcmp(prop_name, 'varargin')
308  continue
309  end
310  obj.Clear( prop_name );
311  end
312  end
313 
314  obj.Initialize();
315 
316 
317  end
318 
319 %% CreateClone
320 %> @brief Creates a clone of the present class.
321 %> @param varargin Cell array of optional parameters (https://www.mathworks.com/help/matlab/ref/varargin.html):
322 %> @param 'empty' Set true to create an empty clone, or false (default) to clone all atributes.
323 %> @return Returns with the cloned object.
324  function ret = CreateClone( obj, varargin )
325 
326  p = inputParser;
327  p.addParameter('empty', false );
328 
329  p.parse(varargin{:});
330  empty = p.Results.empty;
331 
332  ret = CreateHamiltonians(obj.Opt, obj.param, obj.varargin{:});
333 
334  if empty
335  return
336  end
337 
338  meta_data = metaclass(obj);
339 
340  for idx = 1:length(meta_data.PropertyList)
341  prop_name = meta_data.PropertyList(idx).Name;
342  ret.Write( prop_name, obj.(prop_name));
343  end
344 
345  end
346 
347 
348 %% RemoveSites
349 %> @brief Removes specific sites from the model of the scattering region. For example see function #ScatterPotQD.
350 %> @param indexes Logical array. Sites with true values will be removed from the system.
351  function RemoveSites( obj, indexes )
352 
353  % update the array of external degrees of freedom
354  if ~isempty( obj.kulso_szabfokok )
355  all_sites = 1:size(obj.Hscatter,1);
356  sites2remove = all_sites( indexes );
357 
358  for idx = length(sites2remove):-1:1
359  indexes_tmp = find( obj.kulso_szabfokok == sites2remove(idx), 1 );
360  if ~isempty(indexes_tmp)
361  error(['EQuUs:', class(obj), ':RemoveSites'], 'Sites cannot be removed from the Hamiltonian.');
362  end
363 
364  indexes_tmp = obj.kulso_szabfokok > sites2remove(idx);
365  obj.kulso_szabfokok(indexes_tmp) = obj.kulso_szabfokok(indexes_tmp) - 1;
366  end
367  end
368 
369  % removing sites from the scattering Hamiltonian
370  obj.Hscatter = obj.Hscatter(~indexes, ~indexes);
371 
372  % removing sites from the matrix of the transverse coupling
373  if ~isempty(obj.Hscatter_transverse)
374  obj.Hscatter_transverse = obj.Hscatter_transverse(~indexes, ~indexes);
375  end
376 
377  % removing sites from the matrix of the overlap integrals
378  if ~isempty(obj.Sscatter )
379  obj.Sscatter = obj.Sscatter(~indexes, ~indexes);
380  end
381 
382  % removing sites from the matrix of the overlap integrals of the transverse coupling
383  if ~isempty(obj.Sscatter_transverse )
384  obj.Sscatter_transverse = obj.Sscatter_transverse(~indexes, ~indexes);
385  end
386 
387  % removing sites from the matrix of the Peierls phases
388  if ~isempty(obj.fazis_mtx_scatter )
389  obj.fazis_mtx_scatter = obj.fazis_mtx_scatter(~indexes, ~indexes);
390  end
391 
392  % removing sites from the matrix of the Peierls phases of the transverse coupling
393  if ~isempty(obj.fazis_mtx_scatter_t )
394  obj.fazis_mtx_scatter_t = obj.fazis_mtx_scatter_t(~indexes, ~indexes);
395  end
396 
397  % removing sites from structure coordinates
398  obj.coordinates = obj.coordinates.RemoveSites( indexes );
399 
400 
401  end
402 
403 %% saveScatterHamiltonian
404 %> @brief Saves the Hamiltonian and other data of the scattering region
405 %> @param filename The string containing the path to the file. (In octave use absolute paths only)
406  function saveScatter( filename )
407  if ~exist('filename', 'var')
408  filename = 'Hscatter.mat';
409  end
410  save(filename,'Hscatter', 'Hscatter_transverse', 'coordinates', 'param', 'fazis_mtx_scatte', 'fazis_mtx_scatte_t', 'width', 'height', 'M')
411  end
412 
413 %% LoadHamiltonian
414 %> @brief Loads the Hamiltonian and other data of the scattering region from a file.
415 %> @param filename The string containing the path to the file. (In octave use absolute paths only)
416  function loadScatter( obj, filename )
417  if ~exist('filename', 'var')
418  filename = 'Hscatter.mat';
419  end
420  disp('EQuUs::CreateHamiltonian::loadScatter: Loading scatter Hamiltonian from file')
421  HandleForLoad = LoadFromFile( filename );
422  obj.Hscatter = HandleForLoad.LoadVariable('Hscatter', 'NoEmpty', 'On');
423  obj.Hscatter_transverse = HandleForLoad.LoadVariable('Hscatter_transverse', 'NoEmpty', 'On');
424  obj.Sscatter = HandleForLoad.LoadVariable('Sscatter', 'NoEmpty', 'On');
425  obj.Sscatter_transverse = HandleForLoad.LoadVariable('Sscatter_transverse', 'NoEmpty', 'On');
426  obj.coordinates = HandleForLoad.LoadVariable('coordinates', 'NoEmpty', 'On');
427  obj.fazis_mtx_scatter = HandleForLoad.LoadVariable('fazis_mtx_scatte', 'NoEmpty', 'Off');
428  obj.fazis_mtx_scatter_t = HandleForLoad.LoadVariable('fazis_mtx_scatte_t', 'NoEmpty', 'Off');
429  obj.param = HandleForLoad.LoadVariable('param', 'NoEmpty', 'On');
430  obj.M = HandleForLoad.LoadVariable('M', 'NoEmpty', 'On');
431  obj.width = HandleForLoad.LoadVariable('width', 'NoEmpty', 'Off');
432  obj.height = HandleForLoad.LoadVariable('height', 'NoEmpty', 'On');
433  obj.q = HandleForLoad.LoadVariable('q', 'NoEmpty', 'On');
434  HandleForLoad.ClearLoadedVariable();
435 end
436 
437 %% Write
438 %> @brief Sets the value of an attribute in the class.
439 %> @param MemberName The name of the attribute to be set.
440 %> @param input The value to be set.
441  function Write(obj, MemberName, input)
442 
443  if strcmp(MemberName, 'param')
444  obj.param = input;
445  obj.Reset();
446  return
447  elseif strcmp(MemberName, 'params')
448  obj.param.scatter = input;
449  return
450  else
451  try
452  obj.(MemberName) = input;
453  catch
454  error(['EQuUs:', class(obj), ':Read'], ['No property to write with name: ', MemberName]);
455  end
456  end
457 
458  end
459 
460 %% Read
461 %> @brief Query for the value of an attribute in the class.
462 %> @param MemberName The name of the attribute to be set.
463 %> @return Returns with the value of the attribute.
464  function ret = Read(obj, MemberName)
465  try
466  ret = obj.(MemberName);
467  catch
468  error(['EQuUs:', class(obj), ':Read'], ['No property to read with name: ', MemberName]);
469  end
470  end
471 
472 %% MemberClear
473 %> @brief Clears the value of an attribute in the class.
474 %> @param MemberName The name of the attribute to be cleared.
475  function Clear(obj, MemberName)
476  try
477  obj.(MemberName) = [];
478  catch
479  error(['EQuUs:', class(obj), ':Clear'], ['No property to clear with name: ', MemberName]);
480  end
481 
482  end
483 
484 end % methods public
485 
486 methods ( Access = private )
487 
488 
489 %% Initialize
490 %> @brief Initializes object attributes.
491  function Initialize(obj)
492 
494  obj.HamiltoniansCreated = false;
495  obj.HamiltoniansDecimated = false;
496  obj.MagneticFieldApplied = false;
497  obj.GaugeTransformationApplied = false;
498  obj.OverlapApplied = false;
499 
500  obj.InputParsing( obj.varargin{:} );
501  end
502 
503 %% queryHamiltonians
504 %> @brief Obtains Hamiltonians from a class instance Custom_Hamiltonians
505 %> @param cCustom_Hamiltonians An instance of class #Custom_Hamiltonians
506  function queryHamiltonians( obj, cCustom_Hamiltonians )
507  if isempty( cCustom_Hamiltonians )
508  cCustom_Hamiltonians = Custom_Hamiltonians( obj.Opt, obj.param );
509  end
510 
511  if ~cCustom_Hamiltonians.Read( 'Hamiltonians_loaded' )
512  cCustom_Hamiltonians.LoadHamiltonians();
513  end
514 
515  obj.coordinates = cCustom_Hamiltonians.Read( 'coordinates_scatter' );
516  obj.Hscatter = cCustom_Hamiltonians.Read( 'Hscatter' );
517  obj.Hscatter_transverse = cCustom_Hamiltonians.Read( 'Hscatter_transverse' );
518  obj.Sscatter = cCustom_Hamiltonians.Read( 'Sscatter' );
519  obj.Sscatter_transverse = cCustom_Hamiltonians.Read( 'Sscatter_transverse' );
520  obj.HamiltoniansCreated = true;
521  obj.MagneticFieldApplied = false;
522  obj.GaugeTransformationApplied = false;
523  obj.HamiltoniansDecimated = false;
524 
525  % determine kulso_szabfokok
526  Hcoupling = cCustom_Hamiltonians.Read( 'Hcoupling' );
527 
528  if iscell( Hcoupling )
529  for idx = 1:length( Hcoupling )
530  coupled_sites = CoupledSites( Hcoupling{idx} );
531  obj.kulso_szabfokok = [obj.kulso_szabfokok, coupled_sites];
532  end
533  obj.kulso_szabfokok = unique( obj.kulso_szabfokok );
534  else
535  obj.kulso_szabfokok = CoupledSites( Hcoupling );
536  end
537 
538 
539  % tranforming into the BdG model if necessary
540  if ~isempty( obj.Opt.BdG ) && obj.Opt.BdG
541  obj.Transforms2BdG()
542  end
543 
544  % nested functions
545 
546  % determine sites coupled to the leads
547  function ret = CoupledSites( Hcoupling )
548  [rows, cols] = find(Hcoupling);
549  ret = unique( cols );
550  ret = reshape(ret, 1, numel(ret));
551  end
552 
553  % end nested functions
554  end
555 
556 %% Transforms2BdG
557 %> @brief Transforms the Hamiltonians into a Bogoliubov de Gennes model.
558  function Transforms2BdG( obj )
559  if isempty( obj.param.scatter.pair_potential )
560  error('CreateHamiltonian:Transform2BdG', 'Pair potential need to be set for the scattering region.');
561  end
562 
563  if ~isempty(obj.coordinates.BdG_u)
564  obj.display('Hamiltonians already transformed to BdG model.')
565  return
566  end
567 
568  fnames = fieldnames( obj.coordinates );
569  for idx = 1:length(fnames)
570  fname = fnames{idx};
571  if strcmp(fname, 'a') || strcmp(fname, 'b')
572  continue
573  end
574  obj.coordinates.(fname) = [ obj.coordinates.(fname); obj.coordinates.(fname) ];
575  end
576 
577  obj.coordinates.BdG_u = [ true(size(obj.Hscatter,1),1), false(size(obj.Hscatter,1),1)];
578 
579  length_kulso_szabfokok = length(obj.kulso_szabfokok);
580  obj.kulso_szabfokok = [obj.kulso_szabfokok(1:length_kulso_szabfokok), obj.kulso_szabfokok(1:length_kulso_szabfokok)+size(obj.Hscatter,1) ];
581 
582  % transforming the Hamiltonians
583  pair_potential = obj.param.scatter.pair_potential;
584  site_num = size( obj.Hscatter, 1 );
585  obj.coordinates.BdG_u = [true( site_num, 1); false( site_num, 1) ];
586 
587  if isempty( obj.Sscatter )
588  Sscatter = speye(size(obj.Hscatter));
589  else
590  Sscatter = obj.Sscatter;
591  end
592 
593  obj.Hscatter = [ obj.Hscatter, Sscatter*pair_potential;
594  Sscatter*conj(pair_potential), -conj(obj.Hscatter) ];
595 
596  % transforming the overlap integrals
597  if isempty( obj.Sscatter )
598  return;
599  end
600 
601  obj.Sscatter = [ obj.Sscatter, sparse([],[],[], site_num, site_num );
602  sparse([],[],[], site_num, site_num ), obj.Sscatter ];
603 
604 
605  end
606 
607 %% InputParsing
608 %> @brief Parses the optional parameters for the class constructor.
609 %> @param varargin Optional parameters, see the web documantation.
610 %> @param 'q' The transverse momentum quantum number.
612 
613  p = inputParser;
614  p.addParameter('q', []);
615 
616  p.parse(varargin{:});
617 
618  obj.q = p.Results.q;
619 
620  end
621 
622 
623 end %methods protected
624 
625 end % Global end
626 
function LoadHamiltonians(varargin)
Obtain the Hamiltonians from the external source.
function InputParsing(varargin)
Parses the optional parameters for the class constructor.
Class to create the Hamiltonian of one unit cell in a translational invariant lead made of Triangle l...
function Custom_Hamiltonians(Opt, param, varargin)
Constructor of the class.
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
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 display(message, nosilent)
Displays output messages on the screen.
Property varargin
list of optional parameters (see InputParsing for details)
function Transport(Energy, B)
Calculates the conductance at a given energy value.
function Reset()
Resets all elements in the object.
Property Sscatter_transverse
overlap integrals for the transverse coupling in the scattering region
function Hamiltonians(varargin)
Function to create the custom Hamiltonians for the 1D chain.
function Initialize()
Initializes object properties.
Property Hcoupling
Cell array of couplings between the scattering region and the leads.
Property Sscatter
Overlap integrals of the scattering region.
function Write(MemberName, input)
Sets the value of an attribute in the class.
A class to import custom Hamiltonians provided by other codes or created manually
Property H0
Cell array of Hamiltonians of one slab in the leads.
function()
Class to create the Hamiltonian of one unit cell in a translational invariant lead made of TMDC_Monol...
Property Hscatter_transverse
transverse coupling for the scattering region
Structure param contains data structures describing the physical parameters of the scattering center ...
Definition: structures.m:45
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
function Clear(MemberName)
Clears the value of an attribute in the class.
Property coordinates
Cell array of coordinates of the leads.
Property Opt
An instance of structure Opt.
Definition: Messages.m:31
Property H1
Cell array of couplings between the slabs of the leads.
Property Hscatter
Hamiltonian of the scattering region.
A class responsible for the Peierls and gauge transformations.
Definition: Peierls.m:24
function Read(MemberName)
Query for the value of an attribute in the class.
width
The number of sites in the cross section.
Definition: structures.m:108
Property H1_transverse
Cell array of transverse coupling between the unit cells of the lead.
A class providing interface to load variables from a file.
Definition: LoadFromFile.m:24
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...
height
Number of unit cells along the logitudinal direction in the scattering region.
Definition: structures.m:110
A class to create and store Hamiltonian of the scattering region.