Computational Physics - Exercise 5: 0 Python Primer
Computational Physics - Exercise 5: 0 Python Primer
0 Python Primer
In order to guarantee that all students have the required Python skills to solve the Hartree-Fock
exercises, a Python Primer is provided. The script ex_000_primer/primer.py is a python
program that consists of eight sections. Each section introduces a new Python feature, some
example code and a problem that can be solved once the corresponding feature is understood.
When all eight problems are solved, the script should run without an error message. Run the
script after solving each problem (in order) to see if your solution works:
cd ex_000_primer/
./primer.py
Page 1/2
a. Construct the Fock matrix for the alpha electrons. This consists of a kinetic energy,
nuclear attraction, Hartree and exchange term. Take the correct linear combination of
these operators.
b. Check if the old orbitals already diagonalize the Fock matrix. Propose a measure to
compute the error. If this error drops below a pre-defined threshold, the loop can be
interrupted.
c. Diagonalize the Fock matrix to obtain a new set of alpha orbitals and alpha orbital
energies. Construct a new density matrix
4. Compute the Hartree-Fock energy.
Some results to check your program:
• The lowest orbital energy of the initial guess is: -1.99436423289 Eh.
• The lowest orbital energy of the HF solution is: -0.917123967703 Eh.
• The HF energy is -2.85570466771 Eh.
Page 2/2