1D Heat equation in Matlab with variable heat Flux at one side
4 views (last 30 days)
Show older comments
I have a similar problem to the one formulated in the following question:
In my case, however, the heat flux density is not constant and is added to the geometry.
I am trying to implement Beck's nonlinear estimation method. For this I have to evaluate the equation in each iteration step once with the heat flux density q and once with q(1+e), where e = 10^-3, to calculate a sensitivity factor. As I understand it, the temperatures with the heat flow density q(1+e) should always be greater than those of q, but this is not always the case for me. I don't know if I have the wrong idea or if there is a bug in my code. I would be very grateful for any help!
This is my current code:
function pdepeSolverTest
xmesh = 0:.0001:0.014;
tmesh = -1:.05:20;
m = 0;
e = 10^-3;
lamb = 26.7;
rho = 7600;
cp = 496;
T0 = 300;
Tr = 300;
currqdt = 10000;
Tq = pdepe(m,@heatConduction,@heatConductionIni,@heatConductionBc,xmesh, tmesh);
currqdt = 10000 *(e+1);
Tqe = pdepe(m,@heatConduction,@heatConductionIni,@heatConductionBc,xmesh, tmesh);
function [pl,ql,pr,qr] = heatConductionBc(xl,ul,xr,ur,t)
pl = currqdt;
ql = 1;
pr = ur - Tr;
qr = 0;
end
function u0 = heatConductionIni(x)
u0 = T0;
end
function [c,f,s] = heatConduction(x,t,u,dudx)
c = rho*cp;
f = lamb*dudx;
s = 0;
end
end
In the current code, Tq is larger than Tqe in a few places.
0 Comments
Accepted Answer
Torsten
on 10 Nov 2023
You are doing numerics here. The maximum difference is 1e-13, I think this is acceptable:
pdepeSolverTest()
function pdepeSolverTest
xmesh = 0:.0001:0.014;
tmesh = -1:.05:20;
m = 0;
e = 10^-3;
lamb = 26.7;
rho = 7600;
cp = 496;
T0 = 300;
Tr = 300;
currqdt = 10000;
Tq = pdepe(m,@heatConduction,@heatConductionIni,@heatConductionBc,xmesh, tmesh,odeset('RelTol',1e-12,'AbsTol',1e-12));
currqdt = 10000 *(e+1);
Tqe = pdepe(m,@heatConduction,@heatConductionIni,@heatConductionBc,xmesh, tmesh,odeset('RelTol',1e-12,'AbsTol',1e-12));
any(Tq(:)-Tqe(:)>0)
nnz(Tq(:)-Tqe(:)>0)
max(Tq(:)-Tqe(:))
function [pl,ql,pr,qr] = heatConductionBc(xl,ul,xr,ur,t)
pl = currqdt;
ql = 1;
pr = ur - Tr;
qr = 0;
end
function u0 = heatConductionIni(x)
u0 = T0;
end
function [c,f,s] = heatConduction(x,t,u,dudx)
c = rho*cp;
f = lamb*dudx;
s = 0;
end
end
3 Comments
Torsten
on 10 Nov 2023
For which location and at which time do you want to compute the sensitivity of temperature on heat flux density ?
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
