{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "7d41f71f",
   "metadata": {},
   "source": [
    "```\n",
    "$\\require{mhchem}$\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9ca46c73",
   "metadata": {},
   "source": [
    "### Question\n",
    "\n",
    "The standard electrode potential at 298 K, under alkaline conditions, for the reduction of $\\ce{ClO4^{-}(aq)}$ to $\\ce{ClO3^{-}(aq)}$ is 0.37 V. Under acidic conditions it is 1.20 V. Use this information to deduce the value for the autoionization constant of water, $K_\\mathrm{w}$, and its decimal cologarithm, $\\mathrm{p}K_\\mathrm{w}$."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8210b6d8",
   "metadata": {},
   "source": [
    "### Answer"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "06a22352",
   "metadata": {},
   "source": [
    "The half cell reactions are as follows. Under alkaline conditions ($E^\\ominus = 0.37\\;\\mathrm{V}$):"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5c961824",
   "metadata": {},
   "source": [
    "$$\n",
    "\\ce{ClO4^{-}(aq) + H2O(l) + 2e- -> ClO3^-(aq) + 2OH^{-}(aq)}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b5b2be92",
   "metadata": {},
   "source": [
    "Under acidic conditions ($E^\\ominus = 1.20\\;\\mathrm{V}$):"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0418ed2f",
   "metadata": {},
   "source": [
    "$$\n",
    "\\ce{ClO4^{-}(aq) + 2H^+(aq) + 2e- -> ClO3^{-}(aq) + H2O(l)}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "10176b07",
   "metadata": {},
   "source": [
    "A cell constructed with the first half-cell on the righthand side and the second on the lefthand side will have a conventional cell reaction:"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "63a0bcd5",
   "metadata": {},
   "source": [
    "$$\n",
    "\\ce{2H2O(l) -> 2OH^{-}(aq) + 2H^{+}(aq)}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8915aa73",
   "metadata": {},
   "source": [
    "The standard EMF of this cell is:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "122feb49",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-0.83"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Estd = 0.37 - 1.20\n",
    "Estd"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "19d04528",
   "metadata": {},
   "source": [
    " That is, $E^\\ominus = -0.83\\;\\mathrm{V}$. The corresponding standard molar Gibbs Free Energy change is:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "593fbc9b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "80082.55"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "# Faraday constant (C.mol-1) and gas constant (J.K-1.mol-1)\n",
    "F, R = 96485, 8.314\n",
    "# Temperature, K\n",
    "T = 298\n",
    "DrG_std = -F * Estd\n",
    "DrG_std"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "803e7cf9",
   "metadata": {},
   "source": [
    "That is, $\\Delta_\\mathrm{r}G^\\ominus_\\mathrm{m} = 80.08\\;\\mathrm{kJ\\,mol^{-1}}$. The autoionization constant (ionic product) of water is the equilibrium constant of the above cell reaction, written as:\n",
    "\n",
    "$$\n",
    "K_\\mathrm{w} = [\\ce{OH^{-}}][\\ce{H^{+}}]\n",
    "$$\n",
    "\n",
    "since the concentrations are so small they can approximate the ion activities well. This is related to $\\Delta_\\mathrm{r}G^\\ominus_\\mathrm{m}$ through:\n",
    "\n",
    "$$\n",
    "\\Delta_\\mathrm{r}G^\\ominus_\\mathrm{m} = -RT \\ln K_\\mathrm{w}.\n",
    "$$\n",
    "\n",
    "Therefore,"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "f3825837",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9.168560848141593e-15"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Kw = np.exp(-DrG_std / R / T)\n",
    "Kw"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9d68eee1",
   "metadata": {},
   "source": [
    "This value is usually expressed as the negative of the decimal logarithm (the decimal cologarithm), $\\mathrm{p}K_\\mathrm{w}$:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a4312bf7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "14.03769882842608"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pKw = -np.log10(Kw)\n",
    "pKw"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "39b5d9bf",
   "metadata": {},
   "source": [
    "That is, $\\mathrm{p}K_\\mathrm{w} = 14$ for pure water at 298 K."
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Tags",
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
