Running the relaxation with DFT

Hi!
From the article of the challenge I see that

Second, the dataset would enable the training of models that take as input rough initial starting positions of the system’s atoms from which the relaxed geometries and energies could be computed.

I know it is very expensive, and out of scope for the challenge itself, but is there an easy way, similar to

python main.py --mode run-relaxations --config-yml configs/s2ef/2M/schnet/schnet.yml \
        --checkpoint checkpoints/[TIMESTAMP]/checkpoint.pt

(from TRAIN.me) to actually perform a second relaxation based on DFT?
Thanks!

We currently don’t have such a script available. Part of the reason is we used a commercial software for DFT - VASP. For those with access to VASP, all our settings are publicly available here. We plan on releasing a script to run VASP DFT calculations in the near future.

With the community’s help, we hope to have a Quantum Espresso or other free DFT package implementation as well for people to explore.

1 Like

I’ve been seeing what is needed to carry out a DFT implementation of this. I think that the place where the model is called for the relaxation procedure is this one
https://github.com/Open-Catalyst-Project/ocp/blob/35467132545abdcdce1ef3e3b4cce57331c6dedc/ocpmodels/common/relaxation/optimizers/lbfgs_torch.py#L160 coming from

  1. https://github.com/Open-Catalyst-Project/ocp/blob/35467132545abdcdce1ef3e3b4cce57331c6dedc/ocpmodels/trainers/forces_trainer.py#L629
  2. https://github.com/Open-Catalyst-Project/ocp/blob/35467132545abdcdce1ef3e3b4cce57331c6dedc/ocpmodels/common/relaxation/ml_relaxation.py#L18
  3. https://github.com/Open-Catalyst-Project/ocp/blob/35467132545abdcdce1ef3e3b4cce57331c6dedc/ocpmodels/common/relaxation/optimizers/lbfgs_torch.py#L69

On the DFT side, I have sometimes used pyscf a bit, and I have found
https://github.com/pyscf/pyscf/blob/627ca5f73e3f39a945bf5b2e5b1057e046aeb1bb/pyscf/dft/rks.py#L297
and its periodic boundary condition option
https://github.com/pyscf/pyscf/blob/627ca5f73e3f39a945bf5b2e5b1057e046aeb1bb/pyscf/pbc/dft/rks.py#L190
Or perhaps just use the pyscf.gradients package: pyscf.grad package — PySCF
The idea would be to embed such calculation in a torch module to compute the gradients and just substitute the computation in the function above?

Also, perhaps I am missing something, but how is the DFT relaxation different from a geometric optimization https://pyscf.org/user/geomopt.html?

Are you referring to inserting the full DFT calculation inside autograd? That isn’t something we’re currently thinking about or plan on releasing. What I was referring to is releasing DFT code snippets to run DFT calculations on the user’s end if they were curious to gain more general intuition about the problem.

PySCF is certainly a plausible alternative that, if a sample code was available (with relatively consistent settings to what we did with VASP) would be useful to the community to experiment with. Other free packages include QE and GPAW. As far as geometric optimization - DFT relaxations are synonymous, no difference.

Well, I was talking about carrying out a DFT relaxation after the GNN relaxation rather than a single-point DFT calculation. I only mentioned autograd because to obtain the forces one has to derive the energy with respect to the atom positions, that’s why. So I guess that you are not doing that no?
Thanks!

Ah I see. As far as DFT is concerned, it returns both energies and forces so wrapping it in autograd isn’t necessary. You can think of DFT as a black box that returns ground truth energy and forces at the theoretical level we have selected.

1 Like

Thanks! I think my error was to think that DFT would only return the energy of the state, not the forces. But that is quite clarifying. Thanks again! I have seen that probably the easiest way to run a second relaxation would be to use https://pyscf.org/user/geomopt.html, https://psicode.org/psi4manual/1.2.1/opt.html#table-grad-gen or any of the libraries you mention to perform the optimization afterward. I think they all provide out-of-the-box methods for that, either using DFT or any other method (although post-hartree fock might be too expensive).
But that was clarifying. Thanks!

1 Like