Skip to content
Tutorials Center
My learning

Topics

Lesson 42 of 45 · Projects and Practice

Project: Build a Complex Analyzer

Write a small program that parses a complex formula and reports oxidation state, d count, spin state, magnetic moment and color, then plot spin states.

In this project you will combine nearly everything from chapters 6 and 7 into one working tool. You give it a formula such as [Fe(CN)6]4-, and it tells you the oxidation state of the metal, the d-electron count, the geometry, whether the complex is high spin or low spin, the number of unpaired electrons, the spin-only magnetic moment and the wavelength equivalent of the splitting. Building it forces you to state each rule precisely enough for a computer to follow, which is one of the best ways to find out whether you really understand it.

Four stages: input a formula, parse metal ligands and charge, compute oxidation state d count spin moment and wavelength, and print a report with a sample for hexacyanidoferrate(II).
The analyzer is a four-stage pipeline from a formula string to a report.

What you will learn

  • Break a chemistry procedure into parse, compute and report stages.
  • Encode the d-count, spin-state and magnetism rules as code.
  • Use experimental Δo and pairing-energy tables instead of guessing.
  • Visualize the high-spin and low-spin boundary.

Key terms

Homoleptic complex: one in which all ligands are the same, such as [Fe(CN)₆]⁴⁻.

Pairing energy (P): the energy cost of putting two electrons in the same orbital.

Lookup table: a stored set of measured values the program reads rather than computes.

Edge case: an input the rules do not cover, such as a complex with no data for Δo.

Design

The program is limited by design: it handles homoleptic octahedral or four-coordinate complexes with one kind of ligand, written as [M(L)n]charge. Ligand names are CN, CO, NH3, H2O, F, Cl and en. The charge and ligand count give the oxidation state, the metal's group number gives the d count, and measured Δo and P values (from the TryIt's table) decide the spin state when d is 4 to 7. Anything outside the table is reported as "unknown" rather than guessed, which is an important habit in scientific code.

The rules the code implements:

  1. oxidation state = overall charge − (ligand count × ligand charge)
  2. d count = group number − oxidation state
  3. coordination number = ligand count × denticity (en counts 2)
  4. For d⁴ to d⁷ with CN 6: low spin if Δo > P, else high spin; other d counts have no choice.
  5. Unpaired electrons from the filling rules; μ = √(n(n+2)).
  6. The wavelength equivalent of Δo, λ = 10⁷ / Δo, which equals the lowest absorption band only for d¹ and d³ ions.

The code

Run it, change the formulas in the last lines and see how the report changes. The Δo and P values are rounded textbook numbers in cm⁻¹.

JS Complex analyzer

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Notice what the program does for [Mn(CN)6]4-: Δo is missing from the table, so it says so rather than guessing. That is a sound design rule for scientific software.

Visualize the spin boundary

The decisive comparison is Δo against P. Plot each complex in the table as a point; those above the diagonal are low spin, those below are high spin.

Python High-spin and low-spin map

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Extension ideas

  1. Add more ligands (I, Br, OH, ox) and more measured Δo values.
  2. Support mixed complexes such as [Co(NH3)5Cl]2+ by accepting a list of ligands.
  3. Add the square planar rule: CN 4 with d⁸ and a 4d or 5d metal.
  4. Print the IUPAC name by reusing the naming tool from the ligands lesson.
  5. Compute CFSE in kJ/mol using 0.011963 × Δo.

Common misconceptions

"The program proves the answer." It applies simplified rules to rounded data; it is a model, not an experiment.

"Missing data can be filled with a typical value." Doing so hides uncertainty. Report unknowns as unknown.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. Which complex in the analyzer table is low spin?

    Δo (23,000) exceeds P (21,000) for Co³⁺ with ammonia.
  2. 2. Why does the program report unknown for [Mn(CN)6]4-?

    The lookup table has no entry, and the program avoids guessing.
  3. 3. What is the oxidation state of Fe in [Fe(CN)6]3-?

    Six CN⁻ give −6; the overall charge is −3, so Fe is +3.
  4. 4. For which d counts does the program need Δo and P?

    Only d⁴ to d⁷ have a choice between high and low spin.

Summary

  • A useful chemistry tool is a pipeline: parse, compute, report.
  • The analyzer encodes oxidation state, d count, spin state, μ and λ in a few rules and tables.
  • Measured Δo and P values decide spin states; missing data should be reported, not invented.
  • Plotting Δo against P shows the high-spin and low-spin regions at a glance.

Next: Glossary