Solving a PDE using Method Of Lines

조회 수: 41 (최근 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 CenterFile Exchange에서 Geometry and Mesh에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by