Hello I am trying to use explicit Euler for time advancement and the second-order centraldifference scheme for the spatial derivative, solve the equation to steady
state on a uniform grid. Plot the exact and numerical steady solutions for Nx = 10, 20.
๐๐/๐๐ก = ๐ผ*( ๐^2๐/๐๐ฅ^2) + ๐(๐ฅ) on the boundary of 0 โค ๐ฅ โค ๐ฟ๐ฅ The initial and boundary conditions are ๐(๐ฅ, 0) = 0 ๐(0,๐ก) = 0 ๐(๐ฟ๐ฅ,๐ก) = ๐steady(๐ฟ๐ฅ) Take ๐ผ = 1, ๐ฟ๐ฅ = 15, and ๐(๐ฅ) = โ(๐ฅ 2 โ 4๐ฅ + 2)๐ โ๐ฅ . The exact steady solution is ๐steady(๐ฅ) = ๐ฅ 2๐ โ๐ฅ
heres the code I have can someone explain where I went wrong
alpha =0;
x = 0;
n =10;
T(0)4ess = 0;
h=0.1;
s(x)=-(x^2-4*x+2)*exp^(-x);
for i=1:n
T(i+1)=T(i) + h;
T(i)^(n+1)=T(i+1)^n+((alpha*h)/(x+h)^2)*(T(i+1)^n-2T(i)^n+T(i-1)^n)+h*s(x);
x = x +1;
h = h +0.1;
end
plot(x,T);
grid on;