{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "Short intro: basic plotting using the periodic table\n", "==========\n", "\n", "- **Complexity level**: novice\n", "- **Requirements**: basic knowledge of chemistry and Python\n", "\n", "The reader would probably agree, that the periodic table is crucially important. The **chemical elements**, as well as the **chemical formulae** are introduced here. Let's explore this a bit.\n", "\n", "We know the inorganic chemical formulae are constructed according to the electronegativities of the chemical elements. Generally, **the more** the electronegativity value, **the more** to the right the chemical element in the formula. Although there are some details, concerned with the exact definition of the electronegativity.\n", "\n", "Let's plot the Pauling electronegativities _vs._ periodic numbers of the chemical elements using the popular `matplotlib` Python library.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "plt.switch_backend('agg')\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "Now we define the periodic table and electronegativities.\n", "\n", "Note that there are several electronegativity scales (see _e.g._ those given in the [mendeleev database](http://mendeleev.readthedocs.io/en/stable/data.html#electronegativities)). And here we use the Pauling's scale.\n", "\n", "The **periodic numbers** reflect the periodic table proposed by Julius-Lothar Meyer in 1870. How is that different from the well-known one by Dmitry Mendeleev? The rows and columns are exchanged!\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "chemical_elements = [\n", "'H', 'He',\n", "'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne',\n", "'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar',\n", "'K', 'Ca', 'Sc', 'Ti', 'V', 'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr',\n", "'Rb', 'Sr', 'Y', 'Zr', 'Nb', 'Mo', 'Tc', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb', 'Te', 'I', 'Xe',\n", "'Cs', 'Ba', 'La', 'Ce', 'Pr', 'Nd', 'Pm', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 'Yb', 'Lu', 'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg', 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn',\n", "'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U', 'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr', 'Rf', 'Db', 'Sg', 'Bh', 'Hs', 'Mt', 'Ds', 'Rg', 'Cn', 'Nh', 'Fl', 'Mc', 'Lv', 'Ts', 'Og']\n", "\n", "periodic_numbers = [\n", "1, 112,\n", "2, 8, 82, 88, 94, 100, 106, 113,\n", "3, 9, 83, 89, 95, 101, 107, 114,\n", "4, 10, 14, 46, 50, 54, 58, 62, 66, 70, 74, 78, 84, 90, 96, 102, 108, 115,\n", "5, 11, 15, 47, 51, 55, 59, 63, 67, 71, 75, 79, 85, 91, 97, 103, 109, 116,\n", "6, 12, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 86, 92, 98, 104, 110, 117,\n", "7, 13, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 87, 93, 99, 105, 111, 118]\n", "\n", "electronegativities = [\n", "2.2, 0,\n", "0.98, 1.57, 2.04, 2.55, 3.04, 3.44, 3.98, 0,\n", "0.93, 1.31, 1.61, 1.90, 2.19, 2.58, 3.16, 0,\n", "0.82, 1.00, 1.36, 1.54, 1.63, 1.66, 1.55, 1.83, 1.88, 1.91, 1.9, 1.65, 1.81, 2.01, 2.18, 2.55, 2.96, 3,\n", "0.82, 0.95, 1.22, 1.33, 1.60, 2.16, 1.90, 2.20, 2.28, 2.20, 1.93, 1.69, 1.78, 1.96, 2.05, 2.10, 2.66, 2.6,\n", "0.79, 0.89, 1.1, 1.12, 1.13, 1.14, 1.13, 1.17, 1.2, 1.2, 1.1, 1.22, 1.23, 1.24, 1.25, 1.1, 1.27, 1.30, 1.50, 2.36, 1.90, 2.20, 2.20, 2.28, 2.54, 2.00, 1.62, 2.33, 2.02, 2.00, 2.20, 2.20,\n", "0.70, 0.90, 1.1, 1.30, 1.50, 1.38, 1.36, 1.28, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "Then we _massage_ our data a little bit adding a summary trend line.\n", "\n", "We're good to go:\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "\n", "points = [pair for pair in zip(electronegativities, periodic_numbers) if pair[0] > 0]\n", "x, y = zip(*points)\n", "\n", "fitted_coeffs = np.polyfit(x, y, 1)\n", "fitted_fn = np.poly1d(fitted_coeffs)\n", "\n", "fig, ax = plt.subplots(figsize=(15, 10))\n", "\n", "ax.set_xlabel('Electronegativity')\n", "ax.set_ylabel('Periodic Number')\n", "\n", "ax.scatter(x, y, c='b', s=2, label='Chem. elements')\n", "plt.plot(x, fitted_fn(x), c='g', linewidth=0.5, label='Linear fit')\n", "plt.legend()\n", "\n", "for i, label in enumerate(chemical_elements):\n", " ax.annotate(\n", " label,\n", " (electronegativities[i], periodic_numbers[i]),\n", " size=10\n", " )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "Look, the whole chemistry is encoded in the resulted figure :)\n", "\n", "Were you able to follow everything? Please, try to explain the plot: why it looks specifically like this?\n" ] } ], "metadata": {}, "nbformat": 4, "nbformat_minor": 2 }