From bb2755df6a406af91b076b3f9b06cc7edd824ef8 Mon Sep 17 00:00:00 2001 From: = Date: Fri, 22 Mar 2024 16:00:08 -0400 Subject: [PATCH] add hydrogen energy --- qctools/hydrogen.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/qctools/hydrogen.py b/qctools/hydrogen.py index fa24518..e3ba1a0 100644 --- a/qctools/hydrogen.py +++ b/qctools/hydrogen.py @@ -60,4 +60,32 @@ def hydrogenic_wavefunction(r, theta, phi, n, l, m, Z=2): float The value of the hydrogenic wavefunction at given r, theta, and phi. """ - return radial(r, n, l, Z)*special.sph_harm(m, l, phi, theta) \ No newline at end of file + return radial(r, n, l, Z)*special.sph_harm(m, l, phi, theta) + +def calc_energy(n, Z=1, units='hartree'): + """ + Compute the energy of a hydrogenic orbital. + + Parameters + ---------- + n : int + The principal quantum number. + Z : int + The atomic number. + units : str + The units of energy to return. Either 'hartree' or 'eV'. + + Returns + ------- + float + The energy of the hydrogenic orbital in the specified units. + """ + E = -Z**2/(2*n**2) + if units == 'hartree': + return E + elif units == 'eV': + return E*27.2114 + elif units == 'SI': + return E*4.3597482e-18 + else: + raise ValueError("Invalid units. Must be 'hartree', 'eV', or 'SI'.") \ No newline at end of file