This repository presents a numerical simulation of the one-dimensional heat conduction in a rod, based on the analytical solution of the heat equation using a Fourier series. The project is implemented in Python using NumPy and Matplotlib.
This project simulates the temperature distribution T(x, t) in a one-dimensional rod of length L, given an initial temperature profile. The solution is based on the analytical solution of the 1D heat equation with Dirichlet boundary conditions (T=0 at both ends), using the classical Fourier sine series expansion.
The heat equation (1D) is given by:
With:
- Initial condition: ( T(x, 0) = T_0 )
- Boundary conditions: ( T(0, t) = T(L, t) = 0 )
The analytical solution using the Fourier sine series is implemented.
L = 1: Length of the rodT0 = 100: Initial temperature of the rodalpha = 0.01: Thermal diffusivityterms = 100: Number of terms in Fourier seriesx = np.linspace(0, L, 200)t = 0 to 10 secondswith step0.25
The result is a dynamic plot of the temperature distribution over time, showing how the rod cools down from its initial temperature distribution.
Example:
Install the required Python packages using:
pip install numpy matplotlib