0% found this document useful (0 votes)
58 views

Computational Hydrogen: exp (− c α r Hc = Esc

This notebook solves the ground state for the hydrogen atom computationally using four Gaussian functions as the basis set

Uploaded by

周子暄
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Computational Hydrogen: exp (− c α r Hc = Esc

This notebook solves the ground state for the hydrogen atom computationally using four Gaussian functions as the basis set

Uploaded by

周子暄
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Computational Hydrogen

Summary. This notebook solves the ground state for the hydrogen atom computationally using four
Gaussian functions as the basis set. Given this expression for the wavefunction, the Schrodinger equation
reduces to a generalized eigenvalue problem that we solve numerically.

You can change the width of each gaussian and explore how the description changes. Compare the energy
and wave function with the exact solution.

Use. Feel free to download the improve on it, add features and re-deploy it in nanoHUB for the community to
use.

Approach. We write the wavefunction as a linear combination of gaussian functions:


2
Ψ = ∑ ci exp(−αi r )

Plugging this anzats into the Schrodinger equation results a generalized eigenvalue problem:
H C = ES C

where C is a column vector with the unknown linear coefficients in the wave function, H is the Hamiltonian
matrix, S is the overlap matrix and E is the energy.

The advantage of using Gaussian functions is that the integrals in the Hamiltonian and overlap matrix can be
evaluated analytically. The eigenvalue problem can then be easily solved using linear algebra.

In [1]:

%pylab inline

from scipy import linalg

Populating the interactive namespace from numpy and matplotlib

In [2]:

# Define the width of the Gaussians in the basis sets

# We will use atomic units throughout the code

alpha = array( [13.00773, 1.962079, 0.444529, 0.1219492] )

#alpha=np.random.rand(4)

print(alpha)

[ 13.00773 1.962079 0.444529 0.1219492]

In [3]:

# Define overlap, kinetic energy and potential energy matrices

S = empty((4,4))

T = empty((4,4))

V = empty((4,4))

3/2
2 2
3 −α i r −α j r π
Sij = ∫ d re e = ( )
α i +α j

3/2
2 2 αi αj π
3 −α i r 2 −α j r
Tij = ∫ d re ∇ e = 3
5/2
(α i +α j )

2 2
3 −α i r 1 −α j r 2
Vij = ∫ d re e = −
r α i +α j

In [4]:

#Compute the overlap, kinetic and potential energies matrices

for i in range(alpha.size):

for j in range(alpha.size):

S[i,j] = (math.pi/(alpha[i]+alpha[j]))**(3./2.)

T[i,j] = 3.*(alpha[i]*alpha[j]*math.pi**(3./2.))/(alpha[i]+alpha[j])**(5./2.
)

V[i,j] = -2.*math.pi/(alpha[i]+alpha[j])

In [5]:

# Print the matrices

print("Overlap matrix")

print(S)
print("Hamiltonia matrix")

H = T+V

print(H)

Overlap matrix

[[ 4.19640644e-02 9.61391815e-02 1.12857904e-01 1.17042513e-0


1]

[ 9.61391815e-02 7.16316708e-01 1.49147774e+00 1.85084232e+0


0]

[ 1.12857904e-01 1.49147774e+00 6.64247101e+00 1.30602054e+0


1]

[ 1.17042513e-01 1.85084232e+00 1.30602054e+01 4.62286682e+0


1]]

Hamiltonia matrix

[[ 0.57726847 0.07200247 -0.3215405 -0.43612626]

[ 0.07200247 0.50704993 -0.98918483 -2.37741992]

[ -0.3215405 -0.98918483 -2.63808243 -7.34221693]

[ -0.43612626 -2.37741992 -7.34221693 -17.30516271]]

In [6]:

#Solve the generalized eigenvalue problem

# e are arrays with eigenvuales and eigenvectors

# The eigenvualue corresponding to e[i] is the column w[:,i].

e,w = linalg.eig(H,S)

print("Eigenvalues: ", e.real)

Eigenvalues: [ 21.14436519 2.59229957 0.11321392 -0.49927841]

In [7]:

# Print the ground state energy

print(" Ground State Energy: ", e.real.min())

# Index of the ground state eigenvalue and eigenvector

imin = e.real.argmin()

# Ground state eigenvector, i.e. the gaussian coefficients of the ground state w
avefunction

psi = np.atleast_1d(w[:,imin])

print(" Ground State Eigenvector: ", psi)

Ground State Energy: -0.499278405667

Ground State Eigenvector: [-0.34932283 -0.59255692 -0.67459675 -


0.26789752]

Wave functional normalization. We need to scale the coefficients in order for the wave function to be
properly normalized:
⋆ 3 2 2 3
∫ Ψ Ψd r = 1 = ∫ ∑ ci exp(−αi r ) ∑ cj exp(−αj r )d r

i j

∑ ci cj Sij = 1

i,j

In [8]:

#Normalize the ground state wavefunction.

norm = 0.0

for i in range(alpha.size):

for j in range(alpha.size):

norm = norm + psi[i]*psi[j]*S[i,j]

print(norm)

psi = psi / sqrt(norm)

13.212757071

In [9]:

#Plot numerical wavefucntion, exact solution, and the individual gaussians.

x = np.linspace(0, 5, 100)

plt.plot(x, 1/sqrt(np.pi)*exp(-x), linewidth=2, color='red', label='Exact')

plt.plot(x, abs(psi[0]*exp(-1.*alpha[0]*x*x) + psi[1]*exp(-1.*alpha[1]*x*x) + ps


i[2]*exp(-1.*alpha[2]*x*x) + psi[3]*exp(-1.*alpha[3]*x*x)), linewidth=2, color=
'blue', label='Computational')

plt.plot(x, abs(psi[0]*exp(-1.*alpha[0]*x*x)), linewidth=1, color='black')

plt.plot(x, abs(psi[1]*exp(-1.*alpha[1]*x*x)), linewidth=1, color='black')

plt.plot(x, abs(psi[2]*exp(-1.*alpha[2]*x*x)), linewidth=1, color='black')

plt.plot(x, abs(psi[3]*exp(-1.*alpha[3]*x*x)), linewidth=1, color='black')

plt.title('Ground State Energy: %.6f hartree' % w.real.min())

plt.xlabel('r (bohr)')

plt.ylabel('1/bohr^3')

plt.legend(loc='upper right')

plt.show()

In [ ]:

You might also like