Challenge

Week 5.1 - Mid term project - Solving the steady and unsteady 2D heat conduction problem

clear all
close all
clc


%matrix
A = [5 1 2;-3 9 4;1 2 -7]
% X= [x1;x2;x3]
B=[10 -14 -33]

% Matrix decomposition
L = [0 0 0; -3 0 0; 1 2 0]
U = [0 1 2;0 0 4;0 0 0]
D = [5 0 0; 0 9 0; 0 0 -7]

%co-efficient matrix
A =L+U+D;

%magnifine factor
m_factor=0.5:0.1:2

for i=1:1:length(m_factor)
D1=D*m_factor(i);
%
iter_mac_jac = (inv(D1))*(U+L);

eig_val_jac=roots(poly(iter_mac_jac));

spectral_radius_jac(i)=max(abs(eig_val_jac));

iter_mac_gs=-(inv(D+L))*U;

eig_val_gs=roots(poly(iter_mac_gs));

spectral_radius_gs(i)=max(abs(eig_val_gs));

omega=0.95;
iter_mac_sor=-(inv(D+omega*L))*(1-omega)*L*U;

eig_val_sor=roots(poly(iter_mac_sor));

spectral_radius_sor(i)=max(abs(eig_val_sor));


end

figure(1)
plot(m_factor,spectral_radius_jac,'-r')
hold on
plot(m_factor,spectral_radius_gs,'-b')
hold on
plot(m_factor,spectral_radius_sor,'-g')
hold off
grid on
legend('spectral_radius_jac','spectral_radius_gs','spectral_radius_sor')



Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.