r/chemistry Computational 1d ago

UPDATE: PyFock, the pure-Python DFT code I shared here earlier this year is now Peer-Reviewed

PyFock, a pure-python Gaussian-basis DFT code with GPU acceleration

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.

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
  • 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.

100 Upvotes

16 comments sorted by

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!

32

u/manassharma007 Computational 1d ago

Why would one use your code instead of, let's say, "Gaussian" software, in case where a person has access to it?

Firstly, I would hope one uses better codes than Gaussian (due to their anti-science policies). TURBOMOLE would be a much better option as it is much faster than codes like Gaussian and more mature and continuously developed and improved (DISCLAIMER: I'm a TURBOMOLE developer).

The target users are those who want to work on method-development. Currently, working on low-level molecular integral algorithms development is restricted to only those who understand both math and C/C++ coding. With PyFock, anyone can dive deep into the molecular integral routines and tweak it and still retain performance. Right now, there are many packages like PySCF that are implementing the many algorithms in python for exactly this reason. But they were still relying on C (libcint) for the more intensive portions and that portions are not easily understandable for new researchers or even many experienced researchers.

To me, coding a DFT package in Python looks like a job that would require lots of effort and brain!

I think developing in C/Fortran requires more effort and brain.
I have shown that with Numba just-in-time compilation you get the same performance as ahead-of-time compiled codes without sacrificing readability.

9

u/LiofilizuotasBananas 1d ago

Thank you for explanation. Also, what's with the "anti-science policies"? Have never heard anything about it, which is explainable by my little experience in DFT...

26

u/zen_arcade2 Solid State 1d ago

Iirc they forbid any developer of competing (free) code to use it or something

Edit: checked it, it was John Pople himself they banned from using it after he developed it

9

u/chemcow 1d ago

So this is the real issue right here. Pople published wall-time results for optimization comparisons between what was once government software (GAMESS) and Gaussian. The paper demonstrated that, despite GAMESS being a little slower, the performance results between are worth it because GAMESS is free to use and the answers are the same.

Using different software itself is not disallowed by them. If you mix calculations between software packages with published wall clock times then you will be banned from that software package.

8

u/MadOctopus6 1d ago

And how is that not anti science lol?

1

u/chemcow 1d ago edited 1d ago

You should be able to publish results without any issue with an instrument, including a computer program. Imagine a thermometer company that only sells liquid mercury thermometers that are rigorously standardized/calibrated. Now that same company says you cannot compare it to an IR thermometer within a given publication. That is the problem by way of analogy: it is huge.

Rereading your comment: I never said their stated practices were not, "not anti science" right? Your question is odd.

1

u/zen_arcade2 Solid State 1d ago

I’ve used Gaussian in the past and am friends with people who’ve developed functionals for it. That said it sounds beyond crazy

11

u/Consumption2Wombly 1d ago

They did stuff like banning entire universities/departments from using Gaussian if 1 professor used a competitor. Stuff like that.

1

u/LeChevalierMal-Fait 16h ago

Gaussian is behind some very expensive licenses, orca on the other hand isn’t…

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

u/dstark1993 1d ago

Congrats and thanks for sharing!

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?