Heating of Finite Slab
This example shows how to find the temperature distribution of a one-dimensional finite slab by solving the governing differential equation. The example uses Symbolic Math Toolbox™ to solve the problem of heat transfer analytically in a finite slab as discussed in [1].
The finite slab has constant thermal properties. Assume that heat transfer is due only to conduction with a given thermal diffusivity . The slab is located in the space between and , where heat propagates along the -direction. Initially, the slab is at temperature . At time , the edges at are suddenly raised to temperature and maintained there. This example solves for the temperature distribution of the slab as a function of the -coordinate and time by following these steps:
Define the heat transfer equation.
Use the method of separation of variables.
Apply boundary conditions to find the mode solutions.
Find the coefficients of the general solution by computing the integral of orthogonal functions.
Plot the solution for the temperature as a function of the -coordinate and time.
Define Heat Transfer Equation
For a three-dimensional homogeneous medium, the heat transfer equation due to conduction is given by
.
Because heat is transferred along the -direction, you can reduce the heat transfer equation to
.
Next, define these dimensionless variables:
Dimensionless temperature
Dimensionless coordinate
Dimensionless time
The differential equation for the heat transfer in terms of these dimensionless variables is
,
where the initial condition at is , and the boundary conditions at are for .
Define the main differential equation.
syms Theta(eta,tau)
eqMain = diff(Theta,tau) == diff(Theta,eta,eta)
eqMain(eta, tau) =
Method of Separation of Variables
Use the method of separation of variables to find the solution for . This method separates the spatial and time dependencies by writing them as a product of spatial and time-dependent functions, where .
syms f(eta) g(tau) eqTheta = Theta(eta,tau) == f(eta)*g(tau)
eqTheta =
Substitute this ansatz into the differential equation.
eqMain = subs(eqMain,lhs(eqTheta),rhs(eqTheta))
eqMain(eta, tau) =
Separate the and terms so that they are be on different sides of the equation.
eqMain = eqMain/g(tau)/f(eta)
eqMain(eta, tau) =
Set each side of the equation to a constant. For convenience, let this constant be .
syms c real eq1(tau) = lhs(eqMain) == -c^2
eq1(tau) =
eq2(eta) = rhs(eqMain) == -c^2
eq2(eta) =
Apply Boundary Conditions to Find Mode Solution
Next, find the solutions for and by applying the appropriate boundary conditions.
Solve the first-order differential equation for by using dsolve.
gsol(tau) = dsolve(eq1)
gsol(tau) =
For , find the even solution based on the symmetry along the -axis. Because the slab is located at to and the temperature at both edges is fixed at , the function is symmetrical with respect to the origin. Find the general solution using dsolve
.
fsol(eta) = dsolve(eq2)
fsol(eta) =
For a well-behaved function, you can also write the general solution as . The even part of this solution is and the odd part of this solution is . Define the even solution of .
fsol_even(eta) = (fsol(eta) + fsol(-eta))/2
fsol_even(eta) =
Symbolic Math Toolbox uses as a dummy variable to represent a constant. In the solutions for and above, the variable represents different constants. Rewrite the variable from the even solution of as .
syms C1 C_f fsol = subs(fsol_even,C1,C_f)
fsol(eta) =
Apply the other boundary condition at , where , and solve for the parameter .
[csol,params,conds] = solve(fsol(1)==0,c,ReturnConditions=true)
csol =
params =
conds =
The parameter in the solutions for and depends on an integer parameter , where .
Substitute the solutions for and into .
eqTheta = subs(eqTheta,{f g},{fsol gsol})
eqTheta =
Rewrite the constant term as . Rewrite the solution to depend on as well. This mode solution uses the index for the dimensionless temperature .
syms C(k) D(k) eqTheta = subs(eqTheta,{C1*C_f c},{C(k) csol})
eqTheta =
Compute Integral of Orthogonal Functions
Next, construct the general solution of the differential equation from the mode solution. Get the right side of the equation in eqTheta
to perform further computations.
Theta_k(eta,tau,k) = rhs(eqTheta)
Theta_k(eta, tau, k) =
Following the steps in the textbook [1], combine the terms with indices and . Simplify these combined terms.
Theta_k2(eta,tau,k) = simplify(Theta_k(eta,tau,k) + Theta_k(eta,tau,-(k+1)))
Theta_k2(eta, tau, k) =
Rewrite the general solution by summing all of these modes. Here, define another coefficient to represent . Then, take the summation of the indices from 0 to .
Theta_sol = symsum(subs(Theta_k2,C(-k-1)+C(k),D(k)),k,0,Inf)
Theta_sol(eta, tau) =
Next, find the coefficient based on the initial condition of the problem. To do this, set the boundary condition and find the integral of the orthogonal functions that involve the function. Set the initial boundary condition .
ThetaBound = Theta_sol(eta,0) == 1
ThetaBound =
Multiply both sides of the above equation by , and find the integral with respect to . Here, the indices and are integers.
syms m k integer ThetaBound = ThetaBound*cos((m+1/2)*pi*eta)
ThetaBound =
ThetaBound = int(lhs(ThetaBound),eta,-1,1) == int(rhs(ThetaBound),eta,-1,1)
ThetaBound =
This integration involves a symbolic summation series that uses the symsum
function. Symbolic Math Toolbox does not find this integral explicitly, so you need to investigate the integral of each summation term on the left side of the above equation. Extract each symbolic summation term that has the indices and . Define this term as a new expression. You can copy and paste from the output above when defining this expression manually.
expr_temp = cos(sym(pi)*eta*(m + sym(1/2)))*cos((sym(pi)*eta*(2*k + 1))/2)*D(k)
expr_temp =
Next, find the integral of the expression over from to .
expr_int = int(expr_temp,eta,-1,1)
expr_int =
Symbolic Math Toolbox simplifies the integral. To compare this result with the one in the textbook without simplification, check this integral by assuming that and are equal (as in the first piecewise condition above).
expr_temp2 = cos(pi*eta*(m+1/2))*cos(pi*eta*(m+1/2))*D(m)
expr_temp2 =
Without simplification, Symbolic Math Toolbox returns the integral as in the textbook example.
expr_int2 = int(expr_temp2,eta,-1,1)
expr_int2 =
Because is an integer, you can simplify this result.
expr_int2 = simplify(expr_int2)
expr_int2 =
Next, find the coefficient by applying the boundary condition from the previous step. Simplify the equation for with the applied boundary condition, and isolate on the left side of the equation.
ThetaBound = expr_int2 == rhs(ThetaBound)
ThetaBound =
ThetaBound = isolate(simplify(ThetaBound),D(m))
ThetaBound =
Change the dummy variable to . Finally, substitute into the general solution. This solution represents the heat transfer of a finite one-dimensional slab.
ThetaBound = subs(ThetaBound,m,k); Theta_sol = subs(Theta_sol,D,rhs(ThetaBound))
Theta_sol(eta, tau) =
Plot Solution for Temperature
Plot the dimensionless temperature of the slab as a function of at various values of . Because the temperature solution involves a summation series with infinite terms, evaluating all these terms when plotting can be slow. To improve the plotting performance, you can approximate the infinite summation series as a summation series of up to . Note that the temperature solution is a converging series and numerically stable. For this reason, approximating the series works well to improve the plotting performance.
Theta_sol_approx = subs(Theta_sol,Inf,40);
Plot the temperature of the slab for various values of by using fplot
.
% Plot the result as in figure 12.1-1 of reference [1] fplot(eta,1-Theta_sol_approx(eta,0.01),[0 1]) axis equal hold on fplot(eta,1-Theta_sol_approx(eta,0.04),[0 1]) fplot(eta,1-Theta_sol_approx(eta,0.1),[0 1]) fplot(eta,1-Theta_sol_approx(eta,0.2),[0 1]) fplot(eta,1-Theta_sol_approx(eta,0.4),[0 1]) fplot(eta,1-Theta_sol_approx(eta,0.6),[0 1]) fplot(eta,1-Theta_sol_approx(eta,1),[0 1]) text(0,1.03,"center of slab") text(1,1.03,"surface of slab") xlabel("$y/b$",interpreter="latex") ylabel("$\frac{T-T_0}{T_1-T_0}$",interpreter="latex") legend("$\tau=0.01$","$\tau=0.04$","$\tau=0.1$","$\tau=0.2$", ... "$\tau=0.4$","$\tau=0.6$","$\tau=1$", ... interpreter="latex",Location="eastoutside") hold off
Next, plot the temperature in the SI unit as a function of the -coordinate and time, where , , , and . Define these parameters and assume the units are in SI.
T1 = 1000; T0 = 500; b = 0.2; alpha = 10^-4;
Define variables for the temperature , coordinate , and time . From the dimensionless temperature solution in Theta_sol
, find the temperature solution in by substituting these parameter values. Also, replace the infinite summation terms with a summation term of up to to improve the performance when plotting this solution.
syms T y t T_eqn = (T1-T)/(T1-T0) == subs(Theta_sol,{eta,tau},{y/b,alpha*t/b^2}); T_sol = isolate(T_eqn,T); T_sol = subs(rhs(T_sol),Inf,40);
Create a surface plot of the temperature as a function of the -coordinate and time. You can see that initially the slab is at with edges at , and after about , the temperature across the slab reaches the steady-state value of .
figure fsurf(T_sol,[1 600 -b b]) xlabel("time (s)") ylabel("y-coordinate (m)") zlabel("temperature (K)")
References
[1] Bird, R. Byron, Warren E. Stewart, and Edwin N. Lightfoot. Transport Phenomena, 2nd ed. (New York: Wiley, 2007), 376–378, Example 12.1-2.
See Also
dsolve
| solve
| int
| symsum
| subs
| fplot
| fsurf