2 % Copyright (C) 2015-2018 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 % Interface to
import Siesta hamiltonian from Syslabe.HSX provided by other codes or created
21 %> @file Siesta_Interface.m
22 %> @brief Creates the
Hamiltonians and overlap integrals from the loaded data from the Siesta package.
25 %> EQuUs v4.9.... or later
26 %> @
param WorkingDir is declared in the input,
this is where the SIESTA files are to be found
27 %> @
param Param contains input parameters
28 %> @
param q k-point, where the Hamiltonian and Overlap matrices should be constructed
29 %> @
return The Leads
' H0 and H1 as HL0, SL0, HL1, SL1, the hamiltonian of the scattering part as HSC and SSC and coupling between the scattering region and the leads as Hc and SC. Coordinates and the Fermi energy is returned as well. 30 function [HL0, SL0, HL1, SL1, coordsLeads, HSC, SSC, coordsSC, ... 31 H1_t, S1_t, HSC_t, SSC_t, HC, SC, EF] = Siesta_Interface(WorkingDir, Param, q) 33 Syslabel = Param.scatter.FileName(1:end-4); 34 XML_file = [WorkingDir, '/
', Syslabel, '.xml
']; 35 HSX_file = [WorkingDir, '/
', Syslabel, '.HSX
']; 37 %THESE ARE THE FIELDS FROM XML THAT ARE USED LATER 38 fieldsfromxml = {'siesta:E_Fermi
', 'siesta:nkpoints
', 'Initial System
', 'siesta:kpoints
', 'siesta:kpt_band
'}; 39 xml_params = Read_Siesta_XML(XML_file, fieldsfromxml, false); 40 EF = xml_params.E_Fermi; 41 % Use only those k-points that have kz=kpoint(3)=0.0000 ASSUMING THAT 42 % THE DIRECTION OF THE TRANSPORT IS ALONG THE Z AXIS 43 kpoints = xml_params.kpoints(abs(xml_params.kpoints(:,3))<0.0000001,:); 45 % bug fixed: variable atom confronting with object atom 46 % see doc. MATLAB/Octave language support for Atom at https://atom.io/packages/language-matlab 54 NumLeads=length(Param.Leads); 55 natoms=length(Param.scatter(1).Atom); 57 natoms = natoms + length(Param.Leads{ilead}.Atom); 62 Number_of_layers_in_leads = zeros(NumLeads); 63 Terminating_layer_in_leads = zeros(NumLeads); 64 Lead_orientation = zeros(NumLeads); 66 if size(Param.Leads{ilead}.Atom)~=0; 67 Number_of_layers_in_leads(ilead) = max([Param.Leads{ilead}.Atom(1).PL, Param.Leads{ilead}.Atom(end).PL]); 68 Terminating_layer_in_leads(ilead) = max([Param.Leads{ilead}.Atom(1).PL, Param.Leads{ilead}.Atom(end).PL]); 69 Lead_orientation(ilead) = Param.Leads{ilead}.Lead_Orientation; 71 for atm=Param.Leads{ilead}.Atom 72 atom(atm.Id,2) = ilead; 73 atom(atm.Id,3) = atm.PL; 79 %% READ SCATTERING REGION FROM SIESTA HSX 82 %[HS_EM, coordsSC, H1_t, S1_t, HSC_t, tiorb] = Siesta_Equus_Read_EM(Param, HSX_file, xml_params, q); 83 [HS_EM, coordsSC, tiorb, Param, ScatterAtoms] = Read_Siesta_Scatter(Param, HSX_file, xml_params, q); 85 %THIS SHOWS WHICH ORBITAL BELONGS TO WHICH ATOM 86 iorb = [tiorb(:,1), atom(tiorb(:,1),2:3), tiorb(:,2:end)]; 88 % THIS JUST INDICATES WHETHER THE HAMILTONIAN IS IN ONE BLOCK OR TWO 89 % IN CASE OF COLLINEAR POLARIZED SPIN CALCULATION IT IS IN 2 SUBBLOCKS 90 % OTHERWISE IN 1 SUBBLOCK 92 if Param.scatter.nspin==2 94 Param.scatter.ElementNumber = [Param.scatter.ElementNumber, Param.scatter.ElementNumber]; 95 Param.scatter.ElementSymbol = [Param.scatter.ElementSymbol, Param.scatter.ElementSymbol]; 96 Param.scatter.Atom = [Param.scatter.Atom, Param.scatter.Atom]; 97 siorb = size(iorb, 1); 99 %iorb(siorb+1:end, 1) = iorb(1:siorb, 1) + siorb; 101 % READ SCATTERING INFORMATIONS --------------------------------------- 106 %CREATE ORBITAL REGISTER 107 Orbitals.Mol = intersect(find(iorb(:,2)==0), find(iorb(:,3)==0)); 108 Orbitals.ExtMol = Orbitals.Mol';
110 if Terminating_layer_in_leads(ilead)==1 & ~Param.
Leads{ilead}.Use_External_Lead
111 fprintf(
'There must be more than 1 unit cell for leads if no external is provided!');
114 for ipl=1:Terminating_layer_in_leads(ilead)
115 aux = intersect(find(iorb(:,2)==ilead), find(iorb(:,3)==ipl));
116 Orbitals.Lead{ilead}.PL{ipl} = aux;
117 if ipl<Terminating_layer_in_leads(ilead)
118 Orbitals.ExtMol = [Orbitals.ExtMol, aux
']; 122 Orbitals.ExtMol = sort(Orbitals.ExtMol); 124 % END OF ORBITAL INFOS ------------------------------------ 128 % for ispin = 1:gspin 129 %for ik = 1:length(param.scatter.kpoints) 130 for id_lead=1:NumLeads 131 if Param.Leads{id_lead}.Use_External_Lead == 1 132 %% READ EXTERNAL LEADS IF REQUESTED 133 disp(' Reading LEAD Hamiltonian from Siesta
') 135 %aux = orbLead(ilead,:,leadp(ilead,2)); 136 aux = Orbitals.Lead{id_lead}.PL{1}; 137 shift = mean(mean(HS_EM(1).H(aux,aux))); 138 [HS_Lead(id_lead).lead, coordsLeads{id_lead}, LeadAtoms{id_lead}] = Read_Siesta_Lead(id_lead, Param, HSX_file, xml_params, shift, q); 140 HL0{id_lead} = HS_Lead(id_lead).lead(1).H0; 141 SL0{id_lead} = HS_Lead(id_lead).lead(1).S0; 142 HL1{id_lead} = HS_Lead(id_lead).lead(1).H1; 143 SL1{id_lead} = HS_Lead(id_lead).lead(1).S1; 144 H1_t{id_lead} = zeros(size(HL1)); 145 S1_t{id_lead} = zeros(size(SL1)); 148 %% OR FROM SCATTERING REGION 150 LastTerminatingLayer = Terminating_layer_in_leads(id_lead); 151 if LastTerminatingLayer 152 aux0 = Orbitals.Lead{id_lead}.PL{LastTerminatingLayer}; 153 aux1 = Orbitals.Lead{id_lead}.PL{LastTerminatingLayer-1}; 154 HL0{id_lead} = HS_EM(1).H(aux0, aux0); 155 HL1{id_lead} = HS_EM(1).H(aux0, aux1); 156 SL0{id_lead} = HS_EM(1).S(aux0, aux0); 157 SL1{id_lead} = HS_EM(1).S(aux0, aux1); 158 coordsLeads{id_lead}.x = coordsSC.x([aux0; aux1]); 159 coordsLeads{id_lead}.y = coordsSC.y([aux0; aux1]); 160 coordsLeads{id_lead}.z = coordsSC.z([aux0; aux1]); 161 LeadAtoms{id_lead} = ScatterAtoms([aux0; aux1]); 163 if Param.scatter.nspin==2 164 HL0 = [HL0{id_lead}, sparse([],[],[], size(HL0{id_lead},1), size(HL0{id_lead},2)); sparse([],[],[], size(HL0{id_lead},1), size(HL0{id_lead},2)), HS_EM(2).H(aux0, aux0)]; 165 HL1 = [HL1{id_lead}, sparse([],[],[], size(HL1{id_lead},1), size(HL1{id_lead},2)); sparse([],[],[], size(HL1{id_lead},1), size(HL1{id_lead},2)), HS_EM(2).H(aux0, aux1)]; 166 coordsLeads{id_lead}.x = [coordsLeads{id_lead}.x, coordsLeads{id_lead}.x]; 167 coordsLeads{id_lead}.y = [coordsLeads{id_lead}.y, coordsLeads{id_lead}.y]; 168 coordsLeads{id_lead}.z = [coordsLeads{id_lead}.z, coordsLeads{id_lead}.z]; 169 LeadAtoms{id_lead} = [LeadAtoms{id_lead}, LeadAtoms{id_lead}]; 170 coordsLeads{id_lead}.spinup = [ true(size(HL0{id_lead},1),1); false(size(HL0{id_lead},1),1)]; 177 % coordsLeads{id_lead}.x = []; 178 % coordsLeads{id_lead}.y = []; 179 % coordsLeads{id_lead}.z = []; 182 H1_t{id_lead} = zeros(size(HL1)); 183 S1_t{id_lead} = zeros(size(SL1)); 188 % END OF LEADS SETUP INFOS ------------------------------------ 192 coordsSC.x = coordsSC.x(Orbitals.Mol); 193 coordsSC.y = coordsSC.y(Orbitals.Mol); 194 coordsSC.z = coordsSC.z(Orbitals.Mol); 195 ScatterAtoms = ScatterAtoms(Orbitals.Mol); 197 if Param.scatter.nspin==2 198 coordsSC{id_lead}.x = [coordsSC{id_lead}.x, coordsSC{id_lead}.x]; 199 coordsSC{id_lead}.y = [coordsSC{id_lead}.y, coordsSC{id_lead}.y]; 200 coordsSC{id_lead}.z = [coordsSC{id_lead}.z, coordsSC{id_lead}.z]; 201 coordsSC{id_lead}.Atoms = [coordsSC{id_lead}.Atoms, coordsSC{id_lead}.Atoms]; 202 coordsSC{id_lead}.spinup = [ true(size(HL0{id_lead},1),1); false(size(HL0{id_lead},1),1)]; 205 % FROM THE WHOLE HAMILTONIAN CUT OUT THE EFFECT OF PERIODICITY 208 for il2=il1+1:NumLeads 210 for ipl1=1:Terminating_layer_in_leads(il1) 211 %Leadorb1 = [Leadorb1; Orbitals.Lead{il1}.PL{ipl1}]; 212 Leadorb1 = [Leadorb1, Orbitals.Lead{il1}.PL{ipl1}]; 214 for ipl2=1:Terminating_layer_in_leads(il2) 215 %Leadorb2 = [Leadorb2; Orbitals.Lead{il2}.PL{ipl2}]; 216 Leadorb2 = [Leadorb2, Orbitals.Lead{il2}.PL{ipl2}'];
217 HS_EM(ispin).H(Leadorb1, Leadorb2) = 0;
218 HS_EM(ispin).H(Leadorb2, Leadorb1) = 0;
227 %% LOAD SCATTERING REGION INTO HSC, SSC
229 HSC = HS_EM(1).H(Orbitals.Mol, Orbitals.Mol);
230 SSC = HS_EM(1).S(Orbitals.Mol, Orbitals.Mol);
231 if Param.scatter.nspin==2
232 HSC = [HSC, sparse([],[],[], size(HSC, 1), size(HSC, 2)); sparse([],[],[], size(HSC, 1), size(HSC, 2)), HS_EM(2).H(Orbitals.Mol, Orbitals.Mol)];
233 SSC = [SSC, sparse([],[],[], size(SSC, 1), size(SSC, 2)); sparse([],[],[], size(SSC, 1), size(HSC, 2)), HS_EM(2).S(Orbitals.Mol, Orbitals.Mol)];
235 %% LOAD INTERFACE INTO HC, SC
236 for ilead =1:NumLeads
237 LastTerminatingLayer = Terminating_layer_in_leads(ilead);
238 if LastTerminatingLayer
239 C = Orbitals.Lead{ilead}.PL{max(LastTerminatingLayer-1, 1)};
241 HC{ilead} = HS_EM(ispin).H(C, Orbitals.Mol);
242 SC{ilead} = HS_EM(ispin).S(C, Orbitals.Mol);
249 HSC_t = zeros(size(HSC));
250 SSC_t = zeros(size(SSC));
258 % %Returns with element number
259 %
function indx = get_atomindex(sym)
260 % Syms={
'H',
'He',
'Li',
'Be',
'B',
'C',
'N',
'O',
'F',
'Ne',
'Na',
'Mg',
'Al',
'Si',
'P',
'S',
'Cl',...
261 %
'Ar',
'K',
'Ca',
'Sc',
'Ti',
'V',
'Cr',
'Mn',
'Fe',
'Co',
'Ni',
'Cu',
'Zn',
'Ga',
'Ge',
'As',...
262 %
'Se',
'Br',
'Kr',
'Rb',
'Sr',
'Y',
'Zr',
'Nb',
'Mo',
'Tc',
'Ru',
'Rh',
'Pd',
'Ag',
'Cd',
'In',...
263 %
'Sn',
'Sb',
'Te',
'I',
'Xe',
'Cs',
'Ba',
'La',
'Ce',
'Pr',
'Nd',
'Pm',
'Sm',
'Eu',
'Gd',
'Tb',...
264 %
'Dy',
'Ho',
'Er',
'Tm',
'Yb',
'Lu',
'Hf',
'Ta',
'W',
'Re',
'Os',
'Ir',
'Pt',
'Au',
'Hg',
'Tl',
'Pb',...
265 %
'Bi',
'Po',
'At',
'Rn',
'Fr',
'Ra',
'Ac',
'Th',
'Pa',
'U',
'Np',
'Pu',
'Am',
'Cm',
'Bk',
'Cf',
'Es',
'Fm',
'Md',
'No',...
266 %
'Lr',
'Rf',
'Db',
'Sg',
'Bh',
'Hs',
'Mt',
'Ds',
'Rg',
'Cn',
'Uut',
'Uuq',
'Uup',
'Uuh',
'Uus',
'Uuo'};
268 % indx=find(ismember(Syms,sym)==1);
lead_param Leads
A list of structures lead_param containing the physical parameters for the scattering region.
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
Structure param contains data structures describing the physical parameters of the scattering center ...