├── Close_Files.m ├── Esort.m ├── FERMIONIC CHAIN ├── .gitkeep ├── Close_Files.m ├── Esort.m ├── ITend.m ├── Impose.m ├── Input_Variables.m ├── Iteration.m ├── Iteration_0.m ├── NRG.m ├── Open_Files.m ├── Parms.m ├── Plot_Figures.m ├── Thermodynamics.m ├── dekode.m ├── delta_enkode.m └── enkode.m ├── ITend.m ├── Impose.m ├── Input_Variables.m ├── Iteration.m ├── Iteration_0_2IK.m ├── Iteration_0_Anderson.m ├── Iteration_0_Kondo.m ├── LICENSE ├── NRG.m ├── Open_Files.m ├── Opmat.m ├── Opmat0_2IK.m ├── Opmat0_Anderson.m ├── Opmat0_Kondo.m ├── Parms.m ├── Plot_Figures.m ├── Plots ├── .gitkeep ├── Cv.png ├── Energy_Flows.png ├── S.png ├── S12.png └── Tchi.png ├── README.md ├── Readme.txt ├── Sample_Outputs ├── .gitkeep ├── ANDERSON │ ├── .gitkeep │ ├── Cv.pdf │ ├── Energy_Even.pdf │ ├── Energy_Odd.pdf │ ├── Entropy.pdf │ ├── OpTherm.dat │ ├── TChi.pdf │ ├── Therm.dat │ ├── Thermavg.dat │ └── out.dat ├── FERMIONIC CHAIN │ ├── .gitkeep │ ├── Therm.dat │ ├── Thermavg.dat │ └── out.dat └── KONDO │ ├── .gitkeep │ ├── Cv.pdf │ ├── Energy_Even.pdf │ ├── Energy_Odd.pdf │ ├── Entropy.pdf │ ├── OpTherm.dat │ ├── TChi.pdf │ ├── Therm.dat │ ├── Thermavg.dat │ └── out.dat ├── Thermodynamics.m ├── dec2dual.m ├── dekode.m ├── delta_enkode.m ├── enkode.m └── therm.data /Close_Files.m: -------------------------------------------------------------------------------- 1 | fclose(FNOUT); 2 | if (EO_PRINT) 3 | fclose(FNEVEN); fclose(FNODD); 4 | end 5 | if (THERMO) 6 | fclose(FNTHERM); fclose(FNTHERMAVG); 7 | end 8 | if (OPMAT) 9 | fclose(FNOPMAT); 10 | end -------------------------------------------------------------------------------- /Esort.m: -------------------------------------------------------------------------------- 1 | function [Es,cs,Ks] = Esort(E0,c0,Kodep0,L) 2 | [Es,ix] = sort(E0); 3 | cs = zeros(L); Ks = zeros(L,1); 4 | for i = 1:L 5 | cs(:,i) = c0(:,ix(i)); 6 | Ks(i) = Kodep0(ix(i)); 7 | end 8 | end -------------------------------------------------------------------------------- /FERMIONIC CHAIN/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /FERMIONIC CHAIN/Close_Files.m: -------------------------------------------------------------------------------- 1 | fclose(FNOUT); 2 | if (EO_PRINT) 3 | fclose(FNEVEN); fclose(FNODD); 4 | end 5 | if (THERMO) 6 | fclose(FNTHERM); fclose(FNTHERMAVG); 7 | end -------------------------------------------------------------------------------- /FERMIONIC CHAIN/Esort.m: -------------------------------------------------------------------------------- 1 | function [Es,cs,Ks] = Esort(E0,c0,Kodep0,L) 2 | [Es,ix] = sort(E0); 3 | cs = zeros(L); Ks = zeros(L,1); 4 | for i = 1:L 5 | cs(:,i) = c0(:,ix(i)); 6 | Ks(i) = Kodep0(ix(i)); 7 | end 8 | end -------------------------------------------------------------------------------- /FERMIONIC CHAIN/ITend.m: -------------------------------------------------------------------------------- 1 | % Print out the energies in output file 2 | 3 | fprintf(FNOUT, '%s %i \n','Iteration =', it); 4 | fprintf(FNOUT,'---------------\n'); 5 | fprintf(FNOUT, ' %3s %2s %5s %3s %10s \n', 'It.', '#', '2Sz', 'Q', 'E'); 6 | fprintf(FNOUT,'--------------------------------------\n'); 7 | for i=1:min(KEPT,L) 8 | fprintf(FNOUT, '%3i %3i %4i %4i %20.16f \n', it, i, Sz(i), Q(i), E(i)); 9 | end 10 | fprintf(FNOUT, '\n'); 11 | 12 | % Save even/odd energies for plotting 13 | 14 | if(PLOT_E || EO_PRINT) 15 | if( mod(it,2) == 0 ) 16 | EvenIt((it/2)+1) = it; 17 | for i = 1:min(L,ENMAX_PL) 18 | EvenE((it/2)+1,i) = E(i); 19 | end 20 | else 21 | OddIt(int16(it/2)) = it; 22 | for i = 1:min(L,ENMAX_PL) 23 | OddE(int16(it/2),i) = E(i); 24 | end 25 | end 26 | end 27 | 28 | % Print Even/Odd Energies 29 | 30 | if(EO_PRINT) 31 | if( mod(it,2) == 0 ) 32 | NP = FNEVEN; 33 | else NP = FNODD; 34 | end 35 | fprintf(NP,'%3i', it); 36 | for i = 1:min(L,ENMAX_PR) 37 | fprintf(NP, '%8.4f', E(i)); 38 | end 39 | fprintf(NP,'\n'); 40 | end 41 | 42 | % Print out Thermodynamic qts. 43 | 44 | if(THERMO) 45 | fprintf(FNTHERM, '%4i %14.6e %14.8f %14.8f %14.8f \n', it, temp(it+1), s(it+1), tchi(it+1), Cv(it+1)); 46 | end 47 | -------------------------------------------------------------------------------- /FERMIONIC CHAIN/Impose.m: -------------------------------------------------------------------------------- 1 | function E1 = Impose(E0,L,SMALL) 2 | % Impose degeneracy on nearly degenerate states 3 | 4 | E1 = E0; 5 | i = 1; 6 | while (i<=L) 7 | j = i+1; 8 | while( (j <= L) && (abs(E0(j)-E0(i)) < SMALL)) 9 | j=j+1; 10 | end 11 | E1(i:j-1) = mean(E0(i:j-1)); 12 | i=j; 13 | end 14 | 15 | end -------------------------------------------------------------------------------- /FERMIONIC CHAIN/Input_Variables.m: -------------------------------------------------------------------------------- 1 | % Input Parameters ======================================================== 2 | % 3 | % MODEL : Type of Model 4 | % FC (Fermionic chain) 5 | % 6 | % ITMAX : Max. No. of It. it = 0,1,2,...,ITMAX. 7 | % KEPT : Max. No. of states kept after each It. 8 | % Lambda : Discretization Parameter, t_n ~ \Lambda^{-n/2} 9 | % 10 | % IMPOSE(T/F) : Impose degeneracy of nearly degenerate states. 11 | % SMALL : Tolerance for IMPOSE. 12 | % 13 | % PLOT(T/F) : Plot Energies and Thermodynamics at the end of the run. 14 | % 15 | % THERMO(T/F) : Calculate Thermodynamics 16 | % 17 | % OPMAT(T/F) : Calculate Matrix. Elements of operator(s) \hat Op. 18 | % NOP : No. of Operators to calculate Opmat. 19 | % 20 | % PLOT_E(T/F) : Plot Odd and Even Energies at the end of the run. 21 | % PLOT_T(T/F) : Plot Thermodynaic Qts. at the end of the run. 22 | % EO_PRINT(T/F) : Print Even/Odd Energies at the end of each It. 23 | % 24 | % ENMAX_PL : Number of states to plot for even/odd iterations. 25 | % ENMAX_PR : Number of states to print for even/odd iterations. 26 | % ENMAX_PR <= ENMAX_PL 27 | % ========================================================================= 28 | 29 | MODEL = 'FC'; 30 | 31 | KEPT = 600; ITMAX = 30; Lambda = 3.0; 32 | 33 | IMPOSE = true; SMALL = 1e-10; 34 | 35 | THERMO = true; 36 | 37 | PLOT_T = false; PLOT_E = false; EO_PRINT = false; 38 | 39 | ENMAX_PL = 16; ENMAX_PR = 16; 40 | 41 | % ========================================================================= 42 | 43 | -------------------------------------------------------------------------------- /FERMIONIC CHAIN/Iteration.m: -------------------------------------------------------------------------------- 1 | tic; 2 | 3 | % Set up the Hamiltonian Matrix elements for current It. 4 | H(1:L*F_NS,1:L*F_NS) = 0.0; 5 | H(1:L,L+1:2*L) = t*fdag_u(1:L,1:L); 6 | H(2*L+1:3*L,3*L+1:4*L) = -t*fdag_u(1:L,1:L); 7 | H(1:L,2*L+1:3*L) = t*fdag_d(1:L,1:L); 8 | H(L+1:2*L,3*L+1:4*L) = t*fdag_d(1:L,1:L); 9 | 10 | % Symmetrize the Hamiltonian 11 | H = H+H'; 12 | % Set up main diagonal entries 13 | for i=1:L 14 | H(i,i) = E(i)*Lambda^0.5; H(L+i,L+i) = E(i)*Lambda^0.5; 15 | H(2*L+i,2*L+i) = E(i)*Lambda^0.5; H(3*L+i,3*L+i) = E(i)*Lambda^0.5; 16 | end 17 | 18 | % Set up the matrices for fdag_{u,d} for current It. 19 | fdag_u(1:L*F_NS,1:L*F_NS) = 0.0; fdag_d(1:L*F_NS,1:L*F_NS) = 0.0; 20 | fdag_u(L+1:2*L,1:L) = eye(L); fdag_u(3*L+1:4*L,2*L+1:3*L) = eye(L); 21 | fdag_d(2*L+1:3*L,1:L) = eye(L); fdag_d(3*L+1:4*L,L+1:2*L) = -eye(L); 22 | 23 | % Assign the Kodes for all the basis states in terms of Kodes for prev. It. 24 | Kode(1:L) = Kodep(1:L) + delta_enkode(dSz(1),dQ(1)); 25 | Kode(L+1:2*L) = Kodep(1:L) + delta_enkode(dSz(2),dQ(2)); 26 | Kode(2*L+1:3*L) = Kodep(1:L) + delta_enkode(dSz(3),dQ(3)); 27 | Kode(3*L+1:4*L) = Kodep(1:L) + delta_enkode(dSz(4),dQ(4)); 28 | 29 | L=L*F_NS; % Increase No. of basis states by F_NS 30 | 31 | t1 = toc; tic; 32 | 33 | % ------------------------------------------------------------------------- 34 | % Block Diagonalize the Hamiltonian. 35 | 36 | % xK : Finds all the unique Kode values. 37 | % nK : No. of unique Kode values. 38 | % iK : Counter that counts the blocks/states computed. 39 | xK = unique(Kode(1:L)); nK = length(xK); iK = 0; 40 | E(1:L) = 0.0; c(1:L,1:L) = 0.0; HK(1:L,1:L) = 0.0; 41 | 42 | % Loop over all blocks 43 | for blk = 1:nK 44 | % Find the position of all the basis states for the Blk. 45 | % b = (b1,b2,..) stores the Pos. of basis states in the original H. 46 | % LK : Dim. of the block k. 47 | b = find(Kode(1:L) == xK(blk)); LK = length(b); 48 | 49 | % Form Hamilton Matrix HQ for the current block k 50 | for i = 1:LK 51 | for j = 1:LK 52 | HK(i,j) = H(b(i),b(j)); 53 | end 54 | end 55 | 56 | % Find eigenvalues and eigenvectors of the Blk. k 57 | [cK(1:LK,1:LK), EK(1:LK)] = eig(HK(1:LK,1:LK),'vector'); 58 | 59 | % Save the Eig. Vec. and Eig. Energies in the original Matrices. 60 | for i = 1:LK 61 | for j = 1:LK 62 | c(b(i),b(j)) = cK(i,j); 63 | end 64 | E(b(i)) = EK(i); 65 | Kodep(b(i)) = xK(blk); 66 | end 67 | iK = iK + LK; 68 | end 69 | 70 | t2 = toc; tic; 71 | 72 | %-------------------------------------------------------------------------- 73 | % Sort the states in ascending order in Energies and shift the Energies. 74 | 75 | % Sort Energies + c + Kode 76 | [E(1:L),c(1:L,1:L),Kodep(1:L)] = Esort(E(1:L),c(1:L,1:L),Kodep(1:L),L); 77 | 78 | % Keep only the first KEPT states and ignore the other states 79 | K = L; 80 | if(L>KEPT) 81 | L=KEPT; 82 | end 83 | 84 | % Imposing degeneracy on nearly degenate energy states 85 | if (IMPOSE) 86 | E(1:L) = Impose(E(1:L),L,SMALL); 87 | end 88 | 89 | % Shift energies such that the ground state has an energy of 0 90 | E(1:L) = E(1:L) - E(1); 91 | 92 | t3 = toc; tic; 93 | 94 | %-------------------------------------------------------------------------- 95 | 96 | % Rotate the Matrices for the fdag_{u,d} Operators - to be used in next It. 97 | fdag_u(1:L,1:L) = c(1:K,1:L)'*fdag_u(1:K,1:K)*c(1:K,1:L); 98 | fdag_d(1:L,1:L) = c(1:K,1:L)'*fdag_d(1:K,1:K)*c(1:K,1:L); 99 | 100 | % ------------------------------------------------------------------------- 101 | 102 | % Extract Qtm. Nos. Sz and Q for printing 103 | [Sz(1:L),Q(1:L)] = dekode(Kodep(1:L)); 104 | 105 | % Compute Thermodynamics of the system 106 | if (THERMO) 107 | Thermodynamics(); 108 | end 109 | 110 | t4 = toc; 111 | 112 | % End of Iteration. Print out energy levels and Thermodynamics 113 | ITend(); 114 | 115 | % The times calculated are as follows: 116 | % t1: Set up H, fdag_{u,d}, Kodep; t2 : Block diagonalizing H; 117 | % t3: Sort and shift E, t4: Thermodynamics + Opmat + Printing. 118 | fprintf(FNOUT, 'Elapsed Time = %8.5f + %8.5f +%8.5f + %8.5f = %8.5f \n\n', t1, t2, t3, t4, t1+t2+t3+t4 ); 119 | -------------------------------------------------------------------------------- /FERMIONIC CHAIN/Iteration_0.m: -------------------------------------------------------------------------------- 1 | it = 0; % Iteration 0 2 | 3 | L = 4; % Possible No. of Config. of the f0 site. 4 | 5 | % Set up the matrices for fdag_{u,d} for current It. 6 | fdag_u(1:L,1:L) = [0 0 0 0; 1 0 0 0; 0 0 0 0; 0 0 1 0]; 7 | fdag_d(1:L,1:L) = [0 0 0 0; 0 0 0 0; 1 0 0 0; 0 -1 0 0]; 8 | 9 | % Find out the (trivial) eigenstates and eigenenergies of the system. 10 | [c(1:L,1:L),E(1:L)] = eig(H(1:L,1:L),'vector'); 11 | 12 | % Rotate the Matrices for the fdag_{u,d} Operators - to be used in next It. 13 | fdag_u(1:L,1:L) = c(1:L,1:L)'*fdag_u(1:L,1:L)*c(1:L,1:L); 14 | fdag_d(1:L,1:L) = c(1:L,1:L)'*fdag_d(1:L,1:L)*c(1:L,1:L); 15 | 16 | % Define Q and 2Sz qtm. nos for f0 site. 17 | Q(1:L) = [-1 0 0 1]; 18 | Sz(1:L) = [0 1 -1 0]; 19 | 20 | % Assign Kodes to the eigenstates. 21 | Kodep(1:L) = enkode(Sz(1:L),Q(1:L)); 22 | 23 | % Compute thermodynamics of the system 24 | if(THERMO) 25 | Thermodynamics(); 26 | end 27 | 28 | % End of Iteration. Print out energy levels and Thermodynamics 29 | ITend(); -------------------------------------------------------------------------------- /FERMIONIC CHAIN/NRG.m: -------------------------------------------------------------------------------- 1 | function NRG() 2 | 3 | % Load Input parameters. 4 | Input_Variables(); 5 | 6 | % Declare Run Variables. 7 | Parms(); 8 | 9 | % Open output files 10 | Open_Files(); 11 | 12 | % Set timer 13 | t0 = cputime; 14 | 15 | % Iteration 0 16 | Iteration_0(); 17 | 18 | % ========================================================================= 19 | 20 | % NRG Iterations 21 | for it=1:ITMAX 22 | 23 | % Set up hopping coeffecients 24 | n = it-1; 25 | t = (1+Lambda^-1)*(1-Lambda^(-n-1))/(2*sqrt(1-Lambda^(-2*n-1))*sqrt(1-Lambda^(-2*n-3))); 26 | 27 | % Set up the Hamiltonian and Diagonalize. 28 | Iteration(); 29 | 30 | end 31 | 32 | if (THERMO) 33 | % Print out average thermodynamics 34 | for it=1:ITMAX-1 35 | savg(it+1) = 0.25*(s(it)+2*s(it+1)+s(it+2)); 36 | tchiavg(it+1)= 0.25*(tchi(it)+2*tchi(it+1)+tchi(it+2)); 37 | Cvavg(it+1) = 0.25*(Cv(it)+2*Cv(it+1)+Cv(it+2)); 38 | fprintf(FNTHERMAVG, '%14.6e %14.8f %14.8f %14.8f \n', temp(it+1), savg(it+1), tchiavg(it+1), Cvavg(it+1)); 39 | end 40 | end 41 | 42 | % Print the total time for the run. 43 | tf = cputime; 44 | fprintf(FNOUT, 'Total time = %8.4f \n', tf-t0); 45 | 46 | % Close all output files 47 | Close_Files(); 48 | 49 | % Plot Energies and Thermodynamics 50 | Plot_Figures(); 51 | 52 | end 53 | -------------------------------------------------------------------------------- /FERMIONIC CHAIN/Open_Files.m: -------------------------------------------------------------------------------- 1 | % Open output files ======================================================= 2 | 3 | % out.dat : Print out Energies 4 | % even.dat/odd.dat : Print out Energies for even/odd It. 5 | % Therm.dat : Print out Thermodynamic qts. , , vs Temp. 6 | % Thermavg.dat : Print out 3-pt. avgs , , vs Temp. 7 | % OpTherm.dat: Print out the expectation values of the Imp. Operators. 8 | 9 | %-------------------------------------------------------------------------- 10 | 11 | FNOUT = fopen('out.dat' ,'w+'); 12 | if (EO_PRINT) 13 | FNEVEN = fopen('even.dat','w+'); FNODD = fopen('odd.dat' ,'w+'); 14 | end 15 | if(THERMO) 16 | FNTHERM = fopen('Therm.dat','w+'); FNTHERMAVG = fopen('Thermavg.dat','w+'); 17 | end 18 | 19 | % ------------------------------------------------------------------------- 20 | 21 | % Print out header information ============================================ 22 | 23 | header_line = '1-Channel Fermionic Chain \n'; 24 | 25 | fprintf(FNOUT,header_line); clear header_line; 26 | 27 | fprintf(FNOUT, 'Lambda = %5.3f, KEPT = %4i, ITMAX = %3i \n \n', Lambda,KEPT,ITMAX); 28 | 29 | % Therm.dat: , , 30 | if (THERMO) 31 | fprintf(FNTHERM, '# %3s %10s %12s %16s %12s \n', 'It','Temp.','','','Cv'); 32 | fprintf(FNTHERM, '#---------------------------------------------------------------\n'); 33 | fprintf(FNTHERMAVG,'# %10s %12s %16s %12s \n', 'Temp.','S_avg','TChi_avg','Cv_avg'); 34 | fprintf(FNTHERMAVG,'#- --------------------------------------------------------\n'); 35 | end 36 | 37 | % even.dat + odd.dat 38 | if (EO_PRINT) 39 | fprintf(FNODD, '#it'); fprintf(FNEVEN, '#it'); 40 | for i = 1:ENMAX_PR 41 | fprintf(FNODD, ' E%2i ',i); fprintf(FNEVEN, ' E%2i ',i); 42 | end 43 | fprintf(FNODD, '\n'); fprintf(FNEVEN, '\n'); 44 | end 45 | 46 | %-------------------------------------------------------------------------- 47 | %========================================================================== -------------------------------------------------------------------------------- /FERMIONIC CHAIN/Parms.m: -------------------------------------------------------------------------------- 1 | % Declaration of Run variables ============================================ 2 | % 3 | % RUN VARIABLES------------------------------------------------------------ 4 | % F_NS : D.o.f of each site of the fermionic chain. 5 | % For a One-channel chain, the states are {|0>, |1>, |-1>, |2>}. 6 | % 7 | % MAXDIM = F_NS*KEPT : Max. dim. of Hamiltonian matrix. 8 | % H(MAXDIM,MAXDIM) : Hamiltonian Matrix. 9 | % c(MAXDIM,MAXDIM) : Coeff. of eigenvectors after diagonalization. 10 | % E(MAXDIM) : Array that stores Energies before and after sorting. 11 | % MAXBLKDIM = KEPT: Max, dim. of a Hamiltonian block. 12 | % HK(MAXBLKDIM,MAXBLKDIM) : Hamiltonain Matrix. of a Blk. 13 | % cK(MAXBLKDIM,MAXBLKDIM) : Coeff. of eigenvectors after Blk. diag. 14 | % EK(MAXBLKDIM) : Array that stores Energies after Blk. diag. 15 | % fdag_u(MAXDIM,MAXDIM) : Matrix rep. of fdag_u at each It. 16 | % fdag_d(MAXDIM,MAXDIM) : Matrix rep. of fdag_u at each It. 17 | % 18 | % QTM NOS.----------------------------------------------------------------- 19 | % Kode = enkode(Sz,Q) stores the qtm. numbers 2Sz and Q together. 20 | % They can be retrieved using [Sz,Q] = dekode(Kode) 21 | % Kode(MAXDIM) : Stores the Kode of of each state in the current iteration. 22 | % Kodep(MAXDIM): Stores the Kode of of each state in the prev. iteration. 23 | % Sz(MAXDIM) : Stores Qtm. No. 2Sz of the eigenstates. 24 | % Q(MAXDIM) : Stores charge Qtm. No. Q = n^-nv of the eigenstates. 25 | % Sz_good(T/F): Sz is a good Qtm. No. 26 | % Q_good(T/F) : Q is a good Qtm. No. 27 | % dSz/dQ : Change in Sz Qtm. No. for the new basis states. 28 | % (by taking a cross product with the new f0-site). 29 | % 30 | % THERMODYNAMICS----------------------------------------------------------- 31 | % temp(ITMAX+1): Array that stores temp. of each It. 32 | % s(ITMAX+1) : Array that stores Entropy at each It. 33 | % savg(ITMAX+1): Array that stores 3-pt. avg. of . 34 | % tChi(ITMAX+1): Array that stores at each It. 35 | % tchiavg(ITMAX+1) : Array that stores 3-pt. avg. of . 36 | % Cv(ITMAX+1 ) : Array that stores Specific heat at each It. 37 | % Cvavg(ITMAX+1): Array that stores 3-pt. avg. of . 38 | % s0, tchi0, Cv0 : Array that stores resp. thermodynamics from band file 39 | % simp, tchiimp, Cvimp : Imp. contribution to resp. thermodynamic qts. 40 | % 41 | % ========================================================================= 42 | 43 | F_NS = 4; MAXDIM = F_NS*KEPT; MAXBLKDIM = KEPT; 44 | H = zeros(MAXDIM); c = zeros(MAXDIM); E = zeros(MAXDIM,1); 45 | HK = zeros(MAXBLKDIM); cK = zeros(MAXBLKDIM); EK = zeros(MAXBLKDIM,1); 46 | fdag_u = zeros(MAXDIM); fdag_d = zeros(MAXDIM); 47 | 48 | Kode = zeros(MAXDIM,1); Kodep = zeros(MAXDIM,1); 49 | Sz = zeros(MAXDIM,1) ; Q = zeros(MAXDIM,1); 50 | 51 | if (THERMO) 52 | temp = zeros(ITMAX+1,1); 53 | s = zeros(ITMAX+1,1); savg = zeros(ITMAX+1,1); 54 | tchi = zeros(ITMAX+1,1); tchiavg = zeros(ITMAX+1,1); 55 | Cv = zeros(ITMAX+1,1); Cvavg = zeros(ITMAX+1,1); 56 | end 57 | 58 | if (PLOT_E || EO_PRINT) 59 | EvenE = zeros(int16(ITMAX/2)+1,ENMAX_PL); EvenIt= zeros(int16(ITMAX/2)+1,1); 60 | OddE = zeros(int16(ITMAX/2),ENMAX_PL); OddIt = zeros(int16(ITMAX/2),1); 61 | end 62 | 63 | Sz_good = true; Q_good = true; 64 | 65 | dSz = [0 0 0 0]; dQ = [0 0 0 0]; 66 | if ( Sz_good == true ) 67 | dSz = [0 1 -1 0]; 68 | end 69 | if (Q_good == true ) 70 | dQ = [-1 0 0 1]; 71 | 72 | end 73 | 74 | % ========================================================================= 75 | -------------------------------------------------------------------------------- /FERMIONIC CHAIN/Plot_Figures.m: -------------------------------------------------------------------------------- 1 | if (PLOT_E) 2 | % Plot first few Even Energy levels 3 | plot(EvenIt,EvenE); 4 | title_txt = ['Energy vs Iterations (EVEN)']; 5 | title(title_txt); 6 | xlabel('Iterations[It]'); 7 | ylabel('Energy[E]'); 8 | 9 | % Plot first few Odd Energy levels 10 | figure; 11 | plot(OddIt,OddE); 12 | title_txt = ['Energy vs Iterations (ODD)']; 13 | title(title_txt); 14 | xlabel('Iterations[It]'); 15 | ylabel('Energy[E]'); 16 | end 17 | 18 | if (PLOT_T) 19 | % Plot Entropy 20 | figure; 21 | semilogx(temp(2:ITMAX),savg(2:ITMAX)); 22 | title_txt = 'Entropy vs Temperature'; 23 | title(title_txt); 24 | xlabel('Temperature[T]'); 25 | ylabel('Entropy[Savg]'); 26 | 27 | % Plot TChi 28 | figure; 29 | semilogx(temp(2:ITMAX),tchiavg(2:ITMAX)); 30 | title_txt = 'TChi vs Temperature'; 31 | title(title_txt); 32 | xlabel('Temperature[T]'); 33 | ylabel('[TChi]'); 34 | 35 | % Plot Specific Heat 36 | figure; 37 | semilogx(temp(2:ITMAX),Cvavg(2:ITMAX)); 38 | title_txt = 'Specific Heat vs Temperature'; 39 | title(title_txt); 40 | xlabel('Temperature[T]'); 41 | ylabel('Specific Heat [Cv]'); 42 | end 43 | -------------------------------------------------------------------------------- /FERMIONIC CHAIN/Thermodynamics.m: -------------------------------------------------------------------------------- 1 | beta = Lambda^(+0.5); temp(it+1) = (Lambda^(-(it-1)/2))/beta; 2 | 3 | z = sum(exp(-beta*E(1:L))); 4 | 5 | s(it+1) = beta*(sum(E(1:L).*exp(-beta*E(1:L)))/z) + log(z); 6 | tchi(it+1) = 0.25*sum(Sz(1:L).*Sz(1:L).*exp(-beta*E(1:L)))/z - 0.5*sum(Sz(1:L).*exp(-beta*E(1:L)))/z; 7 | Cv(it+1) = sum(E(1:L).*E(1:L).*exp(-beta*E(1:L)))/z - sum(E(1:L).*exp(-beta*E(1:L)))/z; 8 | -------------------------------------------------------------------------------- /FERMIONIC CHAIN/dekode.m: -------------------------------------------------------------------------------- 1 | function [Sz,Q] = dekode(kode) 2 | Q = rem(kode,100)-50; 3 | Sz = (kode-rem(kode,100))/100-50; 4 | end -------------------------------------------------------------------------------- /FERMIONIC CHAIN/delta_enkode.m: -------------------------------------------------------------------------------- 1 | function delta_kode = delta_encode(Sz,Qz) 2 | delta_kode = (Sz)*100 + (Qz); 3 | end -------------------------------------------------------------------------------- /FERMIONIC CHAIN/enkode.m: -------------------------------------------------------------------------------- 1 | function kode = encode(Sz,Qz) 2 | kode = (Sz+50)*100 + (Qz+50); 3 | end -------------------------------------------------------------------------------- /ITend.m: -------------------------------------------------------------------------------- 1 | % Print out the energies in output file ----------------------------------- 2 | 3 | fprintf(FNOUT, '%s %i \n','Iteration =', it); 4 | fprintf(FNOUT,'---------------\n'); 5 | fprintf(FNOUT, ' %3s %2s %5s %3s %10s \n', 'It.', '#', '2Sz', 'Q', 'E'); 6 | fprintf(FNOUT,'--------------------------------------\n'); 7 | for i=1:min(KEPT,L) 8 | fprintf(FNOUT, '%3i %3i %4i %4i %20.16f \n', it, i, Sz(i), Q(i), E(i)); 9 | end 10 | fprintf(FNOUT, '\n'); 11 | 12 | % Save even/odd energies for plotting ------------------------------------ 13 | 14 | if(PLOT_E || EO_PRINT) 15 | if( mod(it,2) == 0 ) 16 | EvenIt((it/2)+1) = it; 17 | for i = 1:min(L,ENMAX_PL) 18 | EvenE((it/2)+1,i) = E(i); 19 | end 20 | else 21 | OddIt(int16(it/2)) = it; 22 | for i = 1:min(L,ENMAX_PL) 23 | OddE(int16(it/2),i) = E(i); 24 | end 25 | end 26 | end 27 | 28 | % Print Even/Odd Energies ------------------------------------------------- 29 | 30 | if(EO_PRINT) 31 | if( mod(it,2) == 0 ) 32 | NP = FNEVEN; 33 | else NP = FNODD; 34 | end 35 | fprintf(NP,'%3i', it); 36 | for i = 1:min(L,ENMAX_PR) 37 | fprintf(NP, '%8.4f', E(i)); 38 | end 39 | fprintf(NP,'\n'); 40 | end 41 | 42 | % Print out Thermodynamic qts. -------------------------------------------- 43 | 44 | if(THERMO) 45 | fprintf(FNTHERM, '%4i %14.6e %14.8f %14.8f %14.8f \n', it, temp(it+1), s(it+1), tchi(it+1), Cv(it+1)); 46 | end 47 | 48 | % Print out Exp. Values of Operators. ------------------------------------- 49 | 50 | if(OPMAT) 51 | if ( NOP == 1) 52 | fprintf(FNOPMAT, '%14.4e %16.8f \n', temp(it+1), op_exp(it+1,1)); 53 | else 54 | fprintf(FNOPMAT, '%14.4e', temp(it+1)); 55 | for i = 1:NOP 56 | fprintf(FNOPMAT, '%16.8f',op_exp(it+1,i)); 57 | end 58 | fprintf(FNOPMAT, '\n'); 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /Impose.m: -------------------------------------------------------------------------------- 1 | function E1 = Impose(E0,L,SMALL) 2 | % Impose degeneracy over closely lying states 3 | 4 | E1 = E0; 5 | i = 1; 6 | while (i<=L) 7 | j = i+1; 8 | while( (j <= L) && (abs(E0(j)-E0(i)) < SMALL)) 9 | j=j+1; 10 | end 11 | E1(i:j-1) = mean(E0(i:j-1)); 12 | i=j; 13 | end 14 | 15 | end -------------------------------------------------------------------------------- /Input_Variables.m: -------------------------------------------------------------------------------- 1 | % Input Parameters ======================================================== 2 | % 3 | % MODEL : Type of Model 4 | % KO (KONDO), AN (ANDERSON), 2IK (2-IMP. KONDO) 5 | % 6 | % ITMAX : Max. No. of It. it = 0,1,2,...,ITMAX. 7 | % KEPT : Max. No. of states kept after each It. 8 | % Lambda : Discretization Parameter, t_n ~ \Lambda^{-n/2} 9 | % 10 | % IMPOSE(T/F) : Impose degeneracy of nearly degenerate states. 11 | % SMALL : Tolerance for IMPOSE. 12 | % 13 | % PLOT(T/F) : Plot Energies and Thermodynamics at the end of the run. 14 | % 15 | % THERMO(T/F) : Calculate Thermodynamics 16 | % 17 | % OPMAT(T/F) : Calculate Matrix. Elements of operator(s) \hat Op. 18 | % NOP : No. of Operators to calculate Opmat. 19 | % 20 | % FIND_Tk : Calculate T_k/T_c. Use to determine T_k/T_c. 21 | % Simp_UL / Simp_LL : Simp_(UpperLower)_Limit. 22 | % Simp(T_k) = (Simp_UL + Simp_UL)/2 23 | % 24 | % Kondo Model: 25 | % Jk : Kondo coupling between site-f0 and Imp. Simp. 26 | % Anderson Model: 27 | % Gamma : Hybridization between site-f0 and Imp. site d 28 | % ed = \epsilon_d : Imp. occupation energy. 29 | % U : Coulomb repulsion between ^ and v spins at Imp. 30 | % 2-Imp Kondo: 31 | % Jk1 : Kondo coupling between site-f0 and Imp. Spin S1. 32 | % Jk2 : Kondo coupling between site-f0 and Imp. Spin S2. 33 | % J12 : Exchange coupling between spins 1 and 2. 34 | % 35 | % himp = Imp. magnetic field (TO BE IMPLEMENTED) 36 | % 37 | % PLOT_E(T/F) : Plot Odd and Even Energies at the end of the run. 38 | % PLOT_T(T/F) : Plot Thermodynaic Qts. at the end of the run. 39 | % EO_PRINT(T/F) : Print Even/Odd Energies at the end of each It. 40 | % 41 | % ENMAX_PL : Number of states to plot for even/odd iterations. 42 | % ENMAX_PR : Number of states to print for even/odd iterations. 43 | % ENMAX_PR <= ENMAX_PL 44 | % ========================================================================= 45 | 46 | MODEL = 'KO'; 47 | 48 | % Kondo: 49 | %Jk = 0.0; 50 | 51 | % Anderson Model 52 | %Gamma = 0.1; ed = -0.2; U = 0.4; 53 | 54 | % 2 Imp. Kondo 55 | %Jk1 = 0.25; Jk2 = 0.25; J12 = 0.01; 56 | 57 | KEPT = 800; ITMAX = 60; Lambda = 3.0; 58 | 59 | IMPOSE = true; SMALL = 1e-6; 60 | 61 | THERMO = true; 62 | 63 | OPMAT = false; NOP = 1; 64 | 65 | PLOT_T = false; PLOT_E = false; EO_PRINT = false; 66 | 67 | ENMAX_PL = 32; ENMAX_PR = 16; 68 | 69 | FIND_Tk = true; Simp_UL = log(4); Simp_LL = log(2); 70 | 71 | % ========================================================================= 72 | 73 | -------------------------------------------------------------------------------- /Iteration.m: -------------------------------------------------------------------------------- 1 | tic; 2 | 3 | % Set up the Hamiltonian Matrix elements for current It. 4 | H(1:L*F_NS,1:L*F_NS) = 0.0; 5 | H(1:L,L+1:2*L) = t*fdag_u(1:L,1:L); 6 | H(2*L+1:3*L,3*L+1:4*L) = -t*fdag_u(1:L,1:L); 7 | H(1:L,2*L+1:3*L) = t*fdag_d(1:L,1:L); 8 | H(L+1:2*L,3*L+1:4*L) = t*fdag_d(1:L,1:L); 9 | 10 | % Symmetrize the Hamiltonian 11 | H = H+H'; 12 | % Set up main diagonal entries 13 | for i=1:L 14 | H(i,i) = E(i)*Lambda^0.5; H(L+i,L+i) = E(i)*Lambda^0.5; 15 | H(2*L+i,2*L+i) = E(i)*Lambda^0.5; H(3*L+i,3*L+i) = E(i)*Lambda^0.5; 16 | end 17 | 18 | % Set up the matrices for fdag_{u,d} for current It. 19 | fdag_u(1:L*F_NS,1:L*F_NS) = 0.0; fdag_d(1:L*F_NS,1:L*F_NS) = 0.0; 20 | fdag_u(L+1:2*L,1:L) = eye(L); fdag_u(3*L+1:4*L,2*L+1:3*L) = eye(L); 21 | fdag_d(2*L+1:3*L,1:L) = eye(L); fdag_d(3*L+1:4*L,L+1:2*L) = -eye(L); 22 | 23 | % Set up Matrix for the Calc. of Op. Matrix elements. 24 | if (OPMAT) 25 | Opmat(); 26 | end 27 | 28 | % Assign the Kodes for all the basis states in terms of Kodes for prev. It. 29 | Kode(1:L) = Kodep(1:L) + delta_enkode(dSz(1),dQ(1)); 30 | Kode(L+1:2*L) = Kodep(1:L) + delta_enkode(dSz(2),dQ(2)); 31 | Kode(2*L+1:3*L) = Kodep(1:L) + delta_enkode(dSz(3),dQ(3)); 32 | Kode(3*L+1:4*L) = Kodep(1:L) + delta_enkode(dSz(4),dQ(4)); 33 | 34 | L=L*F_NS; % Increase No. of basis states by F_NS 35 | 36 | t1 = toc; tic; 37 | 38 | % ------------------------------------------------------------------------- 39 | % Block Diagonalize the Hamiltonian. 40 | 41 | % xK : Finds all the unique Kode values. 42 | % nK : No. of unique Kode values. 43 | % iK : Counter that counts the blocks/states computed. 44 | xK = unique(Kode(1:L)); nK = length(xK); iK = 0; 45 | E(1:L) = 0.0; c(1:L,1:L) = 0.0; HK(1:L,1:L) = 0.0; 46 | 47 | % Loop over all blocks 48 | for blk = 1:nK 49 | % Find the position of all the basis states for the Blk. 50 | % b = (b1,b2,..) stores the Pos. of basis states in the original H. 51 | % LK : Dim. of the block k. 52 | b = find(Kode(1:L) == xK(blk)); LK = length(b); 53 | 54 | % Form Hamilton Matrix HQ for the current block k 55 | for i = 1:LK 56 | for j = 1:LK 57 | HK(i,j) = H(b(i),b(j)); 58 | end 59 | end 60 | 61 | % Find eigenvalues and eigenvectors of the Blk. k 62 | [cK(1:LK,1:LK), EK(1:LK)] = eig(HK(1:LK,1:LK),'vector'); 63 | 64 | % Save the Eig. Vec. and Eig. Energies in the original Matrices. 65 | for i = 1:LK 66 | for j = 1:LK 67 | c(b(i),b(j)) = cK(i,j); 68 | end 69 | E(b(i)) = EK(i); 70 | Kodep(b(i)) = xK(blk); 71 | end 72 | iK = iK + LK; 73 | end 74 | 75 | t2 = toc; tic; 76 | 77 | %-------------------------------------------------------------------------- 78 | % Sort the states in ascending order in Energies and shift the Energies. 79 | 80 | % Sort Energies + c + Kode 81 | [E(1:L),c(1:L,1:L),Kodep(1:L)] = Esort(E(1:L),c(1:L,1:L),Kodep(1:L),L); 82 | 83 | % Keep only the first KEPT states and ignore the other states 84 | K = L; 85 | if (L>KEPT) 86 | L=KEPT; 87 | end 88 | 89 | % Imposing degeneracy on nearly degenate energy states 90 | if (IMPOSE) 91 | E(1:L) = Impose(E(1:L),L,SMALL); 92 | end 93 | 94 | % Shift energies such that the ground state has an energy of 0 95 | E(1:L) = E(1:L) - E(1); 96 | 97 | t3 = toc; tic; 98 | 99 | %-------------------------------------------------------------------------- 100 | 101 | % Rotate the Matrices for the fdag_{u,d} Operators - to be used in next It. 102 | fdag_u(1:L,1:L) = c(1:K,1:L)'*fdag_u(1:K,1:K)*c(1:K,1:L); 103 | fdag_d(1:L,1:L) = c(1:K,1:L)'*fdag_d(1:K,1:K)*c(1:K,1:L); 104 | 105 | % ------------------------------------------------------------------------- 106 | 107 | % Extract Qtm. Nos. Sz and Q for printing 108 | [Sz(1:L),Q(1:L)] = dekode(Kodep(1:L)); 109 | 110 | % Rotate Matrix using Unitary transf. and save it for next It. 111 | if (OPMAT) 112 | for i = 1:NOP 113 | op_n(1:L,1:L,i) = c(1:K,1:L)'*op(1:K,1:K,i)*c(1:K,1:L); 114 | end 115 | end 116 | 117 | % Compute Thermodynamics of the system 118 | if (THERMO) 119 | Thermodynamics(); 120 | end 121 | 122 | t4 = toc; 123 | 124 | % End of Iteration. Print out energy levels and Thermodynamics 125 | ITend(); 126 | 127 | % The times calculated are as follows: 128 | % t1: Set up H, fdag_{u,d}, Kodep; t2 : Block diagonalizing H; 129 | % t3: Sort and shift E, t4: Thermodynamics + Opmat + Printing. 130 | fprintf(FNOUT, 'Elapsed Time = %8.5f + %8.5f +%8.5f + %8.5f = %8.5f \n\n', t1, t2, t3, t4, t1+t2+t3+t4 ); 131 | -------------------------------------------------------------------------------- /Iteration_0_2IK.m: -------------------------------------------------------------------------------- 1 | it = 0; % Iteration 0 2 | 3 | tic; 4 | 5 | % This code is a modified version of a problem that deals with a generic 6 | % Imp. cluster consisting of spin d.o.f's. 7 | % NS : No. of spins in the Imp. cluster. 8 | % LS : No. of links in the spin cluster. 9 | % LF = No. of links between f0 site and Imp. cluster. 10 | NS = 2; LS = 3; LF = 2; 11 | 12 | site1 = zeros(1,LS); 13 | site2 = zeros(1,LS); 14 | alpha = zeros(1,LS); 15 | J = zeros(1,LS); 16 | 17 | % Def. of Kitaev Cluster 18 | site1(1:LS) = [1 1 1]; 19 | site2(1:LS) = [2 2 2]; 20 | alpha(1:LS) = [1 2 3]; 21 | J(1:LS) = J12; 22 | 23 | % Def. of f0- links to the cluster 24 | sitef = zeros(1,LF); JK = zeros(1,LF); 25 | % It is assumed that sitef = [1 2 3 4 ..] etc. 26 | % It needs to be changed according to the resp. model. 27 | for i = 1:LF 28 | sitef(i) = i; 29 | end 30 | JK(1) = Jk1; JK(2) = Jk2; 31 | 32 | L = 2^NS; 33 | 34 | % Set up the Hamiltonian for the Imp. cluster. 35 | for i = 0:(L-1) 36 | z = dec2dual(i,NS); 37 | for j = 1:LS 38 | p = site1(j); 39 | q = site2(j); 40 | i_prime = i + (1-2*z(p))*2^(p-1) + (1-2*z(q))*2^(q-1); 41 | if (alpha(j) == 1) 42 | H(i_prime+1,i+1) = H(i_prime+1,i+1) + 0.25*J(j); 43 | end 44 | if (alpha(j) == 2) 45 | H(i_prime+1,i+1) = H(i_prime+1,i+1) - 0.25*J(j)*(2*z(p)-1)*(2*z(q)-1); 46 | end 47 | if (alpha(j) == 3) 48 | H(i+1,i+1) = H(i+1,i+1) + 0.25*J(j)*(2*z(p)-1)*(2*z(q)-1); 49 | end 50 | end 51 | end 52 | 53 | % Copy the Imp. Hamiltonian into Diagonal Blocks. 54 | H(L+1:2*L,L+1:2*L) = H(1:L,1:L); 55 | H(2*L+1:3*L,2*L+1:3*L) = H(1:L,1:L); 56 | H(3*L+1:4*L,3*L+1:4*L) = H(1:L,1:L); 57 | 58 | % Set up the Hamiltonian for Imp.-f0 links 59 | for i = 0:(L*F_NS-1) 60 | k = mod(i,2^NS); % k = 0,1: spin config. of Imp. site(s). 61 | z = dec2dual(k,NS); % z : spin rep. of Imp. site(s) 62 | q = (i-k)/2^NS; % q = 0,1,2,3 : config. of f0 site. 63 | 64 | for j = 1:LF 65 | p = sitef(j); % p = Imp. cluster site index. 66 | 67 | % z component interactions 68 | if(q == 1 || q == 2) % q = 1 : ^, q = 2 : v 69 | H(i+1,i+1) = H(i+1,i+1) + 0.25*JK(j)*(2*z(p)-1)*(3-2*q); 70 | end 71 | % x,y components interactions. 72 | if((2*z(p)-1) + (3-2*q) == 0) 73 | i_prime = (3-q)*2^NS + k + (1-2*z(p))*2^(p-1); 74 | H(i_prime+1,i+1) = H(i_prime+1,i+1) + 0.5*JK(j); 75 | end 76 | end 77 | end 78 | 79 | % Set up Qtm. Nos. 2Sz and Q for Imp. cluster. 80 | % For Kitaev Imps. Sz is not conserved. So Sz is assumed to be 0 for all 81 | % basis states. 82 | for i = 1:L 83 | z = dec2dual(i-1,NS); 84 | Sz(i) = sum(2*z-1); Q(i) = 0; 85 | end 86 | Kodep(1:L) = enkode(Sz(1:L),Q(1:L)); 87 | 88 | % Set up the matrices for fdag_{u,d} for It. 0. 89 | fdag_u(1:L*F_NS,1:L*F_NS) = 0.0; fdag_d(1:L*F_NS,1:L*F_NS) = 0.0; 90 | fdag_u(L+1:2*L,1:L) = eye(L); fdag_u(3*L+1:4*L,2*L+1:3*L) = eye(L); 91 | fdag_d(2*L+1:3*L,1:L) = eye(L); fdag_d(3*L+1:4*L,L+1:2*L) = -eye(L); 92 | 93 | % Assign the Kodes for all the basis states in terms of Kodes for prev. It. 94 | Kode(1:L) = Kodep(1:L) + delta_enkode(dSz(1),dQ(1)); 95 | Kode(L+1:2*L) = Kodep(1:L) + delta_enkode(dSz(2),dQ(2)); 96 | Kode(2*L+1:3*L) = Kodep(1:L) + delta_enkode(dSz(3),dQ(3)); 97 | Kode(3*L+1:4*L) = Kodep(1:L) + delta_enkode(dSz(4),dQ(4)); 98 | 99 | if (OPMAT) 100 | Opmat0_2IK(); Opmat(); 101 | end 102 | 103 | L=L*F_NS; % Increase No. of basis states by F_NS 104 | 105 | t1 = toc; tic; 106 | 107 | % ------------------------------------------------------------------------- 108 | % Block Diagonalize the Hamiltonian. 109 | 110 | % xK : Finds all the unique Kode values. 111 | % nK : No. of unique Kode values. 112 | % iK : Counter that counts the blocks/states computed. 113 | xK = unique(Kode(1:L)); nK = length(xK); iK = 0; 114 | E(1:L) = 0.0; c(1:L,1:L) = 0.0; HK(1:L,1:L) = 0.0; 115 | 116 | % Loop over all blocks 117 | for blk = 1:nK 118 | % Find the position of all the basis states for the Blk. 119 | % b = (b1,b2,..) stores the Pos. of basis states in the original H. 120 | % LK : Dim. of the block k. 121 | b = find(Kode(1:L) == xK(blk)); LK = length(b); 122 | 123 | % Form Hamilton Matrix HQ for the current block k 124 | for i = 1:LK 125 | for j = 1:LK 126 | HK(i,j) = H(b(i),b(j)); 127 | end 128 | end 129 | 130 | % Find eigenvalues and eigenvectors of the Blk. k 131 | [cK(1:LK,1:LK), EK(1:LK)] = eig(HK(1:LK,1:LK),'vector'); 132 | 133 | % Save the Eig. Vec. and Eig. Energies in the original Matrices. 134 | for i = 1:LK 135 | for j = 1:LK 136 | c(b(i),b(j)) = cK(i,j); 137 | end 138 | E(b(i)) = EK(i); 139 | Kodep(b(i)) = xK(blk); 140 | end 141 | iK = iK + LK; 142 | end 143 | 144 | E(1:L) = E(1:L)*Lambda^(-0.5); 145 | 146 | t2 = toc; tic; 147 | 148 | %-------------------------------------------------------------------------- 149 | % Sort the states in ascending order in Energies and shift the Energies. 150 | 151 | % Sort Energies + c + Kode 152 | [E(1:L),c(1:L,1:L),Kodep(1:L)] = Esort(E(1:L),c(1:L,1:L),Kodep(1:L),L); 153 | 154 | % Keep only the first KEPT states and ignore the other states 155 | K = L; 156 | if(L>KEPT) 157 | L=KEPT; 158 | end 159 | 160 | % Imposing degeneracy on nearly degenate energy states 161 | if (IMPOSE) 162 | E(1:L) = Impose(E(1:L),L,SMALL); 163 | end 164 | 165 | % Shift energies such that the ground state has an energy of 0 166 | E(1:L) = E(1:L) - E(1); 167 | 168 | t3 = toc; tic; 169 | 170 | %-------------------------------------------------------------------------- 171 | 172 | % Rotate the Matrices for the fdag_{u,d} Operators - to be used in next It. 173 | fdag_u(1:L,1:L) = c(1:K,1:L)'*fdag_u(1:K,1:K)*c(1:K,1:L); 174 | fdag_d(1:L,1:L) = c(1:K,1:L)'*fdag_d(1:K,1:K)*c(1:K,1:L); 175 | 176 | % ------------------------------------------------------------------------- 177 | 178 | % Extract Qtm. Nos. Sz and Q for printing 179 | [Sz(1:L),Q(1:L)] = dekode(Kodep(1:L)); 180 | 181 | % Compute Operator Matrix elements 182 | if (OPMAT) 183 | % Rotate Matrix using Unitary transf. and save it for next It. 184 | op_n(1:L,1:L) = c(1:K,1:L)'*op(1:K,1:K)*c(1:K,1:L); 185 | end 186 | 187 | % Compute Thermodynamics of the system 188 | if (THERMO) 189 | Thermodynamics(); 190 | end 191 | 192 | t4 = toc; 193 | 194 | % End of Iteration. Print out energy levels and Thermodynamics 195 | ITend(); 196 | 197 | % The times calculated are as follows: 198 | % t1: Set up H, fdag_{u,d}, Kodep; t2 : Block diagonalizing H; 199 | % t3: Sort and shift E, t4: Thermodynamics + Opmat + Printing. 200 | fprintf(FNOUT, 'Elapsed Time = %8.5f + %8.5f +%8.5f + %8.5f = %8.5f \n\n', t1, t2, t3, t4, t1+t2+t3+t4 ); 201 | -------------------------------------------------------------------------------- /Iteration_0_Anderson.m: -------------------------------------------------------------------------------- 1 | it = 0; % Iteration 0 2 | 3 | tic; 4 | 5 | % This code deals with an Anderson Impurity. 6 | 7 | % L = Initial conf. of the Imp. 8 | L = 4; 9 | 10 | % Set up the matrices for ddag_{u,d} for setting up H0. 11 | fdag_u(1:L,1:L) = 0; fdag_d(1:L,1:L) = 0; 12 | fdag_u(2,1) = 1; fdag_u(4,3) = 1; 13 | fdag_d(3,1) = 1; fdag_d(4,2) = -1; 14 | 15 | % Set up the Hamiltonian Matrix elements for current It. 16 | H(1:L*F_NS,1:L*F_NS) = 0.0; 17 | H(1:L,L+1:2*L) = Gamma*fdag_u(1:L,1:L); 18 | H(2*L+1:3*L,3*L+1:4*L) = -Gamma*fdag_u(1:L,1:L); 19 | H(1:L,2*L+1:3*L) = Gamma*fdag_d(1:L,1:L); 20 | H(L+1:2*L,3*L+1:4*L) = Gamma*fdag_d(1:L,1:L); 21 | 22 | % Symmetrize the Hamiltonian 23 | H = H+H'; 24 | % Set up main diagonal entries 25 | for i=0:F_NS-1 26 | H(i*F_NS+2,i*F_NS+2) = ed; H(i*F_NS+3,i*F_NS+3) = ed; 27 | H(i*F_NS+4,i*F_NS+4) = 2*ed+U; 28 | end 29 | 30 | % Set up Qtm. Nos. 2Sz and Q for Imp. levels. 31 | Sz(1:L) = [0 1 -1 0]; Q(1:L) = [-1 0 0 1]; 32 | Kodep(1:L) = enkode(Sz(1:L),Q(1:L)); 33 | 34 | % Set up the matrices for fdag_{u,d} for It. 0. 35 | fdag_u(1:L*F_NS,1:L*F_NS) = 0.0; fdag_d(1:L*F_NS,1:L*F_NS) = 0.0; 36 | fdag_u(L+1:2*L,1:L) = eye(L); fdag_u(3*L+1:4*L,2*L+1:3*L) = eye(L); 37 | fdag_d(2*L+1:3*L,1:L) = eye(L); fdag_d(3*L+1:4*L,L+1:2*L) = -eye(L); 38 | 39 | % Assign the Kodes for all the basis states in terms of Kodes for prev. It. 40 | Kode(1:L) = Kodep(1:L) + delta_enkode(dSz(1),dQ(1)); 41 | Kode(L+1:2*L) = Kodep(1:L) + delta_enkode(dSz(2),dQ(2)); 42 | Kode(2*L+1:3*L) = Kodep(1:L) + delta_enkode(dSz(3),dQ(3)); 43 | Kode(3*L+1:4*L) = Kodep(1:L) + delta_enkode(dSz(4),dQ(4)); 44 | 45 | if (OPMAT) 46 | Opmat0_Anderson(); Opmat(); 47 | end 48 | 49 | L=L*F_NS; % Increase No. of basis states by F_NS 50 | 51 | t1 = toc; tic; 52 | 53 | % ------------------------------------------------------------------------- 54 | % Block Diagonalize the Hamiltonian. 55 | 56 | % xK : Finds all the unique Kode values. 57 | % nK : No. of unique Kode values. 58 | % iK : Counter that counts the blocks/states computed. 59 | xK = unique(Kode(1:L)); nK = length(xK); iK = 0; 60 | E(1:L) = 0.0; c(1:L,1:L) = 0.0; HK(1:L,1:L) = 0.0; 61 | 62 | % Loop over all blocks 63 | for blk = 1:nK 64 | % Find the position of all the basis states for the Blk. 65 | % b = (b1,b2,..) stores the Pos. of basis states in the original H. 66 | % LK : Dim. of the block k. 67 | b = find(Kode(1:L) == xK(blk)); LK = length(b); 68 | 69 | % Form Hamilton Matrix HQ for the current block k 70 | for i = 1:LK 71 | for j = 1:LK 72 | HK(i,j) = H(b(i),b(j)); 73 | end 74 | end 75 | 76 | % Find eigenvalues and eigenvectors of the Blk. k 77 | [cK(1:LK,1:LK), EK(1:LK)] = eig(HK(1:LK,1:LK),'vector'); 78 | 79 | % Save the Eig. Vec. and Eig. Energies in the original Matrices. 80 | for i = 1:LK 81 | for j = 1:LK 82 | c(b(i),b(j)) = cK(i,j); 83 | end 84 | E(b(i)) = EK(i); 85 | Kodep(b(i)) = xK(blk); 86 | end 87 | iK = iK + LK; 88 | end 89 | 90 | E(1:L) = E(1:L)*Lambda^(-0.5); 91 | 92 | t2 = toc; tic; 93 | 94 | %-------------------------------------------------------------------------- 95 | % Sort the states in ascending order in Energies and shift the Energies. 96 | 97 | % Sort Energies + c + Kode 98 | [E(1:L),c(1:L,1:L),Kodep(1:L)] = Esort(E(1:L),c(1:L,1:L),Kodep(1:L),L); 99 | 100 | % Keep only the first KEPT states and ignore the other states 101 | K = L; 102 | if(L>KEPT) 103 | L=KEPT; 104 | end 105 | 106 | % Imposing degeneracy on nearly degenate energy states 107 | if (IMPOSE) 108 | E(1:L) = Impose(E(1:L),L,SMALL); 109 | end 110 | 111 | % Shift energies such that the ground state has an energy of 0 112 | E(1:L) = E(1:L) - E(1); 113 | 114 | t3 = toc; tic; 115 | 116 | %-------------------------------------------------------------------------- 117 | 118 | % Rotate the Matrices for the fdag_{u,d} Operators - to be used in next It. 119 | fdag_u(1:L,1:L) = c(1:K,1:L)'*fdag_u(1:K,1:K)*c(1:K,1:L); 120 | fdag_d(1:L,1:L) = c(1:K,1:L)'*fdag_d(1:K,1:K)*c(1:K,1:L); 121 | 122 | % ------------------------------------------------------------------------- 123 | 124 | % Extract Qtm. Nos. Sz and Q for printing 125 | [Sz(1:L),Q(1:L)] = dekode(Kodep(1:L)); 126 | 127 | % Compute Operator Matrix elements 128 | if (OPMAT) 129 | % Rotate Matrix using Unitary transf. and save it for next It. 130 | op_n(1:L,1:L) = c(1:K,1:L)'*op(1:K,1:K)*c(1:K,1:L); 131 | end 132 | 133 | % Compute Thermodynamics of the system 134 | if (THERMO) 135 | Thermodynamics(); 136 | end 137 | 138 | t4 = toc; 139 | 140 | % End of Iteration. Print out energy levels and Thermodynamics 141 | ITend(); 142 | 143 | % The times calculated are as follows: 144 | % t1: Set up H, fdag_{u,d}, Kodep; t2 : Block diagonalizing H; 145 | % t3: Sort and shift E, t4: Thermodynamics + Opmat + Printing. 146 | fprintf(FNOUT, 'Elapsed Time = %8.5f + %8.5f +%8.5f + %8.5f = %8.5f \n\n', t1, t2, t3, t4, t1+t2+t3+t4 ); 147 | -------------------------------------------------------------------------------- /Iteration_0_Kondo.m: -------------------------------------------------------------------------------- 1 | it = 0; % Iteration 0 2 | 3 | tic; 4 | 5 | % This code is a modified version of a problem that deals with a generic 6 | % Imp. cluster consisting of spin d.o.f's. 7 | % NS : No. of spins in the Imp. cluster. 8 | % LS : No. of links in the spin cluster. 9 | % LF = No. of links between f0 site and Imp. cluster. 10 | NS = 1; LS = 0; LF = 1; 11 | 12 | L = 2^NS; 13 | 14 | % Set up the Hamiltonian for Imp.-f0 links 15 | for i = 0:(L*F_NS-1) 16 | k = mod(i,2^NS); % k = 0,1: spin config. of Imp. site(s). 17 | z = dec2dual(k,NS); % z : spin rep. of Imp. site(s) 18 | q = (i-k)/2^NS; % q = 0,1,2,3 : config. of f0 site. 19 | p = 1; % p = Imp. cluster site index. 20 | 21 | % z component interactions 22 | if(q == 1 || q == 2) % q = 1 : ^, q = 2 : v 23 | H(i+1,i+1) = H(i+1,i+1) + 0.25*Jk*(2*z(p)-1)*(3-2*q); 24 | end 25 | % x,y components interactions. 26 | if((2*z(p)-1) + (3-2*q) == 0) 27 | i_prime = (3-q)*2^NS + k + (1-2*z(p))*2^(p-1); 28 | H(i_prime+1,i+1) = H(i_prime+1,i+1) + 0.5*Jk; 29 | end 30 | end 31 | 32 | % Set up Qtm. Nos. 2Sz and Q for Imp. cluster. 33 | for i = 1:L 34 | z = dec2dual(i-1,NS); 35 | Sz(i) = sum(2*z-1); Q(i) = 0; 36 | end 37 | Kodep(1:L) = enkode(Sz(1:L),Q(1:L)); 38 | 39 | % Set up the matrices for fdag_{u,d} for It. 0. 40 | fdag_u(1:L*F_NS,1:L*F_NS) = 0.0; fdag_d(1:L*F_NS,1:L*F_NS) = 0.0; 41 | fdag_u(L+1:2*L,1:L) = eye(L); fdag_u(3*L+1:4*L,2*L+1:3*L) = eye(L); 42 | fdag_d(2*L+1:3*L,1:L) = eye(L); fdag_d(3*L+1:4*L,L+1:2*L) = -eye(L); 43 | 44 | Kode(1:L) = Kodep(1:L) + delta_enkode(dSz(1),dQ(1)); 45 | Kode(L+1:2*L) = Kodep(1:L) + delta_enkode(dSz(2),dQ(2)); 46 | Kode(2*L+1:3*L) = Kodep(1:L) + delta_enkode(dSz(3),dQ(3)); 47 | Kode(3*L+1:4*L) = Kodep(1:L) + delta_enkode(dSz(4),dQ(4)); 48 | 49 | if (OPMAT) 50 | Opmat0_Kondo(); Opmat(); 51 | end 52 | 53 | L=L*F_NS; % Increase No. of basis states by F_NS 54 | 55 | t1 = toc; tic; 56 | 57 | % ------------------------------------------------------------------------- 58 | % Block Diagonalize the Hamiltonian. 59 | 60 | % xK : Finds all the unique Kode values. 61 | % nK : No. of unique Kode values. 62 | % iK : Counter that counts the blocks/states computed. 63 | xK = unique(Kode(1:L)); nK = length(xK); iK = 0; 64 | E(1:L) = 0.0; c(1:L,1:L) = 0.0; HK(1:L,1:L) = 0.0; 65 | 66 | % Loop over all blocks 67 | for blk = 1:nK 68 | % Find the position of all the basis states for the Blk. 69 | % b = (b1,b2,..) stores the Pos. of basis states in the original H. 70 | % LK : Dim. of the block k. 71 | b = find(Kode(1:L) == xK(blk)); LK = length(b); 72 | 73 | % Form Hamilton Matrix HQ for the current block k 74 | for i = 1:LK 75 | for j = 1:LK 76 | HK(i,j) = H(b(i),b(j)); 77 | end 78 | end 79 | 80 | % Find eigenvalues and eigenvectors of the Blk. k 81 | [cK(1:LK,1:LK), EK(1:LK)] = eig(HK(1:LK,1:LK),'vector'); 82 | 83 | % Save the Eig. Vec. and Eig. Energies in the original Matrices. 84 | for i = 1:LK 85 | for j = 1:LK 86 | c(b(i),b(j)) = cK(i,j); 87 | end 88 | E(b(i)) = EK(i); 89 | Kodep(b(i)) = xK(blk); 90 | end 91 | iK = iK + LK; 92 | end 93 | 94 | E(1:L) = E(1:L)*Lambda^(-0.5); 95 | 96 | t2 = toc; tic; 97 | 98 | %-------------------------------------------------------------------------- 99 | % Sort the states in ascending order in Energies and shift the Energies. 100 | 101 | % Sort Energies + c + Kode 102 | [E(1:L),c(1:L,1:L),Kodep(1:L)] = Esort(E(1:L),c(1:L,1:L),Kodep(1:L),L); 103 | 104 | % Keep only the first KEPT states and ignore the other states 105 | K = L; 106 | if(L>KEPT) 107 | L=KEPT; 108 | end 109 | 110 | % Imposing degeneracy on nearly degenate energy states 111 | if (IMPOSE) 112 | E(1:L) = Impose(E(1:L),L,SMALL); 113 | end 114 | 115 | % Shift energies such that the ground state has an energy of 0 116 | E(1:L) = E(1:L) - E(1); 117 | 118 | t3 = toc; tic; 119 | 120 | %-------------------------------------------------------------------------- 121 | 122 | % Rotate the Matrices for the fdag_{u,d} Operators - to be used in next It. 123 | fdag_u(1:L,1:L) = c(1:K,1:L)'*fdag_u(1:K,1:K)*c(1:K,1:L); 124 | fdag_d(1:L,1:L) = c(1:K,1:L)'*fdag_d(1:K,1:K)*c(1:K,1:L); 125 | 126 | % ------------------------------------------------------------------------- 127 | 128 | % Extract Qtm. Nos. Sz and Q for printing 129 | [Sz(1:L),Q(1:L)] = dekode(Kodep(1:L)); 130 | 131 | % Compute Operator Matrix elements 132 | if (OPMAT) 133 | % Rotate Matrix using Unitary transf. and save it for next It. 134 | op_n(1:L,1:L) = c(1:K,1:L)'*op(1:K,1:K)*c(1:K,1:L); 135 | end 136 | 137 | % Compute Thermodynamics of the system 138 | if (THERMO) 139 | Thermodynamics(); 140 | end 141 | 142 | t4 = toc; 143 | 144 | % End of Iteration. Print out energy levels and Thermodynamics 145 | ITend(); 146 | 147 | % The times calculated are as follows: 148 | % t1: Set up H, fdag_{u,d}, Kodep; t2 : Block diagonalizing H; 149 | % t3: Sort and shift E, t4: Thermodynamics + Opmat + Printing. 150 | fprintf(FNOUT, 'Elapsed Time = %8.5f + %8.5f +%8.5f + %8.5f = %8.5f \n\n', t1, t2, t3, t4, t1+t2+t3+t4 ); 151 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Tathagata Chowdhury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NRG.m: -------------------------------------------------------------------------------- 1 | function NRG() 2 | 3 | % Load Input parameters. 4 | Input_Variables(); 5 | 6 | % Declare Run Variables. 7 | Parms(); 8 | 9 | % Open output files 10 | Open_Files(); 11 | 12 | % Set timer 13 | t0 = cputime; 14 | 15 | % Iteration 0 16 | if (strcmp(MODEL,'KO')) 17 | Iteration_0_Kondo(); 18 | elseif (strcmp(MODEL,'AN')) 19 | Iteration_0_Anderson(); 20 | elseif (strcmp(MODEL,'2IK')) 21 | Iteration_0_2IK(); 22 | end 23 | 24 | % ========================================================================= 25 | 26 | % NRG Iterations 27 | for it=1:ITMAX 28 | 29 | % Set up hopping coeffecients 30 | n = it-1; 31 | t = (1+Lambda^-1)*(1-Lambda^(-n-1))/(2*sqrt(1-Lambda^(-2*n-1))*sqrt(1-Lambda^(-2*n-3))); 32 | 33 | % Set up the Hamiltonian and Diagonalize. 34 | Iteration(); 35 | 36 | end 37 | 38 | if (THERMO) 39 | % Print out average thermodynamics 40 | for it=1:ITMAX-1 41 | savg(it+1) = 0.25*(s(it)+2*s(it+1)+s(it+2)); simp(it+1) = savg(it+1) - s0(it+1); 42 | tchiavg(it+1)= 0.25*(tchi(it)+2*tchi(it+1)+tchi(it+2)); tchiimp(it+1) = tchiavg(it+1) - tchi0(it+1); 43 | Cvavg(it+1) = 0.25*(Cv(it)+2*Cv(it+1)+Cv(it+2)); Cvimp(it+1) = Cvavg(it+1) - Cv0(it+1); 44 | fprintf(FNTHERMAVG, '%14.6e %14.8f %14.8f %14.8f \n', temp(it+1), simp(it+1), tchiimp(it+1), Cvimp(it+1)); 45 | end 46 | 47 | % Find T_k/T_c 48 | if(FIND_Tk) 49 | Tk = 0.0; 50 | found = false; i = 2; simp_cr = 0.5*(Simp_UL+Simp_LL); 51 | while (found == false && i simp_cr && simp(i+1) < simp_cr) 53 | found = true; 54 | Tk = exp(log(temp(i+1)) + (log(temp(i))-log(temp(i+1)))*(simp_cr-simp(i+1))/(simp(i)-simp(i+1))); 55 | end 56 | i = i+1; 57 | end 58 | fprintf(FNOUT,'Kondo/Crossover Temp. T_K = %12.4e \n', Tk); 59 | end 60 | end 61 | 62 | % Print the total time for the run. 63 | tf = cputime; 64 | fprintf(FNOUT, 'Total time = %8.4f \n', tf-t0); 65 | 66 | % Close all output files 67 | Close_Files 68 | 69 | % Plot Energies and Thermodynamics 70 | Plot_Figures 71 | 72 | end 73 | -------------------------------------------------------------------------------- /Open_Files.m: -------------------------------------------------------------------------------- 1 | % Open output files ======================================================= 2 | 3 | % out.dat : Print out Energies 4 | % even.dat/odd.dat : Print out Energies for even/odd It. 5 | % Therm.dat : Print out Thermodynamic qts. , , vs Temp. 6 | % Thermavg.dat : Print out 3-pt. avgs , , vs Temp. 7 | % OpTherm.dat: Print out the expectation values of the Imp. Operators. 8 | 9 | %-------------------------------------------------------------------------- 10 | 11 | FNOUT = fopen('out.dat' ,'w+'); 12 | if (EO_PRINT) 13 | FNEVEN = fopen('even.dat','w+'); FNODD = fopen('odd.dat' ,'w+'); 14 | end 15 | if(THERMO) 16 | FNTHERM = fopen('Therm.dat','w+'); FNTHERMAVG = fopen('Thermavg.dat','w+'); 17 | end 18 | if (OPMAT) 19 | FNOPMAT = fopen('OpTherm.dat', 'w+'); 20 | end 21 | 22 | % ------------------------------------------------------------------------- 23 | 24 | % OPTIONAL ---------------------------------------------------------------- 25 | % Choose filename according to Jk (or other parameter) values. 26 | 27 | % file_out = num2str(Jk,'out_Jk=%5.3f.dat'); 28 | % FNOUT = fopen(file_out ,'w+'); 29 | % 30 | % if (EO_PRINT) 31 | % file_even = num2str(Jk,'even_Jk=%5.3f.dat'); 32 | % file_odd = num2str(Jk,'odd_Jk=%5.3f.dat'); 33 | % FNEVEN = fopen(file_even,'w+'); FNODD = fopen(file_odd ,'w+'); 34 | % end 35 | % 36 | % if(THERMO) 37 | % file_therm = num2str(Jk,'Therm_Jk=%5.3f.dat'); 38 | % file_thermavg = num2str(Jk,'Thermavg_Jk=%5.3f.dat'); 39 | % FNTHERM = fopen(file_Therm,'w+'); FNTHERMAVG = fopen(file_thermavg,'w+'); 40 | % end 41 | % 42 | % if (OPMAT) 43 | % file_optherm = num2str(Jk,'OpTherm_Jk=%5.3f.dat'); 44 | % FNOPMAT = fopen(file_optherm, 'w+'); 45 | % end 46 | %-------------------------------------------------------------------------- 47 | 48 | % Print out header information ============================================ 49 | 50 | % out.dat: 51 | if (strcmp(MODEL,'KO')) 52 | header_line = '1-Imp. 1-Channel Kondo Model \n'; 53 | elseif (strcmp(MODEL,'AN')) 54 | header_line = '1-Imp. 1-Channel Anderson Model \n'; 55 | elseif (strcmp(MODEL,'2IK')) 56 | header_line = '2-Imp. 1-Channel Kondo Model \n'; 57 | end 58 | 59 | fprintf(FNOUT,header_line); clear header_line; 60 | 61 | if (strcmp(MODEL,'KO')) 62 | fprintf(FNOUT,'Jk = %8.4f \n', Jk); 63 | elseif (strcmp(MODEL,'AN')) 64 | fprintf(FNOUT,'Ed = %8.4f, U = %8.4f, Gamma = %8.4f \n ', ed, U, Gamma); 65 | elseif (strcmp(MODEL,'2IK')) 66 | fprintf(FNOUT,'J1 = %8.4f, J2 = %8.4f, J12 = %8.4f \n', Jk1, Jk2, J12); 67 | end 68 | 69 | fprintf(FNOUT, 'Lambda = %5.3f, KEPT = %4i, ITMAX = %3i \n \n', Lambda,KEPT,ITMAX); 70 | 71 | % Therm.dat: , , 72 | if (THERMO) 73 | fprintf(FNTHERM, '# %3s %10s %12s %16s %12s \n', 'It','Temp.','','','Cv'); 74 | fprintf(FNTHERM, '#---------------------------------------------------------------\n'); 75 | fprintf(FNTHERMAVG,'# %10s %12s %16s %12s \n', 'Temp.','S_avg','TChi_avg','Cv_avg'); 76 | fprintf(FNTHERMAVG,'#- --------------------------------------------------------\n'); 77 | end 78 | 79 | % even.dat + odd.dat 80 | if (EO_PRINT) 81 | fprintf(FNODD, '#it'); fprintf(FNEVEN, '#it'); 82 | for i = 1:ENMAX_PR 83 | fprintf(FNODD, ' E%2i ',i); fprintf(FNEVEN, ' E%2i ',i); 84 | end 85 | fprintf(FNODD, '\n'); fprintf(FNEVEN, '\n'); 86 | end 87 | %-------------------------------------------------------------------------- 88 | 89 | if (THERMO) 90 | % Read Thermodynamics of fermionic chain from band file 91 | 92 | delimiterIn = ' '; headerlinesIn = 2; 93 | A = importdata('therm.data', delimiterIn,headerlinesIn); 94 | [band_itmax, ncol]=size(A.data); 95 | for i = 1:band_itmax 96 | s0(i+1)= A.data(i,2); tchi0(i+1)= A.data(i,3); Cv0(i+1)= A.data(i,4); 97 | %temp0(it) = A.data(i-1,2); 98 | end 99 | 100 | % Check if ITMAX of band file = ITMAX of current run. 101 | % If not, make sure (manually) that band file has converged and fill the 102 | % rest of the values with the last entry. 103 | if (ITMAX > band_itmax) 104 | for it = band_itmax+1:ITMAX 105 | s0(it) = s0(band_itmax); tchi0(it) = tchi0(band_itmax); Cv0(it) = Cv0(band_itmax); 106 | end 107 | end 108 | clear A; 109 | end 110 | 111 | %========================================================================== -------------------------------------------------------------------------------- /Opmat.m: -------------------------------------------------------------------------------- 1 | op(1:L*F_NS,1:L*F_NS,1:NOP) = 0.0; 2 | op(1:L,1:L,1:NOP) = op_n(1:L,1:L,1:NOP); 3 | op(L+1:2*L,L+1:2*L,1:NOP) = op_n(1:L,1:L,1:NOP); 4 | op(2*L+1:3*L,2*L+1:3*L,1:NOP) = op_n(1:L,1:L,1:NOP); 5 | op(3*L+1:4*L,3*L+1:4*L,1:NOP) = op_n(1:L,1:L,1:NOP); 6 | 7 | -------------------------------------------------------------------------------- /Opmat0_2IK.m: -------------------------------------------------------------------------------- 1 | % Definition of Operator(s) whose expectation values are to be calculated. 2 | % Op = 3 | for i = 0:(L-1) 4 | z = dec2dual(i,NS); 5 | 6 | p = 1; 7 | q = 2; 8 | 9 | op_n(i+1,i+1) = op_n(i+1,i+1) + 0.25*(2*z(p)-1)*(2*z(q)-1); 10 | 11 | if (z(p) + z(q) == 1) 12 | i_prime = i + (1-2*z(p))*2^(p-1) + (1-2*z(q))*2^(q-1); 13 | op_n(i_prime+1,i+1) = op_n(i_prime+1,i+1) + 0.5; 14 | end 15 | end -------------------------------------------------------------------------------- /Opmat0_Anderson.m: -------------------------------------------------------------------------------- 1 | % Definition of Operator(s) whose expectation values are to be calculated. 2 | % Op = 3 | op_n(2,2) = 1; op_n(3,3) = 1; op_n(4,4) = 2; -------------------------------------------------------------------------------- /Opmat0_Kondo.m: -------------------------------------------------------------------------------- 1 | % Definition of Operator(s) whose expectation values are to be calculated. 2 | % Op = 3 | op_n(1:L,1:L) = [1/4 0; 0 1/4]; -------------------------------------------------------------------------------- /Parms.m: -------------------------------------------------------------------------------- 1 | % Declaration of Run variables ============================================ 2 | % 3 | % RUN VARIABLES------------------------------------------------------------ 4 | % F_NS : D.o.f of each site of the fermionic chain. 5 | % For a One-channel chain, the states are {|0>, |-1>, |1>, |2>}. 6 | % 7 | % MAXDIM = F_NS*KEPT : Max. dim. of Hamiltonian matrix. 8 | % H(MAXDIM,MAXDIM) : Hamiltonian Matrix. 9 | % c(MAXDIM,MAXDIM) : Coeff. of eigenvectors after diagonalization. 10 | % E(MAXDIM) : Array that stores Energies before and after sorting. 11 | % MAXBLKDIM = KEPT: Max, dim. of a Hamiltonian block. 12 | % HK(MAXBLKDIM,MAXBLKDIM) : Hamiltonain Matrix. of a Blk. 13 | % cK(MAXBLKDIM,MAXBLKDIM) : Coeff. of eigenvectors after Blk. diag. 14 | % EK(MAXBLKDIM) : Array that stores Energies after Blk. diag. 15 | % fdag_u(MAXDIM,MAXDIM) : Matrix rep. of fdag_u at each It. 16 | % fdag_d(MAXDIM,MAXDIM) : Matrix rep. of fdag_u at each It. 17 | % 18 | % QTM NOS.----------------------------------------------------------------- 19 | % Kode = enkode(Sz,Q) stores the qtm. numbers 2Sz and Q together. 20 | % They can be retrieved using [Sz,Q] = dekode(Kode) 21 | % Kode(MAXDIM) : Stores the Kode of of each state in the current iteration. 22 | % Kodep(MAXDIM): Stores the Kode of of each state in the prev. iteration. 23 | % Sz(MAXDIM) : Stores Qtm. No. 2Sz of the eigenstates. 24 | % Q(MAXDIM) : Stores charge Qtm. No. Q = n^-nv of the eigenstates. 25 | % Sz_good(T/F): Sz is a good Qtm. No. 26 | % Q_good(T/F) : Q is a good Qtm. No. 27 | % dSz/dQ : Change in Sz Qtm. No. for the new basis states. 28 | % (by taking a cross product with the new f0-site). 29 | % 30 | % THERMODYNAMICS----------------------------------------------------------- 31 | % temp(ITMAX+1): Array that stores temp. of each It. 32 | % s(ITMAX+1) : Array that stores Entropy at each It. 33 | % savg(ITMAX+1): Array that stores 3-pt. avg. of . 34 | % tChi(ITMAX+1): Array that stores at each It. 35 | % tchiavg(ITMAX+1) : Array that stores 3-pt. avg. of . 36 | % Cv(ITMAX+1 ) : Array that stores Specific heat at each It. 37 | % Cvavg(ITMAX+1): Array that stores 3-pt. avg. of . 38 | % s0, tchi0, Cv0 : Array that stores resp. thermodynamics from band file 39 | % simp, tchiimp, Cvimp : Imp. contribution to resp. thermodynamic qts. 40 | % 41 | % OPMAT (Operator Matrix Elements)----------------------------------------- 42 | % NOP : No. of Operators. 43 | % op(MAXDIM,MAXDIM,NOP) : Matrix elements ; where i,j are basis 44 | % states of current It. 45 | % op_n(MAXDIM,MAXDIM,NOP): Matrix elements ; where i,j are 46 | % eigenstates. of current It. (to be used to set up Opmat in next It.) 47 | % ========================================================================= 48 | 49 | F_NS = 4; MAXDIM = F_NS*KEPT; MAXBLKDIM = KEPT; 50 | H = zeros(MAXDIM); c = zeros(MAXDIM); E = zeros(MAXDIM,1); 51 | HK = zeros(MAXBLKDIM); cK = zeros(MAXBLKDIM); EK = zeros(MAXBLKDIM,1); 52 | fdag_u = zeros(MAXDIM); fdag_d = zeros(MAXDIM); 53 | 54 | Kode = zeros(MAXDIM,1); Kodep = zeros(MAXDIM,1); 55 | Sz = zeros(MAXDIM,1) ; Q = zeros(MAXDIM,1); 56 | 57 | if (THERMO) 58 | temp = zeros(ITMAX+1,1); 59 | s = zeros(ITMAX+1,1); savg = zeros(ITMAX+1,1); 60 | tchi = zeros(ITMAX+1,1); tchiavg = zeros(ITMAX+1,1); 61 | Cv = zeros(ITMAX+1,1); Cvavg = zeros(ITMAX+1,1); 62 | s0 = zeros(ITMAX+1,1); simp = zeros(ITMAX+1,1); 63 | tchi0= zeros(ITMAX+1,1); tchiimp = zeros(ITMAX+1,1); 64 | Cv0 = zeros(ITMAX+1,1); Cvimp = zeros(ITMAX+1,1); 65 | end 66 | 67 | if (PLOT_E || EO_PRINT) 68 | EvenE = zeros(int16(ITMAX/2)+1,ENMAX_PL); EvenIt= zeros(int16(ITMAX/2)+1,1); 69 | OddE = zeros(int16(ITMAX/2),ENMAX_PL); OddIt = zeros(int16(ITMAX/2),1); 70 | end 71 | 72 | if (OPMAT) 73 | op = zeros(MAXDIM,MAXDIM,NOP); op_n = zeros(MAXDIM,MAXDIM,NOP); 74 | op_exp = zeros(ITMAX+1,NOP); 75 | end 76 | 77 | Sz_good = true; Q_good = true; 78 | 79 | dSz = [0 0 0 0]; dQ = [0 0 0 0]; 80 | if ( Sz_good == true ) 81 | dSz = [0 1 -1 0]; 82 | end 83 | if (Q_good == true ) 84 | dQ = [-1 0 0 1]; 85 | 86 | end 87 | % ========================================================================= -------------------------------------------------------------------------------- /Plot_Figures.m: -------------------------------------------------------------------------------- 1 | if (PLOT_E) 2 | % Plot first few Even Energy levels 3 | plot(EvenIt,EvenE); 4 | title_txt = ['Energy vs Iterations (EVEN)']; 5 | title(title_txt); 6 | xlabel('Iterations[It]'); 7 | ylabel('Energy[E]'); 8 | 9 | % Plot first few Odd Energy levels 10 | figure; 11 | plot(OddIt,OddE); 12 | title_txt = ['Energy vs Iterations (ODD)']; 13 | title(title_txt); 14 | xlabel('Iterations[It]'); 15 | ylabel('Energy[E]'); 16 | end 17 | 18 | if (PLOT_T) 19 | % Plot Entropy 20 | figure; 21 | semilogx(temp(2:ITMAX),simp(2:ITMAX)); 22 | title_txt = 'Entropy vs Temperature'; 23 | title(title_txt); 24 | xlabel('Temperature[T]'); 25 | ylabel('Entropy[Savg]'); 26 | 27 | % Plot TChi 28 | figure; 29 | semilogx(temp(2:ITMAX),tchiimp(2:ITMAX)); 30 | title_txt = 'TChi vs Temperature'; 31 | title(title_txt); 32 | xlabel('Temperature[T]'); 33 | ylabel('[TChi]'); 34 | 35 | % Plot Specific Heat 36 | figure; 37 | semilogx(temp(2:ITMAX),Cvimp(2:ITMAX)); 38 | title_txt = 'Specific Heat vs Temperature'; 39 | title(title_txt); 40 | xlabel('Temperature[T]'); 41 | ylabel('Specific Heat [Cv]'); 42 | end -------------------------------------------------------------------------------- /Plots/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Plots/Cv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tatha04/Numerical-Renormalization-Group/f9edc696f26bad341617332f32d3672e92b9ce0d/Plots/Cv.png -------------------------------------------------------------------------------- /Plots/Energy_Flows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tatha04/Numerical-Renormalization-Group/f9edc696f26bad341617332f32d3672e92b9ce0d/Plots/Energy_Flows.png -------------------------------------------------------------------------------- /Plots/S.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tatha04/Numerical-Renormalization-Group/f9edc696f26bad341617332f32d3672e92b9ce0d/Plots/S.png -------------------------------------------------------------------------------- /Plots/S12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tatha04/Numerical-Renormalization-Group/f9edc696f26bad341617332f32d3672e92b9ce0d/Plots/S12.png -------------------------------------------------------------------------------- /Plots/Tchi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tatha04/Numerical-Renormalization-Group/f9edc696f26bad341617332f32d3672e92b9ce0d/Plots/Tchi.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Numerical-Renormalization-Group 2 | 3 | ## Introduction 4 | 5 | The Numerical Renormalization Group (NRG) Technique is a non-perturbative numerical method that was primarily developed to solve the Kondo problem. The Kondo problem deals with a situation that arises in metals due to the interaction of the conduction electrons with spin 1/2 magnetic impurities (arising from unpaired electrons in the d or f orbitals). Any perturbative treatment of this problem exhibits logarithmic divergences at characteristic temperatures. The NRG was able to solve this problem to low temperatures and capture the formation of the singlet ground state. Since then, the NRG has been used in a range of applications including magnetic hosts in metallic, semi-metallic and superconducting hosts, quantum dots, heavy fermion systems and quantum phase transitions. 6 | 7 | For references see 8 | * [Kondo effect](http://www.scholarpedia.org/article/Kondo_effect) (Scholarpedia) 9 | * [Reviews of Modern Physics](https://doi.org/10.1103/RevModPhys.80.395) paper by Bulla et. al. 10 | * [The Kondo Problem to Heavy Fermions](https://doi.org/10.1017/CBO9780511470752) by A. C. Hewson. 11 | * [Computational Physics Blog](https://compphys.go.ro/the-numerical-renormalization-group/) by Adrian Roman. 12 | 13 | ## Method 14 | The NRG consists of the following key steps: 15 | * Partition of the conduction band into logarithmic bins. 16 | * Mapping the conduction band into a semi-infinite tight binding fermionic chain with nearest neighbor hopping, known as the Wilson chain (WC). The impurity is attached to one end of the WC. 17 | * The hopping coeffecients drop off exponentially, ensuring convergence of the ground state(s). 18 | * Iterative diagonalization of the WC, where an additional site of the WC is added in each iteration. The basis states of the current iteration are formed using the eigenstates of the previous iteration and the basis states of the additional site of the WC. 19 | 20 | ## About the code 21 | This is a relatively simple code in MATLAB that implements the NRG for a flat band (constant density of states). The z-component of the total spin (S_z) and the total charge (Q) can be treated as good quantum numbers. This can be used to block-diagonalize the Hamiltonian matrix for computational efficiency. 22 | The main function that runs the code is NRG(). **For details on code usage, input parameters, and other features, please see the file 'Readme.txt'.** 23 | The code can be used to treat three models: 24 | * The spin 1/2 Kondo model wiht 1 impurity, 25 | * The Anderson Impurity model with 1 impurity, 26 | * Two-impurity Kondo model with inter-impurity coupling. 27 | * The code can be easily extended to treat other complex spin-impurity systems. 28 | 29 | Sample output files for each of the above cases can be found in the corresponding directory under 'Sample_Outputs/' 30 | 31 | ## Output 32 | The output file out.dat prints the renormalized eigen-energies for each iteration along with the corresponding quantum numers. The spectrum is shifted such that the ground energy is zero. The following graphs plots the RG flows of the renormalized energy levels for even and odd iterations for the Kondo model with coupling J_k = 0.2 33 | 34 | ![](./Plots/Energy_Flows.png) 35 | 36 | NRG can also be used to calculate the impurity contribution to themodynamic quantities such as the magnetic susceptibility, entropy and specific heat. The following graphs plots these quantities as a function of temperature for the Kondo model for Kondo coupling Jk = 0.2. 37 | 38 | ![](./Plots/Tchi.png) 39 | ![](./Plots/S.png) 40 | ![](./Plots/Cv.png) 41 | 42 | Additionally, one can slo compute expectation values of impurity operators. As an example, the following graph plots the expectation value of the operator for the two-impurity Kondo model as a function of temperature T. Plots are shown for two values of J12, keeping the Kondo couplings J_k fixed at J_k = 0.3. 43 | 44 | ![](./Plots/S12.png) 45 | 46 | Note: I have used units where the bandwidth D = k_B = hbar = 1. 47 | 48 | ## Updates 49 | The code can be further expanded to include non-uniform density of states, and to deal with multi-channel cases. Further one case also use the Clebsch Gordan coefficients to use total S and the corresponding axial charge operators to further reduce the effective size of the matrices that needs to be diagonalized. The codes will be updated when these changes are implemented. 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /Readme.txt: -------------------------------------------------------------------------------- 1 | USAGE: 2 | ------ 3 | 4 | 1. The program can be run using Matlab. The main function is contained in 5 | the file NRG.m. Thus to run this, change Matlab's working directory 6 | to the directory where all the files are stored. 7 | In Matlab's command window, type NRG(). 8 | If running from a terminal, Matlab can be run without graphics using: 9 | matlab -nodisplay -nojvm 10 | In that case, please set the variables PLOT_T and PLOT_E = false. 11 | 12 | 2. Edit the file Input_Variables.m and select the appropriate model. 13 | eg, FC: Fermionic chain, KO: Kondo Model, etc. 14 | Set the appropriate model parameter(s). 15 | eg, for the Kondo model, set the value of Jk; 16 | for the 2Imp. Kondo model, set the values of Jk1, Jk2, J12; 17 | for the Anderson model, set the values of ed, U, Gamma; etc,.. 18 | and comment out the rest of the input lines. 19 | 20 | 3. For Imp. Thermodynamics, one needs to subtract off the contribution towards 21 | the thermodynamic quantity due to the band alone. 22 | Run NRG for the FERMIONIC CHAIN with THERMO = true. 23 | The necessary files are contained in the directory './FERMIONIC CHAIN' 24 | Ensure that ITMAX is high enough such that the 's have converged. 25 | Make a copy or a symbolic link to file Thermavg.dat and save it as therm.data. 26 | 27 | 4. By default the code assumes that Sz and Q are good Qtm. Nos. In case this 28 | is not true, make necessary changes in file Parms.m so that the values 29 | of the relevant Qtm. No is set to zero for all basis states. 30 | 31 | 32 | Notes and Advanced diagnostics: 33 | ------------------------------ 34 | 35 | 3. Make sure that the variables KEPT (Total number of Kept states), 36 | MAXDIM =4*KEPT (Max. Dimension of the Hamiltonian) for a standard 37 | fermionic chain, and MAXBLKDIM (Max. Dimension of a Block for a 38 | given set of Quantum Nos.) are consistent. 39 | 40 | 4. Logical Variables Sz_good and Q_good determines whether Sz and Q are good 41 | Qtm. Nos. If yes, the the Hamiltonian is broken up into sub-blocks 42 | labelled by the Qtm. Nos. 43 | 44 | 5. Function [kode = enkode(Sz,Q)] and [Sz,Q = dekode(kode)] encodes and decodes 45 | respectively the Qtm. Nos. into a single integer code and vice versa. 46 | Function delta_enkode(dSz,dQ) calculates the change in the kode of the 47 | basis state when taking a cross product with a new fermionic site 48 | with Qtm. Nos dSz and dQ resp. 49 | The kodes of the eigenstates are then saved into the array Kode. 50 | 51 | 6. Let the eigen states for It. N be |i> where i = 1,..,L. 52 | Then the basis states for It. N+1 are as follows (for 1-channel): 53 | |j> = |i> x |0> , j = 1,...,L; |j> = |i> x |^> , j = L+1,...,2L; 54 | |j> = |i> x |v> , j = 2L+1,...,3L; |j> = |i> x |2> , j = 3L+1,...,4L; 55 | 56 | 7. Iteration 0: The file Iteration 0 is different for different Imp. models. 57 | The basis states for It. 0 are as follows: 58 | {[0,..,0], ..,[1,,,,1]} x {|0>, |^>, |v>, |2>}, 59 | where 0:v and 1:^ in the Imp. (spin) part of the Imp. Hamiltonian 60 | representation [first {}], and |0>, |^>, |v>, |2> denote null, up, 61 | down and doubly occupied states, respectively, of the f_0 site. 62 | 63 | 8. For Imp. that are fermionic in nature, the basis states are as follows: 64 | {|0>, |^>, |v>, |2>} x {|0>, |^>, |v>, |2>}. 65 | Situations with more than 1 Fermionic Imp. needs to be implemented. 66 | 67 | 68 | ======================================================================== 69 | 70 | OPTIONAL: 71 | 72 | Imp. Thermodynamics: If the parameter THERMO == TRUE, then the Impurity 73 | contribution to the following quantities are calculated. 74 | Entropy (S), Magnetic Susceptibility (T*\Chi), and Specific Heat (Cv). 75 | These are calculated at the end of each Iterations and the values 76 | are stored in the arrays s, tchi and Cv resp. 77 | At the end of the NRG run, the 3-point averages are calculated 78 | and saved in the arrays savg, tchiavg and Cvavg resp. 79 | Finally the Imp. contribution (simp, tchiimp, and Cvimp) is 80 | calculated by subtracting off the contribution due to bath alone. 81 | 82 | Find_Tk: Calculate the Kondo Temp. or optionally any crossover Temp. 83 | defined as the Temp. at which the entropy crosses half-way 84 | between Simp_UL and Simp_LL. 85 | 86 | Opmat: Calculate Operator matrix elements for 1 or more Operators. 87 | At the end of each iteration, the thermodynamic expectation 88 | value of the Operator(s) is printed. 89 | 90 | ======================================================================= 91 | 92 | Definition of Output and Input Files: 93 | ------------------------------------- 94 | 95 | out.dat: Print out the Renormalized energy levels at the end of each NRG 96 | iteration. Also prints out (i) the time taken for each Iteration, 97 | and (ii) total time taken for the run. 98 | The Qtm. Nos 2Sz and Q are also printed beside each energy. 99 | In case Sz or Q are not good quantum nos, the corresponding values 100 | are set to 0. 101 | 102 | even/odd.dat: Prints out first few energy levels for even/odd Iterations. 103 | They can then be plotted using standard plotting tools. 104 | 105 | Therm.dat: Print out the total values of the Thermodynamic quantities against 106 | Iteration # as well as Temp. 107 | 108 | Theravg.dat: Prints out the 3-point average of the Imp. Thermodynamic 109 | contributions. 110 | 111 | OpTherm.dat: Prints out the expectation value of the Imp. Operator(s). 112 | 113 | therm.data: This files contain the Thermodynamics of the Fermionic 114 | chain (FC) by itself. The program Open_Files() reads this file and subtract 115 | off the contributions from the bath. 116 | 117 | ====================================================================== 118 | 119 | Definition of Matlab functions and sub-routines: 120 | ------------------------------------------------ 121 | 122 | NRG.m : Contains the main function NRG(). 123 | 124 | Input Variables.m : Declares the set of parameters for the NRG run. 125 | 126 | Parms.m : (pre-)Declares the various variables/Parameters used for the run. 127 | 128 | Open_Files.m: Subroutine that opens all the necessary files for the NRG run. 129 | 130 | Iteration0: Set up and Diagonalize the Hamiltonian for Iteration 0 of the run. 131 | 132 | Iteration.m: Set up and Diagonalize the Hamiltonian for Iterations > 0. 133 | 134 | ITend.m: End of Iteration. Print out NRG energies (measured from the ground 135 | state), Thermodynamics and . 136 | 137 | Plot_Figures.m: Plot (using Matlab's plotting tool) the Energy flow diagrams 138 | for even and odd iterations. Also plots the various thermodynamic 139 | quantities calculated against temperature. 140 | 141 | Close_Files.m: Close all the files that were opened during the run. 142 | 143 | Impose.m: Imposes an artifical degeneracy over closely lying energy levels 144 | (\delta E < SMALL). 145 | 146 | Esort.m: Sorts the eigenstates with respect to Energy. In addition to energy, 147 | also sorts the matrix c(containing eigenvectors) and Kode(containing 148 | Qtm. Nos.). 149 | 150 | =========================================================================== 151 | 152 | Sample output files and plots for the Fermionic Chain, Kondo and Andersoncan 153 | be found at the './Sample_Outputs' 154 | 155 | Last edited: 30.09.2020. 156 | 157 | -------------------------------------------------------------------------------- /Sample_Outputs/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Sample_Outputs/ANDERSON/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Sample_Outputs/ANDERSON/Cv.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tatha04/Numerical-Renormalization-Group/f9edc696f26bad341617332f32d3672e92b9ce0d/Sample_Outputs/ANDERSON/Cv.pdf -------------------------------------------------------------------------------- /Sample_Outputs/ANDERSON/Energy_Even.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tatha04/Numerical-Renormalization-Group/f9edc696f26bad341617332f32d3672e92b9ce0d/Sample_Outputs/ANDERSON/Energy_Even.pdf -------------------------------------------------------------------------------- /Sample_Outputs/ANDERSON/Energy_Odd.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tatha04/Numerical-Renormalization-Group/f9edc696f26bad341617332f32d3672e92b9ce0d/Sample_Outputs/ANDERSON/Energy_Odd.pdf -------------------------------------------------------------------------------- /Sample_Outputs/ANDERSON/Entropy.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tatha04/Numerical-Renormalization-Group/f9edc696f26bad341617332f32d3672e92b9ce0d/Sample_Outputs/ANDERSON/Entropy.pdf -------------------------------------------------------------------------------- /Sample_Outputs/ANDERSON/OpTherm.dat: -------------------------------------------------------------------------------- 1 | 1.0000e+00 1.00000000 2 | 5.7735e-01 1.00000000 3 | 3.3333e-01 1.00000000 4 | 1.9245e-01 1.00000000 5 | 1.1111e-01 0.99999971 6 | 6.4150e-02 1.00000000 7 | 3.7037e-02 1.00000000 8 | 2.1383e-02 1.00000000 9 | 1.2346e-02 1.00000001 10 | 7.1278e-03 1.00000000 11 | 4.1152e-03 1.00000000 12 | 2.3759e-03 1.00000000 13 | 1.3717e-03 1.00000000 14 | 7.9198e-04 1.00000000 15 | 4.5725e-04 1.00000000 16 | 2.6399e-04 1.00000000 17 | 1.5242e-04 1.00000000 18 | 8.7997e-05 1.00000000 19 | 5.0805e-05 1.00000000 20 | 2.9332e-05 1.00000000 21 | 1.6935e-05 1.00000000 22 | 9.7775e-06 1.00000000 23 | 5.6450e-06 1.00000000 24 | 3.2592e-06 1.00000000 25 | 1.8817e-06 1.00000000 26 | 1.0864e-06 1.00000000 27 | 6.2723e-07 1.00000000 28 | 3.6213e-07 1.00000000 29 | 2.0908e-07 1.00000000 30 | 1.2071e-07 1.00000000 31 | 6.9692e-08 1.00000000 32 | 4.0237e-08 1.00000000 33 | 2.3231e-08 1.00000000 34 | 1.3412e-08 1.00000000 35 | 7.7435e-09 1.00000000 36 | 4.4707e-09 1.00000000 37 | 2.5812e-09 1.00000000 38 | 1.4902e-09 1.00000000 39 | 8.6039e-10 1.00000000 40 | 4.9675e-10 1.00000000 41 | 2.8680e-10 1.00000000 42 | -------------------------------------------------------------------------------- /Sample_Outputs/ANDERSON/TChi.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tatha04/Numerical-Renormalization-Group/f9edc696f26bad341617332f32d3672e92b9ce0d/Sample_Outputs/ANDERSON/TChi.pdf -------------------------------------------------------------------------------- /Sample_Outputs/ANDERSON/Therm.dat: -------------------------------------------------------------------------------- 1 | # It Temp. Cv 2 | #--------------------------------------------------------------- 3 | 0 1.000000e+00 2.76266932 0.26177470 -0.09722171 4 | 1 5.773503e-01 3.71925743 0.34493613 0.05002169 5 | 2 3.333333e-01 4.19519118 0.39018127 0.39846209 6 | 3 1.924501e-01 4.16133753 0.40929651 0.75473940 7 | 4 1.111111e-01 4.02270050 0.43512481 0.60783955 8 | 5 6.415003e-02 3.81074262 0.45093065 0.73370735 9 | 6 3.703704e-02 3.69934213 0.46044797 0.49924725 10 | 7 2.138334e-02 3.64435231 0.45832239 0.58943917 11 | 8 1.234568e-02 3.65153169 0.45952279 0.45735581 12 | 9 7.127781e-03 3.62999175 0.45555284 0.57906934 13 | 10 4.115226e-03 3.64437891 0.45618440 0.45793808 14 | 11 2.375927e-03 3.62537224 0.45189048 0.57670824 15 | 12 1.371742e-03 3.64104627 0.45206361 0.46209224 16 | 13 7.919757e-04 3.62264700 0.44734909 0.57528307 17 | 14 4.572474e-04 3.63819820 0.44683885 0.46875581 18 | 15 2.639919e-04 3.61973089 0.44148142 0.57388182 19 | 16 1.524158e-04 3.63428002 0.43994536 0.47857883 20 | 17 8.799730e-05 3.61517276 0.43359648 0.57209385 21 | 18 5.080526e-05 3.62756990 0.43049667 0.49327714 22 | 19 2.933243e-05 3.60678649 0.42258522 0.56961641 23 | 20 1.693509e-05 3.61475796 0.41702812 0.51602929 24 | 21 9.777478e-06 3.58983959 0.40659802 0.56628406 25 | 22 5.645029e-06 3.58823630 0.39712767 0.55191687 26 | 23 3.259159e-06 3.55313929 0.38273297 0.56248245 27 | 24 1.881676e-06 3.53049132 0.36737917 0.60540382 28 | 25 1.086386e-06 3.47271530 0.34780014 0.55893513 29 | 26 6.272255e-07 3.41076173 0.32599724 0.66413465 30 | 27 3.621288e-07 3.32132880 0.30393696 0.54727110 31 | 28 2.090752e-07 3.22377933 0.28165648 0.67777956 32 | 29 1.207096e-07 3.13851482 0.26629462 0.50696148 33 | 30 6.969172e-08 3.05863424 0.25210863 0.63545553 34 | 31 4.023653e-08 3.02221260 0.24680275 0.46292725 35 | 32 2.323057e-08 2.97798410 0.23955088 0.60088615 36 | 33 1.341218e-08 2.97594273 0.23953903 0.44207284 37 | 34 7.743524e-09 2.94871446 0.23516782 0.58705046 38 | 35 4.470726e-09 2.96016007 0.23707816 0.43479324 39 | 36 2.581175e-09 2.93881562 0.23369814 0.58231258 40 | 37 1.490242e-09 2.95489641 0.23625639 0.43237131 41 | 38 8.603916e-10 2.93550643 0.23320790 0.58072639 42 | 39 4.967473e-10 2.95314315 0.23598239 0.43156656 43 | 40 2.867972e-10 2.93440255 0.23304448 0.58019716 44 | -------------------------------------------------------------------------------- /Sample_Outputs/ANDERSON/Thermavg.dat: -------------------------------------------------------------------------------- 1 | # Temp. S_avg TChi_avg Cv_avg 2 | #- -------------------------------------------------------- 3 | 5.773503e-01 1.35391706 0.14596292 0.01850101 4 | 3.333333e-01 1.30775736 0.15913285 0.09949299 5 | 1.924501e-01 1.21379095 0.17758631 0.15539879 6 | 1.111111e-01 1.06301177 0.19836835 0.17106686 7 | 6.415003e-02 0.89324512 0.21499809 0.13793069 8 | 3.703704e-02 0.77053702 0.22314942 0.07479123 9 | 2.138334e-02 0.71688294 0.22475470 0.02830550 10 | 1.234568e-02 0.70130997 0.22382795 0.01524860 11 | 7.127781e-03 0.69592008 0.22229971 0.01280773 12 | 4.115226e-03 0.69297365 0.22054918 0.01236396 13 | 2.375927e-03 0.69098433 0.21860325 0.01281289 14 | 1.371742e-03 0.68946950 0.21643767 0.01349524 15 | 7.919757e-04 0.68807603 0.21399611 0.01480492 16 | 4.572474e-04 0.68663493 0.21122300 0.01612051 17 | 2.639919e-04 0.68492635 0.20803271 0.01822596 18 | 1.524158e-04 0.68280727 0.20433811 0.02023473 19 | 8.799730e-05 0.67999020 0.20000470 0.02346231 20 | 5.080526e-05 0.67621610 0.19488971 0.02651753 21 | 2.933243e-05 0.67091655 0.18876976 0.03158620 22 | 1.693509e-05 0.66347684 0.18140582 0.03644115 23 | 9.777478e-06 0.65260970 0.17243391 0.04457996 24 | 5.645029e-06 0.63680421 0.16149254 0.05260145 25 | 3.259159e-06 0.61319289 0.14808915 0.06502279 26 | 1.881676e-06 0.57865065 0.13191882 0.07750769 27 | 1.086386e-06 0.52861225 0.11284013 0.09130357 28 | 6.272255e-07 0.46083323 0.09152885 0.10307027 29 | 3.621288e-07 0.37624101 0.06947786 0.10356549 30 | 2.090752e-07 0.28379191 0.04898209 0.09689931 31 | 1.207096e-07 0.19680214 0.03218454 0.07624090 32 | 6.969172e-08 0.12644032 0.01992461 0.05465134 33 | 4.023653e-08 0.07720223 0.01191220 0.03500043 34 | 2.323057e-08 0.04547223 0.00695684 0.02114449 35 | 1.341218e-08 0.02658735 0.00404514 0.01247196 36 | 7.743524e-09 0.01532427 0.00233416 0.00719314 37 | 4.470726e-09 0.00890389 0.00135152 0.00418877 38 | 2.581175e-09 0.00511327 0.00077866 0.00239882 39 | 1.490242e-09 0.00297006 0.00045066 0.00139679 40 | 8.603916e-10 0.00170444 0.00025960 0.00079905 41 | 4.967473e-10 0.00099016 0.00015024 0.00046556 42 | -------------------------------------------------------------------------------- /Sample_Outputs/FERMIONIC CHAIN/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Sample_Outputs/FERMIONIC CHAIN/Therm.dat: -------------------------------------------------------------------------------- 1 | # It Temp. Cv 2 | #--------------------------------------------------------------- 3 | 0 1.000000e+00 1.38629436 0.12500000 0.00000000 4 | 1 5.773503e-01 2.35933136 0.20014795 0.00933103 5 | 2 3.333333e-01 2.87575006 0.23268064 0.30861768 6 | 3 1.924501e-01 2.92911643 0.23255458 0.57714695 7 | 4 1.111111e-01 2.95142006 0.23576403 0.43127370 8 | 5 6.415003e-02 2.93347752 0.23292072 0.58016404 9 | 6 3.703704e-02 2.95217230 0.23583626 0.43117693 10 | 7 2.138334e-02 2.93380901 0.23295809 0.57995818 11 | 8 1.234568e-02 2.95225634 0.23584433 0.43116611 12 | 9 7.127781e-03 2.93384586 0.23296225 0.57993532 13 | 10 4.115226e-03 2.95226569 0.23584523 0.43116491 14 | 11 2.375927e-03 2.93384995 0.23296271 0.57993278 15 | 12 1.371742e-03 2.95226672 0.23584533 0.43116477 16 | 13 7.919757e-04 2.93385041 0.23296276 0.57993250 17 | 14 4.572474e-04 2.95226684 0.23584534 0.43116476 18 | 15 2.639919e-04 2.93385046 0.23296276 0.57993247 19 | 16 1.524158e-04 2.95226685 0.23584534 0.43116476 20 | 17 8.799730e-05 2.93385046 0.23296277 0.57993246 21 | 18 5.080526e-05 2.95226685 0.23584534 0.43116476 22 | 19 2.933243e-05 2.93385046 0.23296277 0.57993246 23 | 20 1.693509e-05 2.95226685 0.23584534 0.43116476 24 | 21 9.777478e-06 2.93385046 0.23296277 0.57993246 25 | 22 5.645029e-06 2.95226685 0.23584534 0.43116476 26 | 23 3.259159e-06 2.93385046 0.23296277 0.57993246 27 | 24 1.881676e-06 2.95226685 0.23584534 0.43116476 28 | 25 1.086386e-06 2.93385046 0.23296277 0.57993246 29 | 26 6.272255e-07 2.95226685 0.23584534 0.43116476 30 | 27 3.621288e-07 2.93385046 0.23296277 0.57993246 31 | 28 2.090752e-07 2.95226685 0.23584534 0.43116476 32 | 29 1.207096e-07 2.93385046 0.23296277 0.57993246 33 | 30 6.969172e-08 2.95226685 0.23584534 0.43116476 34 | -------------------------------------------------------------------------------- /Sample_Outputs/FERMIONIC CHAIN/Thermavg.dat: -------------------------------------------------------------------------------- 1 | # Temp. S_avg TChi_avg Cv_avg 2 | #- -------------------------------------------------------- 3 | 5.773503e-01 2.24517678 0.18949414 0.08181993 4 | 3.333333e-01 2.75998697 0.22451595 0.30092833 5 | 1.924501e-01 2.92135074 0.23338846 0.47354632 6 | 1.111111e-01 2.94135852 0.23425084 0.50496460 7 | 6.415003e-02 2.94263685 0.23436043 0.50569468 8 | 3.703704e-02 2.94290778 0.23438783 0.50561902 9 | 2.138334e-02 2.94301167 0.23439919 0.50556485 10 | 1.234568e-02 2.94304189 0.23440225 0.50555643 11 | 7.127781e-03 2.94305344 0.23440351 0.50555041 12 | 4.115226e-03 2.94305680 0.23440385 0.50554948 13 | 2.375927e-03 2.94305808 0.23440399 0.50554881 14 | 1.371742e-03 2.94305845 0.23440403 0.50554871 15 | 7.919757e-04 2.94305859 0.23440405 0.50554863 16 | 4.572474e-04 2.94305864 0.23440405 0.50554862 17 | 2.639919e-04 2.94305865 0.23440405 0.50554861 18 | 1.524158e-04 2.94305866 0.23440405 0.50554861 19 | 8.799730e-05 2.94305866 0.23440405 0.50554861 20 | 5.080526e-05 2.94305866 0.23440405 0.50554861 21 | 2.933243e-05 2.94305866 0.23440405 0.50554861 22 | 1.693509e-05 2.94305866 0.23440405 0.50554861 23 | 9.777478e-06 2.94305866 0.23440405 0.50554861 24 | 5.645029e-06 2.94305866 0.23440405 0.50554861 25 | 3.259159e-06 2.94305866 0.23440405 0.50554861 26 | 1.881676e-06 2.94305866 0.23440405 0.50554861 27 | 1.086386e-06 2.94305866 0.23440405 0.50554861 28 | 6.272255e-07 2.94305866 0.23440405 0.50554861 29 | 3.621288e-07 2.94305866 0.23440405 0.50554861 30 | 2.090752e-07 2.94305866 0.23440405 0.50554861 31 | 1.207096e-07 2.94305866 0.23440405 0.50554861 32 | -------------------------------------------------------------------------------- /Sample_Outputs/KONDO/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Sample_Outputs/KONDO/Cv.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tatha04/Numerical-Renormalization-Group/f9edc696f26bad341617332f32d3672e92b9ce0d/Sample_Outputs/KONDO/Cv.pdf -------------------------------------------------------------------------------- /Sample_Outputs/KONDO/Energy_Even.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tatha04/Numerical-Renormalization-Group/f9edc696f26bad341617332f32d3672e92b9ce0d/Sample_Outputs/KONDO/Energy_Even.pdf -------------------------------------------------------------------------------- /Sample_Outputs/KONDO/Energy_Odd.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tatha04/Numerical-Renormalization-Group/f9edc696f26bad341617332f32d3672e92b9ce0d/Sample_Outputs/KONDO/Energy_Odd.pdf -------------------------------------------------------------------------------- /Sample_Outputs/KONDO/Entropy.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tatha04/Numerical-Renormalization-Group/f9edc696f26bad341617332f32d3672e92b9ce0d/Sample_Outputs/KONDO/Entropy.pdf -------------------------------------------------------------------------------- /Sample_Outputs/KONDO/OpTherm.dat: -------------------------------------------------------------------------------- 1 | 1.0000e+00 0.25000000 2 | 5.7735e-01 0.25000000 3 | 3.3333e-01 0.25000000 4 | 1.9245e-01 0.25000000 5 | 1.1111e-01 0.25000000 6 | 6.4150e-02 0.25000000 7 | 3.7037e-02 0.25000000 8 | 2.1383e-02 0.25000000 9 | 1.2346e-02 0.25000000 10 | 7.1278e-03 0.25000000 11 | 4.1152e-03 0.25000000 12 | 2.3759e-03 0.25000000 13 | 1.3717e-03 0.25000000 14 | 7.9198e-04 0.25000000 15 | 4.5725e-04 0.25000000 16 | 2.6399e-04 0.25000000 17 | 1.5242e-04 0.25000000 18 | 8.7997e-05 0.25000000 19 | 5.0805e-05 0.25000000 20 | 2.9332e-05 0.25000000 21 | 1.6935e-05 0.25000000 22 | 9.7775e-06 0.25000000 23 | 5.6450e-06 0.25000000 24 | 3.2592e-06 0.25000000 25 | 1.8817e-06 0.25000000 26 | 1.0864e-06 0.25000000 27 | 6.2723e-07 0.25000000 28 | 3.6213e-07 0.25000000 29 | 2.0908e-07 0.25000000 30 | 1.2071e-07 0.25000000 31 | 6.9692e-08 0.25000000 32 | -------------------------------------------------------------------------------- /Sample_Outputs/KONDO/TChi.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tatha04/Numerical-Renormalization-Group/f9edc696f26bad341617332f32d3672e92b9ce0d/Sample_Outputs/KONDO/TChi.pdf -------------------------------------------------------------------------------- /Sample_Outputs/KONDO/Therm.dat: -------------------------------------------------------------------------------- 1 | # It Temp. Cv 2 | #--------------------------------------------------------------- 3 | 0 1.000000e+00 2.07743878 0.36210476 -0.07583742 4 | 1 5.773503e-01 3.04851100 0.43192505 0.01054302 5 | 2 3.333333e-01 3.56242026 0.45859995 0.32426543 6 | 3 1.924501e-01 3.61710347 0.45698859 0.57338991 7 | 4 1.111111e-01 3.63955829 0.45834879 0.45281547 8 | 5 6.415003e-02 3.62285108 0.45442647 0.57606999 9 | 6 3.703704e-02 3.64049916 0.45509892 0.45737522 10 | 7 2.138334e-02 3.62283944 0.45077811 0.57553287 11 | 8 1.234568e-02 3.63942969 0.45085838 0.46301377 12 | 9 7.127781e-03 3.62141908 0.44603619 0.57468962 13 | 10 4.115226e-03 3.63708693 0.44532972 0.47064093 14 | 11 2.375927e-03 3.61864255 0.43978105 0.57340442 15 | 12 1.371742e-03 3.63289456 0.43792987 0.48154103 16 | 13 7.919757e-04 3.61354887 0.43127212 0.57153806 17 | 14 4.572474e-04 3.62518420 0.42767771 0.49786022 18 | 15 2.639919e-04 3.60372722 0.41926618 0.56887911 19 | 16 1.524158e-04 3.61003499 0.41292350 0.52326648 20 | 17 8.799730e-05 3.58342095 0.40168303 0.56536926 21 | 18 5.080526e-05 3.57811528 0.39097531 0.56320197 22 | 19 2.933243e-05 3.53893857 0.37538551 0.56161718 23 | 20 1.693509e-05 3.50849392 0.35837408 0.62040072 24 | 21 9.777478e-06 3.44301085 0.33766850 0.55766584 25 | 22 5.645029e-06 3.36999821 0.31487129 0.67383722 26 | 23 3.259159e-06 3.27600412 0.29350603 0.54037814 27 | 24 1.881676e-06 3.17732834 0.27267860 0.67039371 28 | 25 1.086386e-06 3.10217252 0.25994015 0.49473941 29 | 26 6.272255e-07 3.03190280 0.24784832 0.62477862 30 | 27 3.621288e-07 3.00631031 0.24429016 0.45590032 31 | 28 2.090752e-07 2.96783603 0.23802384 0.59613193 32 | 29 1.207096e-07 2.97042764 0.23867926 0.43952964 33 | 30 6.969172e-08 2.94525713 0.23465392 0.58539734 34 | -------------------------------------------------------------------------------- /Sample_Outputs/KONDO/Thermavg.dat: -------------------------------------------------------------------------------- 1 | # Temp. S_avg TChi_avg Cv_avg 2 | #- -------------------------------------------------------- 3 | 5.773503e-01 0.68904348 0.23164456 -0.01444142 4 | 3.333333e-01 0.68762678 0.22701243 0.00718762 5 | 1.924501e-01 0.68769563 0.22434302 0.00741886 6 | 1.111111e-01 0.68840926 0.22277732 0.00880811 7 | 6.415003e-02 0.68880305 0.22121473 0.00988799 8 | 3.703704e-02 0.68876443 0.21946277 0.01096930 9 | 2.138334e-02 0.68839026 0.21747919 0.01229883 10 | 1.234568e-02 0.68773759 0.21523051 0.01350608 11 | 7.127781e-03 0.68678526 0.21266161 0.01520808 12 | 4.115226e-03 0.68550208 0.20971532 0.01679449 13 | 2.375927e-03 0.68375857 0.20630143 0.01919889 14 | 1.371742e-03 0.68143668 0.20232420 0.02145743 15 | 7.919757e-04 0.67823553 0.19763390 0.02507071 16 | 4.572474e-04 0.67385248 0.19206938 0.02848578 17 | 2.639919e-04 0.66760976 0.18537934 0.03417262 18 | 1.524158e-04 0.65874588 0.17729500 0.03964672 19 | 8.799730e-05 0.64568938 0.16741217 0.04875313 20 | 5.080526e-05 0.62658886 0.15535074 0.05779899 21 | 2.933243e-05 0.59806292 0.14062605 0.07116065 22 | 1.693509e-05 0.55667566 0.12304649 0.08447250 23 | 9.777478e-06 0.49806980 0.10274154 0.09684379 24 | 5.645029e-06 0.42169419 0.08082523 0.10588099 25 | 3.259159e-06 0.33177504 0.05923644 0.10069819 26 | 1.881676e-06 0.24014967 0.04029679 0.08842763 27 | 1.086386e-06 0.16033539 0.02569776 0.06561418 28 | 6.272255e-07 0.10001345 0.01557769 0.04450063 29 | 3.621288e-07 0.06003121 0.00920907 0.02762919 30 | 2.090752e-07 0.03504385 0.00535022 0.01637485 31 | 1.207096e-07 0.02042845 0.00310502 0.00959853 32 | -------------------------------------------------------------------------------- /Thermodynamics.m: -------------------------------------------------------------------------------- 1 | beta = Lambda^(+0.5); temp(it+1) = (Lambda^(-(it-1)/2))/beta; 2 | 3 | z = sum(exp(-beta*E(1:L))); 4 | 5 | s(it+1) = beta*(sum(E(1:L).*exp(-beta*E(1:L)))/z) + log(z); 6 | tchi(it+1) = 0.25*sum(Sz(1:L).*Sz(1:L).*exp(-beta*E(1:L)))/z - 0.5*sum(Sz(1:L).*exp(-beta*E(1:L)))/z; 7 | Cv(it+1) = sum(E(1:L).*E(1:L).*exp(-beta*E(1:L)))/z - sum(E(1:L).*exp(-beta*E(1:L)))/z; 8 | 9 | if(OPMAT) 10 | for i = 1:NOP 11 | op_exp(it+1,i) = sum(diag(op_n(1:L,1:L,i)).*exp(-beta*E(1:L)))/z; 12 | end 13 | end -------------------------------------------------------------------------------- /dec2dual.m: -------------------------------------------------------------------------------- 1 | function z = dec2dual(M,N) 2 | z = zeros(N,1); 3 | i=1; 4 | while(M > 1) 5 | z(i) = mod(M,2); 6 | M = (M-z(i))/2; 7 | i = i+1; 8 | end 9 | if (M > 0) 10 | z(i) = M; 11 | end 12 | end -------------------------------------------------------------------------------- /dekode.m: -------------------------------------------------------------------------------- 1 | function [Sz,Q] = dekode(kode) 2 | Q = rem(kode,100)-50; 3 | Sz = (kode-rem(kode,100))/100-50; 4 | end -------------------------------------------------------------------------------- /delta_enkode.m: -------------------------------------------------------------------------------- 1 | function delta_kode = delta_encode(Sz,Qz) 2 | delta_kode = (Sz)*100 + (Qz); 3 | end -------------------------------------------------------------------------------- /enkode.m: -------------------------------------------------------------------------------- 1 | function kode = encode(Sz,Qz) 2 | kode = (Sz+50)*100 + (Qz+50); 3 | end -------------------------------------------------------------------------------- /therm.data: -------------------------------------------------------------------------------- 1 | # Temp. S_avg TChi_avg Cv_avg 2 | #- -------------------------------------------------------- 3 | 5.773503e-01 2.24517678 0.18949414 0.08181993 4 | 3.333333e-01 2.75989269 0.22451341 0.30057796 5 | 1.924501e-01 2.92013257 0.23336036 0.46981168 6 | 1.111111e-01 2.93881950 0.23419191 0.49713531 7 | 6.415003e-02 2.93980519 0.23429366 0.49680157 8 | 3.703704e-02 2.94007424 0.23432099 0.49672225 9 | 2.138334e-02 2.94017735 0.23433232 0.49666712 10 | 1.234568e-02 2.94020714 0.23433534 0.49665822 11 | 7.127781e-03 2.94021846 0.23433659 0.49665205 12 | --------------------------------------------------------------------------------