Handling of pdepe function

Hello at this moment I am working to solve a heat transfer problem by conduction and I am using the partial differential equations to find a solution for it I have been using the pdepe function, however one of the boundary conditions varies in time and I would like to add it as an external variable but the pdepe function does not allow me and I have not found in the documentation how to solve it finally I would like to know if it is possible to use the solution of this type of equations in a simulink block I add the code that I have implemented.
close all
clc
L_bi = 0.22;
L_be = 0.33;
r_bi = 0.8;
H_b = 1.85; %% [m]
kbi = 0.28; %% W/(m×K)JM23
kbe = 0.01; % --------------
hbi = 5;
rho_bi = 800; %% [ kg/m³]
rho_be = 480;
Cp_bi = 0.85; %% (kJ/kg/°K)
Cp_be = 0.85;
Ti = 278.15; %% [Kelvin]
T_ext = 288.15;%%
% pdepe
N = 1001;
m = 2; %
t_final = 24*60*60;
x = linspace(r_bi,r_bi+L_be,N); %
t = linspace(0,t_final,N); % T
sol= pdepe(m,@pdefun,@icfun,@bcfun,x,t,u); %
function [c,f,s] = pdefun(x,t,u,DuDx)
kbi = 280; %% W/(m×K)JM23
kbe = 400; % --------------
rho_bi = 800; %% [ kg/m³]
rho_be = 480;
Cp_bi = 850; %% (kJ/kg/°K)
Cp_be = 850;
hbi = 5;
hbe = 5;
if(x < 1.02)
c = rho_bi*Cp_bi;
f = kbi*DuDx;
s = 0;
else
c = rho_be*Cp_be;
f = kbe*DuDx;
s = 0;
end
end
function u0 = icfun(x)
u0 = 288.15; %
end
function [pl,ql,pr,qr] = bcfun(xl,ul,xr,ur,t)
T_inf = 270.15;%%
A = 28000*rand(1);
q= A*sin(0.1*rand(1)*t);
%q = 28000;
kbi = 0.28; %% W/(m×K)JM23
kbe = 0.4; % --------------
hbi = 5;
hbe = 5;
pl = q; %
ql = kbi;
pr = -hbe*(ur-T_inf); %
qr = -kbe;
end

Answers (1)

Torsten
Torsten on 22 May 2023
Moved: Torsten on 22 May 2023
In any numerical method that uses the smoothness of the input data and functions to produce results (like e.g. pdepe), it is forbidden to use random inputs that change from iteration to iteration. You can use a function continuously varying in time for your boundary condition, but not a stochastic random number generator.

Asked:

on 22 May 2023

Moved:

on 22 May 2023

Community Treasure Hunt

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

Start Hunting!