How do I solve this 1D transient convection-diffusion equation with the convection term coupled with transient boundary values?
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Albert Kim
el 21 de Feb. de 2023
Comentada: Albert Kim
el 23 de Feb. de 2023
The following equation is a non-dimensionlized 1D transient convection diffusion equation, where tau and eta are dimensionless time and y-axis from 0 to infinity for both. Because the boundary value phi_m is coupled in the convection term, I have some difficulty to use MATLAB PDE solver. Can anybody help me to figure out?
0 comentarios
Respuesta aceptada
Bill Greene
el 23 de Feb. de 2023
Editada: Bill Greene
el 23 de Feb. de 2023
I have created a PDE solver (pde1dm) that is similar to pdepe but includes some enhancements such as the capability to add some scalar equations to the set of PDE. In your example, one of these scalar equations can track the value of ϕ at the left end and this can be used in defining the PDE.
If you want to try pde1dm, it can be downloaded here. My MATLAB code for solving your example with pde1dm is shown below.
function matlabAnswers_2_21_2023
phi_p=1e-3;
phi_star=2.22;
Nx=20;
xInf=4;
x = linspace(0,xInf,Nx);
tf=1;
t = linspace(0,tf,200);
xOde = 0.0; % ODE at left end
%% solve pde
m = 0;
odeicf = @() ode_IC;
pdef=@(x,t,u,dudx,v) pde_F(x,t,u,dudx,v,phi_star);
pdebc=@(xl,ul,xr,ur,t) pde_BC(xl,ul,xr,ur,t, phi_p, phi_star);
[sol,odeSol] = pde1dm(m,pdef,@pde_IC,pdebc,x,t,@ode_F, odeicf,xOde);
figure; plot(x, sol(end,:)); grid; xlabel("eta");
title("phi at final time");
figure; plot(t, sol(:,1)); grid; xlabel("time");
title("phi at left end (phi_m)");
figure; plot(t, odeSol); grid; xlabel("time");
end
%% functions
function [c,f,s] = pde_F(x,t,u,dudx,v,phi_star) % PDE to be solved
phi_m=v;
c = 1;
f = dudx;
s = (phi_star-phi_m)*dudx;
end
% ---------------------------------------------
function u0 = pde_IC(x) % Initial conditions of PDE
u0=1;
end
% ---------------------------------------------
function [pl,ql,pr,qr] = pde_BC(xl,ul,xr,ur,t, phi_p, phi_star) % BCs
phi_m=ul;
pl=(phi_m-phi_star)*phi_p + (phi_star-phi_m)*phi_m;
ql=1;
qr=0;
pr=ur-1;
end
function R=ode_F(t,v,vdot,x,u,DuDx,f, dudt, du2dxdt) % ODE to be solved
R= u-v;
end
function value = ode_IC() % initial condition of ODE
value = pde_IC(0);
end
Más respuestas (1)
Ver también
Categorías
Más información sobre PDE Solvers 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!