{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "496e6091",
   "metadata": {},
   "source": [
    "# Online Resource 2: Screening estimate of recoverable flue-gas heat at Port Harcourt (Table 7)\n",
    "\n",
    "Supplementary code for Section 5.7. It needs only the Python standard library and prints every number quoted in Section 5.7."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7ab70236",
   "metadata": {},
   "outputs": [],
   "source": [
    "\"\"\"Table 7: screening estimate of recoverable flue-gas heat at Port Harcourt (Section 5.7).\"\"\"\n",
    "BTU, DAY = 1055.06, 86400.0\n",
    "def fired_MW(kBtu_per_bbl, kbpd):                 # fired duty from fuel intensity\n",
    "    return kBtu_per_bbl * 1e3 * kbpd * 1e3 * BTU / DAY / 1e6\n",
    "kg_fg = 17.2 * 1.20 + 1.0                         # kg flue gas per kg fuel gas (20% excess air)\n",
    "LHV, CP, T_STACK = 48.0, 1.10, 165.0              # MJ/kg, kJ/kg K, surrogate stack temperature (C)\n",
    "phi = lambda T_src: kg_fg / LHV * CP * (T_src - T_STACK) / 1e3   # recoverable share of fired duty\n",
    "CDU = (50.0, 106.8)                               # atmospheric distillation, kBtu/bbl (PME, CAE)\n",
    "CRU = (203.0, 254.0)                              # catalytic reforming, kBtu/bbl (PME, CAE)\n",
    "cases = {\"Old CDU at 20 kbd\": (20, 0), \"Old CDU at 60 kbd\": (60, 0),\n",
    "         \"Old CDU 60 kbd + reformer 6 kbd\": (60, 6),\n",
    "         \"Old + new CDU 210 kbd + reformer 6 kbd\": (210, 6)}\n",
    "lo, hi = phi(250.0), phi(335.0)\n",
    "print(f\"recoverable share of fired duty: {phi(250):.1%}, {phi(300):.1%}, {phi(335):.1%}\")\n",
    "for name, (c, r) in cases.items():\n",
    "    fl = fired_MW(CDU[0], c) + fired_MW(CRU[0], r)\n",
    "    fh = fired_MW(CDU[1], c) + fired_MW(CRU[1], r)\n",
    "    print(f\"{name}: fired {fl:.0f}-{fh:.0f} MW, recoverable {fl*lo:.1f}-{fh*hi:.1f} MW\")\n",
    "print(f\"649 kW at 335 C = {0.649/phi(335.0):.1f} MW fired duty\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
