You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add Classical and Quantum Hamiltonian functions to physics algorithms #13235
I would like to suggest adding functions for the Hamiltonian in both classical mechanics and quantum mechanics
to the physics directory.
Proposed functions
Classical Hamiltonian
Computes H = T + V for a particle or system, where T is kinetic energy and V is potential energy.
Example use case: free particle, harmonic oscillator, simple pendulum.
Quantum Hamiltonian (1D)
Constructs the Hamiltonian matrix for a particle in a 1D potential using finite difference discretization.
Example use case: solving the time-independent Schrödinger equation.
Benefits
Provides a practical way for learners to understand and simulate physical systems in Python.
Fits the existing educational purpose of the physics directory as a collection of algorithmic implementations.
Hello, I’m Dev
I would like to work on this issue as part of Hacktoberfest. This would be my first open-source contribution.
And I will really appreciate any advice or guidance you might have for me. or you can specify more if you can.
Could you please assign this issue to me so I can start working on it?
Hello, I’m Dev
I would like to work on this issue as part of Hacktoberfest. This would be my first open-source contribution.
And I will really appreciate any advice or guidance you might have for me. or you can specify more if you can.
Could you please assign this issue to me so I can start working on it?
@cclauss reviewed #15012 — approved. Doctests verified by hand and the finite-difference quantum Hamiltonian is correct (tridiagonal, diagonal ħ²/(m·dx²)+V, off-diagonals -ħ²/(2m·dx²)); classical H=T+V checks out too. CI green. One optional nit noted (num_points duplicates len(potential)), non-blocking.
Activity
devx099 commentedon Oct 5, 2025
Hello, I’m Dev
I would like to work on this issue as part of Hacktoberfest. This would be my first open-source contribution.
And I will really appreciate any advice or guidance you might have for me. or you can specify more if you can.
Could you please assign this issue to me so I can start working on it?
morgen-code commentedon Oct 5, 2025
Hi Dev (@devx099 )
That’s great to hear. Thank you for your interest in working on this issue.
Yes, please go ahead and start working on it.
Here’s a suggested structure:
classical_hamiltonian(m, p, V)→ returnsp**2 / (2*m) + Vquantum_hamiltonian_1d(m, hbar, V, dx)→ builds the Hamiltonian matrix using the finite difference method.hbaris included as an input parameter to allow flexible choice of unit systems (e.g., natural units or SI units).Let me know if you have any questions or would like feedback while implementing.
I’ll be happy to help.
pipineitor commentedon Oct 6, 2025
cclauss commentedon Sep 10, 2026
@priya-sundaram-dev, please review this issue with the pull request #15012
priya-sundaram-dev commentedon Sep 10, 2026
@cclauss reviewed #15012 — approved. Doctests verified by hand and the finite-difference quantum Hamiltonian is correct (tridiagonal, diagonal ħ²/(m·dx²)+V, off-diagonals -ħ²/(2m·dx²)); classical H=T+V checks out too. CI green. One optional nit noted (num_points duplicates len(potential)), non-blocking.
Add hamiltonian functions (#15012)