Reaction diffusion equation script
Show older comments
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
Torsten
on 3 Dec 2018
You mean
du/dx = f(u) +D(du/dx)^2
or
du/dt = f(u) +D(du/dx)^2
?
Irit Amelchenko
on 3 Dec 2018
Torsten
on 4 Dec 2018
And you really mean (du/dx)^2 and not d^2u/dx^2 ?
Answers (0)
Categories
Find more on Electromagnetics 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!