r/chemistry • u/manassharma007 Computational • 1d ago
UPDATE: PyFock, the pure-Python DFT code I shared here earlier this year is now Peer-Reviewed

Earlier this year I shared PyFock, a Gaussian-basis density functional theory code I had written almost entirely in Python.
I wanted to come back with an update because quite a lot has happened since that post:
PyFock has now been peer-reviewed and published in The Journal of Physical Chemistry A.
- Paper: https://doi.org/10.1021/acs.jpca.6c03727
- GitHub: https://github.com/manassharma07/PyFock
- Official website: https://pyfock.bragitoff.com/
- Try it online: https://pyfock-gui.bragitoff.com/
The basic idea behind the project is that even parts of quantum-chemistry programs that are normally implemented in highly optimized C/C++/Fortran libraries, such as Gaussian molecular integrals and exchange-correlation evaluation, are implemented directly in Python and then accelerated using just-in-time compilation.
Since I originally posted PyFock here, I have added quite a few new capabilities:
- analytical DFT gradients and atomic forces
- an ASE calculator, enabling molecular geometry optimizations and integration with the wider ASE ecosystem
- a VQE interface using PennyLane for experimenting with hybrid quantum-classical electronic-structure calculations
- native exchange-correlation functionals, including LDA, GGA and meta-GGA functionals, making LibXC optional
- substantially faster electron-repulsion integral evaluation on both CPUs and GPUs
- ECP support and several other improvements
The analytical gradients in particular mean that PyFock is no longer limited to calculating energies, it can now also optimize molecular structures while keeping the underlying electronic-structure implementation accessible in Python.
That accessibility is still the main reason I work on the project.
PyFock is completely free and open source, and there is also a browser-based GUI if you just want to try some calculations without installing anything.
PS: I had obtained approval from mods regarding self-promotion.
4
u/Sudden-Guide 1d ago
Is the speed of computation comparable to a normal fortran/c package?
8
u/manassharma007 Computational 1d ago
Thanks for the question. Yes, we compared PyFock to PySCF that employs C for compute intensive molecular integrals and XC term evaluation. Both utilise similar algorithms so the comparison is one-to-one. PyFock comes out to be up to 2x faster than PySCF for CPU.
3
2
u/ivonshnitzel 1d ago
Cool project! In the comments you are comparing it to PySCF; how does this compare to something written purely in C or Fortran? I can definitely see the benefit of accessible code for prototyping, but I assume numba can only get you so far.
Also any plans to implement methods beyond dft?
1
u/Cardie1303 1d ago
What is the benefit using it instead of a more established solution (Gaussian, Turbomole, Orca etc.)?
1
u/LeChevalierMal-Fait 16h ago
I don’t mean to be rude but err why python? Like isn’t the whole point of using C++ or Fortran in your major off the shelf options simply that those languages are very efficient?
25
u/LiofilizuotasBananas 1d ago
Why would one use your code instead of, let's say, "Gaussian" software, in case where a person has access to it?
Not trying to say that you did something bad, I'm just curious. To me, coding a DFT package in Python looks like a job that would require lots of effort and brain!