Solving an integral within a partial derivative
Show older comments
Hi everyone,
I am having trouble solving the following heat equation in Matlab


As you can see there will be an integral within the partial derivative.
When solving my equations work, but do not work over time. Thus i have a feeling I do something wrong with solving the integral. This is how I currently describe the problem. I did not fully iplement the higher order terms, as it does not work yet.
P = dimensionless term cf/kf
Z = 1/kf(w/W)
tmax = 1000 s
Any help would be greatly appreciated
m = 0;
sol = pdepe(m,@heatpde,@heatic,@heatbc,x,t);
function [c,f,s] = heatpde(x,t,u,dudx)
global B tmax Z P
c =P;
f = dudx;
y = @(u) (u.*(1-B/3*u+7*B^2/45*u.^2));
A = sqrt(2*B *integral(y,0,tmax))
s = -Z*u/A;
end
function u0 = heatic(x)
u0 = 0;
end
function [pl,ql,pr,qr] = heatbc(xl,ul,xr,ur,t)
pl = ul-1;
ql = 0;
pr = ur;
qr = 0;
Answers (1)
You have to solve a second ordinary differential equation for y:
dy/dt = 2*Ste * theta_f*(1-Ste/3 * theta_f + 7/45*Ste^2*theta_f^2)
y(t=0,x) = 0
Then y_LS = sqrt(y) in your equation for theta_f.
This can give problems because "pdepe" is designed to solve partial differential equations, not ordinary differential equations.
But since you prescribe theta_f at both ends of the spatial interval, you can compute y at these endpoints, too, and prescribe its value in "heatbc":
at x = 0: y = 2*Ste*integral(1-Ste/3+7/45*Ste^2) dt = 2*Ste*(1-Ste/3+7/45*Ste^2)*t
at x = L: y = 2*Ste*integral(0 dt) = 0
Is y_LS' differentiation with respect to t or with respect to x ? Same question for theta_f'.
13 Comments
kjell revenberg
on 21 Dec 2023
Since you set theta_f = 0 in your boundary condition part for "pdepe" instead of d(theta_f)/dx = 0 as in your description from above, I suggested to set
at x = 0: y = 2*Ste*integral(1-Ste/3+7/45*Ste^2) dt = 2*Ste*(1-Ste/3+7/45*Ste^2)*t
at x = L: y = 2*Ste*integral(0 dt) = 0
in the boundary condition part for y.
You can try y = 2*Ste*(1-Ste/3+7/45*Ste^2)*t at x = 0 and dy/dx = 0 at x = L instead :
function [pl,ql,pr,qr] = heatbc(xl,ul,xr,ur,t)
Ste = ...;
pl = [ul(1)-1;ul(2)-2*Ste*(1-Ste/3+7/45*Ste^2)*t];
ql = [0;0];
pr = [0;0];
qr = [1;1];
end
kjell revenberg
on 21 Dec 2023
Torsten
on 21 Dec 2023
m = 0;
sol = pdepe(m,@heatpde,@heatic,@heatbc,x,t);
function [c,f,s] = heatpde(x,t,u,dudx)
global B P
theta_f = u(1);
y_LS = sqrt(u(2));
d_theta_f_dx = dudx(1);
d_y_LS_dx = 1/(2*u(2))*dudx(2);
c = [P;1];
f = [dudx(1);0];
s = [-1/(k_f*w/W)*(theta_f/y_LS+B*theta_f*(theta_f+2*d_theta_f_dx/d_y_LS_dx*y_LS)/(6*y_LS)-...
B^2*theta_f^2*(40*(d_theta_f_dx/d_y_LS_dx)^2*theta_f^2+85*theta_f*d_theta_f_dx/d_y_LS_dx*y_LS+19*theta_f^2)/(360*y_LS));...
2*B * theta_f*(1-B/3 * theta_f + 7/45*B^2*theta_f^2)]
end
function u0 = heatic(x)
u0 = [0;0];
end
function [pl,ql,pr,qr] = heatbc(xl,ul,xr,ur,t)
global B
pl = [ul(1)-1;ul(2)-2*B*(1-B/3+7/45*B^2)*t];
ql = [0;0];
pr = [0;0];
qr = [1;1];
end
kjell revenberg
on 3 Jan 2024
Torsten
on 3 Jan 2024
Make a function in which you compute theta_f according to your infinite series for given t and x (e.g. by a while loop which stops if the absolute value of the n-th summand in the infinite series is smaller than a specified tolerance).
Call this function in "heatic" to give initial values to theta_f at t=t*. The initial values for y_ls can also be computed with this function by using "trapz" to evaluate the integral from 0 to t*.
kjell revenberg
on 5 Jan 2024
Torsten
on 5 Jan 2024
u0 = [0.1;0];
d_y_LS_dx = 1/(2*u(2))*dudx(2);
This will immediately result in a division by zero.
kjell revenberg
on 5 Jan 2024
kjell revenberg
on 8 Jan 2024
y(2) must always have initial value 0 for all x because t equals 0, and the integral from 0 to 0 of a function is 0. That's why I don't understand how the division by y(2) in your PDE can be dealt with. Maybe setting u0(2) = 0.00001 as you did is the best way to handle this problem.
If you set y(1) = 1 at x = 0, y(2) can by directly computed via the integral definition. It won't be y(2) = 1 - that's for sure. It will be t*(2*STE * 1*(1-STE/3 * 1 + 7/45*STE^2*1)).
kjell revenberg
on 9 Jan 2024
Torsten
on 9 Jan 2024
I wondered how you came to the formula for
dy_ls_dx as I think there lies the error.
Thanks in advance
Yes, it's sqrt(u(2)) instead of u(2) in the denominator:
y_ls = sqrt(u(2)) -> d(y_ls)/dx = 1/(2*sqrt(u(2))) * dudx(2)
Categories
Find more on Heat Transfer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

