2 % Copyright (C) 2009-2015 Peter Rakyta, Ph.D.
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.
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.
14 % You should have received a copy of the GNU General Public License
15 % along with
this program. If not, see http:
17 %> @addtogroup basic Basic Functionalities
20 %> @brief A
class to create and store Hamiltonian of the scattering region
22 %> @brief A
class to create and store Hamiltonian of the scattering region
26 properties ( Access =
protected )
27 %> An instance of structure
param 29 %> A list of the
sites to be kept after decimation.
31 %> Hscatter - E*Sscatter
33 %> Hscatter_transverse - E*Sscatter_transverse
35 %> The matrix of the Hamiltonian.
37 %> The matrix of the Hamiltonian corresponding to the transverse coupling.
39 %> The matrix of the overlap integrals in the Hamiltonian.
41 %> The matrix of the overlap integrals
for the transverse coupling.
45 %> The matrix of the
Peierls phases
for the transverse coupling.
47 %> An instance of the structure coordinates.
49 %> The length of the scattering region in units of the lattice contant.
51 %> The number of
sites in the cross section.
53 %> The number of
sites in one unit cell.
55 %> A logical value. True
if the Hamiltonian was created,
false otherwise.
57 %> A logical value. True
if the Hamiltonian was decimated, or
false otherwise.
59 %> A logical value. True
if the overlap integrals were applied,
false otherwise.
61 %> A logical value. True
if the vector potential was incorporated into the Hamiltonian or
false otherwise.
63 %> A logical value. True
if a gauge transformation was applied on the
Hamiltonians, or
false otherwise.
64 GaugeTransformationApplied
65 %> A transverse momentum.
67 %> list of optional parameters (see http:
73 methods ( Access =
public )
74 %% constructorof the
class 75 %> @brief Constructor of the
class.
78 %> @
param varargin Cell array of optional parameters. For details see #InputParsing.
79 %> @
return An instance of the
class 84 obj.varargin = varargin;
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:
95 function CreateScatterH( obj,
varargin )
97 p.addParameter(
'Scatter_UC', []);
98 p.addParameter(
'CustomHamiltonian', []);
100 Scatter_UC = p.Results.Scatter_UC;
101 CustomHamiltonian = p.Results.CustomHamiltonian;
103 shape = obj.param.scatter.shape;
106 obj.height =
shape.
height; % number of unit cells!!!!!!!!
108 if isempty(Scatter_UC)
110 if strcmpi(obj.Opt.Lattice_Type,
'Square')
112 [
H0,
H1,
H1_transverse,coordinates_unitcell] = createH.SquareLattice_Lead_Hamiltonians(obj.param.scatter, obj.width,
'q', obj.q);
113 elseif strcmpi(obj.Opt.Lattice_Type,
'SSH')
115 [
H0,
H1,
H1_transverse,coordinates_unitcell] = createH.SSH_Lead_Hamiltonians(obj.param.scatter,
'q', obj.q);
116 elseif strcmp(obj.Opt.Lattice_Type,
'Lieb')
118 [obj.H0,obj.H1,obj.H1_transverse,obj.coordinates] = createH.Lieb_Lead_Hamiltonians(obj.params, obj.width,
'q', obj.q);
120 elseif strcmpi(obj.Opt.Lattice_Type, 'Graphene
') 121 End_Type = obj.param.scatter.End_Type; 122 createH = Hex_Lead_Hamiltonians(); 123 [H0,H1,H1_transverse,coordinates_unitcell] = createH.Graphene_Lead_Hamiltonians(obj.param.scatter, obj.width, End_Type, 'q
', obj.q); 124 elseif strcmpi(obj.Opt.Lattice_Type, 'Silicene
') 125 End_Type = obj.param.scatter.End_Type; 126 createH = Hex_Lead_Hamiltonians(); 127 [H0,H1,H1_transverse,coordinates_unitcell] = createH.Silicene_Lead_Hamiltonians(obj.param.scatter, obj.width, End_Type, 'q
', obj.q); 128 elseif strcmpi(obj.Opt.Lattice_Type, 'Graphene_Bilayer
') 129 End_Type = obj.param.scatter.End_Type; 130 createH = Hex_Lead_Hamiltonians(); 131 [H0,H1,H1_transverse,coordinates_unitcell] = createH.Graphene_Bilayer_Lead_Hamiltonians(obj.param.scatter, obj.width, End_Type, 'q
', obj.q); 132 elseif strcmpi(obj.Opt.Lattice_Type, 'Graphene_Bilayer_2
') 133 End_Type = obj.param.scatter.End_Type; 134 createH = Hex_Lead_Hamiltonians(); 135 [H0,H1,H1_transverse,coordinates_unitcell] = createH.Graphene_Bilayer_Lead_Hamiltonians2(obj.param.scatter, obj.width, End_Type, 'q
', obj.q); 136 elseif strcmpi(obj.Opt.Lattice_Type, 'Graphene_Bilayer_3
') 137 End_Type = obj.param.scatter.End_Type; 138 createH = Hex_Lead_Hamiltonians(); 139 [H0,H1,H1_transverse,coordinates_unitcell] = createH.Graphene_Bilayer_Lead_Hamiltonians3(obj.param.scatter, obj.width, End_Type, 'q
', obj.q); 140 elseif ~isempty( obj.Opt.custom_Hamiltonians ) 141 obj.queryHamiltonians( CustomHamiltonian ); 144 error(['EQuUs:
', class(obj), ':CreateScatterH:
'], 'Unrecognized lattice type, or the claculation options are not
set to use outher DFT source.
') 147 H0 = Scatter_UC.Read( 'H0
' ); 148 H1 = Scatter_UC.Read( 'H1
' ); 149 H1_transverse = Scatter_UC.Read( 'H1_transverse
' ); 150 coordinates_unitcell = Scatter_UC.Read( 'coordinates' ); 151 obj.MagneticFieldApplied = Scatter_UC.Read( 'MagneticFieldApplied
' ); 152 obj.GaugeTransformationApplied = Scatter_UC.Read( 'GaugeTransformationApplied
' ); 153 obj.width = size(H0, 1); 164 HCell = repmat({H1}, 1, height-1);
165 H1_big = blkdiag(HCell{:});
166 HCell = repmat({H1adj}, 1, height-1);
167 H1adj_big = blkdiag(HCell{:});
168 HCell = repmat({
H0}, 1, height);
171 H1_big = [[sparse([],[],[], size(H1_big,1), size(H1,2)), H1_big]; sparse([],[],[], size(H1,1), size(H1_big,2)+size(H1,2))];
172 H1adj_big = [sparse([],[],[], size(H1,1), size(H1adj_big,1)+size(H1,2)); [H1adj_big, sparse([],[],[], size(H1adj_big,1), size(H1,2))]];
174 Hscatter = Hscatter + H1_big + H1adj_big;
177 HCell = repmat({H1_transverse}, 1, height);
180 Hscatter_transverse = [];
183 coordfieldnames = fieldnames( coordinates_unitcell );
184 for idx = 1:length( coordfieldnames )
185 coordfieldname = coordfieldnames{idx};
186 if strcmpi( coordfieldname,
'a') || strcmpi( coordfieldname,
'b')
188 elseif strcmpi( coordfieldname,
'x')
189 tmp = ones(size(coordinates_unitcell.x))*(coordinates_unitcell.a(1)*(0:height-1));
190 tmp = reshape(tmp, numel(tmp), 1);
191 coordinates.x = repmat(coordinates_unitcell.x, height, 1) + tmp;
192 elseif strcmpi( coordfieldname,
'y')
193 tmp = ones(size(coordinates_unitcell.y))*(coordinates_unitcell.a(2)*(0:height-1));
194 tmp = reshape(tmp, numel(tmp), 1);
195 coordinates.y = repmat(coordinates_unitcell.y, height, 1) + tmp;
196 elseif ~isempty(coordinates_unitcell.(coordfieldname))
197 coordinates.(coordfieldname) = repmat(coordinates_unitcell.(coordfieldname), height, 1);
206 obj.HamiltoniansCreated =
true;
207 obj.MagneticFieldApplied =
false;
208 obj.GaugeTransformationApplied =
false;
209 obj.OverlapApplied =
false;
210 obj.HamiltoniansDecimated =
false;
216 %% ApplyOverlapMatrices
217 %> @brief Applies the overlap matrices to the
Hamiltonians: K = H-ES
218 %> @
param E The energy value.
219 function ApplyOverlapMatrices(obj, E)
221 if obj.OverlapApplied
222 obj.display([
'EQuUs:',
class(obj),
':ApplyOverlapMatrices: Overlap matrices were already applied.']);
226 if ~isempty( obj.Sscatter )
227 obj.Kscatter = obj.Hscatter - E*obj.Sscatter;
228 obj.OverlapApplied =
true;
230 obj.Kscatter = obj.Hscatter - eye(size(obj.H0))*E;
234 if ~isempty( obj.Sscatter_transverse )
235 obj.Kscatter_transverse = obj.Hscatter_transverse - E*obj.Sscatter_transverse;
236 elseif ~isempty( obj.H1_transverse )
237 obj.Kscatter_transverse = obj.Hscatter_transverse;
243 %> @brief Shifts the on-site energies in the Scattering region by a given energy.
244 %> @
param Energy The energy value to be used.
245 function shiftFermiEnergy( obj, Energy )
246 if isempty( obj.Sscatter )
247 energyshift = speye( size( obj.Hscatter ) )*Energy;
249 energyshift = obj.Sscatter*Energy;
252 obj.Hscatter = obj.Hscatter - energyshift;
253 if ~isempty( obj.param.scatter) && ~isempty( obj.param.scatter.epsilon )
258 %% projectHamiltonian2Spin
259 %> @brief Projects the Hamiltonian to a spin states of $s=\pm1$
260 %> @
param s The quantum index of the spin (\pm1)
261 function projectHamiltonian2Spin( obj, s )
263 obj.coordinates.x = obj.coordinates.x(obj.coordinates.spinup);
264 obj.coordinates.y = obj.coordinates.y(obj.coordinates.spinup);
265 obj.Hscatter = obj.Hscatter( obj.coordinates.spinup, obj.coordinates.spinup);
267 obj.Hscatter_transverse = obj.Hscatter_transverse( obj.coordinates.spinup, obj.coordinates.spinup);
270 obj.coordinates.x = obj.coordinates.x(~obj.coordinates.spinup);
271 obj.coordinates.y =obj.
coordinates.y(~obj.coordinates.spinup);
272 obj.Hscatter = obj.Hscatter( ~obj.coordinates.spinup, ~obj.coordinates.spinup);
274 obj.Hscatter_transverse = obj.Hscatter_transverse( ~obj.coordinates.spinup, ~obj.coordinates.spinup);
277 display([
'EQuUs:',
class(obj),
':projectHamiltonian2Spin: spin should be +/-1'], 1)
280 obj.coordinates.spinup = [];
287 %> @brief Resets all elements in the
class.
290 if strcmpi(
class(obj),
'CreateHamiltonians' )
291 meta_data = metaclass(obj);
293 for idx = 1:length(meta_data.PropertyList)
294 prop_name = meta_data.PropertyList(idx).Name;
295 if strcmp(prop_name,
'Opt') || strcmp( prop_name,
'param') || strcmp(prop_name,
'varargin')
298 obj.Clear( prop_name );
308 %> @brief Creates a clone of the present
class.
310 %> @
param 'empty' Set
true to create an empty clone, or
false (
default) to clone all atributes.
311 %> @
return Returns with the cloned
object.
312 function ret = CreateClone( obj,
varargin )
315 p.addParameter(
'empty',
false );
318 empty = p.Results.empty;
326 meta_data = metaclass(obj);
328 for idx = 1:length(meta_data.PropertyList)
329 prop_name = meta_data.PropertyList(idx).Name;
330 ret.Write( prop_name, obj.(prop_name));
337 %> @brief Removes specific
sites from the model of the scattering region. For example see
function #ScatterPotQD.
338 %> @
param indexes Logical array. Sites with
true values will be removed from the system.
339 function RemoveSites( obj, indexes )
341 % update the array of external degrees of freedom
342 if ~isempty( obj.kulso_szabfokok )
343 all_sites = 1:size(obj.Hscatter,1);
344 sites2remove = all_sites( indexes );
346 for idx = length(sites2remove):-1:1
347 indexes_tmp = find( obj.kulso_szabfokok == sites2remove(idx), 1 );
348 if ~isempty(indexes_tmp)
349 error([
'EQuUs:',
class(obj),
':RemoveSites'],
'Sites cannot be removed from the Hamiltonian.');
352 indexes_tmp = obj.kulso_szabfokok > sites2remove(idx);
353 obj.kulso_szabfokok(indexes_tmp) = obj.kulso_szabfokok(indexes_tmp) - 1;
357 % removing
sites from the scattering Hamiltonian
358 obj.Hscatter = obj.Hscatter(~indexes, ~indexes);
360 % removing
sites from the matrix of the transverse coupling
361 if ~isempty(obj.Hscatter_transverse)
362 obj.Hscatter_transverse = obj.Hscatter_transverse(~indexes, ~indexes);
365 % removing
sites from the matrix of the overlap integrals
366 if ~isempty(obj.Sscatter )
367 obj.Sscatter = obj.Sscatter(~indexes, ~indexes);
370 % removing
sites from the matrix of the overlap integrals of the transverse coupling
371 if ~isempty(obj.Sscatter_transverse )
372 obj.Sscatter_transverse = obj.Sscatter_transverse(~indexes, ~indexes);
376 if ~isempty(obj.fazis_mtx_scatter )
377 obj.fazis_mtx_scatter = obj.fazis_mtx_scatter(~indexes, ~indexes);
380 % removing
sites from the matrix of the
Peierls phases of the transverse coupling
381 if ~isempty(obj.fazis_mtx_scatter_t )
382 obj.fazis_mtx_scatter_t = obj.fazis_mtx_scatter_t(~indexes, ~indexes);
386 obj.coordinates = obj.coordinates.RemoveSites( indexes );
391 %% saveScatterHamiltonian
392 %> @brief Saves the Hamiltonian and other data of the scattering region
393 %> @
param filename The
string containing the path to the file. (In octave use absolute paths only)
394 function saveScatter( filename )
395 if ~exist(
'filename',
'var')
396 filename =
'Hscatter.mat';
398 save(filename,
'Hscatter',
'Hscatter_transverse',
'coordinates',
'param',
'fazis_mtx_scatte',
'fazis_mtx_scatte_t',
'width',
'height',
'M')
402 %> @brief Loads the Hamiltonian and other data of the scattering region from a file.
403 %> @
param filename The
string containing the path to the file. (In octave use absolute paths only)
404 function loadScatter( obj, filename )
405 if ~exist(
'filename',
'var')
406 filename =
'Hscatter.mat';
408 disp(
'EQuUs::CreateHamiltonian::loadScatter: Loading scatter Hamiltonian from file')
410 obj.Hscatter = HandleForLoad.LoadVariable(
'Hscatter',
'NoEmpty',
'On');
411 obj.Hscatter_transverse = HandleForLoad.LoadVariable(
'Hscatter_transverse',
'NoEmpty',
'On');
412 obj.Sscatter = HandleForLoad.LoadVariable(
'Sscatter',
'NoEmpty',
'On');
413 obj.Sscatter_transverse = HandleForLoad.LoadVariable(
'Sscatter_transverse',
'NoEmpty',
'On');
414 obj.coordinates = HandleForLoad.LoadVariable(
'coordinates',
'NoEmpty',
'On');
415 obj.fazis_mtx_scatter = HandleForLoad.LoadVariable(
'fazis_mtx_scatte',
'NoEmpty',
'Off');
416 obj.fazis_mtx_scatter_t = HandleForLoad.LoadVariable(
'fazis_mtx_scatte_t',
'NoEmpty',
'Off');
417 obj.param = HandleForLoad.LoadVariable(
'param',
'NoEmpty',
'On');
418 obj.M = HandleForLoad.LoadVariable(
'M',
'NoEmpty',
'On');
419 obj.width = HandleForLoad.LoadVariable(
'width',
'NoEmpty',
'Off');
420 obj.height = HandleForLoad.LoadVariable(
'height',
'NoEmpty',
'On');
421 obj.q = HandleForLoad.LoadVariable(
'q',
'NoEmpty',
'On');
422 HandleForLoad.ClearLoadedVariable();
426 %> @brief Sets the value of an attribute in the
class.
427 %> @
param MemberName The name of the attribute to be
set.
428 %> @
param input The value to be
set.
429 function Write(obj, MemberName, input)
431 if strcmp(MemberName,
'param')
435 elseif strcmp(MemberName,
'params')
436 obj.param.scatter = input;
440 obj.(MemberName) = input;
442 error([
'EQuUs:',
class(obj),
':Read'], [
'No property to write with name: ', MemberName]);
449 %> @brief Query
for the value of an attribute in the
class.
450 %> @
param MemberName The name of the attribute to be
set.
451 %> @
return Returns with the value of the attribute.
452 function ret =
Read(obj, MemberName)
454 ret = obj.(MemberName);
456 error([
'EQuUs:',
class(obj),
':Read'], [
'No property to read with name: ', MemberName]);
461 %> @brief Clears the value of an attribute in the
class.
462 %> @
param MemberName The name of the attribute to be cleared.
463 function Clear(obj, MemberName)
465 obj.(MemberName) = [];
467 error([
'EQuUs:',
class(obj),
':Clear'], [
'No property to clear with name: ', MemberName]);
474 methods ( Access =
private )
478 %> @brief Initializes
object attributes.
482 obj.HamiltoniansCreated =
false;
483 obj.HamiltoniansDecimated =
false;
484 obj.MagneticFieldApplied =
false;
485 obj.GaugeTransformationApplied =
false;
486 obj.OverlapApplied =
false;
488 obj.InputParsing( obj.varargin{:} );
492 %> @brief Obtains
Hamiltonians from a
class instance Custom_Hamiltonians
493 %> @
param cCustom_Hamiltonians An instance of
class #Custom_Hamiltonians
494 function queryHamiltonians( obj, cCustom_Hamiltonians )
495 if isempty( cCustom_Hamiltonians )
499 if ~cCustom_Hamiltonians.
Read(
'Hamiltonians_loaded' )
508 obj.HamiltoniansCreated =
true;
509 obj.MagneticFieldApplied =
false;
510 obj.GaugeTransformationApplied =
false;
511 obj.HamiltoniansDecimated =
false;
513 % determine kulso_szabfokok
516 if iscell( Hcoupling )
517 for idx = 1:length( Hcoupling )
518 coupled_sites = CoupledSites( Hcoupling{idx} );
519 obj.kulso_szabfokok = [obj.kulso_szabfokok, coupled_sites];
521 obj.kulso_szabfokok = unique( obj.kulso_szabfokok );
523 obj.kulso_szabfokok = CoupledSites( Hcoupling );
527 % tranforming into the BdG model
if necessary
528 if ~isempty( obj.
Opt.BdG ) && obj.
Opt.BdG
534 % determine
sites coupled to the leads
535 function ret = CoupledSites( Hcoupling )
536 [rows, cols] = find(Hcoupling);
537 ret = unique( cols );
538 ret = reshape(ret, 1, numel(ret));
541 % end nested functions
545 %> @brief Transforms the
Hamiltonians into a Bogoliubov de Gennes model.
546 function Transforms2BdG( obj )
547 if isempty( obj.
param.scatter.pair_potential )
548 error(
'CreateHamiltonian:Transform2BdG',
'Pair potential need to be set for the scattering region.');
552 obj.
display(
'Hamiltonians already transformed to BdG model.')
557 for idx = 1:length(fnames)
559 if strcmp(fname,
'a') || strcmp(fname,
'b')
567 length_kulso_szabfokok = length(obj.kulso_szabfokok);
568 obj.kulso_szabfokok = [obj.kulso_szabfokok(1:length_kulso_szabfokok), obj.kulso_szabfokok(1:length_kulso_szabfokok)+size(obj.
Hscatter,1) ];
571 pair_potential = obj.
param.scatter.pair_potential;
573 obj.
coordinates.BdG_u = [
true( site_num, 1);
false( site_num, 1) ];
584 % transforming the overlap integrals
590 sparse([],[],[], site_num, site_num ), obj.
Sscatter ];
596 %> @brief Parses the optional parameters
for the
class constructor.
597 %> @
param varargin Optional parameters, see the web documantation.
598 %> @
param 'q' The transverse momentum quantum number.
599 function InputParsing( obj, varargin)
602 p.addParameter(
'q', []);
604 p.parse(varargin{:});
611 end %methods
protected function LoadHamiltonians(varargin)
Obtain the Hamiltonians from the external source.
function InputParsing(varargin)
Parses the optional parameters for the class constructor.
function Custom_Hamiltonians(Opt, param, varargin)
Constructor of the class.
A class containing methodes for displaying several standard messages.
Structure Opt contains the basic computational parameters used in EQuUs.
Structure shape contains data about the geometry of the scattering region.
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)
creating the Ribbon class representing the twoterminal setup
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.
epsilon
A physical parameter, see the individual lattice documentations for details.
Property Hscatter_transverse
transverse coupling for the scattering region
Structure param contains data structures describing the physical parameters of the scattering center ...
scatter_param scatter
An instance of the structure scatter_param containing the physical parameters for the scattering regi...
Structure sites contains data to identify the individual sites in a matrix.
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.
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.
function Read(MemberName)
Query for the value of an attribute in the class.
Property param
An instance of structure param.
width
The number of sites in the cross section.
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.
function structures(name)
height
Number of unit cells along the logitudinal direction in the scattering region.
A class to create and store Hamiltonian of the scattering region.