phase diagram of 3D Anderson model
L = 10; % system size
nr = 10;
nsteps = 100;
W_values = linspace(0, 20, nsteps);
IPR_over_W = cell(1, nsteps);
eigenvalues_cell = cell(nr, nsteps);
for W_index = 1:nsteps
W = W_values(W_index);
IPRs_for_this_W = zeros(1, nr);
for ir = 1:nr
H = generate_hamiltonian(L, W);
[eigenstates, D] = eig(H);
eigenvalues = diag(D);
energy_levels{ir} = eigenvalues(:)’;
IPR{ir} = compute_IPR(eigenstates);
IPRs_for_this_W(ir) = mean(IPR{ir});
% Store the eigenvalues in a cell array
eigenvalues_cell{ir, W_index} = eigenvalues(:)’;
end
% Store the mean IPR over 100 realizations for this W value
IPR_over_W{W_index} = mean(IPRs_for_this_W);
disp([W, IPR_over_W{W_index}])
end
%
% Create a figure for the color plot
figure;
% Define the colormap and use the IPR values for coloring
cmap = jet;
% Loop over W values
for W_index = 1:nsteps
W = W_values(W_index);
% Extract eigenvalues from the cell array
eigenvalues_for_W = eigenvalues_cell(:, W_index);
% Initialize arrays to store eigenvalues and y-axis values
eigenvalues_numeric = [];
y_values = [];
cdata = []; % Initialize color data
% Convert eigenvalues_for_W to a numeric array and create y_values
for ir = 1:nr
eigenvalues_ir = eigenvalues_for_W{ir};
eigenvalues_numeric = [eigenvalues_numeric, eigenvalues_ir];
y_values = [y_values, W * ones(size(eigenvalues_ir))];
% Calculate IPR values (You should have a function for this)
IPR_value = compute_IPR(eigenvalues_ir);
cdata = [cdata, IPR_value];
end
% Create a scatter plot with eigenvalues on the x-axis and y_values on the y-axis
scatter(eigenvalues_numeric, y_values, 20, cdata*1e-4, ‘filled’);
% imagesc(W_values, 1:nr, IPR_matrix);
colormap(cmap);
colorbar; % Add a colorbar
hold on;
end
xlabel(‘Eigenvalues’);
ylabel(‘W’);
title(‘Color Plot: Eigenvalues vs. W vs. IPR’);
hold off;
%%% box disorder
function disorder = generate_disorder(L, W)
disorder = W * ((rand(L, L, L) – 0.5));
end
% Generate the Hamiltonian matrix for one realization of the random disorder
function H = generate_hamiltonian(L, W)
H = zeros(L * L * L, L * L * L);
disorder = generate_disorder(L, W);
for i = 1:L
ip1 = mod(i, L) + 1;
for j = 1:L
jp1 = mod(j, L) + 1;
for k = 1:L
kp1 = mod(k, L) + 1;
H((i – 1) * L * L + (j – 1) * L + k, (i – 1) * L * L + (j – 1) * L + k) = disorder(i, j, k);
H(ip1 * L * L + j * L + k, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + jp1 * L + k, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + kp1, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, ip1 * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, (i – 1) * L * L + jp1 * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, (i – 1) * L * L + j * L + kp1) = 1.0;
end
end
end
end
function IPR = compute_IPR(eigenstates)
IPR = sum(abs(eigenstates).^4, 1);
endL = 10; % system size
nr = 10;
nsteps = 100;
W_values = linspace(0, 20, nsteps);
IPR_over_W = cell(1, nsteps);
eigenvalues_cell = cell(nr, nsteps);
for W_index = 1:nsteps
W = W_values(W_index);
IPRs_for_this_W = zeros(1, nr);
for ir = 1:nr
H = generate_hamiltonian(L, W);
[eigenstates, D] = eig(H);
eigenvalues = diag(D);
energy_levels{ir} = eigenvalues(:)’;
IPR{ir} = compute_IPR(eigenstates);
IPRs_for_this_W(ir) = mean(IPR{ir});
% Store the eigenvalues in a cell array
eigenvalues_cell{ir, W_index} = eigenvalues(:)’;
end
% Store the mean IPR over 100 realizations for this W value
IPR_over_W{W_index} = mean(IPRs_for_this_W);
disp([W, IPR_over_W{W_index}])
end
%
% Create a figure for the color plot
figure;
% Define the colormap and use the IPR values for coloring
cmap = jet;
% Loop over W values
for W_index = 1:nsteps
W = W_values(W_index);
% Extract eigenvalues from the cell array
eigenvalues_for_W = eigenvalues_cell(:, W_index);
% Initialize arrays to store eigenvalues and y-axis values
eigenvalues_numeric = [];
y_values = [];
cdata = []; % Initialize color data
% Convert eigenvalues_for_W to a numeric array and create y_values
for ir = 1:nr
eigenvalues_ir = eigenvalues_for_W{ir};
eigenvalues_numeric = [eigenvalues_numeric, eigenvalues_ir];
y_values = [y_values, W * ones(size(eigenvalues_ir))];
% Calculate IPR values (You should have a function for this)
IPR_value = compute_IPR(eigenvalues_ir);
cdata = [cdata, IPR_value];
end
% Create a scatter plot with eigenvalues on the x-axis and y_values on the y-axis
scatter(eigenvalues_numeric, y_values, 20, cdata*1e-4, ‘filled’);
% imagesc(W_values, 1:nr, IPR_matrix);
colormap(cmap);
colorbar; % Add a colorbar
hold on;
end
xlabel(‘Eigenvalues’);
ylabel(‘W’);
title(‘Color Plot: Eigenvalues vs. W vs. IPR’);
hold off;
%%% box disorder
function disorder = generate_disorder(L, W)
disorder = W * ((rand(L, L, L) – 0.5));
end
% Generate the Hamiltonian matrix for one realization of the random disorder
function H = generate_hamiltonian(L, W)
H = zeros(L * L * L, L * L * L);
disorder = generate_disorder(L, W);
for i = 1:L
ip1 = mod(i, L) + 1;
for j = 1:L
jp1 = mod(j, L) + 1;
for k = 1:L
kp1 = mod(k, L) + 1;
H((i – 1) * L * L + (j – 1) * L + k, (i – 1) * L * L + (j – 1) * L + k) = disorder(i, j, k);
H(ip1 * L * L + j * L + k, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + jp1 * L + k, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + kp1, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, ip1 * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, (i – 1) * L * L + jp1 * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, (i – 1) * L * L + j * L + kp1) = 1.0;
end
end
end
end
function IPR = compute_IPR(eigenstates)
IPR = sum(abs(eigenstates).^4, 1);
end L = 10; % system size
nr = 10;
nsteps = 100;
W_values = linspace(0, 20, nsteps);
IPR_over_W = cell(1, nsteps);
eigenvalues_cell = cell(nr, nsteps);
for W_index = 1:nsteps
W = W_values(W_index);
IPRs_for_this_W = zeros(1, nr);
for ir = 1:nr
H = generate_hamiltonian(L, W);
[eigenstates, D] = eig(H);
eigenvalues = diag(D);
energy_levels{ir} = eigenvalues(:)’;
IPR{ir} = compute_IPR(eigenstates);
IPRs_for_this_W(ir) = mean(IPR{ir});
% Store the eigenvalues in a cell array
eigenvalues_cell{ir, W_index} = eigenvalues(:)’;
end
% Store the mean IPR over 100 realizations for this W value
IPR_over_W{W_index} = mean(IPRs_for_this_W);
disp([W, IPR_over_W{W_index}])
end
%
% Create a figure for the color plot
figure;
% Define the colormap and use the IPR values for coloring
cmap = jet;
% Loop over W values
for W_index = 1:nsteps
W = W_values(W_index);
% Extract eigenvalues from the cell array
eigenvalues_for_W = eigenvalues_cell(:, W_index);
% Initialize arrays to store eigenvalues and y-axis values
eigenvalues_numeric = [];
y_values = [];
cdata = []; % Initialize color data
% Convert eigenvalues_for_W to a numeric array and create y_values
for ir = 1:nr
eigenvalues_ir = eigenvalues_for_W{ir};
eigenvalues_numeric = [eigenvalues_numeric, eigenvalues_ir];
y_values = [y_values, W * ones(size(eigenvalues_ir))];
% Calculate IPR values (You should have a function for this)
IPR_value = compute_IPR(eigenvalues_ir);
cdata = [cdata, IPR_value];
end
% Create a scatter plot with eigenvalues on the x-axis and y_values on the y-axis
scatter(eigenvalues_numeric, y_values, 20, cdata*1e-4, ‘filled’);
% imagesc(W_values, 1:nr, IPR_matrix);
colormap(cmap);
colorbar; % Add a colorbar
hold on;
end
xlabel(‘Eigenvalues’);
ylabel(‘W’);
title(‘Color Plot: Eigenvalues vs. W vs. IPR’);
hold off;
%%% box disorder
function disorder = generate_disorder(L, W)
disorder = W * ((rand(L, L, L) – 0.5));
end
% Generate the Hamiltonian matrix for one realization of the random disorder
function H = generate_hamiltonian(L, W)
H = zeros(L * L * L, L * L * L);
disorder = generate_disorder(L, W);
for i = 1:L
ip1 = mod(i, L) + 1;
for j = 1:L
jp1 = mod(j, L) + 1;
for k = 1:L
kp1 = mod(k, L) + 1;
H((i – 1) * L * L + (j – 1) * L + k, (i – 1) * L * L + (j – 1) * L + k) = disorder(i, j, k);
H(ip1 * L * L + j * L + k, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + jp1 * L + k, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + kp1, (i – 1) * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, ip1 * L * L + j * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, (i – 1) * L * L + jp1 * L + k) = 1.0;
H((i – 1) * L * L + j * L + k, (i – 1) * L * L + j * L + kp1) = 1.0;
end
end
end
end
function IPR = compute_IPR(eigenstates)
IPR = sum(abs(eigenstates).^4, 1);
end colormap MATLAB Answers — New Questions