Problem when using pdepe with time dependant and nonconsistent boundary conditions

I have defined a system of four pde equations to solve a diffussion model. The inicial and boundary conditions of my system of pdes are the following:
function u0 = pdeic(x, params) % Initial Conditions
if x<1
u0=[0; 0; 0; 0];
else
u0 = [0.014; 0; 0; 0];
end
end
function [pl,ql,pr,qr] = pdebc(xl,ul,xr,ur, t, params) % Boundary Conditions
pl = [0; 0; 0; 0];
ql = [1; 1; 1; 1];
qr = [1; 1; 1; 1];
pr = [-2.51E-04/3; 0; 0; 0];
end
The only dependant varibale giving wrong results is the first one. I think it is related to the inconsistent condition for u0 and qr, pr. That is, the right boundary specifies that there is a change with the independant variable "x", whereas the initial condition specifies that for 0<x<1 the solution is a constant value and only at x=1 the solution is 0.014 (it is like a step at zero time). How could I fix this issue when the boundary and the initial conditions are not consistent?
Thanks for any help.

Answers (1)

If you specify the gradients of the solution variables as boundary conditions (as you do in your boundary function), you cannot have an inconsistency in the setting.
My guess is that the problem is the discontinuity in the initial condition of the first equation, but we must have executable code to verify this.

Products

Release

R2022a

Edited:

on 26 Jul 2023

Community Treasure Hunt

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

Start Hunting!