bessavagner / heateq

Solve the heat equation in 1D

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Heat Equation

The module heateq can be used to solve the heat equation in 1D.

Getting Started

This module solve the partial differential (PDE) equation describing, for instance, the heat diffusion fenomena. The equation is as follows:

The boundary condition is , where is the size of the sample.

Prerequisites

Make sure you have installed numpy and scipy in your systems or environment. It is suggested to install via pip:

pip install numpy
pip install scipy

Usage

In example bellow, the defalt sample is initiated: 10 mm linear sample (with spacing 0.1mm - equivalent to 100 points), heated at 100°C (372 K) and smoothly cooled down until both edges at 20ºC (296 K). The choosen material is iron (D = 23 mm²/s).

import heateq as heq
import matplotlib.pyplot as plt

D = 23  # for iron
dx = 0.1
u0, t, xscale = heq.initiate(dx=dx)
k = heq.kappa(u0, dx)  # The FFT frequencies (wavenumbers)

u = heq.solve(dudt, u0, t, D, k)

plt.figure(figsize=(8, 8))
plt.contourf(xscale, t, u, 100)
plt.colorbar()
plt.show()

Here's the sample image:

Time varying map of the temperature distribution

Built With

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • IFCE - Instituto Federal de Ciência, Tecnologia e Educação do Ceara - Brazil
  • Inspiration: Steve Brunton See his chanel

About

Solve the heat equation in 1D

License:MIT License


Languages

Language:Python 100.0%