Solving self-consistent equations that involve matrices
Show older comments
I want to calculate
for a given value of
and E. The self-consistent equation is
for a given value of 
And

here
is identity matrix of order 3,
is 3-by-3 matrix, and
are constants. The other variables are given in my code below. To solve this equation, I have wrote the following code (with help of ChatGPT) but this code does not coverge. Can someone please help me.
is identity matrix of order 3,
is 3-by-3 matrix, and clear; clc;
% System Parameters
kx = pi/3;
ky = pi/5;
E = 8.5;
n_imp = 0.2;
u = 5;
JN = 1;
s = 1;
a = 1;
Dz = 0.75;
% Convergence Parameters
max_iterations = 1000;
convergence_threshold = 1e-6;
% Integration Limits
xmin = -2*pi/(3); xmax = 4*pi/(3);
ymin = -2*pi/(sqrt(3)); ymax = 2*pi/(sqrt(3));
H = @(kx, ky) [4*JN*s, -(s*cos((a*kx)/4 + (3^(1/2)*a*ky)/4)*(Dz*4i + 4*JN))/2, (s*cos((a*kx)/4 - (3^(1/2)*a*ky)/4)*(Dz*4i - 4*JN))/2
(s*cos((a*kx)/4 + (3^(1/2)*a*ky)/4)*(Dz*4i - 4*JN))/2, 4*JN*s, -(s*cos((a*kx)/2)*(Dz*4i + 4*JN))/2
-(s*cos((a*kx)/4 - (3^(1/2)*a*ky)/4)*(Dz*4i + 4*JN))/2, (s*cos((a*kx)/2)*(Dz*4i - 4*JN))/2, 4*JN*s];
% Initial guess for G^R
G_R_fun = @(kx, ky) inv(E * eye(3) - H(kx, ky)); % Initial G^R function
G_R = inv(E * eye(3) - H(kx, ky)); %value at given kx, ky and E
figure();
xlim([1 max_iterations])
diffs = [];
for iter = 1:max_iterations
% Calculate the denominator integration involving the GR
integral_term = zeros(3);
xs = xmin:0.01:xmax;
Nx = length(xs);
parfor ix = 1:Nx
qx = xs(ix);
for qy = ymin:0.01:ymax
integral_term = integral_term + 1/(4*pi^2) * G_R_fun(qx, qy) * u * 0.01 * 0.01;
end
end
%Evaluate Sigma^R:
SigmaR = n_imp * u * inv(eye(3) - integral_term);
% Calculate the updated GR using the self-consistent equation
G0_R_new_fun = @(kx, ky) inv(E * eye(3) - H(kx, ky) - SigmaR); %function
G0_R_new = G0_R_new_fun(kx, ky); %value at given kx, ky and E
% Check for convergence
diff = norm(G0_R_new - G_R, 'fro');
fprintf('Iteration: %d, Difference: %0.8f\n', iter, diff);
if diff < convergence_threshold
fprintf('Converged after %d iterations\n', iter);
break;
end
% Update Green's function for the next iteration
G_R = G0_R_new;
G_R_fun = G0_R_new_fun;
% Plotting differences:
diffs(iter) = diff;
plot(1:iter,diffs,'Marker','*','LineWidth',2,'Color','Black');
drawnow;
end
fprintf('Final Green''s function:\n');
disp(G_R);
8 Comments
Torsten
on 13 Aug 2023
You cannot "calculate G^R for a given value of k_y, k_y and E". As written, it requires G^R to be known for all xmin <= q_x <= x_max and ymin <= q_y <= ymax.
Luqman Saleem
on 13 Aug 2023
I wrote this because in your question, you write that you want to "calculate G^R for a given value of k_y, k_y and E".
"a" would mean: one.
I didn't know whether it's obvious for you that you have to compute G^R for all values xmin <= q_x <= x_max and ymin <= q_y <= ymax in order to be able to evaluate it in one specified point.
I don't know what you exactly mean with "self-consistent" in this context.
Bruno Luong
on 13 Aug 2023
Edited: Bruno Luong
on 13 Aug 2023
I'm confused, in your equation the denominator of
is a matrix, and ChatGPT obviously understood as inverse of the matrix. Same for
.
Honestly I never seen in the math literature the inverse is written as denominator of the expression.
I have a doubt how to correctly interpret your equation.
Luqman Saleem
on 13 Aug 2023
Luqman Saleem
on 13 Aug 2023
Bruno Luong
on 13 Aug 2023
Edited: Bruno Luong
on 13 Aug 2023
How physics peoples interpret
? Is it
or
?
? Is it And why you write (
) at the end?
) at the end?
so the
is not relevant in your equation. And why not pull out u outside the double integral, put it over outside
?
is not relevant in your equation. And why not pull out u outside the double integral, put it over outside And it is self-consistent in a sense that one needs to guess G^R first then put it in given equation and then check if the guess is the actual solution, if not, update the guess and keep going. is not it?
In mathematics, the method is called "fixed-point iteration" and it converges if you have a contraction mapping for G^R:
As I said, I've never heard of self-consistent in this context.
The task reminds me of solving integral equations for all 9 components of your matrix G^R.
Accepted Answer
More Answers (0)
Categories
Find more on App Building in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!