A transient 3D battery thermal model combining heat generation, boundary cooling, and numerical-method validation.
Developed a 125,000-node thermal simulation of a simplified EV battery module using MATLAB and Python. Compared transient conduction, internal heat generation and cooling boundary conditions across both implementations, then tested numerical convergence and execution time on identical hardware.
Why model a battery in three dimensions?
Battery temperature is spatially nonuniform: heat is generated within the material, removed by cooling hardware, and exchanged with the surrounding air. A single average temperature conceals local hot spots and gradients that matter when assessing cooling strategies and computational methods.
I used a simplified rectangular battery module to compare numerical methods under matched conditions. The engineering question was twofold: could two independently implemented solvers reproduce comparable three-dimensional temperature fields, and how different would their execution times be on an ordinary laptop?
From heat equation to a reproducible numerical problem
I represented conductive transport and internal heat generation with the transient three-dimensional diffusion equation. Density, heat capacity and conductivity determined the thermal diffusivity, while the source term represented a time-dependent battery heat load.
A 254 × 152.4 × 101.6 mm volume was discretized into 100 × 50 × 25 points. Nonuniform spacing placed additional resolution near surfaces with stronger gradients. Second-order spatial differences and Crank–Nicolson time integration allowed temperature to advance toward a converged field.
- Initial condition: 25 °C throughout the module.
- Bottom face: prescribed coolant profile increasing from 20 to 30 °C along the plate.
- Other five faces: convective exchange with 25 °C air using a 10 W/(m²·K) coefficient.
- Convergence checked against the maximum absolute pointwise change between successive iterations.
α = k/(ρ cₚ), where k is thermal conductivity, ρ is density and cₚ is specific heat capacity.
Geometry. 0.254 × 0.1524 × 0.1016 m rectangular module
Discretization. 100 × 50 × 25 nodes (125,000 total); non-uniform spacing with boundary refinement
Benchmark hardware. 2020 Apple M1 MacBook Air, 8 GB RAM; equivalent mesh, model and stopping tolerance
Physical and thermal parameters
| Parameter | Symbol | Value |
|---|---|---|
| Density | ρ | 2,500 kg/m³ |
| Specific heat | cₚ | 780 J/(kg·K) |
| Thermal conductivity | k | 1.5 W/(m·K) |
| Thermal diffusivity | α | 7.69 × 10⁻⁷ m²/s |
| Internal heat generation | q̇ | 10,000–25,000 W/m³ |
| Air convection coefficient | hₐᵢᵣ | 10 W/(m²·K) |
| Initial temperature | T₀ | 25 °C |
| Coolant boundary temperature | T꜀ | 20–30 °C, spatially varying |
Initial and boundary conditions
| Domain | Physical condition |
|---|---|
| Bottom (z = 0) | Prescribed coolant temperature varying linearly from 20 to 30 °C |
| Top and four side faces | Convective heat loss to 25 °C ambient air |
| Initial volume | Uniform 25 °C initial temperature |
Additional model equations
Benchmark measurements
| Implementation | Iterations | Runtime |
|---|---|---|
| MATLAB | 11,762 | 81 s |
| Python | 11,760 | 3,450 s |
What the temperature fields reveal
The Python and MATLAB runs produced the same qualitative thermal pattern: cooler regions near the constrained edges and a slightly warmer interior, consistent with internally generated heat balanced by the boundary conditions. Both visualizations depict the mid-depth distribution rather than experimental thermal-camera data.
Inspecting independently generated temperature fields is useful for detecting incorrect boundary orientation, mesh indexing, and mismatched physical assumptions before making any performance claims.
A 42.6× runtime difference, with nearly identical convergence counts
Both implementations ran on the same 2020 M1 MacBook Air with 8 GB of RAM, using the same mesh, material assumptions and convergence tolerance. MATLAB converged in 11,762 iterations after 81 seconds; Python converged in 11,760 iterations after 3,450 seconds.
The result illustrates the performance of these specific implementations and software runtimes, not a general claim that MATLAB is inherently faster for every numerical problem. It is an implementation benchmark rather than a measured 40× optimization of existing code.
Measured simulation runtime
Same 125,000-node mesh, laptop and convergence setting. Runtime for the implementations tested, not a universal language comparison.
Lessons and limitations
The work showed that complex numerical analysis can be reproduced on consumer hardware without assuming both languages have identical execution characteristics. To extend this model toward battery-design decisions, the next steps would be mesh-convergence studies, physical cell-level geometry, temperature-dependent material properties, and validation against measured temperatures.
The strongest outcome is a transparent numerical workflow: fixed physical conditions, comparable solutions, explicit stopping criteria, and a performance comparison that remains honest about its scope.


