File size: 4,595 Bytes
c0ce83e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
title: Quantum Physics Simulation
emoji: ⚛️
colorFrom: indigo
colorTo: blue
sdk: streamlit
sdk_version: "1.32.0"
app_file: app.py
pinned: false
---

# ⚛ Quantum Physics Simulation

This interactive app visualizes:

- Probability density of Hydrogen atom wavefunctions  
- Orbital shapes for quantum numbers n, l, m  
- Node structure  
- Phase visualization  
- Particle-in-a-box wavefunctions  
- 2D & 3D views  
- Animations  

Built using **Streamlit**, **NumPy**, and **Plotly 3D**.

# Quantum Simulation Suite

## Overview
- Particle in a Box (PIB) time-dependent Schrödinger simulation (Crank–Nicolson, Split-Step Fourier)
- Hydrogen spectrum (Rydberg formula, energy levels, stick spectrum)
- TDSE wavepacket evolution with spacetime heatmap
- Modular UIs: Streamlit (dark theme, sidebar navigation) and PySide6 (legacy)
- Physics engine: real constants, potentials, eigenfunctions, TDSE solver with normalization and stability checks

## Project Structure
- `streamlit_main.py` — Streamlit entrypoint with sidebar pages
- `run_app.bat` — Installs deps and launches Streamlit UI
- `run_streamlit_main.bat` — Same as above (alternative launcher)
- `app/core/physics_engine/` — constants, potentials, PIB equations, TDSE solver, hydrogen spectrum
- `app/core/animations/` — Matplotlib animations (PIB, Hydrogen)
- `app/ui_streamlit/` — Streamlit UIs (PIB, Hydrogen, TDSE, TISE placeholder, Custom Potential placeholder)
- `app/ui/` — PySide6 legacy UI (PIB, Hydrogen, main window)
- `app/tests/` — pytest suites for equations, potentials, solver
- `data/`, `docs/` — optional data/docs folders (ignored by git)

## Requirements
- Python 3.10+
- numpy, scipy, matplotlib, streamlit, PySide6, numba, pandas (batch files auto-install)

## How to Run (Streamlit UI)
1) Open a terminal:
   ```bash
   cd "D:\Physics Simulation Project\Physics Simulation Project Code"
   run_app.bat
   ```
   (or `run_streamlit_main.bat` or `streamlit run streamlit_main.py`)
2) In the browser sidebar, choose:
   - **Particle in a Box (PIB)**: set L, n, solver, dt, grid; enable superposition; click Start. Tabs show ψ, |ψ|², energies, live animation. Export PNG/CSV available.
   - **Hydrogen Spectrum**: pick series and n₂>n₁; view wavelengths, photon energies, stick spectrum, energy levels.
   - **TDSE Simulation**: set wavepacket params, domain, dt/steps; compute frames; view animation and |ψ|² heatmap.
   - **TISE / Custom Potential**: placeholders for future extensions.
3) Animations update frame-by-frame (no jumps); energy and norm displayed live.

## How to Use the Simulation
1. Launch UI  
   - Double-click `run_app.bat` (or run `streamlit run streamlit_main.py`).
2. Pick a module in the sidebar:  
   - **Particle in a Box (PIB):** set L, n, dt, grid, solver (CN/SSFM); optionally enable superposition; click **Start**. View tabs for ψ, |ψ|², energies, animation; export PNG/CSV.  
   - **Hydrogen Spectrum:** choose series (Lyman/Balmer/...), set n₂>n₁; see wavelength, photon energy, stick spectrum, energy levels.  
   - **TDSE Simulation:** set wavepacket (x₀, σ, k₀), domain, dt, steps; click **Start TDSE**; scrub frames or auto-play; heatmap in second tab.  
   - **TISE / Custom Potential:** placeholders ready for extension.
3. Tips  
   - Sliders update instantly; animations are frame-by-frame (no jumps).  
   - If norm drifts, reduce dt or increase grid size.  
   - Export buttons provide PNG/CSV snapshots.  
   - Dark theme and auto-scaling are enabled by default.
4. PySide6 (optional)  
   - Run `python main.py` (if wired to PIBWindow); use Start/Pause/Reset.

## How to Run (PySide6 UI, optional)
```bash
cd "D:\Physics Simulation Project\Physics Simulation Project Code"
python main.py
```
(If main.py loads PIBWindow directly.) Use Start/Pause/Reset; plots update via QTimer.

## Testing
```bash
cd "D:\Physics Simulation Project\Physics Simulation Project Code"
python -m pip install pytest
pytest -q
```

## Key Features
- True TDSE solver (CN/SSFM) with normalization each step and stability checks
- Probability current and energy expectation utilities
- Infinite well, finite well, harmonic oscillator potentials
- Hydrogen spectrum calculations (wavelengths, series detection)
- Dark-themed, responsive Streamlit UI with export options and smooth set_ydata updates

## Notes
- If you see missing dependency errors, rerun `run_app.bat`.
- For large grids or small dt, computation may take longer; Streamlit shows progress where applicable.
- Custom potential editor and TISE pages are stubs ready for extension.