Hydrogen Atom Visualization Suite
A comprehensive Python visualization engine that numerically solves the Schrödinger equation for the Hydrogen atom. Unlike standard libraries that often default to complex-valued outputs, this engine explicitly implements Real Spherical Harmonics to render the "textbook" orbital shapes used in chemistry and physics.
🚀 Project Evolution (The Engineering Journey)
This project consists of two distinct stages of development, demonstrating the transition from "Scripting" to "Software Engineering."
The Hydrogen Engine (hydrogen_engine/): The current, production-ready implementation. It features a modular architecture, a unified Command Line Interface (CLI), and a generalized math kernel that calculates any quantum state
Legacy Prototypes (legacy_scripts/): The original hardcoded scripts. Kept for archival purposes to demonstrate the refactoring process and the limitations of non-scalable code.
✨ Features (The Engine)
- 3D Orbital Isosurfaces
Renders the angular geometry of electron orbitals using a wireframe-over-glass aesthetic.
Math: Implements linear combinations of Spherical Harmonics (
Visuals: Automatic phase coloring (Blue/Red for
- 2D Probability Density Heatmaps
Visualizes the internal structure of the atom via a cross-section of the electron probability density (
Math: Correctly handles spherical coordinate transformations ($\theta = \arccos(z/r)$) to ensure phase symmetry.
Analysis: Reveals radial nodes hidden by 3D surface plots.
- Radial Distribution Analysis
Plots the probability
Math: Numerical integration of Generalized Laguerre Polynomials.
🛠️ Installation
Clone the repository:
git clone https://github.com/PranavElayidam/Hydrogen_atom.git cd hydrogen_atom
Install dependencies:
pip install -r requirement.txt
🖥️ Usage
The project is controlled via a central CLI in hydrogen_engine/main.py.
- Visualize a 3D Orbital Shape
python hydrogen_engine/main.py shape -l 2 -m 0
- Visualize 2D Probability Density
python hydrogen_engine/main.py density -n 4 -l 3 -m 0
- Radial Distribution Graph
python hydrogen_engine/main.py radial -n 3 -l 0
💻 CLI Orbital Reference (3D Shapes)
This table maps the common chemical notation (e.g., px, dz2) to the required command-line inputs for visualizing the 3D orbital shape. The principal quantum number n must always be ≥(l+1).
| Orbital Name | Quantum Numbers ( |
Description | Example Command (n=2, 3, or 4) |
|---|---|---|---|
| s Orbitals | l=0, m=0 | Spherical (e.g., 1s, 2s, 3s) | python main.py shape -n 2 -l 0 -m 0 |
| --- | --- | --- | --- |
| p Orbitals (l=1) | |||
| Aligned along the |
python main.py shape -n 2 -l 1 -m 0 |
||
| Lies in the |
python main.py shape -n 2 -l 1 -m 1 |
||
| Lies in the |
python main.py shape -n 2 -l 1 -m -1 |
||
| --- | --- | --- | --- |
| d Orbitals (l=2) | |||
| Aligned along the |
python main.py shape -n 3 -l 2 -m 0 |
||
| Lobes lie in the |
python main.py shape -n 3 -l 2 -m 1 |
||
| Lobes lie in the |
python main.py shape -n 3 -l 2 -m -1 |
||
| Lobes lie along the |
python main.py shape -n 3 -l 2 -m 2 |
||
| Lobes lie between the |
python main.py shape -n 3 -l 2 -m -2 |
||
| --- | --- | --- | --- |
| f Orbitals (l=3) | |||
| Aligned along the |
python main.py shape -n 4 -l 3 -m 0 |
||
| Lobes in the |
python main.py shape -n 4 -l 3 -m 1 |
||
| Lobes in the |
python main.py shape -n 4 -l 3 -m -1 |
||
| Lobes in |
python main.py shape -n 4 -l 3 -m 2 |
||
| Lobes between the axes. | python main.py shape -n 4 -l 3 -m -2 |
||
| Complex shapes. | python main.py shape -n 4 -l 3 -m 3 |
||
| Complex shapes. | python main.py shape -n 4 -l 3 -m -3 |
🧮 Mathematical Implementation
The engine constructs the full wavefunction
Radial Component (
Angular Component (
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.