2 %> @file Read_Siesta_Lead.m
3 %> @brief Creates the
Hamiltonians and overlap integrals from the HSX file data of the Siesta
package for the lead
6 %> @param Param contains general input parameters
7 %> @param SIESTA_HSX_file is the file, where the hamiltonian is stored in a unique sparse format of SIESTA
8 %> @param SIESTA_XML_params parameters from SIESTA xml output
9 %> @param shift, the coordinates to fit to the scattering region
10 %> @param q k-point, where the Hamiltonian and Overlap matrices should be constructed
11 %> @return The constructed Hamiltonian of the whole system as HS, atomic coordinates and a description of the orbital system
13 function [HS, coordsLeads, Atoms] = Siesta_Equus_Read_Lead(id_lead, Param, SIESTA_HSX_file, SIESTA_XML_params,shift, q)
15 %SOME CONSTANTS USE IN SIESTA
16 RytoeV = 1/13.60580; %
17 Bohr = 0.529177; % Angstrom
19 Syslabel = Param.Leads{id_lead}.FileName(1:end-4);
20 xmlfile = [Syslabel,
'.xml'];
22 %THESE ARE THE FIELD FROM XML THAT ARE USED LATER
23 fieldsfromxml = {
'siesta:E_Fermi',
'siesta:nkpoints',
'Initial System' ,
'siesta:kpoints',
'siesta:kpt_band',
'siesta:kscell'};
25 Param.Leads{id_lead}.E_Fermi = Lead_params.E_Fermi;
27 %% EZ ITT RONDA, DE EZ VAN. EZ AZ ADAT NINCS MEG MASHOL
28 %% FIND THE DIRECTORY WHERE THE
"filename.out" FILE IS PLACED AND READ IT
29 output_file = [Syslabel,
'.out'];
30 % directory = inputP.Path_Leads{lead}(1:end-cellfun(@length, output_file(end)));
31 logfile=fileread(output_file);
34 foundat = findstr(logfile,
'SystemLabel');
35 dummy=strsplit(logfile(foundat:foundat+100));
36 system_label = dummy(2);
38 %% FIND SUPERCELL SIZE
39 foundat = findstr(logfile,
'supercell');
41 dummy = strsplit(logfile(foundat:foundat+100));
42 if ~isempty(str2num(dummy{3})) && ~isempty(str2num(dummy{4})) && ~isempty(str2num(dummy{5}))
43 nsc = [str2num(dummy{3}) str2num(dummy{4}) str2num(dummy{5})];
44 elseif ~isempty(str2num(dummy{2})) && ~isempty(str2num(dummy{4})) && ~isempty(str2num(dummy{6}))
45 nsc = [str2num(dummy{2}) str2num(dummy{4}) str2num(dummy{6})];
47 warning(
' ************* OH NO! SIESTA OUTPUT CHANGED AGAIN?! ************')
58 %% TODO kpoints needed?
59 %
param.scatter.kpoints = xml_params.kpoints;
60 %Param.scatter.ElementNumber = SIESTA_XML_params.elmtxv;
61 %Param.scatter.ElementSymbol = SIESTA_XML_params.spxv;
62 %Param.scatter.LatticeVectors = SIESTA_XML_params.Lattice_vectors;
64 kpoints = Lead_params.kpoints;
65 elmtxv = Lead_params.elmtxv;
66 spxv = Lead_params.spxv;
67 LatticeVectors = Lead_params.Lattice_vectors;
69 %STRUCTURES FOR COORDINATES
72 %% SELECT ONLY TRANSVERSE K-POINTS & RESTATE WEIGHTS ??
73 %obj.
param.Leads{}.kpoints;
75 %% READ FILE
"system_label.HSX" 78 %IF USING THE FORTRAN HSX READER, THEN VARIABLES HAVE TO BE CONVERTED TO DOUBLES
80 hsx.listhptr=double(
hsx.listhptr);
81 hsx.indxuo=double(
hsx.indxuo);
83 no_u = double(
hsx.no_u);
84 nspin = double(
hsx.nspin);
91 hsx.hamilt =
hsx.hamilt/RytoeV;
93 %COORDS and %LATTICE VECTORS
97 %% CREATE ORBITAL INFO
99 coords = zeros(no_u,3);
101 iat =
hsx.iaorb(iuo);
102 iphorb =
hsx.iphorb(iuo);
104 % element_index = Param.scatter.ElementNumber(iat);
105 element_index = Lead_params.elmtxv(iat);
106 coordsLead.x(iuo) = Lead_params.coordinates(iat,1);
107 coordsLead.y(iuo) = Lead_params.coordinates(iat,2);
108 coordsLead.z(iuo) = Lead_params.coordinates(iat,3);
110 dum = [ iat,
hsx.nquant(spec,iphorb),
hsx.lquant(spec,iphorb), 0,
hsx.zeta(spec,iphorb),...
114 Param.Leads{id_lead}.coordinates = coordsLead;
115 %IF IT IS COLLINEAR SPIN POLARIZED THEN WE DOUBLE THE SIZE OF THE
116 %HAMILTONIAN AND STORE THEM IN SEPARATE BLOCKS
122 %COMPOSING THE Hk FROM HAMILTONIAN ELEMENTS
123 %EM PART, THE SCATTERING REGION
124 %IN CASE OF JOSEPHSON CURRENT MODE, THIS EXCLUDES THE INTERFACE
125 %WHICH IS PART OF THE ELECTRODES, CLOSEST TO EM, THAT IS NOT USED
126 %FOR THE LEADS CALCULATION
128 %% FIND INDICES BELONGING TO H0 OR H1
131 tt = [ tt 1:
hsx.numh(iuo)];
132 tk= [tk
hsx.listhptr(iuo).*ones(
hsx.numh(iuo),1)
'];%' 138 iuo = [iuo double(ii).*ones(
hsx.numh(ii),1)
'];%' 141 juo = (
hsx.indxuo(jo))
';%' 143 ind0 = find(jo <= no_u*nnsc);
145 juo0 = (
hsx.indxuo(jo0))
';%' 148 ind1 = intersect(intersect(find(jo > no_u*nnsc),find(jo <= 2*no_u*nnsc)),find(
hsx.xij(3,ind) >= 0.0));
150 juo1 = (
hsx.indxuo(jo1))
';%' 153 % Convert
hsx.xij from Bohr to Angstrom
156 %% COMPUTE H and S FOR GIVEN LEAD
157 Rbloch(:,1) = xij(1,ind)
' + coordsLead.x(iuo)' - coordsLead.x(juo)
'; 158 Rbloch(:,2) = xij(2,ind)' + coordsLead.y(iuo)
' - coordsLead.y(juo)';
159 Rbloch(:,3) = xij(3,ind)
' + coordsLead.z(iuo)' - coordsLead.z(juo)
'; 163 eikr = exp(-1.0i* (q(1).*Rbloch(ind,1)+q(2).*Rbloch(ind,2)+q(3).*Rbloch(ind,3))); 165 eikr = ones(length(ind), 1); 167 if Param.scatter.nspin <= 2 168 HS(1).S0 = sparse(juo0,iuo0, hsx.Sover(ind0).*eikr(ind0),no_u,no_u); 169 HS(1).S1 = sparse(juo1,iuo1, hsx.Sover(ind1).*eikr(ind1),no_u,no_u); 170 for is=1:Param.scatter.nspin 171 HS(is).H0 = sparse(juo0,iuo0, hsx.hamilt(ind0,is).*eikr(ind0),no_u,no_u); 172 HS(is).H1 = sparse(juo1,iuo1, hsx.hamilt(ind1,is).*eikr(ind1),no_u,no_u); 174 elseif Param.scatter.nspin == 4 175 HS(1).S0 = kron(eye(2),sparse(juo0,iuo0, hsx.Sover(ind0).*eikr(ind0),no_u,no_u)); 176 HS(1).S1 = kron(eye(2),sparse(juo1,iuo1, hsx.Sover(ind1).*eikr(ind1),no_u,no_u)); 177 H1=kron([1 0; 0 0], sparse(juo0,iuo0, hsx.hamilt(ind0,1).*eikr(ind0),no_u,no_u)); 178 H2=kron([0 0; 0 1], sparse(juo0,iuo0, hsx.hamilt(ind0,2).*eikr(ind0),no_u,no_u)); 179 H3=kron([0 1; 0 0], sparse(juo0,iuo0, (hsx.hamilt(ind0,3)-1i*hsx.hamilt(ind0,4)).*eikr(ind0),no_u,no_u)); 180 H4=kron([0 0; 1 0], sparse(juo0,iuo0, (hsx.hamilt(ind0,3)+1i*hsx.hamilt(ind0,4)).*eikr(ind0),no_u,no_u)); 181 HS(1).H0 = H1 + H2 + H3 + H4; 182 H1=kron([1 0; 0 0], sparse(juo1,iuo1, hsx.hamilt(ind1,1).*eikr(ind1),no_u,no_u)); 183 H2=kron([0 0; 0 1], sparse(juo1,iuo1, hsx.hamilt(ind1,2).*eikr(ind1),no_u,no_u)); 184 H3=kron([0 1; 0 0], sparse(juo1,iuo1, (hsx.hamilt(ind1,3)-1i*hsx.hamilt(ind1,4)).*eikr(ind1),no_u,no_u)); 185 H4=kron([0 0; 1 0], sparse(juo1,iuo1, (hsx.hamilt(ind1,3)+1i*hsx.hamilt(ind1,4)).*eikr(ind1),no_u,no_u)); 186 HS(1).H1 = H1 + H2 + H3 + H4; 187 elseif Param.scatter.nspin == 8 188 HS(1).S0 = kron(eye(2),sparse(juo0,iuo0, hsx.Sover(ind0).*eikr(ind0),no_u,no_u)); 189 HS(1).S1 = kron(eye(2),sparse(juo1,iuo1, hsx.Sover(ind1).*eikr(ind1),no_u,no_u)); 190 H1=kron([1 0; 0 0], sparse(juo0,iuo0, (hsx.hamilt(ind0,1)+1i*hsx.hamilt(ind0,5)).*eikr(ind0),no_u,no_u)); 191 H2=kron([0 0; 0 1], sparse(juo0,iuo0, (hsx.hamilt(ind0,2)+1i*hsx.hamilt(ind0,6)).*eikr(ind0),no_u,no_u)); 192 H3=kron([0 1; 0 0], sparse(juo0,iuo0, (hsx.hamilt(ind0,3)-1i*hsx.hamilt(ind0,4)).*eikr(ind0),no_u,no_u)); 193 H4=kron([0 0; 1 0], sparse(juo0,iuo0, (hsx.hamilt(ind0,7)+1i*hsx.hamilt(ind0,8)).*eikr(ind0),no_u,no_u)); 194 HS(1).H0 = H1 + H2 + H3 + H4; 195 H1=kron([1 0; 0 0], sparse(juo1,iuo1, (hsx.hamilt(ind1,1)+1i*hsx.hamilt(ind1,5)).*eikr(ind1),no_u,no_u)); 196 H2=kron([0 0; 0 1], sparse(juo1,iuo1, (hsx.hamilt(ind1,2)+1i*hsx.hamilt(ind1,6)).*eikr(ind1),no_u,no_u)); 197 H3=kron([0 1; 0 0], sparse(juo1,iuo1, (hsx.hamilt(ind1,3)-1i*hsx.hamilt(ind1,4)).*eikr(ind1),no_u,no_u)); 198 H4=kron([0 0; 1 0], sparse(juo1,iuo1, (hsx.hamilt(ind1,7)+1i*hsx.hamilt(ind1,8)).*eikr(ind1),no_u,no_u)); 199 HS(1).H1 = H1 + H2 + H3 + H4; 202 %% Change Lead orientation if needed 203 if Param.Leads{id_lead}.Lead_Orientation == -1; 204 HS(1).S1 = HS(1).S1';
206 HS(is).H1 = HS(is).H1
'; 211 correction = mean(mean(HS(1).H0))-shift; 213 %for is=1:obj.param.scatter.nspin 215 HS(is).H0 = HS(is).H0 - correction*HS(1).S0; 216 HS(is).H1 = HS(is).H1 - correction*HS(1).S1;
subroutine read_hsx(fname, fname_len, eq_struct)
function Hamiltonians(varargin)
Function to create the custom Hamiltonians for the 1D chain.
Structure param contains data structures describing the physical parameters of the scattering center ...
function Read_Siesta_XML(xmlfile, fields, readanyway)
function Get_Atomic_Mass(Z)
function structures(name)