temperature of a plane wall originally at 20 degrees subject to a large heat flux applied for 0.2 seconds in matlab

Assuming that the plane wall has a constant thermal conductivity and constant density, we can use the following one-dimensional heat conduction equation to calculate the temperature distribution:

$\frac{\partial T}{\partial t} = \frac{\alpha}{\rho c_p} \frac{\partial^2 T}{\partial x^2}$

where $T$ is the temperature as a function of time $t$ and position $x$ along the plane wall. $\alpha$ is the thermal diffusivity given by $\alpha = \frac{k}{\rho c_p}$, where $k$ is the thermal conductivity, $\rho$ is the density, and $c_p$ is the specific heat capacity.

Since the heat flux is already known, we can apply the following boundary condition at the surface of the wall:

$-k\frac{\partial T}{\partial x}\bigg|_{x=0} = q''$

where $q''$ is the heat flux applied and negative sign indicates direction toward the wall surface. During the period of heating, $q''$ is assumed to stay constant.

To solve this equation numerically, we need to discretize the wall into small segments and approximate the second derivative using finite difference method:

$\frac{\partial^2 T}{\partial x^2} \approx \frac{T(x+\Delta x)-2T(x)+T(x-\Delta x)}{(\Delta x)^2}$

where $\Delta x$ is the size of each segment. Then, we can use the following forward difference scheme to move forward in time:

$T_i^{n+1} = T_i^n + \frac{\Delta t \alpha}{(\Delta x)^2 \rho c_p}(T_{i+1}^n - 2T_i^n + T_{i-1}^n)$

where $i$ is the index for each segment, $n$ is the index for each time step, and $\Delta t$ is the time step size. The initial condition is $T_i^0 = 20$ for all $i$.

We can implement this scheme in Matlab as follows:

main.m
% Define parameters
k = 1;          % thermal conductivity
rho = 1;        % density
c_p = 1;        % specific heat capacity
alpha = k/(rho*c_p);    % thermal diffusivity
T0 = 20;        % initial temperature
q = 100000;     % heat flux
t_end = 0.2;    % end time
dx = 0.01;      % segment size
dt = 0.001;     % time step size

% Discretize space and time
x = 0:dx:1;     % wall segment
t = 0:dt:t_end; % time steps

% Set initial condition
T = ones(length(x),length(t)) * T0;

% Solve using forward difference scheme
for n = 1:length(t)-1
    for i = 2:length(x)-1
        T(i,n+1) = T(i,n) + alpha*dt/((dx)^2*rho*c_p)*(T(i+1,n) - 2*T(i,n) + T(i-1,n));
    end
    % Apply boundary condition at surface
    T(1,n+1) = T(2,n+1) - dx*q/k;
end

% Plot temperature distribution
figure
plot(x,T(:,end),'LineWidth',2)
xlabel('Distance (m)')
ylabel('Temperature (C)')
title('Temperature Distribution after 0.2 seconds')
916 chars
34 lines

This will give us the temperature distribution across the wall at the end of the heating period, which can be plotted using plot(x,T(:,end)).

related categories

gistlibby LogSnag