2 % Copyright (C) 2009-2015 Peter Rakyta, 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:
18 %> @addtogroup basic Basic Functionalities
21 %> @brief A
class providing
function handle to reduce the number of
sites in the Hamiltonian via decimation procedure.
23 %> @brief A
class providing
function handle to reduce the number of
sites in the Hamiltonian via decimation procedure.
24 %> The
Decimation parameter in structure #
Opt picks the following decimation procedures \n
32 properties ( Access =
public )
33 %> The
function handle of the decimation method
37 methods ( Access =
public )
38 %% Contructor of the
class 39 %> @brief Constructor of the
class.
41 %> @
param varargin Cell array of optional parameters:
43 %> @
return An instance of the
class 48 p.addParameter(
'ForcedDecimation', []);
51 ForcedDecimation = p.Results.ForcedDecimation;
53 if ~isempty(ForcedDecimation)
54 obj.Opt.Decimation = ForcedDecimation;
63 obj.DecimationFunc = @(E, Way2Hamiltonian, NameOfH, NameOfRegular_sites)(obj.decimation_3(E, Way2Hamiltonian, NameOfH, NameOfRegular_sites));
65 obj.DecimationFunc = @( E, Way2Hamiltonian, NameOfH, NameOfRegular_sites )(obj.decimation_4(E, Way2Hamiltonian, NameOfH, NameOfRegular_sites ));
67 obj.DecimationFunc = @(E, Way2Hamiltonian, NameOfH, NameOfRegular_sites)(obj.decimation_1_and_2(E, Way2Hamiltonian, NameOfH, NameOfRegular_sites));
69 warning(['EQuUs:', class(obj), ':
Decimation:Wrong_Decimation_Parameter'], 'Wrong
Decimation parameter given! Using default 4.')
70 obj.DecimationFunc = @(E, Way2Hamiltonian, NameOfH, NameOfRegular_sites)(obj.decimation_4(E, Way2Hamiltonian, NameOfH, NameOfRegular_sites));
76 %> @brief Algorithm to reduce the number of the
sites in the Hamiltonian via decimation. The number of the decimated
sites in one turn varies dynamically in order to avoid badly conditioned matrices. Equally fast as
#decimation_3, but more stable and more accurate. 77 %> @
param E The energy value
79 %> @
param NameOfH Name of the attribute storing the Hamiltonian to be decimate (typically use
'Hscatter')
80 %> @
param NameOfRegular_sites Name of the attribute storing the idexes of
sites to be kept after the decimation. (typically use
'kulso_szabfokok')
81 function decimation_4(obj, E, Way2Hamiltonian, NameOfH, NameOfRegular_sites )
83 if Way2Hamiltonian.Read(
'HamiltoniansDecimated')
84 obj.display([
'EQuUs:',
class(obj),
':decimation_4: The Hamiltonian is already decimated'],1);
86 elseif ~Way2Hamiltonian.Read(
'HamiltoniansCreated')
87 obj.display([
'EQuUs:',
class(obj),
':decimation_4: The Hamiltonian needs to be created before the decimation'],1);
92 blokk_size_max = obj.Opt.Decimation_block;
94 Hamiltoni = Way2Hamiltonian.Read( NameOfH );
95 regular_sites = Way2Hamiltonian.Read( NameOfRegular_sites );
97 if length(regular_sites) >= size(Hamiltoni,1)
98 obj.
display(['EQuUs:', class(obj), ':decimation_4: Nothing to be decimated']);
102 Way2Hamiltonian.
Clear( NameOfH );
105 blocks = blocks_to_be_decimated();
107 for idx = length(blocks):-1:2
108 decimation_of_block2( blocks(idx)-blocks(idx-1) );
112 Way2Hamiltonian.
Write( NameOfH, Hamiltoni );
117 %-----------------------------------------------------------------
120 %------------------------------------------------------------------
121 % determines the blocks of the Hamiltonian to be decimated out
122 function blocks = blocks_to_be_decimated()
123 blocks = length(regular_sites):blokk_size_max:size(Hamiltoni,1);
124 if blocks(end) < size(Hamiltoni,1)
125 blocks(end+1) = size(Hamiltoni,1);
128 if length(blocks) < 2
129 error(['EQuUs:', class(obj), ':decimation_4'], 'Error in determining the blocks to be decimated');
134 %------------------------------------------------------------------
135 %
sites to be decimated out are sorted to the end
137 indexes = false( size(Hamiltoni,1), 1);
138 indexes(regular_sites) = true;
140 Hamiltoni = [Hamiltoni(indexes,indexes), Hamiltoni(indexes,~indexes);
141 Hamiltoni(~indexes,indexes), Hamiltoni(~indexes,~indexes)];
144 regular_sites = 1:length(regular_sites);
150 %------------------------------------------------------------------
151 % decimates out the given block in the Hamiltonian
152 function decimation_of_block2( num )
156 nevezo = E*eye(num) - Hamiltoni(end-num+1:end, end-num+1:end);
158 cond_number = rcond(full(nevezo));
160 cond_number = rcond(nevezo);
164 %if abs(cond_number-1) > tolerance
165 if cond_number < tolerance && num > 1
166 num2 = increase_condition_number();
167 decimation_of_block2( num2 );
170 % here the given block with good condition number is
172 [~, col_idx] = find( Hamiltoni(end-num+1:end, 1:end-num) );
173 col_blocks = unique(floor(col_idx/blokk_size_max));
174 for jdx = 1:length(col_blocks)
175 col_min = max( [col_blocks(jdx)*blokk_size_max, 1] );
176 col_max = min( [size(Hamiltoni,2)-num, (col_blocks(jdx)+1)*blokk_size_max-1] );
177 cols = col_min:col_max;
178 H_21 = Hamiltoni( end-num+1:end, cols);
179 nevezo2 = nevezo\H_21;
181 [row_idx2, ~] = find( Hamiltoni(1:end-num, end-num+1:end) );
182 row_blocks = unique(floor(row_idx2/blokk_size_max));
183 for kdx = 1:length(row_blocks)
184 row_min = max( [row_blocks(kdx)*blokk_size_max, 1] );
185 row_max = min( [size(Hamiltoni,1)-num, (row_blocks(kdx)+1)*blokk_size_max-1] );
186 rows = row_min:row_max;
187 H_12 = Hamiltoni( rows, end-num+1:end );
190 if issparse(Hamiltoni)
191 size_H = size(Hamiltoni,1);
193 [rows_H11, cols_H11, elements_H11] = find(H_11);
195 rows_H11 = transpose(rows_H11);
196 cols_H11 = transpose(cols_H11);
197 elements_H11 = transpose(elements_H11);
199 rows_H11 = rows_H11 + row_min - 1 ;
200 cols_H11 = cols_H11 + col_min - 1;
202 [rows_H, cols_H, elements] = find( Hamiltoni );
204 Hamiltoni = sparse( [rows_H; rows_H11], [cols_H; cols_H11], [elements; elements_H11], size_H, size_H );
206 Hamiltoni(rows, cols) = Hamiltoni( rows, cols ) + H_11;
213 % delete the decimated
sites from the Hamiltonian
214 if issparse(Hamiltoni)
215 size_H = size(Hamiltoni,1);
216 [rows, cols, elements] = find( Hamiltoni(1:end-num, 1:end-num) );
217 Hamiltoni = sparse( rows, cols, elements, size_H-num, size_H-num );
219 Hamiltoni(:, end-num+1:end ) = [];
220 Hamiltoni(end-num+1:end, :) = [];
224 % convert to full matrix if sparse is not memory
226 whos_H = whos('Hamiltoni');
227 if whos_H.size(1)*whos_H.size(2)*16 <= whos_H.bytes && whos_H.sparse == 1
228 Hamiltoni = full(Hamiltoni);
229 obj.
display(['EQuUs:', class(obj), 'Sparse Hamiltonian was converted to full.']);
240 %-----------------------------------
241 % determine block size for which the matrix can be inverted
242 function num_tmp = increase_condition_number()
244 while cond_number < tolerance
245 num_tmp = floor(num_tmp/2);
249 nevezo = E*eye(num_tmp) - Hamiltoni(end-num_tmp+1:end, end-num_tmp+1:end);
251 cond_number = rcond(full(nevezo));
253 cond_number = rcond(nevezo);
262 %-----------------------------------------------------------------
263 % end nested functions
269 %> @brief Algorithm to reduce the number of the
sites in the Hamiltonian via decimation. The number of the decimated
sites in one turn varies dynamically in order to avoid badly conditioned matrices.
270 %> @
param E The energy value
272 %> @
param NameOfH Name of the attribute storing the Hamiltonian to be decimate (typically use '
Hscatter')
273 %> @
param NameOfRegular_sites Name of the attribute storing the idexes of
sites to be kept after the decimation. (typically use '
kulso_szabfokok')
274 function decimation_3(obj, E, Way2Hamiltonian, NameOfH, NameOfRegular_sites )
277 obj.
display(['EQuUs:', class(obj), ':decimation_3: The Hamiltonian is already decimated'],1);
280 obj.
display(['EQuUs:', class(obj), ':decimation_3: The Hamiltonian needs to be created before the decimation'],1);
284 %blokk_size_max = 50;
285 blokk_size_max = obj.
Opt.Decimation_block;
287 Hamiltoni = Way2Hamiltonian.
Read( NameOfH );
288 regular_sites = Way2Hamiltonian.
Read( NameOfRegular_sites );
289 Way2Hamiltonian.
Clear( NameOfRegular_sites );
291 obj.setCoordinates( Way2Hamiltonian, regular_sites );
293 megmaradt_szabfokok = sites_after_decimation(regular_sites);
294 Way2Hamiltonian.
Write( NameOfRegular_sites, megmaradt_szabfokok );
296 Way2Hamiltonian.
Clear( NameOfH );
298 H_size = size(Hamiltoni ,1);
299 blokkok = indexing_of_regular_sites();
300 belso_szabfokok = find(blokkok{2} ==
'b');
302 whos_H = whos(
'Hamiltoni');
303 if whos_H.size(1)*whos_H.size(2)*16 <= whos_H.bytes && whos_H.sparse == 1
304 Hamiltoni = full(Hamiltoni);
305 obj.display(
'A Hamltoni mar nem ritka');
308 Idx = length(belso_szabfokok);
312 idx = belso_szabfokok(iidx);
313 decimation_of_block();
315 whos_H = whos(
'Hamiltoni');
316 if whos_H.size(1)*whos_H.size(2)*16 <= whos_H.bytes && whos_H.sparse == 1
317 Hamiltoni = full(Hamiltoni);
318 obj.display(
'A Hamltoni mar nem ritka');
326 Way2Hamiltonian.Write( NameOfH, Hamiltoni );
327 Way2Hamiltonian.Write(
'HamiltoniansDecimated', 1)
329 %-----------------------------------------------------------------
332 %------------------------------------------------------------------
333 function decimation_of_block()
335 oszlop = [sum(blokkok{1}(1:idx-1))+1,sum(blokkok{1}(1:idx))];
336 nevezo = E*eye(blokkok{1}(idx)) - Hamiltoni(oszlop(1):oszlop(2),oszlop(1):oszlop(2));
337 cond_number = rcond(nevezo);
340 %
if abs(cond_number-1) > tolerance
341 if cond_number < tolerance
343 [oszlop, nevezo] = increase_condition_number();
346 if cond_number < tolerance
347 obj.display(num2str(cond(nevezo)) )
350 [sor_idx,oszlop_idx] = find(Hamiltoni(oszlop(1):oszlop(2),:));
351 oszlop_szamok = oszlop_szamolo(oszlop_idx
', oszlop, blokk_size_max); 352 Kdx = size(oszlop_szamok,1); 355 oszlop_k = oszlop_szamok(kdx,:); 357 H_darab21 = Hamiltoni(oszlop(1):oszlop(2),oszlop_k(1):oszlop_k(2)); 358 nevezo2 = nevezo\H_darab21; 360 oszlop_j = oszlop_szamok(jdx,:); 361 H_darab11 = Hamiltoni(oszlop_j(1):oszlop_j(2),oszlop_k(1):oszlop_k(2)); 362 H_darab12 = Hamiltoni(oszlop_j(1):oszlop_j(2),oszlop(1):oszlop(2)); 363 H_darab11 = H_darab11 + H_darab12*nevezo2; 365 Hamiltoni(oszlop_j(1):oszlop_j(2),oszlop_k(1):oszlop_k(2)) = H_darab11; 371 if issparse(Hamiltoni) 372 [sor_idx,oszlop_idx,elemek] = find(Hamiltoni); 374 indexek = logical(((oszlop(1)<=sor_idx) & (sor_idx <=oszlop(2))) | ((oszlop(1)<=oszlop_idx) & (oszlop_idx <=oszlop(2)))); 375 sor_idx(indexek) = []; 376 oszlop_idx(indexek) = []; 377 elemek(indexek) = []; 378 indexek = logical(sor_idx>oszlop(2)); 379 sor_idx(indexek) = sor_idx(indexek) - blokkok{1}(idx); 380 indexek = logical(oszlop_idx>oszlop(2)); 381 oszlop_idx(indexek) = oszlop_idx(indexek) - blokkok{1}(idx); 383 blokkok{1}(idx) = []; 384 blokkok{2}(idx) = []; 385 Hamiltoni = sparse(sor_idx,oszlop_idx,elemek,sum(blokkok{1}),sum(blokkok{1})); 386 clear sor_idx oszlop_idx elemek; 388 Hamiltoni(oszlop(1):oszlop(2),:) = []; 389 Hamiltoni(:,oszlop(1):oszlop(2)) = []; 390 blokkok{1}(idx) = []; 391 blokkok{2}(idx) = []; 394 belso_szabfokok = belso_szabfokok -1; 397 %------------------------------------------------------------------ 398 % kiszamolja hogy a kidecimalando szabfokokat hogy kell beoszlopozni 399 function oszlop_szamok = oszlop_szamolo(oszlop_idx, oszlop_decimalo, blokk_size_max) 401 blokk_size_max = 150*blokk_size_max; 403 Ldx = length(oszlop_idx); 405 if oszlop_idx(1) >= oszlop_decimalo(1) 406 while oszlop_idx(ldx) <= oszlop_decimalo(2) 409 oszlop_szamok = [oszlop_idx(ldx),oszlop_idx(ldx)]; 411 oszlop_szamok = [oszlop_idx(1),oszlop_idx(1)]; 416 while (ldx <= Ldx) && (oszlop_decimalo(1) > oszlop_idx(ldx)) 417 if (oszlop_idx(ldx)-oszlop_szamok(end,1) > blokk_size_max) 418 oszlop_szamok(end,2) = oszlop_idx(ldx-1); 419 oszlop_szamok = [oszlop_szamok;[oszlop_idx(ldx),oszlop_idx(ldx)]]; 424 oszlop_szamok(end,2) = oszlop_idx(ldx-1); 426 while (ldx < Ldx) && (oszlop_decimalo(2) > oszlop_idx(ldx)) 430 oszlop_szamok = [oszlop_szamok;[oszlop_idx(ldx),oszlop_idx(ldx)]]; 433 if (oszlop_idx(ldx)-oszlop_szamok(end,1) > blokk_size_max) 434 oszlop_szamok(end,2) = oszlop_idx(ldx-1); 435 oszlop_szamok = [oszlop_szamok;[oszlop_idx(ldx),oszlop_idx(ldx)]]; 440 oszlop_szamok(end,2) = oszlop_idx(ldx-1); 441 %oszlop_szamok = [1,oszlop_decimalo(1)-1;oszlop_decimalo(2)+1,H_size]; 444 %------------------------------------------------------------------ 447 %------------------------------------------------------------------ 448 function [oszlop,nevezo] = increase_condition_number() 450 %display(['condition number =
',num2str(cond_number)]); 451 blokkok{1} = [blokkok{1}(1:idx);blokkok{1}(idx:end)]; 452 blokkok{2} = [blokkok{2}(1:idx);blokkok{2}(idx:end)]; 453 egyik_fele = blokkok{2}(idx); 454 blokkok{1}(idx+1) = 0; 456 %while abs(cond_number-1) >= tolerance && egyik_fele >= 2 457 while cond_number <= tolerance && egyik_fele >= 2 458 egyik_fele = round(blokkok{1}(idx)*2.99/4); 459 masik_fele = blokkok{1}(idx) - egyik_fele; 460 blokkok{1}(idx) = egyik_fele; 461 blokkok{1}(idx+1) = masik_fele + blokkok{1}(idx+1); 462 oszlop = [sum(blokkok{1}(1:idx-1))+1,sum(blokkok{1}(1:idx))]; 463 nevezo = E*eye(blokkok{1}(idx)) - Hamiltoni(oszlop(1):oszlop(2),oszlop(1):oszlop(2)); 464 cond_number = rcond(nevezo); 466 %display(num2str(blokkok{1}(idx))) 467 %display(['atjavitott condition number =
',num2str(cond_number),' valamint kidecimalando szabfokok =
',num2str(blokkok{1}(idx))]); 468 belso_szabfokok = [belso_szabfokok(1:iidx);belso_szabfokok(iidx:end)]; 469 belso_szabfokok(iidx+1:end) = belso_szabfokok(iidx+1:end) + 1; 470 Idx = length(belso_szabfokok); 475 %------------------------------------------------------------------ 479 %------------------------------------------------------------------ 482 %------------------------------------------------------------------ 483 % Determines the blocks of regular sites. 484 function blokkok = indexing_of_regular_sites() 487 regular_sites = sort(regular_sites); 488 iii_max = length(regular_sites); 492 while iiidx <= iii_max 496 if (sum(blokkok{1}) + blokk_size) == regular_sites(iiidx) 497 while (iiidx == iii_max || regular_sites(iiidx+1) == regular_sites(iiidx)+1) && blokk_size <= blokk_size_max 498 blokk_size = blokk_size + 1; 500 if iiidx >= iii_max; blokk_size = blokk_size-1; break; end 502 if blokk_size == 1 && iiidx < iii_max ; iiidx = iiidx + 1; end 503 szabfok_tipus = 'k
'; % kulso szabfok 504 elseif (sum(blokkok{1}) + blokk_size) < regular_sites(iiidx) 505 while (sum(blokkok{1}) + blokk_size + 1 < regular_sites(iiidx)) && blokk_size <= blokk_size_max 506 blokk_size = blokk_size + 1; 508 szabfok_tipus = 'b
'; % kidecimalando belso szabfokok 509 elseif isempty(szabfok_tipus) && (sum(blokkok{1}) + blokk_size) > regular_sites(iiidx) 515 blokkok{1} = [blokkok{1};blokk_size]; 516 blokkok{2} = [blokkok{2};szabfok_tipus]; 521 szabfokok = H_size-sum(blokkok{1}); 524 blokk_size_max = blokk_size_max + 1; 525 blokkok_kieg = ones((szabfokok-mod(szabfokok,blokk_size_max))/blokk_size_max,1)*blokk_size_max; 526 szabfok_tipus_kieg = char(ones((szabfokok-mod(szabfokok,blokk_size_max))/blokk_size_max,1)*'b
'); 527 blokkok{1} = [blokkok{1};blokkok_kieg;mod(szabfokok,blokk_size_max)]; 528 blokkok{2} = [blokkok{2};szabfok_tipus_kieg;'b
']; 532 %------------------------------------------------------------------ 535 %------------------------------------------------------------------ 536 % Determines the sites after decimation 537 function remaining_sites = sites_after_decimation(regular_sites) 539 L = length(regular_sites); 542 Maximum = max(regular_sites); 543 remaining_sites = zeros(L,1); 545 szabfok_max = max(remaining_sites); 546 [ertek,index] = min(regular_sites); 547 if ertek_temp == ertek 548 remaining_sites(index) = szabfok_max; 551 remaining_sites(index) = szabfok_max+1; 553 regular_sites(index) = Maximum+1; 561 % end nested functions 562 %------------------------------------------------------------------ 568 %% decimation_1_and_2 569 %> @brief Algorithm to reduce the number of sites in the Hamiltonian via decimation. The number of the decimated sites is fixed during the calculations. 570 %> @param E The energy value 571 %> @param Way2Hamiltonian An instance of class CreateHamiltonians (or a derived class). 572 %> @param NameOfH Name of the attribute storing the Hamiltonian to be decimate (typically use 'Hscatter') 573 %> @param NameOfRegular_sites Name of the attribute storing the idexes of sites to be kept after the decimation (typically use 'kulso_szabfokok'). 574 function decimation_1_and_2(obj, E, Way2Hamiltonian, NameOfH, NameOfRegular_sites ) 577 obj.display(['EQuUs:
', class(obj), ':decimation_1_and_2: The Hamiltonian is already decimated
'],1); 580 obj.display(['EQuUs:
', class(obj), ':decimation_1_and_2: The Hamiltonian needs to be created before the decimation
'],1); 584 Hamiltoni = Way2Hamiltonian.Read( NameOfH ); 585 regular_sites = Way2Hamiltonian.Read( NameOfRegular_sites ); 586 Way2Hamiltonian.Clear( NameOfH ); 587 Way2Hamiltonian.Clear( NameOfRegular_sites ); 589 obj.setCoordinates( Way2Hamiltonian, regular_sites ); 591 Idx = size(Hamiltoni, 1); 593 [minidx,minkoord] = min(regular_sites); 595 szabfokok_szama = length(regular_sites); 596 megmaradt_szabfokok = zeros(szabfokok_szama,1); 603 if obj.Opt.Decimation == 1 605 regular_sites = regular_sites - 1; 607 Idx = size(Hamiltoni, 1); 608 elseif obj.Opt.Decimation == 2 609 blokk_size_max = obj.Opt.Decimation_block; 610 blokk_size = minidx - idx; 611 if blokk_size > blokk_size_max 612 blokk_size = blokk_size_max; 614 decimalas_blokkonkent(blokk_size); 615 s = whos('Hamiltoni
'); 616 if s.size(1)*s.size(2)*16 <= s.bytes && s.sparse == 1 617 Hamiltoni = full(Hamiltoni); 619 Hamiltoni = sparse(Hamiltoni); 621 regular_sites = regular_sites - blokk_size; 622 minidx = minidx - blokk_size; 623 Idx = size(Hamiltoni, 1); 625 error(['EQuUs:
', class(obj), ':decimation_1_and_2
'], 'Wrong decimation parameter: Opt_Decimation
'); 629 if minidx ~= minidxtemp 634 megmaradt_szabfokok(minkoord) = idx-1; 635 regular_sites(minkoord) = Idx+1; 638 [minidx,minkoord] = min(regular_sites); 644 if megmaradt_szabfokok(minkoord) == 0 645 megmaradt_szabfokok(minkoord) = minidx; 648 Way2Hamiltonian.Write( NameOfH, Hamiltoni ); 649 Way2Hamiltonian.Write( NameOfRegular_sites, megmaradt_szabfokok ); 653 %----------------------------------------------------------------- 656 %------------------------------------------------------------------ 657 function decimalas_blokkonkent(blokk_size) 662 E_matrix = eye(blokk_size)*E; 665 Hamiltoni = Hamiltoni(blokk_size+1:Hsize,blokk_size+1:Hsize) + ... 666 Hamiltoni(blokk_size+1:Hsize,1:blokk_size) /(E_matrix-Hamiltoni(1:blokk_size,1:blokk_size) * Hamiltoni(1:blokk_size,blokk_size+1:Hsize)); 668 elseif idx+blokk_size-1 == Hsize 670 Hamiltoni = Hamiltoni(1:Hsize-blokk_size,1:Hsize-blokk_size) + ... 671 Hamiltoni(1:Hsize-blokk_size,Hsize-blokk_size+1:Hsize) /(E_matrix-Hamiltoni(Hsize-blokk_size+1:Hsize,Hsize-blokk_size+1:Hsize)) * Hamiltoni(Hsize-blokk_size+1:Hsize,1:Hsize-blokk_size); 674 blokk_size = blokk_size-1; 675 nevezo = (E_matrix-Hamiltoni(idx:idx+blokk_size,idx:idx+blokk_size))\eye(size(E_matrix)); 676 Hdeci11 = Hamiltoni(1:idx-1,1:idx-1) + Hamiltoni(1:idx-1,idx:idx+blokk_size)*nevezo*Hamiltoni(idx:idx+blokk_size,1:idx-1); 677 Hdeci12 = Hamiltoni(1:idx-1,idx+blokk_size+1:Hsize) + Hamiltoni(1:idx-1,idx:idx+blokk_size)*nevezo*Hamiltoni(idx:idx+blokk_size,idx+blokk_size+1:Hsize); 678 Hdeci21 = Hamiltoni(idx+blokk_size+1:Hsize,1:idx-1) + Hamiltoni(idx+blokk_size+1:Hsize,idx:idx+blokk_size)*nevezo*Hamiltoni(idx:idx+blokk_size,1:idx-1); 679 Hdeci22 = Hamiltoni(idx+blokk_size+1:Hsize,idx+blokk_size+1:Hsize) + Hamiltoni(idx+blokk_size+1:Hsize,idx:idx+blokk_size)*nevezo*Hamiltoni(idx:idx+blokk_size,idx+blokk_size+1:Hsize); 681 Hamiltoni = [Hdeci11,Hdeci12;Hdeci21,Hdeci22]; 685 %------------------------------------------------------------------ 688 %------------------------------------------------------------------ 689 % decimalas pontonkent 690 function sitewise_decimation() 695 nem_nulla_idx = find(Hamiltoni(:,idx)); 696 rekurzioszam = max(size(nem_nulla_idx)); 699 while sor <= rekurzioszam 701 if ~(nem_nulla_idx(sor) == idx) 703 while oszlop <= rekurzioszam 704 if nem_nulla_idx(oszlop) == idx 707 Hamiltoni(nem_nulla_idx(sor),nem_nulla_idx(oszlop)) = Hamiltoni(nem_nulla_idx(sor),nem_nulla_idx(oszlop)) + ... 708 Hamiltoni(nem_nulla_idx(sor),idx)*Hamiltoni(idx,nem_nulla_idx(oszlop)) / (E-Hamiltoni(idx,idx)); 715 Hamiltoni(idx,:) = []; 716 Hamiltoni(:,idx) = []; 719 %------------------------------------------------------------------ 721 % end nested functions 727 methods ( Access = protected ) 729 %> @brief Sets the coordinates of the remaining sites after the decimation is finshed. 730 %> @param Way2Hamiltonian An instance of class CreateHamiltonians (or a derived class). 731 %> @param regular_sites Array of idexes of sites kept after the decimation 732 function setCoordinates( obj, Way2Hamiltonian, regular_sites ) 734 coordinates = Way2Hamiltonian.Read( 'coordinates' ); 736 if isempty(coordinates) 737 obj.display(['EQuUs:
', class(obj), ':setCoordinates: structure
coordinates is empty!
']) 741 indexes = logical( regular_sites <= length(coordinates.x) ); 743 coordinates.x = coordinates.x(regular_sites(indexes)); 744 coordinates.y = coordinates.y(regular_sites(indexes)); 746 if isprop( coordinates, 'spinup
' ) && ~isempty( coordinates.spinup ) 747 coordinates.spinup = coordinates.spinup(regular_sites(indexes)); 750 if isprop( coordinates, 'BdG_u
' ) && ~isempty( coordinates.BdG_u ) 751 coordinates.BdG_u = coordinates.BdG_u(regular_sites(indexes)); 754 Way2Hamiltonian.Write('coordinates', coordinates ); 758 end %methods protected Property HamiltoniansCreated
A logical value. True if the Hamiltonian was created, false otherwise.
A class containing methodes for displaying several standard messages.
function Write(MemberName, input)
Sets the value of an attribute in the class.
Structure Opt contains the basic computational parameters used in EQuUs.
function display(message, nosilent)
Displays output messages on the screen.
Property coordinates
An instance of the structure coordinates.
function Transport(Energy, B)
Calculates the conductance at a given energy value.
A class providing function handle to reduce the number of sites in the Hamiltonian via decimation pro...
Property kulso_szabfokok
A list of the sites to be kept after decimation.
function Clear(MemberName)
Clears the value of an attribute in the class.
Structure param contains data structures describing the physical parameters of the scattering center ...
Structure sites contains data to identify the individual sites in a matrix.
Property Hscatter
The matrix of the Hamiltonian.
Decimation
Option for using decimation algorith. (see more details at the documenatation of class Decimation)
Property HamiltoniansDecimated
A logical value. True if the Hamiltonian was decimated, or false otherwise.
function Read(MemberName)
Query for the value of an attribute in the class.
A class to create and store Hamiltonian of the scattering region.