Project Description
This Python application simulates the time evolution of a particle in a one-dimensional box. It demonstrates fundamental quantum phenomena such as quantum tunneling, and calculates key properties like position and momentum expectation values. The simulation provides an interactive way to explore quantum mechanics concepts through numerical computation.
Features
Builds a 1D Hamiltonian matrix with a user-defined potential barrier.
Simulates the time evolution of a Gaussian wave packet using explicit time-stepping methods.
Computes the probability of the particle tunneling through the potential barrier.
Calculates the expectation values of position ⟨x⟩ and momentum ⟨p⟩ at various time steps.
Finds stationary energy states and compares them to analytical solutions for a particle in a box.
Prompts the user for key parameters, enabling easy experimentation.
Saves wavefunction data at selected time points to text files for plotting and analysis.
How to Run
Prerequisites
Ensure Python and NumPy are installed on your system.
Execution
Run the simulation with:
The program will then guide you through prompts to define simulation parameters.
User Inputs
The program requires the following parameters:
| Parameter | Description | Example |
|---|---|---|
| Box length L | Size of the 1D box | 1.0 |
| Grid points N | Number of spatial grid points (higher = more accuracy, slower computation) | 100 |
| Barrier height V0 | Height of the potential barrier | 100.0 |
| Barrier center x | Position of the barrier's center | 0.5 |
| Barrier width | Width of the potential barrier | 0.2 |
| Time steps | Number of simulation steps | 50 |
| Time step dt | Size of each time step | 0.001 |
| Wavepacket center x0 | Initial center position of the Gaussian wave packet | 0.2 |
| Wavepacket width σ | Width of the wave packet (smaller = more certain position, less certain p) | 0.1 |
| Momentum k0 | Initial momentum of the wave packet | 50.0 |
Output
The program produces:
- Instructions – overview of the simulation.
- Parameter Summary – recap of user inputs.
- Energy Levels – calculated values vs. analytical solutions.
- Time Evolution Results – for selected times (t = 0, mid, final):
- Probability density ∣ψ∣² at sample points.
- Total tunneling probability.
- Expectation values ⟨x⟩ and ⟨p⟩.
Data files are saved as wavefunction_t0.txt, wavefunction_t, and wavefunction_t. Each contains two columns: position and probability density.
Future Improvements
Use vectorized NumPy operations instead of explicit loops.
Add matplotlib plots for wavefunction evolution.
Develop an interactive GUI or web app.
Extend to double wells and other potentials.
Add stricter validation (e.g., barrier must fit inside box).
Important Note for Code in Place Implementation
This program's full functionality, including the saving of wavefunction data to .txt files, is designed for a standard Python environment. Due to the sandboxed nature of the Code in Place IDE, file-saving operations are not supported, and this part of the code will not function. The rest of the program's core features, such as the console output and calculations, will work as described.