2 % Copyright (C) 2015-2016 Peter Rakyta, Ph.D., David Visontai, 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
import custom
Hamiltonians provided by other codes or created manually
22 %> @brief A
class to import custom
Hamiltonians provided by other codes or created manually
24 %> EQuUs v4.8 or later
28 properties (Access =
protected )
29 %> An instance of structure
param 33 %> Cell array of couplings between the slabs of the leads
35 %> Cell array of transverse coupling between the unit cells of the lead
37 %> Hamiltonian of the scattering region
39 %> transverse coupling
for the scattering region
40 Hscatter_transverse = [];
41 %> Cell array of couplings between the scattering region and the leads
43 %> Cell array of overlap integrals of one slab in the leads
45 %> Cell array of overlap integrals between the slabs of the leads
47 %> overlap integrals
for the transverse coupling between the unit cells of the lead
49 %> Overlap integrals of the scattering region
51 %> overlap integrals
for the transverse coupling in the scattering region
52 Sscatter_transverse = [];
53 %> Cell array of overlap integrals between the scattering region and the leads
55 %> Cell array of coordinates of the leads
57 %> coordinates of the scattering region
58 coordinates_scatter = [];
59 %> logical value:
true if Hamiltonians are loaded,
false otherwise.
60 Hamiltonians_loaded =
false;
63 %> Function Handle
for the custom
Hamiltonians with identical input values as #LoadHamiltonians, and output values described in the example #
Hamiltonians.
64 CustomHamiltoniansHandle
65 %> list of optional parameters (see #InputParsing
for details)
71 methods (Access = public )
74 %% Constructor of the class
75 %> @brief Constructor of the class.
76 %> @
param Opt An instance of the structure
#Opt. 78 %> @
param varargin Cell array of optional parameters. For details see #InputParsing.
79 %> @
return An instance of the
class 83 obj.varargin = varargin;
91 %> @brief Obtain the
Hamiltonians from the external source
92 %> @
param varargin Cell array of optional parameters (https:
93 %> @
param 'q' The transverse momentum quantum number.
94 % @
param 'Extmol' The transverse momentum quantum number.
95 % @
param 'GollumInput' The transverse momentum quantum number.
96 % @
param 'WorkingDir' The transverse momentum quantum number.
97 function LoadHamiltonians(obj, varargin)
101 p.addParameter('q', []);
102 p.addParameter('Extmol', 'Extended_Molecule.mat');
103 p.addParameter('GollumInput', 'input.mat');
104 p.addParameter('WorkingDir', pwd);
106 p.parse(varargin{:});
110 Extmol = p.Results.Extmol;
111 GollumInput = p.Results.GollumInput;
112 WorkingDir = p.Results.WorkingDir;
114 if isempty(obj.Opt.custom_Hamiltonians)
115 % no external source is selected
116 warning([
'EQuUs:',
class(obj),
':LoadHamiltonians'],
'No external source was defined in the input parameters.')
120 elseif strcmpi( obj.
Opt.custom_Hamiltonians, 'siesta' )
123 % Coordinatzes needs to be determined : TODO
124 [obj.H0, obj.S0, obj.H1, obj.S1, obj.coordinates, ...
125 obj.Hscatter, obj.Sscatter, obj.coordinates_scatter, obj.Hcoupling, obj.Scoupling] = obj.Siesta_Equus_interface(WorkingDir, GollumInput, Extmol);
127 %!!!!!!!!!!!!!!!!!! Correct in the Gollum_Equus_interface
128 for idx = 1: length(obj.Hcoupling)
129 obj.Hcoupling{idx} = obj.Hcoupling{idx}
'; 130 obj.Scoupling{idx} = obj.Scoupling{idx}';
133 obj.H1_transverse = cell(size(obj.H0));
135 if ~issparse(obj.Hscatter)
136 obj.Hscatter = sparse(obj.Hscatter);
139 if ~issparse(obj.Sscatter)
140 obj.Sscatter = sparse(obj.Sscatter);
143 % obj.S1{1} = obj.S1{1}
'; 144 % obj.S1{2} = obj.S1{2}';
148 %**************************************** develpoment lines *******************************************************
149 % obj.H0{2} = obj.H0{1};
150 % obj.H1{2} = obj.H1{1};
151 % obj.Hscatter = sparse(obj.H0{1});
153 % obj.S0{2} = obj.S0{1};
154 % obj.S1{2} = obj.S1{1};
155 % obj.Sscatter = sparse(obj.S0{1});
157 % obj.H0{1} = obj.H0{1} + 0.5*obj.S0{1};
158 % obj.H1{1} = obj.H1{1} + 0.5*obj.S1{1};
159 % obj.H0{2} = obj.H0{2} + speye(size(obj.H0{2}));
160 %
for idx = 1:length(obj.H0)
161 % obj.S0{idx} = [];speye(size(obj.S0{idx}));
162 % obj.S1{idx} = [];sparse([],[],[], size(obj.H1{idx},1), size(obj.H1{idx},2));
164 % obj.Sscatter = [];speye(size(obj.Hscatter));
165 %
for idx =1:length(obj.Hcoupling)
166 % obj.Scoupling{idx} = [];sparse([],[],[], size(obj.Hcoupling{idx},1), size(obj.Hcoupling{idx},2));
172 elseif strcmpi( obj.Opt.custom_Hamiltonians,
'custom' )
174 if isempty(obj.CustomHamiltoniansHandle)
175 error(['EQuUs:', class(obj), ':LoadHamiltonians'], 'Undefinied function
handle for the custom
Hamiltonians')
178 [obj.H0, obj.S0, obj.H1, obj.S1, obj.H1_transverse, obj.coordinates, ...
179 obj.Hscatter, obj.Sscatter, obj.Hscatter_transverse, obj.Sscatter_transverse, ...
180 obj.coordinates_scatter, obj.Hcoupling, obj.Scoupling] = obj.CustomHamiltoniansHandle();
183 error(['EQuUs:', class(obj), ':LoadHamiltonians'], 'Undefinied option of the attribute
Opt.custom_Hamiltonians')
189 if ~isempty( obj.EF )
190 for idx = 1:length( obj.S0 )
191 if ~isempty( obj.S0{idx} )
192 obj.H0{idx} = obj.H0{idx} - obj.EF*obj.S0{idx};
193 obj.H1{idx} = obj.H1{idx} - obj.EF*obj.S1{idx};
195 obj.H0{idx} = obj.H0{idx} - obj.EF*speye(size(obj.H0{idx}));
199 for idx = 1:length( obj.Scoupling )
200 if ~isempty( obj.Scoupling{idx} )
201 obj.Hcoupling{idx} = obj.Hcoupling{idx} - obj.EF*obj.Scoupling{idx};
205 if ~isempty(obj.Sscatter)
206 obj.Hscatter = obj.Hscatter - obj.EF*obj.Sscatter;
208 obj.Hscatter = obj.Hscatter - obj.EF*speye(size(obj.Hscatter));
213 obj.Hamiltonians_loaded = true;
215 % for idx = 1:length(obj.H0)
216 % obj.S0{idx} = [];speye(size(obj.S0{idx}));
217 % obj.S1{idx} = [];sparse([],[],[], size(obj.H1{idx},1), size(obj.H1{idx},2));
219 % obj.Sscatter = [];speye(size(obj.Hscatter));
220 %
for idx =1:length(obj.Hcoupling)
221 % obj.Scoupling{idx} = [];sparse([],[],[], size(obj.Hcoupling{idx},1), size(obj.Hcoupling{idx},2));
231 %> @brief Resets all elements in the
object.
232 function Reset( obj )
234 if strcmpi(
class(obj),
'Custom_Hamiltonians' )
235 meta_data = metaclass(obj);
237 for idx = 1:length(meta_data.PropertyList)
238 prop_name = meta_data.PropertyList(idx).Name;
239 if strcmp(prop_name, '
Opt') || strcmp( prop_name, '
param') || strcmp(prop_name, 'varargin')
242 obj.Clear( prop_name );
252 %> @brief Sets the value of an attribute in the class.
253 %> @
param MemberName The name of the attribute to be set.
254 %> @
param input The value to be set.
255 function Write( obj, MemberName, input)
257 if strcmp(MemberName, '
param')
261 elseif strcmp(MemberName, '
Opt')
266 obj.(MemberName) = input;
268 error(['EQuUs:', class(obj), ':Read'], ['No property to write with name: ', MemberName]);
273 %> @brief Query for the value of an attribute in the class.
274 %> @
param MemberName The name of the attribute to be set.
275 %> @return Returns with the value of the attribute.
276 function ret = Read(obj, MemberName)
278 ret = obj.(MemberName);
280 error(['EQuUs:', class(obj), ':Read'], ['No property to read with name: ', MemberName]);
284 %> @brief Clears the value of an attribute in the class.
285 %> @
param MemberName The name of the attribute to be cleared.
286 function Clear(obj, MemberName)
288 obj.(MemberName) = [];
290 error(['EQuUs:', class(obj), ':Clear'], ['No property to clear with name: ', MemberName]);
298 methods ( Access = private )
301 %> @brief Initializes
object properties.
302 function Initialize(obj)
304 obj.Hamiltonians_loaded = false;
307 obj.InputParsing( obj.varargin{:} )
310 %% Siesta_Equus_interface
311 %> @brief Creates the
Hamiltonians and overlap integrals from the loaded data from the Siesta package.
316 function [HL0,SL0,HL1,SL1,coordsLeads,HSC,SSC,coordsSC,HC,SC] = Siesta_Equus_interface( obj, Directory,input,extmol)
321 %----------------------------------------------------------------------------------------
324 % bug fixed: variable atom confronting with
object atom
325 % see doc. MATLAB/Octave language support
for Atom at https:
327 HandleForLoad =
LoadFromFile( fullfile(Directory, input) );
328 atom = HandleForLoad.LoadVariable(
'atom',
'NoEmpty',
'On');
329 leadp = HandleForLoad.LoadVariable(
'leadp',
'NoEmpty',
'On');
330 HandleForLoad.ClearLoadedVariables();
332 HandleForLoad =
LoadFromFile( fullfile(Directory, extmol) );
333 HSM = HandleForLoad.LoadVariable(
'HSM',
'NoEmpty',
'On');
334 iorb = HandleForLoad.LoadVariable(
'iorb',
'NoEmpty',
'On');
335 kpoints_EM = HandleForLoad.LoadVariable(
'kpoints_EM',
'NoEmpty',
'On');
336 nspin = HandleForLoad.LoadVariable(
'nspin',
'NoEmpty',
'On');
337 HandleForLoad.ClearLoadedVariables();
341 numLead=size(leadp,1);
342 iorb = cat(2,atom(iorb(:,1),2:3),iorb); % iorb: Region PL atom-lead atom n l m z
343 norb=size(iorb,1); % Define # of orbitals
344 orb_molecule = find(iorb(:,1)==0); % Orbitals in Extended Molecule
346 %STRUCTURES FOR COORDINATES
347 coordsLeads = cell( 1, length(leadp(:,1)) );
348 for i=1:length(leadp(:,1))
353 %orb_scissors = intersect(find(iorb(:,1)==0),find(iorb(:,2)==0)); % Orbitals in Molecule
355 %GATHER ORBITALS FOR LEADS
356 for lead=1:numLead % Orbitals in PLs up to TPL
357 aux = intersect(find(iorb(:,1)==lead),find(iorb(:,2)==1));
358 for PL=2:leadp(lead,1)
359 aux=cat(2,aux,intersect(find(iorb(:,1)==lead),find(iorb(:,2)==PL)));
372 % coordsLeads(lead).a=1;
373 % if (size(iorb)(2)>7)
374 % coordsLeads(lead).x=iorb(aux(:,leadp(lead,2)),8);
375 % coordsLeads(lead).y=iorb(aux(:,leadp(lead,2)),9);
376 % coordsLeads(lead).z=iorb(aux(:,leadp(lead,2)),10);
378 %MY WAY OF INTERPRETING THE INPUT FILE
379 % coordsLeads(lead).x=iorb(aux(leadp(lead,2)+1:leadp(lead,1)),8);
380 % coordsLeads(lead).y=iorb(aux(leadp(lead,2)+1:leadp(lead,1)),9);
381 % coordsLeads(lead).z=iorb(aux(leadp(lead,2)+1:leadp(lead,1)),10);
385 %LOAD HAMILTONIANS FROM SEPARATE LEAD FILES
386 %-------------------------------------------------------------------------------
390 if (leadp(lead,3)~=0)
391 HandleForLoad =
LoadFromFile( fullfile(Directory, ['Lead_', int2str(lead), '.mat']) );
392 HSL = HandleForLoad.LoadVariable('HSL', 'NoEmpty', 'On');
393 kpoints_Lead = HandleForLoad.LoadVariable('kpoints_Lead', 'NoEmpty', 'On');
394 HandleForLoad.ClearLoadedVariables();
397 HSL_1=HSL; kpoints_1=kpoints_Lead;
399 HSL_2=HSL; kpoints_2=kpoints_Lead;
401 HSL_3=HSL; kpoints_3=kpoints_Lead;
403 HSL_4=HSL; kpoints_4=kpoints_Lead;
411 for k_EM = 1:size(kpoints_EM,1)
420 if (find(HSM(i,1)==k_EM)) % H & S for given k & spin
421 H(HSM(i,2),HSM(i,3))=HSM(i,4+2*spin)+1.0i*HSM(i,5+2*spin);
422 S(HSM(i,2),HSM(i,3))=HSM(i,4)+1.0i*HSM(i,5);
425 % if ( scissors(1) == 1 ) % Add scissor corrections
426 % scissor_corrections;
439 if (leadp(lead,3)~=0)
442 HSL=HSL_1; kpoints_Lead=kpoints_1;
444 HSL=HSL_2; kpoints_Lead=kpoints_2;
446 HSL=HSL_3; kpoints_Lead=kpoints_3;
448 HSL=HSL_4; kpoints_Lead=kpoints_4;
451 for k_Lead=1:size(kpoints_Lead,1)
452 if (abs(kpoints_EM(k_EM,1)+kpoints_Lead(k_Lead,1))<1d-6 && abs(kpoints_EM(k_EM,2)+kpoints_Lead(k_Lead,2))<1d-6)
453 k_choice=k_Lead; kj=1;
454 elseif (abs(kpoints_EM(k_EM,1)-kpoints_Lead(k_Lead,1))<1d-6 && abs(kpoints_EM(k_EM,2)-kpoints_Lead(k_Lead,2))<1d-6)
455 k_choice=k_Lead; kj=0;
460 if (find(HSL(i,1)==k_choice))
461 HL0t(HSL(i,2),HSL(i,3))=HSL(i,4+2*spin) + (-1)^kj*1.0i*HSL(i,5+2*spin);
462 SL0t(HSL(i,2),HSL(i,3))=HSL(i,4) + (-1)^kj*1.0i*HSL(i,5);
463 HL1t(HSL(i,2),HSL(i,3))=HSL(i,4+2*(nspin+spin+1)) + (-1)^kj*1.0i*HSL(i,5+2*(nspin+spin+1));
464 SL1t(HSL(i,2),HSL(i,3))=HSL(i,4+2*(nspin+1)) + (-1)^kj*1.0i*HSL(i,5+2*(nspin+1));
474 aux2 = intersect(find(iorb(:,1)==lead),find(iorb(:,2)==leadp(lead,2)));
476 %WE HAVE TO APPLY THIS SOMEWHERE (ONLY WHEN USING SEPARATE LEAD CALCULATION)
477 correction(lead)=HL0{lead}(1,1)-H(aux2(1),aux2(1));
481 %EM PART, THE SCATTERING REGION
482 %IN CASE OF JOSEPHSON CURRENT MODE, THIS EXCLUDES THE INTERFACE
483 %WHICH IS THE PART OF THE ELECTRODES, CLOSEST TO EM, THAT IS NOT USED
484 %FOR THE LEADS CALCULATION
485 HSC = H(orb_molecule,orb_molecule);
486 SSC = S(orb_molecule,orb_molecule);
487 p_mol=length(HSC); % Define pointers
501 %COUPLING BETWEEN EM AND THE FRIST LEAD UNIT CELL
502 B=reshape(aux,numel(aux),1); C=aux(:,1);
503 HC{lead}=H(orb_molecule,C); %Attach coupling to
Lead 504 SC{lead}=S(orb_molecule,C); %Attach coupling to
Lead 506 if ( leadp(lead,3) == 0 )
507 HL0{lead}=H(aux(:,leadp(lead,1)),aux(:,leadp(lead,1))); %K0=<TPL|K|TPL>
508 HL1{lead}=H(aux(:,leadp(lead,1)),aux(:,leadp(lead,1)-1)); %K1=<TPL|K|TPL-1>+coords=
"in" 509 SL0{lead}=S(aux(:,leadp(lead,1)),aux(:,leadp(lead,1))); %Needed to normalize states
510 SL1{lead}=S(aux(:,leadp(lead,1)),aux(:,leadp(lead,1)-1));
522 %> @brief Parses the optional parameters
for the
class constructor.
523 %> @
param varargin Optional parameters, see the web documantation.
524 %> @
param 'EF' The Fermi energy.
525 %> @
param 'CustomHamiltoniansHandle' A
function handle for the custom
Hamiltonians with identical input values as #LoadHamiltonians, and output values described in the example #
Hamiltonians.
526 function InputParsing( obj, varargin )
529 p.addParameter(
'EF', []);
530 p.addParameter(
'CustomHamiltoniansHandle', []);
532 p.parse(varargin{:});
535 obj.EF = p.Results.EF;
536 obj.CustomHamiltoniansHandle = p.Results.CustomHamiltoniansHandle;
542 end % methods
private Structure Atom contains the atomic identifiers of the sites.
A class containing methodes for displaying several standard messages.
Structure Opt contains the basic computational parameters used in EQuUs.
function Transport(Energy, B)
Calculates the conductance at a given energy value.
function Hamiltonians(varargin)
Function to create the custom Hamiltonians for the 1D chain.
A class to import custom Hamiltonians provided by other codes or created manually
A class to calculate the Green functions and self energies of a translational invariant lead The nota...
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...
A class providing interface to load variables from a file.
function structures(name)