Analytic hydrogen orbital slice visualizer
Project description
H-orbital
H-orbital is a small Python package and CLI tool that plots 2D slices of
hydrogen atomic orbitals from quantum numbers (n, l, m).
This project is a teaching utility for Zhuang Lin's Structural Chemistry course.
The implementation uses the analytic quantum-mechanical solution:
[ \psi_{n,l,m}(r,\theta,\phi)=R_{n,l}(r)Y_l^m(\theta,\phi) ]
No numerical Schrodinger solver is used.
Features
- CLI input with 1 to 3 quantum numbers:
n [l] [m] - Missing quantum numbers default to zero
- Rendering modes:
densityfor (|\psi|^2)realfor (\Re(\psi))imagfor (\Im(\psi))real_imagfor side-by-side real/imag plotsradial_distributionfor (r^2|R_{n,l}(r)|^2) vs (r)spherical_harmonicfor side-by-side (\Re(Y_l^m)) and (\Im(Y_l^m))
- Smart defaults for
plane,value, andrangeif omitted - Default color scaling is linear (
--scale linear) - Optional manual slice plane control by CLI:
--plane x --value c(planex=c)--plane y --value c(planey=c)--plane z --value c(planez=c)
- Select colormap (
--cmap) with default close to the sample image style - Colorbar toggle:
--colorbar/--no-colorbar(default: off)
Install Dependencies
Create and activate a virtual environment, then install:
python -m pip install -e .
This installs required libraries from pyproject.toml.
Usage
Run from repository root:
./H-orbital 2 1 0
GUI Usage
Launch the graphical interface:
./H-orbital-ui
GUI layout:
- Top panel: common parameters (
n,l,m,mode,plane,value) andPlot - Top panel: includes a
Colorbartoggle switch Advanceddialog: finer controls (points,colormap,scale)- Middle area: interactive Matplotlib plot canvas
- Bottom slider: range control in units of
a0 - Export buttons: save current figure as PNG or SVG
If you run without arguments, the command prints full help:
./H-orbital
Examples:
# 1s orbital, defaults l=0, m=0
./H-orbital 1
# Real part of 2p(m=0) on z=0 plane
./H-orbital 2 1 0 --mode real --plane z --value 0
# Probability density of 3d(m=1) on y=0.5 a0 plane
./H-orbital 3 2 1 --mode density --plane y --value 0.5 --scale log
# Two-panel real and imaginary parts
./H-orbital 3 2 2 --mode real_imag --plane z --value 0 --cmap sample --scale symlog
# Radial distribution (independent of plane/value)
./H-orbital 3 0 0 --mode radial_distribution
# Spherical harmonic map (angles only, independent of plane/value)
./H-orbital 3 2 1 --mode spherical_harmonic --scale symlog
Output Naming
If --output is not provided, a filename is generated automatically, e.g.:
orbital_n2_l1_m0_real_z0p0.png
Notes on Units
- Input
--valueand--rangeare in units of Bohr radiusa0. --valuemeans the constant coordinate of the selected slicing plane.- Example:
--plane x --value 0means plotting the planex = 0 * a0.
- Example:
- If
--planeis omitted (defaultauto), the tool picks a central plane (x=0,y=0, orz=0) that best reveals structure for the selected mode. - If
--valueis omitted, the tool uses0in the selected plane. - If
--rangeis omitted, the tool estimates a range from radial probability support and mode-aware heuristics to avoid clipping while preventing excessive zoom-out. - In
radial_distributionandspherical_harmonicmodes,--planeand--valueare not used. - If
--scaleis omitted, the default islinear. - You can still choose
--scale log(good fordensity) or--scale symlog(good for signed fields). - Internal wavefunction formulas are evaluated in SI meters.
Development
Run tests:
pytest
Run a single test:
pytest tests/test_quantum_numbers.py::test_parse_single_value_defaults_l_and_m
Version
Current stable version: 1.0.0.
License
This project is distributed under the MIT License. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file h_orbital-1.0.0.tar.gz.
File metadata
- Download URL: h_orbital-1.0.0.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f74f528d621ed4ff76dd8367da84257a4cfffe0904c71e1c510444394de3a216
|
|
| MD5 |
cbc5db498236b68750f0345a8c9b64d9
|
|
| BLAKE2b-256 |
61bf75f25e052bacea3389faa5d8da5d9bd8ebdc9ef873fd6c72dbf1da857d4b
|
File details
Details for the file h_orbital-1.0.0-py3-none-any.whl.
File metadata
- Download URL: h_orbital-1.0.0-py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86009f14f057430672d7bfc1e00b97f4d1f1d8a9ba4b04c54662ae113f59083b
|
|
| MD5 |
364b2b41e2a78c88982e468b026d3acf
|
|
| BLAKE2b-256 |
4c460e820c79bfc8d67105dce8efe236670384a83f8f3340f3d0734748ef68dc
|