Reaction diffusion equation script
古いコメントを表示
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 件のコメント
Torsten
2018 年 12 月 3 日
You mean
du/dx = f(u) +D(du/dx)^2
or
du/dt = f(u) +D(du/dx)^2
?
Irit Amelchenko
2018 年 12 月 3 日
Torsten
2018 年 12 月 4 日
And you really mean (du/dx)^2 and not d^2u/dx^2 ?
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Electromagnetics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!