find the temperature distribution along a plane wall with large heat flux applied to the inner surface for 0.2 seconds every 1 second in matlab

To find the temperature distribution along a plane wall with large heat flux applied to the inner surface for 0.2 seconds every 1 second in matlab, we can use finite difference method (FDM) with the following steps:

  1. Define the geometry and initial/boundary conditions:
main.m
% Define geometry and discretization
L = 1; % [m] Wall thickness
n = 11; % Number of grid points
dx = L / (n-1); % Grid spacing
x = linspace(0, L, n); % Grid points
t = 1; % [s] simulation time
dt = 0.01; % [s] time step
timesteps = t / dt;

% Define initial temperature distribution
T = zeros(n,1);
T(1) = 100; % [C] Inner surface temperature

% Define boundary conditions
q0 = 1000; % [W/m^2] Heat flux
405 chars
16 lines
  1. Define the FDM coefficients:
main.m
% Define FDM coefficients
a = dt / (rho * Cp * dx^2);
b = -2 * a;
c = q0 / (k * dx);
85 chars
5 lines
  1. Implement the FDM solver:
main.m
% FDM solver
for j = 1:timesteps
    for i = 2:n-1
        % Update temperature at each grid point using FDM
        T(i) = T(i) + a * (T(i+1) - 2*T(i) + T(i-1)) + c * (i==2)* (j*dt<=0.2);
    end
end
201 chars
8 lines
  1. Visualize the temperature distribution:
main.m
% Plot temperature distribution
plot(x,T)
xlabel('Distance (m)')
ylabel('Temperature (C)')
title('Temperature distribution along a plane wall')
144 chars
6 lines

The final code would look like this:

main.m
% Define geometry and discretization
L = 1; % [m] Wall thickness
n = 11; % Number of grid points
dx = L / (n-1); % Grid spacing
x = linspace(0, L, n); % Grid points
t = 1; % [s] simulation time
dt = 0.01; % [s] time step
timesteps = t / dt;

% Define material properties
k = 1; % [W/mK] Thermal conductivity
rho = 1; % [kg/m^3] Density
Cp = 1; % [J/kgK] Specific heat capacity

% Define initial temperature distribution
T = zeros(n,1);
T(1) = 100; % [C] Inner surface temperature

% Define boundary conditions
q0 = 1000; % [W/m^2] Heat flux

% Define FDM coefficients
a = dt / (rho * Cp * dx^2);
b = -2 * a;
c = q0 / (k * dx);

% FDM solver
for j = 1:timesteps
    for i = 2:n-1
        % Update temperature at each grid point using FDM
        T(i) = T(i) + a * (T(i+1) - 2*T(i) + T(i-1)) + c * (i==2)* (j*dt<=0.2);
    end
end

% Plot temperature distribution
plot(x,T)
xlabel('Distance (m)')
ylabel('Temperature (C)')
title('Temperature distribution along a plane wall')
974 chars
40 lines

This code will solve for the temperature distribution along the wall for the given conditions using the finite difference method.

gistlibby LogSnag