Reaction diffusion equation script

25 views (last 30 days)
Irit Amelchenko
Irit Amelchenko on 2 Dec 2018
Commented: Torsten on 4 Dec 2018
I need to build a generic script for solving a reaction-diffusion equation of the form-
du/dx = f(u) +D(du/dx)^2
that is based on the explicit Euler method. I have to include the possibility of choosing different boundary conditions.
I have no idea what to do from this point.
The code I have for the Euler method is-
function [U] = Euler(f,y,dt,tmax)
%func - is a function handle
%dt - the steps
%tmax - the maximal time
%y - the first guess
t = dt:dt:tmax;
n = length(t);
U = zeros(length(y),n);
U(:,1) = y;
U_old = y(:);
for i=1:length(t)-1
U_new = U_old+dt.*f(t(i),U_old);
U(:,i+1)=U_new;
U_old=U_new;
end
% grid on;
% plot3(U(1,:),U(2,:),U(3,:),'-b','linewidth');
% title('Solution with Eulers method','fontsize',15);
% xlabel('x','fontsize',18); ylabel('y','fontsize',18); zlabel('z','fontsize',18);
end
  3 Comments
Irit Amelchenko
Irit Amelchenko on 3 Dec 2018
I meant du/dt = f(u) +D(du/dx)^2
Can't edit the question.
Torsten
Torsten on 4 Dec 2018
And you really mean (du/dx)^2 and not d^2u/dx^2 ?

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!