49

Show HN: Differentiable Quantum Chemistry

When I read this, I thought that the author would be calculating the derivative of the potential energy with respect to nuclear charge for some reason. Here, the derivative being evaluated appears to be the atomic forces, using jax magic, as opposed to the standard Hellmann-Feynman theorem approach.

Calculating the derivative of the energy with respect to nuclear charge would be fun, as it would let you perform some type of "alchemy" smoothly changing from one element to another. I'm not sure that has any practical use.

I read a paper a while back doing something alchemical that I guess this reminded me of: https://pubs.aip.org/aip/jcp/article-abstract/133/8/084104/1...

11 hours agomontecarl

Since the gradients are computed with jax, the library can be used to differentiate with respect to all inputs including nuclear charge and basis set parameters (exponents and contraction coefficients). I agree that computing gradients for the nuclear charges could be interesting in the context of molecular design.

But for the colab demo I thought that sticking to nuclear positions (i.e atomic forces) would be easier to visualize.

6 hours agolowdanie

Trying to read the math behind quantum chemistry, it is never clear to me which parts are fundamental, which parts are tricks, which parts are needed just for close form expressions, which parts are computational approximations, and which are the limitations? For a subject that should be fundamental for future technological advances, and highly dependent on the growth of computation resources, it seems to me exceptionally opaque and I suspect not well presented?

8 hours agoempiricus

In a nutshell, the only approximation in Hartree Fock is the assumption that the electronic wave function has a very specific form. Namely, that it is a Slater determinant of orbitals, and that each orbital is a linear combination of atomic orbitals from a fixed basis set. The linear coefficients of the orbitals are then solved for via the (exact) variational method.

Of course, the true wave function is generally not a Slater determinant. In particular, electrons in a Slater determinant with different spins are uncorrelated.

The standard approach to resolving this is density functional theory. In that model, the main approximation is the choice of an “exchange correlation functional” which approximates the electron exchange and correlation energy. The choice of a functional is unfortunately a dark art in the sense that they can only be evaluated empirically rather than from first principles.

The classic reference for Hartree Fock is Modern Quantum Chemistry by Szabo and Ostland: https://books.google.com/books/about/Modern_Quantum_Chemistr...

It is very well written and I highly recommend it.

I also wrote up some notes here: https://www.daniellowengrub.com/blog/2025/07/26/scf

4 hours agolowdanie

Hi, thanks for the recommendations. I looked a little at the book, basically at the end we can compute some properties for small molecules sitting alone in space? What about arbitrary molecules, interacting? Or computing reaction rates? In a solvent? My understanding is that there are some algorithms for all of these, and there is probably progress made, but I never seen (online) anyone complaining that we cannot compute even this basic chemistry. I feel like we should care more about this problem.

3 hours agoempiricus

I get excited every time I see a "Differentiable X" library, but this one had me the most excited! Seeing the methane molecule acquire its geometry is so cool. Can it work with more complex molecules like small amino acids?

14 hours agofarhanhubble

The short answer is yes, but either memory (if the electron integrals are cached) or runtime (if they are not cached) currently scales like O(n^4) where n is the number of atoms.

In cached mode, it can currently jit compile the graph for molecules of around 10 atoms in ~5 minutes on one T4 gpu. Once the graph is compiled, the actual geometry optimization only takes a few seconds.

I’m working on optimizations that improve the scaling behavior (such as density fitting) with the goal of achieving similar or even better performance for molecules with ~50 atoms.

4 hours agolowdanie

This is great! Lovely to see a clean new codebase implementing quantum chemistry algorithms like Hartree-Fock. I remember using Molpro at my fist job. Venerable and comprehensive it may be, but it is some hoary Fortran code for sure.

15 hours agoarticulatepang

Thanks!

4 hours agolowdanie

This looks super cool! I don't know much about Quantum Chemistry. Can this model interaction between molecules?

14 hours agon_u

Theoretically yes, but the method that is currently implemented (Hartree Fock) is notoriously inaccurate for molecular interactions. For example it does not predict the Van Der Waals force between water molecules.

I’m planning to add support for an alternative method called density functional theory which gives better results for molecular interaction.

4 hours agolowdanie

In quantum chemistry, you decide where the bonds should be drawn. Internally, it's all an electron density field. So yes, you can model chemical reactions, for example by constraining the distance between two atoms, and letting everything else reach an equilibrium.

9 hours agoshrx

Incredible work!

14 hours agonynx

Thanks!