This repository contains a comprehensive Python script for simulating and visualizing the temperature distribution within a lithium-ion battery using a finite difference method. The code integrates various thermal properties, battery dimensions, initial and boundary conditions, and models the heat transfer processes over time, making it an excellent tool for understanding battery thermal behavior and management.
- Thermal Properties: Defines battery density, specific heat, and thermal conductivity.
- Battery Dimensions: Specifies the length, height, and depth of the battery.
- Grid Points: Creates a non-uniform mesh grid for 3D space discretization.
- Initial and Boundary Conditions: Sets initial temperature and boundary conditions for the battery.
- Heat Generation Function: Models internal heat generation within the battery, incorporating sinusoidal fluctuations to simulate driving conditions.
- Time Stepping: Implements time-stepping for the simulation with stability checks.
- Convergence Criterion: Monitors the convergence of the simulation to ensure accurate results.
- Finite Difference Solution: Utilizes finite difference equations to calculate temperature distribution over time.
- Progress Tracking: Provides iterative updates on the simulation's progress and elapsed time.
- 3D Visualization: Generates 3D plots to visualize the temperature distribution at mid-depth of the battery.
The thermal behavior of the lithium-ion battery is governed by the heat diffusion equation, a partial differential equation (PDE) describing how heat propagates through a medium over time:
where:
-
$T(x, y, z, t)$ is the temperature distribution. -
$\alpha$ is the thermal diffusivity. -
$q_{dot}(t)$ is the volumetric heat generation rate. -
$\rho$ is the density. -
$c_p$ is the specific heat capacity.
To simulate dynamic driving conditions, the heat generation rate
where:
-
$q_{base}$ is the baseline heat generation rate. -
$q_{peak}$ is the peak heat generation rate. -
$t_{cycle}$ is the period of the charge/discharge cycle.
- Bottom Face (Coolant Inlet): Linear temperature gradient.
- Top, Sides, Front, & Back: Convective heat transfer to ambient air.
- Spatial Discretization: Central difference approximations for spatial derivatives.
- Temporal Discretization: Crank-Nicolson method for time derivatives.
- Meshing: Non-uniform mesh with refined spacing near boundaries.
- Stability: Time step chosen to satisfy the Courant-Friedrichs-Lewy (CFL) condition.
- Install Dependencies: Ensure you have
numpyandmatplotlibinstalled.pip install numpy matplotlib
