Solving a PDE using Method Of Lines

56 ビュー (過去 30 日間)
Dursman Mchabe
Dursman Mchabe 2020 年 11 月 3 日
コメント済み: Alan Stevens 2020 年 11 月 3 日
Hi everyone
I am trying to solve a PDE through method of lines, using ODE15s.
I get the error message
Not enough input arguments.
Error in TracerFlow (line 3)
dCdt=zeros(Nz,1);
The code script are pasted.
Thanks
% RunTracerFlow
close all
clear all
clc
% Data
tspan = linspace(0,60,61);
L =1;
Nz = 100;
CA0init =0.1;
dz = L./Nz;
Da = 2e-1;
U = 2e-1;
k = 1;
IC = zeros(1,Nz);
% Solver
[t c] = ode15s(@TracerFlow,tspan,IC,[],Nz,CA0init,dz,Da,U,k)
% Recalculation
C(:,1) = CA0init+1./900.*(60.*t-t.^2);
C(:,N+1) = 1./3.*(4.*C(:,Nz) -C(:,Nz-1)); %dCdt = 0
% Plotting
xaxis = linspace(0,L,Nz+1);
yaxis = tspan;
images(xaxis,yaxis,C)
xlabel('axial position')
ylabel('timespan')
colormap jet
colorbar
function dCdt = TracerFlow(t,C,Nz,CA0init,dz,Da,U,k)
% Pre-allocations
dCdt=zeros(Nz,1);
% Define boundary conditions
C(1) = CA0init+1./900.*(60.*t-t.^2);
C(Nz+1) = 1./3.*(4.*C(Nz) -C(Nz-1)); %dCdt = 0
for i = 2:Nz
dCdz(i)= 1./(2.*dz).*(C(i+1)-C(i-1)); %centred
d2Cdz2(i) = 1./(dz.^2).*(C(i+1)-2.*C(i)+C(i-1));
dCdt(i)=Da.*d2Cdz2(i)-U.*dCdz(i)-k.*C(i).^2;
end
end
  1 件のコメント
Alan Stevens
Alan Stevens 2020 年 11 月 3 日
Hmm. I got a different error message from your code! I corrected it as shown below.

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

採用された回答

Alan Stevens
Alan Stevens 2020 年 11 月 3 日
The crucial lines requiring changes are
[t c] = ode15s(@TracerFlow,tspan,IC,[],Nz,CA0init,dz,Da,U,k)
% Recalculation
C(:,1) = CA0init+1./900.*(60.*t-t.^2);
C(:,N+1) = 1./3.*(4.*C(:,Nz) -C(:,Nz-1)); %dCdt = 0
They should be
[t, C] = ode15s(@TracerFlow,tspan,IC,[],Nz,CA0init,dz,Da,U,k);
% Recalculation
C(:,1) = CA0init+1./900.*(60.*t-t.^2);
C(:,Nz+1) = 1./3.*(4.*C(:,Nz) -C(:,Nz-1)); %dCdt = 0
Also, I replaced images by surf.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGeometry and Mesh についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by