Eötvös Quantum Utilities  v4.9.146
Providing the Horsepowers in the Quantum Realm
Custom_Hamiltonians.m
Go to the documentation of this file.
1 %% Eotvos Quantum Transport Utilities - Custom_Hamiltonians
2 % Copyright (C) 2015-2016 Peter Rakyta, Ph.D., David Visontai, Ph.D.
3 %
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.
8 %
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.
13 %
14 % You should have received a copy of the GNU General Public License
15 % along with this program. If not, see http://www.gnu.org/licenses/.
16 %
17 %> @addtogroup basic Basic Functionalities
18 %> @{
19 %> @file Custom_Hamiltonians.m
20 %> @brief A class to import custom Hamiltonians provided by other codes or created manually
21 %> @}
22 %> @brief A class to import custom Hamiltonians provided by other codes or created manually
23 %> @Available
24 %> EQuUs v4.8 or later
25 %%
27 
28 properties (Access = protected )
29  %> An instance of structure param
30  param
31  %> Cell array of Hamiltonians of one slab in the leads
32  H0 = [];
33  %> Cell array of couplings between the slabs of the leads
34  H1 = [];
35  %> Cell array of transverse coupling between the unit cells of the lead
36  H1_transverse = [];
37  %> Hamiltonian of the scattering region
38  Hscatter = [];
39  %> transverse coupling for the scattering region
40  Hscatter_transverse = [];
41  %> Cell array of couplings between the scattering region and the leads
42  Hcoupling = [];
43  %> Cell array of overlap integrals of one slab in the leads
44  S0 = [];
45  %> Cell array of overlap integrals between the slabs of the leads
46  S1 = [];
47  %> overlap integrals for the transverse coupling between the unit cells of the lead
48  S1_transverse = [];
49  %> Overlap integrals of the scattering region
50  Sscatter = [];
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
54  Scoupling = [];
55  %> Cell array of coordinates of the leads
56  coordinates = [];
57  %> coordinates of the scattering region
58  coordinates_scatter = [];
59  %> logical value: true if Hamiltonians are loaded, false otherwise.
60  Hamiltonians_loaded = false;
61  %> The Fermi energy
62  EF
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)
66  varargin
67 end
68 
69 
70 
71 methods (Access = public )
72 
73 
74 %% Constructor of the class
75 %> @brief Constructor of the class.
76 %> @param Opt An instance of the structure #Opt.
77 %> @param param An instance of structure #param.
78 %> @param varargin Cell array of optional parameters. For details see #InputParsing.
79 %> @return An instance of the class
80 function obj = Custom_Hamiltonians( Opt, param, varargin )
81  obj = obj@Messages( Opt );
82  obj.param = param;
83  obj.varargin = varargin;
84 
85  obj.Initialize();
86 
87 end
88 
89 
90 %% LoadHamiltonians
91 %> @brief Obtain the Hamiltonians from the external source
92 %> @param varargin Cell array of optional parameters (https://www.mathworks.com/help/matlab/ref/varargin.html):
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)
98 
99  if strcmpi( obj.Opt.custom_Hamiltonians, 'siesta' )
100 
101  p = inputParser;
102  p.addParamValue('q', [1]);
103  p.addParamValue('Filename', 'HSX');
104  p.addParamValue('WorkingDir', pwd);
105  p.parse(varargin{:});
106  q = p.Results.q;
107 
108  %Filename = p.Results.Filename;
109  % Coordinatzes needs to be determined : TODO
110  [obj.H0, obj.S0, obj.H1, obj.S1, obj.coordinates, ...
111  obj.Hscatter, obj.Sscatter, obj.coordinates_scatter, ...
112  obj.H1_transverse, obj.S1_transverse, ...
113  obj.Hscatter_transverse, obj.Sscatter_transverse, ...
114  obj.Hcoupling, obj.Scoupling, obj.EF] = Siesta_Interface(obj.Opt.WorkingDir, obj.param, q );
115 
116  %obj.H1_transverse = cell(size(obj.H0));
117  obj.Hamiltonians_loaded = true;
118 
119  %% Yaehmop TB hamiltonian
120  elseif strcmpi( obj.Opt.custom_Hamiltonians, 'yaehmop' )
121 
122  p = inputParser;
123  p.addParamValue('q', [1]);
124  p.addParamValue('Filename', 'HS');
125  p.addParamValue('WorkingDir', pwd);
126  p.parse(varargin{:});
127  q = p.Results.q;
128 
129  % Coordinatzes needs to be determined : TODO
130  [obj.H0, obj.S0, obj.H1, obj.S1, obj.coordinates, ...
131  obj.Hscatter, obj.Sscatter, obj.coordinates_scatter, obj.Hcoupling, obj.Scoupling, obj.EF] = Yaehmop_Interface(obj.Opt.WorkingDir, obj.param );
132 
133  obj.H1_transverse = cell(size(obj.H0));
134  obj.Hamiltonians_loaded = true;
135 
136  % Custom created Hamiltonians
137  elseif strcmpi( obj.Opt.custom_Hamiltonians, 'custom' )
138 
139  if isempty(obj.CustomHamiltoniansHandle)
140  error(['EQuUs:', class(obj), ':LoadHamiltonians'], 'Undefinied function handle for the custom Hamiltonians')
141  end
142 
143  [obj.H0, obj.S0, obj.H1, obj.S1, obj.H1_transverse, obj.coordinates, ...
144  obj.Hscatter, obj.Sscatter, obj.Hscatter_transverse, obj.Sscatter_transverse, ...
145  obj.coordinates_scatter, obj.Hcoupling, obj.Scoupling] = obj.CustomHamiltoniansHandle();
146 
147  else
148  error(['EQuUs:', class(obj), ':LoadHamiltonians'], 'Undefinied option of the attribute Opt.custom_Hamiltonians')
149 
150  end
151 
152 
153  % transform Hamiltonians into grand canonical potential
154  if ~isempty( obj.EF )
155  for idx = 1:length( obj.S0 )
156  if ~isempty( obj.S0{idx} )
157  obj.H0{idx} = obj.H0{idx} - obj.EF*obj.S0{idx};
158  obj.H1{idx} = obj.H1{idx} - obj.EF*obj.S1{idx};
159  else
160  obj.H0{idx} = obj.H0{idx} - obj.EF*speye(size(obj.H0{idx}));
161  end
162  end
163 
164  for idx = 1:length( obj.Scoupling )
165  if ~isempty( obj.Scoupling{idx} )
166  obj.Hcoupling{idx} = obj.Hcoupling{idx} - obj.EF*obj.Scoupling{idx};
167  end
168  end
169 
170  if ~isempty(obj.Sscatter)
171  obj.Hscatter = obj.Hscatter - obj.EF*obj.Sscatter;
172  else
173  obj.Hscatter = obj.Hscatter - obj.EF*speye(size(obj.Hscatter));
174  end
175  end
176 
177 
178  obj.Hamiltonians_loaded = true;
179 
180 end
181 
182 
183 
184 
185 
186 %% Reset
187 %> @brief Resets all elements in the object.
188  function Reset( obj )
189 
190  if strcmpi( class(obj), 'Custom_Hamiltonians' )
191  meta_data = metaclass(obj);
192 
193  for idx = 1:length(meta_data.PropertyList)
194  prop_name = meta_data.PropertyList(idx).Name;
195  if strcmp(prop_name, 'Opt') || strcmp( prop_name, 'param') || strcmp(prop_name, 'varargin')
196  continue
197  end
198  obj.Clear( prop_name );
199  end
200  end
201 
202  obj.Initialize();
203  end
204 
205 
206 
207 %% Write
208 %> @brief Sets the value of an attribute in the class.
209 %> @param MemberName The name of the attribute to be set.
210 %> @param input The value to be set.
211  function Write( obj, MemberName, input)
212 
213  if strcmp(MemberName, 'param')
214  obj.param = input;
215  obj.Reset();
216  return
217  elseif strcmp(MemberName, 'Opt')
218  obj.Opt = input;
219  obj.Reset();
220  else
221  try
222  obj.(MemberName) = input;
223  catch
224  error(['EQuUs:', class(obj), ':Read'], ['No property to write with name: ', MemberName]);
225  end
226  end
227  end
228 %% Read
229 %> @brief Query for the value of an attribute in the class.
230 %> @param MemberName The name of the attribute to be set.
231 %> @return Returns with the value of the attribute.
232  function ret = Read(obj, MemberName)
233  try
234  ret = obj.(MemberName);
235  catch
236  error(['EQuUs:', class(obj), ':Read'], ['No property to read with name: ', MemberName]);
237  end
238  end
239 %% Clear
240 %> @brief Clears the value of an attribute in the class.
241 %> @param MemberName The name of the attribute to be cleared.
242  function Clear(obj, MemberName)
243  try
244  obj.(MemberName) = [];
245  catch
246  error(['EQuUs:', class(obj), ':Clear'], ['No property to clear with name: ', MemberName]);
247  end
248 
249  end
250 
251 end % methods public
252 
253 
254 methods ( Access = private )
255 
256 %% Initialize
257 %> @brief Initializes object properties.
258  function Initialize(obj)
259 
260  obj.Hamiltonians_loaded = false;
261  obj.EF = 0;
262 
263  obj.InputParsing( obj.varargin{:} )
264  end
265 
266 %% InputParsing
267 %> @brief Parses the optional parameters for the class constructor.
268 %> @param varargin Optional parameters, see the web documantation.
269 %> @param 'EF' The Fermi energy.
270 %> @param 'CustomHamiltoniansHandle' A function handle for the custom Hamiltonians with identical input values as #LoadHamiltonians, and output values described in the example #Hamiltonians.
271  function InputParsing( obj, varargin )
272 
273  p = inputParser;
274  p.addParameter('EF', []);
275  p.addParameter('CustomHamiltoniansHandle', []);
276 
277  p.parse(varargin{:});
278 
279 
280  obj.EF = p.Results.EF;
281  obj.CustomHamiltoniansHandle = p.Results.CustomHamiltoniansHandle;
282 
283 
284  end
285 
286 
287 end % methods private
288 
289 end
A class containing methodes for displaying several standard messages.
Definition: Messages.m:24
Structure Opt contains the basic computational parameters used in EQuUs.
Definition: structures.m:60
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
function()
Structure param contains data structures describing the physical parameters of the scattering center ...
Definition: structures.m:45