Variational Method with Rational Trial Function
Quantum Chemistry
This page demonstrates the variational principle applied to the hydrogen atom using a rational trial wavefunction. Unlike the exponential form typically used, we explore a rational function as a trial wavefunction.
Trial Wavefunction
We use a rational form for the trial wavefunction:
where and are variational parameters to be optimized.
Energy Functional
For the hydrogen atom, the radial Hamiltonian in atomic units is:
The variational energy is computed as:
This requires computing the Laplacian , which for an s-wave is:
Implementation
The following code implements the variational optimization:
import numpy as np
from scipy.integrate import simps
from scipy.optimize import minimize
# ------------------------------------------------------------
# Trial wavefunction: rational form
# ψ(r) = 1 / (1 + a r + b r^2)
# ------------------------------------------------------------
def psi(r, a, b):
return 1.0 / (1.0 + a*r + b*r*r)
# ------------------------------------------------------------
# Second derivative needed for kinetic energy
# d²ψ/dr² computed analytically
# ------------------------------------------------------------
def psi_second_derivative(r, a, b):
denom = 1 + a*r + b*r*r
d1 = -(a + 2*b*r) / denom**2
d2 = (2*(a + 2*b*r)**2) / denom**3 - (2*b) / denom**2
return d2
# ------------------------------------------------------------
# Energy functional E[a,b]
# Hydrogen radial Hamiltonian in atomic units:
# H = -½ (d²/dr² + 2/r d/dr) - 1/r
#
# We work with full 3D wavefunction ψ(r), and the energy integral is:
# E = ∫ ψ H ψ 4π r^2 dr / ∫ ψ^2 4π r^2 dr
#
# ------------------------------------------------------------
def energy(params, r):
a, b = params
psi_r = psi(r, a, b)
# derivatives
psi_rr = psi_second_derivative(r, a, b)
# kinetic term T = -1/2 ∫ ψ ∇²ψ dV
# ∇²ψ (for s-wave) = ψ'' + 2ψ'/r
# Let's do dψ/dr analytically:
dpsi_dr = -(a + 2*b*r) / (1 + a*r + b*r*r)**2
laplacian = psi_rr + 2*dpsi_dr/r
T_density = -0.5 * psi_r * laplacian
# potential term V = -1/r
V_density = -psi_r**2 / r
# total integrand * 4π r^2
integrand_T = T_density * 4*np.pi * r*r
integrand_V = V_density * 4*np.pi * r*r
integrand_N = psi_r**2 * 4*np.pi * r*r
T = simps(integrand_T, r)
V = simps(integrand_V, r)
N = simps(integrand_N, r)
return (T + V) / N # normalized energy
# ------------------------------------------------------------
# Main execution: minimize E[a,b]
# ------------------------------------------------------------
if __name__ == "__main__":
# grid for r
r = np.linspace(1e-6, 20.0, 20000)
# initial guess for parameters (close to expected)
x0 = np.array([1.0, 0.1])
print("Optimizing variational parameters...")
res = minimize(lambda p: energy(p, r), x0,
method='Nelder-Mead',
options={'maxiter': 200, 'xatol':1e-6, 'fatol':1e-6})
a_opt, b_opt = res.x
E_opt = energy(res.x, r)
print("\nOptimal parameters:")
print("a =", a_opt)
print("b =", b_opt)
print("\nVariational energy:", E_opt)
print("Exact ground-state energy:", -0.5) Results
The optimization finds the optimal parameters and that minimize the energy. The exact ground-state energy for hydrogen is atomic units, and the variational principle guarantees that our result will be an upper bound.