Giter VIP home page Giter VIP logo

hf-tutorial's Introduction

Introduction

This is a tutorial on how to implement a simple program to solve the Hartree-Fock with SCF iterations.

Impement the SCF procedure

We start from step in the algorithm described in Szabo and Ostlund, 3.4.6, p. 146

  • Obtain a guess at the density matrix.
  • Calculate the exchange and coulomb matrices from the density matrix and the two-electron repulsion integrals.
  • Add exchange and coulomb matrices to the core-Hamiltonian to obtain the Fock matrix.
  • Diagonalize the Fock matrix.
  • Select the occupied orbitals and calculate the new density matrix.
  • Compute the energy
  • Compute the errors and check convergence
    • If converged, return the energy
    • If not converged, return to second step with new density matrix

You can first implement it for hydrogen molecule by running the following code:

    mol = "h2"
    r   = 1.0
    inp = f"{mol}-{r:.4f}"
    e = main(inp) # H2 molecule with bond length 1.0

then try some more complicated molecules, such as HeH+

    mol = "heh+"
    r   = 1.0
    inp = f"{mol}-{r:.4f}"
    e = main(inp) # HeH+ molecule with bond length 1.0

and H2O

    mol = "h2o"
    r   = 1.0
    inp = f"{mol}-{r:.4f}"
    e = main(inp) # water molecule with bond length 1.0

Potential Energy Surface

After implementing the SCF procedure, we can use it to compute the potential energy surface of the $\mathrm{H}_2$ molecule. We can do this by varying the internuclear distance and computing the energy at each point.

    for r in numpy.linspace(0.5, 2.5, 21):
        inp = f"h2-{r:.4f}"
        e = main(inp)
        print(f"H2: r={r: 6.4f}, e={e: 12.8f}")

You may also try other molecules, such as $\mathrm{HeH}^+$ and $\mathrm{H_2O}$.

Unrestricted Hartree-Fock

Write a new function solve_uhf to implement the unrestricted Hartree-Fock method. See what's the difference between the restricted and unrestricted Hartree-Fock potential energy surfaces. (Note that to obtain a reasonable dissociation potential energy surface, you may need to play some tricks to get the broken spin-symmetry UHF solution.)

Dependencies

  • numpy
  • scipy
  • If you wish to use ./data/gen_data.py to generate the integrals, pyscf is also required.

Reference

  • Szabo and Ostlund, Modern Quantum Chemistry: Introduction to Advanced Electronic Structure Theory, Dover Publications, New York, 1996
  • Helgaker, Jørgensen, and Olsen, Molecular Electronic-Structure Theory, Wiley, New York, 2000

hf-tutorial's People

Contributors

yangjunjie0320 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.