Computational Chemistry with Python

Build chemistry from the atom up, in code: stoichiometry, structure and bonding, thermodynamics, equilibrium, kinetics, quantum chemistry, and a molecular-dynamics engine, all from scratch with numpy and the standard library.

10 projects, 250 hands-on levels, run in your browser.

Syllabus

  • Atoms, Units & Stoichiometry: Chemistry is bookkeeping for atoms. Start from Avogadro's number and the mole, compute the molar mass of any compound from its formula, then use balanced equations to predict how much product a reaction yields, which reactant runs out first, and how concentrated a solution is. Every tool here returns a number you can check.
  • The Periodic Table & Atomic Structure: Why do elements behave the way they do? It is written in their atoms. Count protons, neutrons, and electrons; average isotope masses; fill electron shells with the Aufbau rule; read periodic trends; and connect light to energy levels with the Bohr model. Finish with an Element class that ties it together.
  • Bonding & Molecular Geometry: Molecules have shapes, and shape is chemistry. Count valence electrons to see how atoms bond, place atoms in 3D with numpy, measure bond lengths and angles with vectors, and predict molecular geometry with VSEPR. The capstone is a geometry analyzer for any molecule you give it.
  • Thermodynamics: Will a reaction happen, and how much heat does it move? Thermodynamics answers both. Track heat and enthalpy, measure disorder with entropy, and combine them into the Gibbs free energy that decides spontaneity. The capstone reports the full energy budget of any reaction.
  • Chemical Equilibrium: Reactions do not always run to completion; they settle at equilibrium. Write the equilibrium constant, compare it to the reaction quotient to predict direction, set up ICE tables, and solve the resulting equations with a bisection root-finder you build from scratch. Le Chatelier predicts how the balance shifts under stress.
  • Acids, Bases & pH: Acidity is a logarithm. Compute pH from hydrogen-ion concentration, handle weak acids with their dissociation constants, design buffers with the Henderson-Hasselbalch equation, and trace a titration curve point by point. The capstone is a pH calculator that handles any of these cases.
  • Reaction Kinetics: How fast does a reaction go? Kinetics measures and predicts rates. Write rate laws, apply the integrated forms for first, second, and zero order, capture temperature dependence with the Arrhenius equation, and integrate the rate equation numerically with Euler and Runge-Kutta methods you build yourself. The capstone is a decay simulator.
  • Quantum Chemistry & Spectroscopy: Atoms and molecules absorb and emit light at sharp, quantized energies. Compute the energy levels of a particle in a box and of hydrogen, connect them to the light absorbed or emitted, and quantify absorption with the Beer-Lambert law. The finite-difference chapter solves the Schrodinger equation numerically with a matrix you build and diagonalize.
  • Molecular Dynamics & Monte Carlo: Simulate matter atom by atom. Model interactions with the Lennard-Jones potential, sum forces and energies across a system with numpy, advance time with the velocity-Verlet integrator, and sample configurations with the Metropolis Monte Carlo method. These are the two engines that power computational chemistry.
  • Capstone: A Molecular Dynamics Engine: The finale. Assemble everything into a working molecular-dynamics engine: represent a system of particles with numpy, compute Lennard-Jones forces across all pairs, advance time with velocity Verlet, track the observables (kinetic energy, temperature, total energy), and wrap it in a simulation class that runs and reports, conserving energy as a real MD code does.

Key concepts

  • Bond angle: The angle between two bonds at a central atom, computed from the dot product of the bond vectors and recovered with the inverse cosine.
  • Electron configuration: How an atom's electrons fill shells and subshells, following the Aufbau order. The outermost (valence) electrons drive an element's chemistry.
  • Enthalpy: The heat content of a reaction ( dH ). Negative means heat is released (exothermic); positive means heat is absorbed (endothermic). Found from formation values…
  • Equilibrium constant: K , the ratio of product to reactant concentrations (each raised to its coefficient) at equilibrium. Comparing the reaction quotient Q to K predicts which way…
  • Gibbs free energy: dG = dH - T dS , the quantity whose sign decides spontaneity: a reaction is spontaneous when dG < 0 . Combines enthalpy and entropy at a given temperature.
  • Lennard-Jones potential: V(r) = 4*eps*((sigma/r)^12 - (sigma/r)^6) , the model of atomic attraction and repulsion. Its minimum sets the equilibrium bond length; its derivative gives th…
  • Limiting reagent: The reactant that runs out first and therefore caps how much product can form. Found by comparing how much product each reactant could make and taking the smal…
  • Molar mass: The mass of one mole of a substance, in grams per mole, found by summing the atomic masses of every atom in its formula. Computed here by looping over an eleme…
  • Mole: Chemistry's counting unit: one mole is Avogadro's number ( 6.022e23 ) of particles. It bridges the mass you weigh and the number of atoms or molecules…
  • Numerical integration: Advancing a differential equation in small timesteps. Euler is the simplest; Runge-Kutta (RK4) is more accurate; velocity Verlet conserves energy and powers mo…
  • pH: -log10[H+] , the logarithmic measure of acidity. Below 7 is acidic, above 7 basic. Weak acids use the dissociation constant Ka; buffers use the Henderson-Hasse…
  • Rate constant: k in a rate law rate = k[A]^n . Its temperature dependence follows the Arrhenius equation k = A exp(-Ea/RT) , which also yields the activation energy from two…
  • Root-finding: Solving f(x) = 0 numerically when there is no formula. Bisection repeatedly halves an interval that brackets a sign change, used here to solve exact equilibriu…
  • Stoichiometry: The bookkeeping of reactions: using the mole ratios in a balanced equation to convert between amounts of reactants and products.
  • VSEPR: Valence Shell Electron Pair Repulsion: electron domains around a central atom spread out to minimize repulsion, setting molecular geometry (linear, trigonal pl…