Skip to content
amurlaniakeaPublic

About

Atomic orbitals with verifiable rigor: exact hydrogen, atoms 1-36, biomedical ions and small molecules (incl. spin density), checked against Hartree-Fock. Orbitales atómicos con rigor verificable.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Orbitae

Atomic orbitals with verifiable rigor. Visualize electron clouds in 3D, from exact hydrogen to atoms 1-36, biomedically relevant ions and small molecules, backed by a numerical test suite that checks every result.

tests DOI Live demo: https://amurlaniakea.github.io/orbitae/ (English and Spanish interface, with an ES | EN switch)

Versión en español

Orbitae viewer

Educational and scientific tool. It is not a medical device nor a clinical guide.

What it does

  • Exact hydrogen mode: orbitals up to n = 4 (s, p, d, f) with real spherical harmonics (p_x, d_xy, ...), two-color phase, energy, 95 % radius and radial distribution with its nodes.
  • Atoms 1-36 mode: clickable periodic table, total cloud and individual orbitals of every subshell, using Slater's rules for the effective charge and Slater-type orbitals.
  • Biomedical context: elements essential to human biology are marked and carry a short note (iron in hemoglobin, sodium and potassium in the membrane potential, and so on).
  • Biomedically relevant ions (Na⁺, K⁺, Mg²⁺, Ca²⁺, Cl⁻, Fe²⁺, Fe³⁺, Cu⁺, Cu²⁺, Zn²⁺, among others), compared against Hartree-Fock.
  • Small molecules (H₂O, NH₃, CO, N₂, CO₂ and the open-shell O₂ and NO) with Hartree-Fock molecular orbitals, spin density and .cube export.
  • Pure WebGL viewer in English and Spanish, with no third-party libraries and a CSP that only allows connections to its own server. It offers a colorblind-safe palette, a brightness control, bonds between nuclei in molecules and a short sheet for each element and ion (group, period, category, outer electrons, isoelectronic series).

Limits (explicit on purpose)

  • Atoms use a didactic approximation: Slater's rules and orbitals without radial nodes, no electron correlation. The total cloud is the spherical average of the subshells. The error against Hartree-Fock is measured (see below).
  • Molecules use Hartree-Fock with fixed experimental geometries: restricted for closed shells and unrestricted (UHF) for O₂ and NO, which show some spin contamination (see below). Virtual orbitals (LUMO) of HF are a reference only, not excited states.
  • Ions are free gas-phase ions: in water or inside a protein they change through hydration and ligands.
  • Automated tests cover the Python core and the logic of the viewer (in a simulated browser, without real WebGL); the 3D drawing is checked by hand.

Install and use

python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev,hf]"
pytest -q

Requires Python 3.10 or later (tested on 3.10, 3.11 and 3.12) and SciPy 1.15 or later. PySCF is optional (.[hf]) and only needed for the Hartree-Fock comparison and for molecules.

To run the viewer locally:

python -m orbitae.export --out web/data
python -m orbitae.atoms --out web/data
python -m orbitae.hf_compare --out web/data   # optional, needs PySCF
python -m orbitae.molecules --out web/data    # molecules, needs PySCF
python3 -m http.server -d web 8000

Open http://localhost:8000.

The viewer data (web/data) is not stored in git: it is generated by those commands and continuous integration regenerates it on every deployment. A functional test of the viewer runs in a simulated browser before publishing (npm ci --prefix tests/viewer && node tests/viewer/viewer.test.js; needs Node 22 or later).

Example in Python:

from orbitae import sample_orbital, radial_cutoff

points = sample_orbital(n=2, l=1, m=1, size=50_000, seed=0)   # 2p_x, shape (N, 3)
r95 = radial_cutoff(2, 1, p=0.95)                              # radius in bohr (a0)

Validation

Every numerical result has a test: radial and angular normalization, orthogonality, the radial Schrödinger equation, energies E_n = −Z²/(2n²), the s, p, d and f harmonics against their Cartesian formulas, radial nodes against analytical values (2s and 3s), sampling against exact moments, Slater effective charges against reference values, the electron configurations of the 36 elements, Hartree-Fock energies against reference values, molecular-orbital normalization and degeneracy, spin contamination and spin density of the open-shell molecules, and the re-reading of an exported .cube file. Continuous integration runs them on every change.

Error of the Slater model against Hartree-Fock

Reference: unrestricted Hartree-Fock with PySCF (def2-TZVP basis, Hund spin, spherically averaged density). The metric is the mean radius of the total electron density (all electrons; it does not measure valence size). HF includes no electron correlation, so it is not the exact value either.

Element HF mean radius (a₀) Slater mean radius (a₀) Difference
H 1.499 1.500 +0.1 %
C 1.189 1.113 −6.4 %
Ne 0.788 0.715 −9.4 %
Na 0.987 0.990 +0.4 %
Ar 0.892 0.861 −3.5 %
Fe 0.841 1.000 +18.9 %
Cu 0.726 0.828 +14.1 %
Kr 0.729 0.746 +2.4 %

The model works well in the first periods and fails for the 3d transition metals (up to +24 % for Cr). The table for all 36 elements is generated with python -m orbitae.hf_compare and the viewer shows it over the radial plot.

Valence subshells

Same method, but comparing the mean radius of each subshell (HF orbitals are classified by l and by energy; the subshell densities add up to the total density, which is checked in the tests).

Subshell HF mean radius (a₀) Slater mean radius (a₀) Difference
C 2p 1.701 1.538 −9.5 %
Na 3s 4.215 4.773 +13.2 %
Cl 3p 1.839 1.721 −6.4 %
Fe 3d 1.075 1.680 +56.2 %
Fe 4s 3.255 4.144 +27.3 %
Cu 3d 0.993 1.338 +34.7 %
Cu 4s 3.313 4.200 +26.8 %
Kr 4p 1.950 1.884 −3.4 %

Slater's model places the 3d subshell (between 35 % and 108 % from Sc to Zn) and the 4s subshell (between 24 % and 44 % from K to Zn) too far from the nucleus, and the 2p and 3p subshells too close (between 6 % and 12 %).

Correction (v0.7). Versions 0.5 to 0.6.1 reported, for Mn, Fe, Co and Ni, a larger error of the mean radius than the real one (Fe +25.1 % instead of +18.9 %). Unrestricted HF converges in those four atoms to the 3d⁽ⁿ⁺¹⁾ 4s¹ configuration rather than 3d⁽ⁿ⁾ 4s², which is the one the model uses, so the comparison mixed both effects. Since v0.7 the same subshell occupation is enforced in HF and a test verifies it on every change. Earlier Zenodo records keep the old values.

Ions

Same metric and reference method (UHF; def2-TZVPD basis, with diffuse functions, for the ions). Cations shrink and anions swell with respect to the neutral atom in both HF and the Slater model.

Ion HF mean radius (a₀) Slater mean radius (a₀) Difference
Li⁺ 0.572 0.556 −2.9 %
Na⁺ 0.663 0.612 −7.6 %
K⁺ 0.788 0.761 −3.4 %
Mg²⁺ 0.573 0.535 −6.6 %
Ca²⁺ 0.708 0.682 −3.7 %
F⁻ 0.996 0.859 −13.8 %
Cl⁻ 1.049 0.995 −5.2 %
Mn²⁺ 0.647 0.762 +17.8 %
Fe²⁺ 0.633 0.738 +16.7 %
Fe³⁺ 0.592 0.678 +14.6 %
Co³⁺ 0.580 0.662 +14.1 %
Cu⁺ 0.629 0.708 +12.5 %
Cu²⁺ 0.588 0.666 +13.1 %
Zn²⁺ 0.574 0.643 +12.0 %

Molecules

Restricted Hartree-Fock (PySCF), def2-TZVP basis and approximate fixed experimental geometries, without optimization. Closed-shell molecules (H₂O, NH₃, CO, N₂, CO₂) use restricted HF. The viewer shows the occupied valence molecular orbitals and the LUMO (inner orbitals are not resolved by the 0.2 bohr grid). Virtual HF orbitals do not describe excited states.

Molecule HF energy (Eh) HF reference (Eh) HF dipole (D) Experimental dipole (D)
H₂O −76.0590 −76.0675 2.16 1.855
NH₃ −56.2183 −56.2252 1.76 1.471
CO −112.7855 −112.7909 0.26 0.122
N₂ −108.9881 −108.9964 0.00 0.000
CO₂ −187.7159 −187.7248 0.00 0.000

Energies are within 0.01 Eh of the reference HF values, and HF overestimates the dipoles, as usual. An example with biomedical interest: the HOMO of CO is a σ lone pair concentrated on carbon (88 % of its density is on the carbon side), the orbital through which CO binds to the iron of the heme group.

Molecules with spin

O₂ (triplet) and NO (doublet) use unrestricted Hartree-Fock (UHF) with Hund's multiplicity, so the α and β orbitals are different; the viewer shows them separately and also the spin density (ρα − ρβ), colored by sign.

Molecule UHF energy (Eh) ⟨S²⟩ (ideal) Spin population (Mulliken) HF dipole (D) Experimental dipole (D)
O₂ −149.6832 2.046 (2.000) O 1.00, O 1.00 0.00 0.000
NO −129.3027 0.797 (0.750) N 0.96, O 0.04 0.25 0.159

UHF has some spin contamination (⟨S²⟩ above the ideal value). The UHF of NO converges only by breaking the cylindrical symmetry (the orientation of its π* orbital around the bond axis is arbitrary); that lower-energy solution is used. The two unpaired electrons of O₂ are shared equally between the two oxygens, and the unpaired electron of NO sits mostly on nitrogen.

Export orbitals to .cube

python -m orbitae.molecules --cube CO --orbital HOMO --cube-out CO_HOMO.cube

The .cube format can be opened with VMD, Avogadro or PyMOL. The tests check that the file is read back and normalized.

How to cite

Use the Cite this repository button on GitHub (generated from CITATION.cff) or the Zenodo DOI: https://doi.org/10.5281/zenodo.24135885

Roadmap

See docs/SDD.md (in Spanish). Next: more small biomolecules and geometry optimization.

License and contact

Copyright (C) Pedro Sordo Martínez amurlaniakea@gmail.com. AGPL-3.0-or-later (see LICENSE).

About

Atomic orbitals with verifiable rigor: exact hydrogen, atoms 1-36, biomedical ions and small molecules (incl. spin density), checked against Hartree-Fock. Orbitales atómicos con rigor verificable.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages