Solving a PDE using Method Of Lines
44 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dursman Mchabe
am 3 Nov. 2020
Kommentiert: Alan Stevens
am 3 Nov. 2020
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 Kommentar
Alan Stevens
am 3 Nov. 2020
Hmm. I got a different error message from your code! I corrected it as shown below.
Akzeptierte Antwort
Alan Stevens
am 3 Nov. 2020
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Boundary Conditions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!