find the temperature distribution along a plane wall with large heat flux applied to the inner surface for short intervals in matlab

To find the temperature distribution along a plane wall with a large heat flux applied to the inner surface for short intervals, we can use the finite difference method. The following code demonstrates this method in MATLAB:

main.m
% Define parameters
L = 1; % length of wall in meters
dx = 0.01; % distance between nodes in meters
x = 0:dx:L; % vector of node locations
k = 0.5; % thermal conductivity in W/(m*K)
rho = 100; % density in kg/m^3
cp = 500; % specific heat capacity in J/(kg*K)
Q = 1e5; % heat flux in W/m^2
t = 1; % time in seconds
dt = 0.1; % time step in seconds
nt = t/dt; % number of time steps

% Initialize temperature vector
T = zeros(size(x));

% Apply boundary conditions
T(1) = 273; % temperature at left end of wall
T(end) = 273; % temperature at right end of wall

% Perform time loop
for i = 1:nt
    % Compute heat flux at each node
    q = zeros(size(x));
    q(1) = Q; % heat flux at left end of wall
    q(end) = 0; % heat flux at right end of wall
    q(2:end-1) = -k/dx*(T(3:end)-T(1:end-2));
    
    % Compute temperature at each node
    T = T + dt/(rho*cp*dx)*q;
end

% Plot temperature distribution
plot(x,T)
xlabel('Distance (m)')
ylabel('Temperature (K)')
965 chars
36 lines

In this code, we first define the parameters of the problem such as the length of the wall, the thermal conductivity, density, and specific heat capacity of the wall material, the heat flux applied to the inner surface, the time interval for which the heat flux is applied, and the time step for the finite difference method. We then initialize the temperature vector to zero and apply the boundary conditions. We then enter a loop that computes the heat flux at each node based on the temperature gradient, and then uses the heat flux to update the temperature at each node. Finally, we plot the temperature distribution along the wall.

gistlibby LogSnag