diffusion with difference finite metod

2 ビュー (過去 30 日間)
bianchi fiammetta
bianchi fiammetta 2019 年 2 月 6 日
コメント済み: Torsten 2019 年 2 月 6 日
Good morning.
I do not understand the error in this script:
param.Cafeed=0.014158;% concentration [mol/dm3]
param.v=0.1;
param.L=1.1245; % led leight [dm]
param.D=0.001;
nx = 100; % to define the dimension of the initial condition
x = linspace(0,param.L,nx);
h = x(2)-x(1);
y0 = zeros(nx,1);
y0(1) = param.Cafeed;% Boundary condition
tspan = linspace(0,30,nx);
[t,y] = ode15s(@(t,y)fun(t,y,param,h),tspan,y0);%To solve the time dependence
function dy=fun(t,y,param,h)
M = length(y)+1;
dy = zeros(M+1,1);
dy(1)= 0;
for i=2:M
dy(i) = -param.v*(y(i)-y(i-1))/h+(param.D/h^2*(-2*y(i)+y(i-1)+y(i+1)));
end
thank you
  1 件のコメント
Torsten
Torsten 2019 年 2 月 6 日
編集済み: Torsten 2019 年 2 月 6 日
  1. You have M-1 unknowns y, but you try to provide M time derivatives dy.
  2. You reference y(M) and y(M+1) in your loop which do not exist.
  3. You have to prescribe a boundary condition at x=L. Open boundaries are not allowed for second-order PDEs.
Best wishes
Torsten.

サインインしてコメントする。

回答 (1 件)

bianchi fiammetta
bianchi fiammetta 2019 年 2 月 6 日
Thank you.
  1 件のコメント
Torsten
Torsten 2019 年 2 月 6 日
By the way:
This kind of equation can be solved using PDEPE.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEigenvalue Problems についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by