Reaction diffusion equation script

조회 수: 15 (최근 30일)
Irit Amelchenko
Irit Amelchenko 2018년 12월 2일
댓글: Torsten 2018년 12월 4일
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
Irit Amelchenko
Irit Amelchenko 2018년 12월 3일
I meant du/dt = f(u) +D(du/dx)^2
Can't edit the question.
Torsten
Torsten 2018년 12월 4일
And you really mean (du/dx)^2 and not d^2u/dx^2 ?

댓글을 달려면 로그인하십시오.

답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by