5. chilli.py [chilli_py]

_images/chilli_py_v02.png

Chilli.py [chilli_py] is purely written in Python3. The primary dependencies are the standard scientific Python packages NumPy and SciPy.

5.1. Design and philosophy

  • Realization of the Educational software pragmas (ESP)

  • Open-Source and Open-Sience

  • Python3

  • one coding language for all source code files

  • clear design that make it possible to code up the package in other languages

  • easy to use and easy to install

  • minimal package dependencies
    • NumPy and SciPy

    • functionality of Pythons standard libary

  • the package should be integratable into other packages

  • the package can interoperate with other chilli codes

  • readability before numerical speed-ups

  • the source code should be readable

  • 50% coding + 50% documenting

  • education, developer, fun purpose code

  • the code does not aim to replace established tool-boxes

  • object-oriented programming (OOP) design

  • mayor functionality is collected in classes
    • structure information -> Atoms()

    • basis set information -> BasisSet()

    • numerical grid -> Grid()

    • methods -> RHF(), RKS(), etc.

  • f-strings, because they are amazing

  • high reproducibility of all values
    • mayor reference is PySCF

    • Dipoles: McMurchie-Davidson (mmd) code, PySCF

  • automatic (small and fast) tests which run on GitLab CI

5.2. Features

  • GTO basis sets supported (G94 format)

  • Restricted Hartree-Fock (RHF)

  • Unrestricted Hartree-Fock (UHF)

  • Restricted Møller–Plesset perturbation theory (RMP2)

  • Restricted Kohn-Sham (RKS)
    • LDA-VWN (default)

    • LDA-PW

    • PBE (debugging)

  • Unrestricted Kohn-Sham (UKS)
    • LDA-VWN (default)

    • LDA-PW

  • Restricted self-interaction correction (RSIC)
    • Fermi-Lowedin-orbital SIC (RFLOSIC)

  • Self-consistent cycle (SCF)
    • direct SCF

    • simple DIIS

  • Properties
    • spin expectation value

    • dipole moment

5.3. History

One of the package authors, i.e., Sebastian Schwalbe, started to implement a simple 1s-orbital restricted Hartree-Fock (HF) Gaussian-type orbitals (GTO) code for atoms and molecules. The first implementation step was dominantly influenced by a YouTube series of the YouTuber Nickel and Copper. In the first step, you need to handle primitive and contracted Gaussian orbitals, and implement basic functionality, i.e., the one-electron integrals namely the overlap matrix S, kinetic energy matrix T, nuclear attraction matrix V and two-electron integrals namely the electron repulsion integrals (ERI). Thus the principal degrees of freedom of HF are system parameters (atoms, chemical symbols, positions, spin, charge) and the used basis set (basis). The package has then been extended to restricted Kohn-Sham density functional theory (DFT) using the VWN exchange-correlation function. In the second step going from HF to DFT, you need a numerical grid (grid) to integrate exchange-correlation properties, i.e., the density, on it. Thus, in DFT the principal degrees of freedom are the system parameters (atoms), the used basis set (basis), and the used numerical grid (grid). In the third step, general support for any type of GTO basis set needs to be implemented. The primitive 1s orbital versions of the one-electron and two-electron operators need to be reimplemented to work for any Gaussian orbital. The reimplemented one and two-electron operations were influenced/guided by their respective counterparts in PyQuante and pyquante2/pyquante2.jl. The overall structure of the code of the previous steps needs to be adjusted, i.e., enhanced modularity e.g. one file/module for each, the basis set, the atoms information, the one and two electron operators, the exchange-correlation functionality, one file for the self-consistent field (SCF) and so on. In the second part, the grid was influenced/guided by the grid implementation of PyQuante and pyquante2/pyquante2.jl. In the third part, the grid was completely rewritten. The grid now was rewritten to improve the agreement of the package with PySCF. Having a fully working restricted Hartree-Fock (RHF) at hand makes it rather easy to implement unrestricted Hartree-Fock (UHF). Only the self-consistent field (SCF) needed to be rewritten to realize the UHF routine starting from the RHF routine. In the fourth part, additional properties were added to the code, such as the calculation of dipole moments and spin expectation values. The implementation of the dipole moment was influenced/guided by the McMurchie-Davidson code. In the fifth step, the implementation of unrestricted Kohn-Sham (UKS), the exchange-correlation routines have to be reassessed. In detail, the exchange-correlation functionals were separated into spin-unpolarized and spin-polarized ones and the call to the exchange-correlation functionals was vectorized. Here PWDFT.jl was a big help and guide for recoding these routines. The vectorization speed-up both RKS and UKS routines significantly.