To find the initial temperature as a function of position in a plane wall under transient heat conduction in MATLAB, you will need to solve the Heat Equation with the given boundary and initial conditions. Here's an approach to solve this problem using the Finite Difference Method:
Discretize the wall into a grid of n x m nodes, with the distance between two adjacent nodes in x direction being dx and in y direction being dy.
Define the time step size dt.
Define the boundary conditions. For example, if the wall is exposed to an environment of constant temperature T_inf1 and T_inf2 on two opposite sides, the boundary conditions can be T(1,j,k) = T_inf1, T(n,j,k) = T_inf2 for j = 1:m and k = 1:Nt (number of time steps).
Define the initial condition. For example, if the wall initially has a uniform temperature T0, the initial condition can be T(i,j,1) = T0 for i = 2:n-1 and j = 2:m-1.
Use the Forward Time Centered Space (FTCS) scheme to update the temperature at each node at each time step. The FTCS scheme is given by:
T(i,j,k+1) = T(i,j,k) + alpha*(T(i+1,j,k) - 2T(i,j,k) + T(i-1,j,k) + T(i,j+1,k) - 2T(i,j,k) + T(i,j-1,k))
where alpha = k/(rho*Cp)*dt/dx^2 is the thermal diffusivity of the material.
Repeat step 5 for k = 1:Nt-1, where Nt is the number of time steps.
The final solution gives the temperature distribution in the wall as a function of position and time.
Here's a sample MATLAB code that implements the above steps for a wall of length L, height H and initial temperature T0:
main.m1158 chars39 lines
This code discretizes the wall into a 100 x 100 grid, uses a time step size of 0.1 and solves for 100 time steps. The resulting temperature distribution is plotted using the contourf
function. You can adjust these parameters as per your requirements.
gistlibby LogSnag