Eötvös Quantum Utilities  v4.9.146
Providing the Horsepowers in the Quantum Realm
Read_Siesta_Scatter.m
Go to the documentation of this file.
1 
2 %> @file Read_Siesta_Scatter.m
3 %> @brief Creates the Hamiltonians and Overlap matrices from the HSX file data of the SIESTA output.
4 %> @Available
5 %> EQuUs v4.9 or later
6 %
7 %> @brief Creates the Hamiltonians and Overlap matrices from the HSX file data of the SIESTA output.
8 %> @param Param contains general input parameters
9 %> @param SIESTA_HSX_file is the file, where the hamiltonian is stored in a unique sparse format of SIESTA
10 %> @param SIESTA_XML_params parameters from SIESTA xml output
11 %> @param q k-point, where the Hamiltonian and Overlap matrices should be constructed
12 %> @return The constructed Hamiltonian of the whole system as HS, atomic coordinates and a description of the orbital system
13  function [HS, coordsSC, iorb, Param, Atoms] = Read_Siesta_Scatter(Param, SIESTA_HSX_file, SIESTA_XML_params, q)
14 
15  %SOME CONSTANTS USE IN SIESTA
16  RytoeV = 1/13.60580; % in SIESTA_HSX_file values are stored in Ry and Bohr
17  Bohr = 0.529177; % These are conversion units to eV and Angstrom
18 
19  %% TODO kpoints needed?
20  %param.scatter.kpoints = xml_params.kpoints;
21  Param.scatter.ElementNumber = SIESTA_XML_params.elmtxv;
22  Param.scatter.ElementSymbol = SIESTA_XML_params.spxv;
23  Param.scatter.LatticeVectors = SIESTA_XML_params.Lattice_vectors;
24 
25  %COORDS and %LATTICE VECTORS
26  coordsSC = structures('coordinates');
27 
28  % TEMP
29  HSXmat= 'SIESTAHSX.mat';
30 
31  %% READ FILE "system_label.HSX"
32  if exist(HSXmat, 'file') == 0 | true
33  hsx = read_hsx(SIESTA_HSX_file);
34 
35  %IF USING THE FORTRAN HSX READER, THEN VARIABLES HAVE TO BE CONVERTED TO DOUBLES
36  hsx.numh=double(hsx.numh);
37  hsx.listhptr=double(hsx.listhptr);
38  hsx.indxuo=double(hsx.indxuo);
39 
40  no_u = double(hsx.no_u);
41  nspin = double(hsx.nspin);
42  Param.scatter.nspin = hsx.nspin;
43 
44  %Set units to eV
45  hsx.hamilt = hsx.hamilt/RytoeV;
46 
47  Atoms = zeros(hsx.no_u);
48 
49  %% CREATE ORBITAL INFO
50  iorb = [];
51  for iuo=1:hsx.no_u
52  iat = hsx.iaorb(iuo);
53  iphorb = hsx.iphorb(iuo);
54  spec = hsx.isa(iat);
55  element_index = Param.scatter.ElementNumber(iat);
56  coordsSC.x(iuo) = SIESTA_XML_params.coordinates(iat,1);
57  coordsSC.y(iuo) = SIESTA_XML_params.coordinates(iat,2);
58  coordsSC.z(iuo) = SIESTA_XML_params.coordinates(iat,3);
59  Atoms(iuo) = iat;
60  dum = [ iat, hsx.nquant(spec,iphorb), hsx.lquant(spec,iphorb), 0, hsx.zeta(spec,iphorb),...
61  element_index, ...
62  Get_Atomic_Mass(element_index)];
63  iorb = [iorb; dum];
64  end
65 
66  %% IF IT IS FROM A COLLINEAR SPIN POLARIZED CALCULATION THEN
67  % WE DOUBLE THE SIZE OF THE HAMILTONIAN AND STORE THEM IN SEPARATE BLOCKS
68  % BUT IN A NONCOLLINEAR CASE
69  if nspin > 2
70  iorb = [iorb; iorb];
71  coordsSC.x = [coordsSC.x; coordsSC.x];
72  coordsSC.y = [coordsSC.y; coordsSC.y];
73  coordsSC.z = [coordsSC.z; coordsSC.z];
74  element_index = [element_index; element_index];
75  Atoms = [Atoms; Atoms];
76  end
77 
78  %% Find supercell size
79  % Transport direction is always into the direction of the z-coordinate
80  sux = floor( max(hsx.xij(1,:)) / Param.scatter.LatticeVectors(1,1)+0.5);
81  sux = 2 * sux + 1;
82  suy = floor( max(hsx.xij(2,:)) / Param.scatter.LatticeVectors(2,2)+0.5);
83  suy = 2 * suy + 1;
84  suz = floor( max(hsx.xij(3,:)) / Param.scatter.LatticeVectors(3,3)+0.5);
85  if suz>0
86  throw('It should not have kpoints into z directions, which is the transport direction')
87  end
88 
89  %COMPOSING THE Hk FROM HAMILTONIAN ELEMENTS
90  %EM PART, THE SCATTERING REGION
91  %IN CASE OF JOSEPHSON CURRENT MODE, THIS EXCLUDES THE INTERFACE
92  %WHICH IS THE PART OF THE ELECTRODES, CLOSEST TO EM, THAT IS NOT USED
93  %FOR THE LEADS CALCULATION
94  tt=[]; tk=[];
95  for iuo=1:no_u
96  tt = [ tt 1:hsx.numh(iuo)];
97  tk= [tk hsx.listhptr(iuo).*ones(hsx.numh(iuo),1)'];%'
98  end
99  ind=(tt+tk)';%'
100 
101  iuo=[];
102  for ii=1:no_u
103  iuo = [iuo double(ii).*ones(hsx.numh(ii),1)'];%'
104  end
105  jo=hsx.listh(ind);
106  juo=(hsx.indxuo(jo))';%'
107 
108  % Convert hsx.xij from Bohr to Angstrom
109  xij = hsx.xij*Bohr;
110 
111  %% TODO maybe coordinates(iuo',1) = coordsSC.x(iorb(iuo',1)
112  Rbloch(:,1) = xij(1,ind)' + coordsSC.x(iuo)' - coordsSC.x(juo)';
113  Rbloch(:,2) = xij(2,ind)' + coordsSC.y(iuo)' - coordsSC.y(juo)';
114  Rbloch(:,3) = xij(3,ind)' + coordsSC.z(iuo)' - coordsSC.z(juo)';
115  %xij = hsx.xij;
116  %save(HSXmat, 'hsx', 'coordsSC', 'iorb', 'Rbloch', 'ind', 'iuo', 'juo', 'no_u');
117  else
118  load(HSXmat);
119  end
120 
121  %% Find supercell size (experiment with this later)
122  %sux = floor( max(hsx.xij(1,:)) / Param.scatter.LatticeVectors(1,1)+0.5);
123  %sux = 2 * sux + 1;
124  %suy = floor( max(hsx.xij(2,:)) / Param.scatter.LatticeVectors(2,2)+0.5);
125  %suy = 2 * suy + 1;
126  %suz = floor( max(hsx.xij(3,:)) / Param.scatter.LatticeVectors(3,3)+0.5);
127  %if suz>0
128  % throw('It should not have kpoints into z directions, which is the transport direction')
129  %end
130 
131  %COMPOSING THE Hk FROM HAMILTONIAN ELEMENTS
132  %EM PART, THE SCATTERING REGION
133  %IN CASE OF JOSEPHSON CURRENT MODE, THIS EXCLUDES THE INTERFACE
134  %WHICH IS THE PART OF THE ELECTRODES, CLOSEST TO EM, THAT IS NOT USED
135  %FOR THE LEADS CALCULATION
136 
137  HS=[];
138  if length(q)>1
139  eikr = exp(-1.0i* (q(1).*Rbloch(ind,1)+q(2).*Rbloch(ind,2)+q(3).*Rbloch(ind,3)));
140  else
141  eikr = ones(length(ind), 1);
142  end
143  if Param.scatter.nspin <= 2
144  HS(1).S = sparse(juo,iuo, hsx.Sover.*eikr,no_u,no_u);
145  for is=1:Param.scatter.nspin
146  HS(is).H = sparse(juo,iuo, hsx.hamilt(:,is).*eikr,no_u,no_u);
147  end
148  elseif Param.scatter.nspin == 4
149  HS(1).S = kron(eye(2),sparse(juo,iuo, hsx.Sover.*eikr,no_u,no_u));
150  H1=kron([1 0; 0 0], sparse(juo,iuo, hsx.hamilt(:,1).*eikr,no_u,no_u));
151  H2=kron([0 0; 0 1], sparse(juo,iuo, hsx.hamilt(:,2).*eikr,no_u,no_u));
152  H3=kron([0 1; 0 0], sparse(juo,iuo, (hsx.hamilt(:,3)-1i*hsx.hamilt(:,4)).*eikr,no_u,no_u));
153  H4=kron([0 0; 1 0], sparse(juo,iuo, (hsx.hamilt(:,3)+1i*hsx.hamilt(:,4)).*eikr,no_u,no_u));
154  HS(1).H = H1 + H2 + H3 + H4;
155  elseif Param.scatter.nspin == 8
156  HS(1).S = kron(eye(2),sparse(juo,iuo, hsx.Sover.*eikr,no_u,no_u));
157  H1=kron([1 0; 0 0], sparse(juo,iuo, (hsx.hamilt(:,1)+1i*hsx.hamilt(:,5)).*eikr,no_u,no_u));
158  H2=kron([0 0; 0 1], sparse(juo,iuo, (hsx.hamilt(:,2)+1i*hsx.hamilt(:,6)).*eikr,no_u,no_u));
159  H3=kron([0 1; 0 0], sparse(juo,iuo, (hsx.hamilt(:,3)-1i*hsx.hamilt(:,4)).*eikr,no_u,no_u));
160  H4=kron([0 0; 1 0], sparse(juo,iuo, (hsx.hamilt(:,7)+1i*hsx.hamilt(:,8)).*eikr,no_u,no_u));
161  HS(1).H = H1 + H2 + H3 + H4;
162  end
163  %end
164 
165 end %function
166 
type(hsx_t), public hsx
Definition: hsx_EQuUs.f90:25
function Read_Siesta_Scatter(Param, SIESTA_HSX_file, SIESTA_XML_params, q)
Creates the Hamiltonians and Overlap matrices from the HSX file data of the SIESTA output.
subroutine read_hsx(fname, fname_len, eq_struct)
Definition: hsx_EQuUs.f90:46
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.
Structure param contains data structures describing the physical parameters of the scattering center ...
Definition: structures.m:45
scatter_param scatter
An instance of the structure scatter_param containing the physical parameters for the scattering regi...
Definition: structures.m:47
function Get_Atomic_Mass(Z)
function structures(name)