please help plot and visualize the results
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
clear
clc
close all
%input data
c0=2;
L=0.5;
eps=0.62;
u=0.06;
De=9.53e-4;
rhop=1940;
kl=0.090;
qm=200;
ks=0.00425;
%Length
Nz=201;
z=linspace(0,L,Nz);
dz=z(2)-z(1);
%time
t=[0 1800];
%initial conditions
ICA=zeros(1,Nz); %for PDE dc/dt...
ICB=zeros(1,Nz); %for ODE dq/dt...
IC=[ICA ICB];
%odesolver
[t, y]=ode15s(@f,t,IC,[],eps,u,kl,c0,rhop,Nz,dz,De,qm,ks);
%define value or recalculation using coding function
%define value
%dont forget :
c=y(:,1:Nz);
qstar=y(:,Nz+1:2*Nz);
%boundary conditions
c(:,1)=c0;
c(:,end)=(4*c(:,end-1)-c(:,end-2))./3; % using backward second order
%function
function dydt=f(t,y,a,eps,u,kl,c0,rhop,Nz,dz,De,qm,ks)
dydt=zeros(length(y),1);
dcdt=zeros(Nz,1);
dqdt=zeros(Nz,1);
dcdz=zeros(Nz,1);
dc2dz2=zeros(Nz,1);
%define value
c=y(1:Nz);
qstar=y(Nz+1:2*Nz);
%boundary conditions
c(1)=c0;
c(end)=(4*c(end-1)-c(end-2))./3; % using backward second order
%interior
for i=2:Nz-1
qstar(i)=qm.*ks.*c(i)./((1+(ks.*c(i))^1/a)); %Toth model
dqdt(i)=kl.*(qstar(i)-q(i));
dcdz(i)=(c(i+1)-c(i-1))./2./dz; %centered finite diff
dc2dz2(i)=(c(i+1)-2*c(i)+c(i-1))./dz.^2; %centred second derivative
dcdt(i)=De.*dc2dz2(i)-u*dcdz(i)-rhop.*((1-eps)./eps).*dqdt(i); %trabsport equation
end
dydt=[dcdt;dqdt];
end
0 comentarios
Respuestas (1)
Sahaj
el 16 de Jul. de 2023
Editada: Sahaj
el 16 de Jul. de 2023
Hi Ofentse.
You can add the following code after the ODE solver section to plot and visualiize your results.
% Plot concentration profile
subplot(2,1,1);
plot(z, c(end,:), 'b-', 'LineWidth', 2);
xlabel('Distance (z)');
ylabel('Concentration (c)');
title('Concentration Profile');
% Plot deposition rate profile
subplot(2,1,2);
plot(z, qstar(end,:), 'r-', 'LineWidth', 2);
xlabel('Distance (z)');
ylabel('Deposition Rate (q*)');
title('Deposition Rate Profile');
0 comentarios
Ver también
Categorías
Más información sobre Geometry and Mesh en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!