Discrete, time varying Dirichlet boundary conditions for heat equation in pdepe

4 visualizaciones (últimos 30 días)
I am trying to determine the thermal diffusivity of a material by iteratively solving the heat equation using pdepe. I have a time series of temperature measurements at discrete time and space intervals (let's say x=0:29, t = 0:15 for this example). I would like to impose Dirichlet boundary conditions using the T(x=0) and T(x = 29) temperatures at each timestep. However, because these are not constant, I am unsure of how to represent these in the BC function. Matlab spits this error: "Spatial discretization has failed. Discretization supports only parabolic and elliptic equations, with flux term involving spatial derivative." Code below. I appreciate any help. Thanks!
L = 29;
x = [0:1:L];
t = [0:1:15];
m = 0;
uUpper = trimmedTempData(1,1:16);
uLower = trimmedTempData(end,1:16);
t0 = trimmedTempData(:,1);
BCFun = @(xU,uU,xL,uL,t) diffusionBCs(xU,uUpper,xL,uLower,t);
ICFun = @(x) diffusionICs(x,t0);
sol = pdepe(m,@diffusionPDE,ICFun,BCFun,x,t);
function [c,f,s] = diffusionPDE(x,t,u,dudx)
alpha = 3.9e-7;
c = 1/alpha;
f = dudx;
s = 0;
end
function u0 = diffusionICs(x,t0)
u0 = t0(x+1);
end
function [pUpper,qUpper,pLower,qLower] = diffusionBCs(xUpper,uUpper,xLower,uLower,t)
pUpper = uUpper(t+1) - uUpper(t+1);
qUpper = 0;
pLower = uLower(t+1) - uLower(t+1);
qLower = 0;
end

Respuesta aceptada

Torsten
Torsten el 29 de Mayo de 2023
L = 29;
x = [0:1:L];
t = [0:1:15];
m = 0;
uUpper = trimmedTempData(1,1:16);
uLower = trimmedTempData(end,1:16);
t0 = trimmedTempData(:,1);
fun_uUpper = @(time) interp1(t,uUpper,time);
fun_uLower = @(time) interp1(t,uLower,time);
fun_u0 = @(xc) interp1(x,t0,xc);
BCFun = @(xU,uU,xL,uL,t) diffusionBCs(xU,uU,fun_uUpper,xL,uL,fun_uLower,t);
ICFun = fun_u0;
sol = pdepe(m,@diffusionPDE,ICFun,BCFun,x,t);
function [c,f,s] = diffusionPDE(x,t,u,dudx)
alpha = 3.9e-7;
c = 1/alpha;
f = dudx;
s = 0;
end
function [pUpper,qUpper,pLower,qLower] = diffusionBCs(xUpper,uUpper,fun_uUpper,xLower,uLower,fun_uLower,t)
pUpper = uUpper - fun_uUpper(t);
qUpper = 0;
pLower = uLower - fun_uLower(t);
qLower = 0;
end

Más respuestas (0)

Categorías

Más información sobre Thermal Analysis 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!

Translated by