Eötvös Quantum Utilities  v4.9.146
Providing the Horsepowers in the Quantum Realm
dgetDiagInv_test.m
Go to the documentation of this file.
1 %% Eotvos Quantum Transport Utilities - dgetDiagInv_test
2 % Copyright (C) 2009-2015 Peter Rakyta, 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 %> @brief Test function for the MEX file dgetDiagInv.
18 %%
19 function dgetDiagInv_test()
20 
21  filename = mfilename('fullpath');
22  [directory, fncname] = fileparts( filename );
23  fncname = fncname(1:end-length('_test'));
24  filename = fullfile( directory, [fncname, '.', mexext] );
25 
26 
27 %% creating the test Hamiltonian
28 Opt = structures('Opt');
29 param = structures('param');
31 param.scatter.shape = structures('shape');
32 
33 param.scatter.epsilon = 0.5;
34 param.scatter.vargamma = -2;
35 Opt.Lattice_Type = 'Square';
36 param.scatter.shape.width = 100;
37 param.scatter.shape.height = 40;
38 
39 CreateH = CreateHamiltonians( Opt, param );
40 CreateH.CreateScatterH();
41 
42 Hscatter = CreateH.Read('Hscatter');
43 CreateH.Clear('Hscatter');
44 
45 display('***************************************************************************')
46 display(['The size of the test matrix is :', num2str(size(Hscatter,1)), 'x', num2str(size(Hscatter,1))])
47 
48 %% Calculeting the surface Green function
49 
50 % reordering the matrix coupling the surface sites to the right-lower corner of the matrix
51 M = CreateH.Read('M');
52 surface_sites = false(size(Hscatter,1),1);
53 surface_sites(1:M) = true;
54 surface_sites(end-M+1:end) = true;
55 
56 Hscatter = [ Hscatter(~surface_sites, ~surface_sites), Hscatter(~surface_sites, surface_sites);
57  Hscatter(surface_sites, ~surface_sites), Hscatter(surface_sites, surface_sites) ];
58 
59 % adding Complex Eenrgy
60 sizeH = size(Hscatter, 1);
61 Hscatter = sparse(1:sizeH, 1:sizeH, 0.23, sizeH, sizeH) - Hscatter;
62 
63 % Test using the mdivide method
64 display(' ')
65 display('Calculating the diagonal element of the inverse with the MATLAB utility:')
66 tic
67 diagG = diag(inv(Hscatter));
68 toc
69 
70 
71 % Test using the partialInv method
72 display(' ')
73 display('Calculating the diagonal element of the inverse with the dgetDiagInv utility:')
74  try
75  tic
76  GDiagInv = dgetDiagInv( Hscatter );
77  toc
78  catch err
79  warning([fncname, ' failed to run. Deleting the compiled MEX file.']);
80  delete(filename);
81  disp( err.identifier )
82  disp( err.message )
83  pause(3)
84  return
85  end
86 
87  error_num = norm( diagG-GDiagInv);
88  if error_num < 1e-11
89  display('***************************************************************************')
90  disp(['Test of ', fncname, ' passed.'])
91  else
92  warning(['Test of ', fncname, ' failed with an error ', num2str(error_num), '. Deleting the compiled MEX file.'])
93  delete(filename);
94  return
95  end
96 
97 
98 end
Lattice_Type
String describing the preprogrammed lattice type. See the documentation of lattice types for details.
Definition: structures.m:80
function test(arg1, arg2)
Brief description of the function.
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()
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 dgetDiagInv_test()
Test function for the MEX file dgetDiagInv.
Structure sites contains data to identify the individual sites in a matrix.
Definition: structures.m:187
Class containing physical parameters of a scattering center defined on a square lattice.
function structures(name)
A class to create and store Hamiltonian of the scattering region.