A Python project for simulating heat diffusion in 1D materials.
This project aims to implement a numerical simulation of heat diffusion using the heat equation:
∂T/∂t = α * ∂²T/∂x²
where:
- T is temperature
- t is time
- x is position
- α is thermal diffusivity
Heat Diffusion Simulator/
├── src/ # Source code
├── tests/ # Unit tests
├── results/ # Output results
├── requirements.txt # Dependencies
└── README.md # This file
- Python 3.8+
- NumPy
- Matplotlib
- pytest (for testing)
pip install -r requirements.txtRun simulations using the command-line interface:
cd src
python main.py --alpha 0.01 --L 1.0 --nx 100 --t-end 10.0 --ic gaussianRequired Parameters:
--alpha: Thermal diffusivity (m²/s)--L: Length of material (m)--nx: Number of grid points--t-end: Simulation time (s)
Initial Conditions:
--ic {gaussian,step}: Initial condition type--ic-center: Center position (default: middle)--ic-width: Width for Gaussian IC--ic-amplitude: Amplitude (default: 1.0)
Boundary Conditions:
--bc {dirichlet,neumann}: Boundary condition type--left-temp: Left boundary temperature--right-temp: Right boundary temperature
Output Options:
--output: Output directory (default: output)--csv: Export to CSV format--no-plot: Skip plots--no-save: Skip saving data--quiet: Suppress output
Gaussian heat pulse:
python main.py --alpha 0.01 --L 1.0 --nx 100 --t-end 10.0 --ic gaussianStep function with Neumann boundaries:
python main.py --alpha 0.005 --L 2.0 --nx 200 --t-end 20.0 --ic step --bc neumann --csvCustom output directory:
python main.py --alpha 0.01 --L 1.0 --nx 150 --t-end 15.0 --ic gaussian --output my_results- ✅ FTCS (Forward-Time Central-Space) finite difference method
- ✅ Multiple initial conditions (Gaussian, step function)
- ✅ Boundary conditions (Dirichlet, Neumann)
- ✅ Stability checking (CFL condition)
- ✅ Temperature profile visualization
- ✅ Temperature evolution plots
- ✅ Data export (NPZ, CSV)
- ✅ Command-line interface
This project is being developed incrementally:
- Day 1: Project setup ✓
- Day 2: Core physics implementation ✓
- Day 3: Initial and boundary conditions ✓
- Day 4: Visualization and data output ✓
- Day 5: Command-line interface ✓
Student - Applied Physics Course