Lumped Capacitance Analysis using Python

Lumped capacitance analysis is used when an object at high temperature is suddenly placed in a cooler medium. If the conductive resistance of the solid is much smaller than the convective resistance, we can treat the object as having uniform temperature throughout (a "lump"). The rate of internal energy change equals the heat transfer to the surrounding fluid.

Hot Object T(t) Surrounding Fluid T? (constant) Heat Transfer q = hA(T - T?)

Mathematical Formulation

The energy balance equation for lumped capacitance analysis is ?

$$\mathrm{?cV\frac{\partial T}{\partial t} \: = \: - hA(T \: - \: T_{\infty}) \: \dotso\dotso \: (1)}$$

Rearranging to get the temperature gradient ?

$$\mathrm{\frac{\partial T}{\partial t} \: = \: - \frac{hA}{?cV}(T \: - \: T_{\infty}) \: \dotso\dotso \: (2)}$$

Integrating equation (2) with initial temperature T? at time t=0 gives ?

$$\mathrm{\frac{T \: - \: T_{\infty}}{T_{0} \: - \: T_{\infty}} \: = \: \exp(-\frac{hA}{?cV}t) \: \dotso\dotso \: (3)}$$

Key Applications

The lumped capacitance equation can be used for two main calculations ?

  • Time to reach final temperature:

$$\mathrm{t \: = \: - \frac{?cV}{hA}\ln(\frac{T_{f} \: - \: T_{\infty}}{T_{0} \: - \: T_{\infty}}) \: \dotso\dotso \: (4)}$$

  • Temperature at specific time:

$$\mathrm{T \: = \: T_{\infty} \: + \: (T_{0} \: - \: T_{\infty}) \: \times \: \exp (-\frac{hA}{?cV}t_{f}) \: \dotso\dotso \: (5)}$$

Example 1: Time to Cool Steel Ball

A steel ball (radius 1 mm) at 1200°C is placed in air at 25°C. Calculate time to cool to 100°C. Given: k = 50 W/mK, c = 500 kJ/kgK, ? = 8000 kg/m³, h = 10000 W/m²K.

Solution

Since we need time, we use equation (4) ?

import numpy as np

# Input Data
T_inf = 25       # Ambient temperature (°C)
r = 1e-3         # Radius (m)
T0 = 1200        # Initial temperature (°C)
Tf = 100         # Final temperature (°C)
k = 50           # Thermal conductivity (W/mK)
c = 500          # Specific heat (J/kgK)
rho = 8000       # Density (kg/m³)
h = 10000        # Convection coefficient (W/m²K)

# Calculate volume and surface area for sphere
A = 4 * np.pi * r**2
V = (4/3) * np.pi * r**3

# Time constant
tau0 = rho * c * V / (h * A)

# Calculate time using equation (4)
t = -tau0 * np.log((Tf - T_inf) / (T0 - T_inf))

print(f'Time to cool from {T0}°C to {Tf}°C: {t:.3f} seconds')
print(f'Time constant ??: {tau0:.6f} seconds')
Time to cool from 1200°C to 100°C: 0.367 seconds
Time constant ??: 0.133333 seconds

Example 2: Temperature at Specific Time

What is the temperature of the steel ball after 0.1 seconds ?

Solution

We use equation (5) to find temperature at given time ?

import numpy as np

# Same input data as Example 1
T_inf = 25
r = 1e-3
T0 = 1200
t = 0.1          # Time (s)

k = 50
c = 500
rho = 8000
h = 10000

# Calculate volume and surface area
A = 4 * np.pi * r**2
V = (4/3) * np.pi * r**3

# Time constant
tau0 = rho * c * V / (h * A)

# Calculate temperature using equation (5)
T = T_inf + (T0 - T_inf) * np.exp(-t / tau0)

print(f'Temperature after {t} seconds: {T:.1f}°C')
print(f'Temperature drop: {T0 - T:.1f}°C')
Temperature after 0.1 seconds: 580.0°C
Temperature drop: 620.0°C

Example 3: Temperature vs Time Plot

To visualize the cooling behavior, we plot temperature variation over time ?

import numpy as np
import matplotlib.pyplot as plt

# Input Data
T_inf = 25
r = 1e-3
T0 = 1200

c = 500
rho = 8000
h = 10000

# Calculate volume and surface area
A = 4 * np.pi * r**2
V = (4/3) * np.pi * r**3

# Time constant
tau0 = rho * c * V / (h * A)

# Time array
t = np.linspace(0, 1.0, 50)

# Temperature using analytical solution
T = T_inf + (T0 - T_inf) * np.exp(-t / tau0)

# Create plot
plt.figure(figsize=(8, 5))
plt.plot(t, T, 'r-o', markersize=4, linewidth=2)
plt.xlabel('Time (s)')
plt.ylabel('Temperature (°C)')
plt.title('Lumped Capacitance Analysis: Steel Ball Cooling')
plt.grid(True, alpha=0.3)
plt.tight_layout()
plt.show()

# Print some key values
print(f'Initial temperature: {T[0]:.1f}°C')
print(f'Temperature at 0.5s: {T[25]:.1f}°C')
print(f'Final temperature: {T[-1]:.1f}°C')
Initial temperature: 1200.0°C
Temperature at 0.5s: 64.7°C
Final temperature: 26.3°C

Numerical Solution Approach

The differential equation can also be solved numerically using explicit finite difference method. We discretize equation (2) using forward difference ?

time i-1 i i+1 ?t T??? T?

The discretized equation becomes ?

$$\mathrm{\frac{T_{i} \: - \: T_{i-1}}{\Delta t} \: = \: -\frac{1}{\tau_0}(T_{i} \: - \: T_{\infty})}$$

Solving for T? ?

$$\mathrm{T_{i} \: = \: T_{i-1} \: - \: \Delta t \: \times \: \frac{(T_{i} \: - \: T_{\infty})}{\tau_0} \: \dotso\dotso \: (6)}$$

Numerical Implementation

import numpy as np
import matplotlib.pyplot as plt

# Input Data
T_inf = 25
r = 1e-3
T0 = 1200

c = 500
rho = 8000
h = 10000

# Calculate volume and surface area
A = 4 * np.pi * r**2
V = (4/3) * np.pi * r**3
tau0 = rho * c * V / (h * A)

n = 35  # Number of time steps
t = np.linspace(0, 1.0, n)
dt = 1 / (n - 1)

# Initialize temperature arrays
T_numerical = np.zeros(n)
T_numerical[0] = T0

# Time marching with iteration
for i in range(1, n):
    # Initial guess
    T_guess = T_numerical[i-1]
    error = 1.0
    
    # Iterate until convergence
    while error > 1e-5:
        T_new = T_numerical[i-1] - dt * (T_guess - T_inf) / tau0
        error = abs(T_new - T_guess)
        T_guess = T_new
    
    T_numerical[i] = T_new

# Analytical solution for comparison
T_analytical = T_inf + (T0 - T_inf) * np.exp(-t / tau0)

# Plot comparison
plt.figure(figsize=(10, 6))
plt.plot(t, T_numerical, 'r-o', label='Numerical', markersize=4)
plt.plot(t, T_analytical, 'b-s', label='Analytical', markersize=3, alpha=0.7)
plt.xlabel('Time (s)')
plt.ylabel('Temperature (°C)')
plt.title('Comparison: Numerical vs Analytical Solution')
plt.legend()
plt.grid(True, alpha=0.3)
plt.tight_layout()
plt.show()

# Print comparison at key points
print("Comparison at selected time points:")
print("Time\tAnalytical\tNumerical\tError")
print("-" * 45)
for i in [0, 10, 20, 30, -1]:
    error = abs(T_analytical[i] - T_numerical[i])
    print(f"{t[i]:.3f}\t{T_analytical[i]:.1f}°C\t\t{T_numerical[i
Updated on: 2026-03-27T14:37:06+05:30

482 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements