- /
-
Fisher-type equation u_t = u_xx + u^2 solved in 2-D
on 14 Nov 2023
- 8
- 39
- 0
- 0
- 653
drawframe(1);
Write your drawframe function below
function drawframe(f)
% Numerical simulation of Fisher-type equation u_t = u_xx + u^2 solved in two
% dimensions. Solution exhibits finite-time blow-up. The value of u is
% assumed to equal zero along all boundaries.
% Initial Variable Setup
I = 41; % Number of points in spatial grid
X = linspace(0,1,I);
Y = X;
U = zeros(I,I,48*11);
% Numerical Parameters
dx = X(2) - X(1);
dt = 0.0000005;
% Initial Conditions
for i=2:I-1
for j=2:I-1
U(i,j,1) = 10*sin(pi*X(i))*sin(pi*Y(j));
end
end
% Plot initial conditions where f = 1
if(f==1)
surf(X,Y,U(:,:,1),'LineStyle','none')
axis([0 1 0 1 0 300],'off')
set(gca,'Color','w','XTick',[],'YTick',[],'ZTick',[])
lightangle(-90,45)
shading(gca,'interp')
end
% For f > 1 simulate time-steps and plot final output
for t = 2:f*11
for i=2:I-1
for j=2:I-1
U(i,j,t) = U(i,j,t-1) + (dt/(dx^2))*(U(i+1,j,t-1)+U(i-1,j,t-1)+U(i,j+1,t-1)+U(i,j-1,t-1)+4*U(i,j,t-1)) + dt*(U(i,j,t-1)^2);
end
end
if(t == f*11)
surf(X,Y,U(:,:,t),'LineStyle','none')
axis([0 1 0 1 0 300],'off')
set(gca,'Color','w','XTick',[],'YTick',[],'ZTick',[])
lightangle(-90,45)
shading(gca,'interp')
end
end
end