Lesson 27 (Capstone 3): Coupled Heat Exchanger, Pipe Friction & Solar Thermal Loop

Courses Integrated: Heat & Mass Transfer (\(\varepsilon\)-NTU & Convection) + Fluid Mechanics (Moody/Colebrook Pumping Power) + Renewable Energy I (Solar Collectors)
Companion Datasets: HMT_Heat_Exchanger_NTU_Data.csv, Solar_Collector_FlatPlate_Hourly_Data.csv

Why Engineers Love Coupled Simulation

In isolated homework problems, Heat Transfer tells you \(D_{\text{tube}} = 10\text{ mm}\) gives high Nusselt number \(Nu\), while Fluids complains \(\Delta P \propto D^{-5}\) explodes! On a real solar hot-water system (Solar Collector -> Glycol Heat Exchanger -> Domestic Water Tank), shrinking tube diameter boosts HX thermal effectiveness at the direct expense of electric pumping watts.

In this capstone, you couple all three domains simultaneously to find the true Pareto optimum!

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from pathlib import Path
from scipy.optimize import brentq

# --- Step 1: Validate Counterflow & Shell-Tube epsilon-NTU Equations Against HMT CSV ---
hx_p = next(p for p in [Path("datasets/HMT_Heat_Exchanger_NTU_Data.csv"), Path("../datasets/HMT_Heat_Exchanger_NTU_Data.csv")] if p.exists())
hx_df = pd.read_csv(hx_p)

def eps_counterflow(ntu, cr):
    if cr < 1e-6: return 1.0 - np.exp(-ntu)
    if abs(cr - 1.0) < 1e-6: return ntu / (1.0 + ntu)
    return (1.0 - np.exp(-ntu * (1.0 - cr))) / (1.0 - cr * np.exp(-ntu * (1.0 - cr)))

max_err_cf = np.max(np.abs(eps_counterflow(hx_df["NTU"].values, 0.5) - hx_df["Eps_Counterflow_Cr05"].values))
print(f"Counterflow Theory vs HMT Dataset Max Deviation (Cr=0.5): {max_err_cf:.2e}")

# --- Step 2: Load Hourly Solar Collector Yield & Invert Required NTU via brentq ---
sol_p = next(p for p in [Path("datasets/Solar_Collector_FlatPlate_Hourly_Data.csv"), Path("../datasets/Solar_Collector_FlatPlate_Hourly_Data.csv")] if p.exists())
sol_df = pd.read_csv(sol_p)
A_col = 16.0  # 16 m^2 rooftop solar array
sol_df["Q_solar_kW"] = A_col * sol_df["G_T_W_m2"] * (sol_df["efficiency_percent"] / 100.0) / 1000.0
peak_q_kw = sol_df["Q_solar_kW"].max()

# Target Counterflow HX duty at Peak Noon: transfer peak_q_kw with glycol C_min = 2400 W/K, C_r = 0.65, dT_in = 42 K
C_min, C_r, dT_in = 2400.0, 0.65, 42.0
eps_req = (peak_q_kw * 1000.0) / (C_min * dT_in)
ntu_req = brentq(lambda n: eps_counterflow(n, C_r) - eps_req, 0.05, 12.0)
UA_req = ntu_req * C_min
print(f"Peak Solar Output (16 m^2) : {peak_q_kw:.2f} kW -> Req Effectiveness eps = {eps_req:.3f}, NTU = {ntu_req:.2f}, UA = {UA_req:.0f} W/K")
Counterflow Theory vs HMT Dataset Max Deviation (Cr=0.5): 3.51e-05
Peak Solar Output (16 m^2) : 9.53 kW -> Req Effectiveness eps = 0.095, NTU = 0.10, UA = 246 W/K
# --- Step 3: Coupled Thermo-Fluid Pareto Sweep (Tube Diameter D -> Required Length L vs Pumping Power W_p) ---
m_dot, rho, mu, k_w, Pr = 0.65, 992.0, 6.5e-4, 0.63, 4.3  # ~40 C water inside N=6 parallel copper tubes
N_tubes = 6
m_tube = m_dot / N_tubes
U_outside_R = 1.0 / 2500.0   # Shell-side thermal resistance per internal area

D_mm_list = np.linspace(8.0, 26.0, 19)
L_needed, P_pump_W, Re_vals = [], [], []

for D_mm in D_mm_list:
    D = D_mm / 1000.0
    A_c = np.pi * D**2 / 4.0
    V = m_tube / (rho * A_c)
    Re = rho * V * D / mu
    # Haaland friction factor + Gnielinski/Dittus-Boelter turbulent convection
    eps_D = 1.5e-6 / D  # Drawn copper tube
    f = (-1.8 * np.log10((eps_D / 3.7)**1.11 + 6.9 / Re)) ** -2 if Re > 2300 else 64.0 / Re
    Nu = 0.023 * (Re ** 0.8) * (Pr ** 0.4) if Re > 3000 else 4.36
    h_i = Nu * k_w / D
    U_overall = 1.0 / (1.0 / h_i + U_outside_R)
    L_t = UA_req / (U_overall * N_tubes * np.pi * D)
    dP = f * (L_t / D) * 0.5 * rho * (V ** 2)
    W_pump = (m_dot / rho) * dP / 0.70   # 70% pump eff
    L_needed.append(L_t); P_pump_W.append(W_pump); Re_vals.append(Re)

fig, ax1 = plt.subplots(figsize=(7.5, 4.4))
ax1.plot(D_mm_list, L_needed, "o-", color="#0284c7", lw=2, label="Required Tube Length $L$ [m]")
ax1.set_xlabel("Inner Tube Diameter $D$ [mm]"); ax1.set_ylabel("Required Tube Length $L$ [m]", color="#0284c7")
ax1.set_title("Thermo-Fluid Pareto Tradeoff: Heat Exchanger Size vs. Pumping Power")
ax1.grid(True, alpha=0.3)
ax2 = ax1.twinx()
ax2.semilogy(D_mm_list, P_pump_W, "s--", color="#dc2626", lw=2, label="Pumping Power [W, log scale]")
ax2.set_ylabel("Tube-Side Pumping Power [W]", color="#dc2626")
lines1, l1 = ax1.get_legend_handles_labels(); lines2, l2 = ax2.get_legend_handles_labels()
ax1.legend(lines1 + lines2, l1 + l2, loc="upper center", fontsize=8.5)
fig.tight_layout()
Coupled Heat Exchanger, Pipe Friction & Solar Thermal Loop Output Plot 1

Look at that crossing curve: from 8 mm to 14 mm, pumping power crashes from >1,000 W down to ~30 W while tube length barely grows, revealing the exact sweet-spot zone (D ~ 14–16 mm) visually!


Capstone Reflection & Challenge Questions

  1. Notice ax2.semilogy on the right axis—why did pumping power span three orders of magnitude while diameter only tripled?
  2. What happens if eps_req exceeds eps_counterflow(ntu -> inf, C_r)? (brentq raises ValueError—which catches an impossible thermal spec immediately!)
  3. (Challenge): Re-evaluate the Pareto tradeoff using a 1–2 Shell-and-Tube Heat Exchanger formula from HMT_Heat_Exchanger_NTU_Data.csv instead of pure counterflow—how much longer must the tubes be?

🎬 Concept & Engineering Animation

🎬 Thermo Fluid Pareto Crossing