JuliaMolSim / DFTK.jl

Density-functional toolkit
https://docs.dftk.org
MIT License
435 stars 89 forks source link

support for BEEF ensembles #732

Open rkurchin opened 2 years ago

rkurchin commented 2 years ago

I'd like to take a crack at implementing support for sampling from BEEF ensembles (assuming you'd accept the PR 😉 ) – should be pretty simple, see e.g. here. Before starting to hack away at it, I wanted to start a discussion here in case you folks had any suggestions/advice/preferences.

In terms of high-level approach, my thought is (at least to start with) to basically replicate the code linked above using Distributions.jl for the sampling and Libxc.jl to actually interface with the functional. Once that works, I think there are some other cool things to potentially play with down the line (e.g. DFTK as an interface for training new ensembles, etc.), but I'd be happy with that as a start!

mfherbst commented 2 years ago

Sounds like a good idea. Thanks for taking a look at that!

I wonder whether this should be in DFTK or outside. I guess one could argue both in this case (especially considering possible error propagation usages). What do you plan?

I think for now the trickiest part is the parameter handling in the BEEF functional in Libxc.jl for doing the evaluation of the ensembles (beware: I'm planning to change the interface of Libxc at some point soonish, but that should only affect one or two function calls).

rkurchin commented 2 years ago

Yes, I'm hoping to use it for error propagation stuff, among other things. Happy to defer to your preference about where to do it – maybe even in Libxc.jl itself could make sense? Let me know your thoughts.

Unless I'm misunderstanding your other point, I don't think the last part should be an issue. AFAICT from looking at the ASE code, the generation of the ensemble only relies on that big omega matrix, which lives outside Libxc itself, so I think the Libxc interfacing should be quite analogous to evaluating any other functional, unless I'm missing something...BTW, in case it's not clear, the ensemble energies are obviously not self-consistent, only the so-called "BEEF-optimal" energy is, and then the ensemble is generated post facto around that value.

antoine-levitt commented 2 years ago

Hi!

I'm not familiar with BEEF but from what I understand it's an outer loop of DFT? For sure prototype outside of DFTK, we should expose pretty much everything that's needed. Then we can see if it makes sense to have it in DFTK proper or possibly as an example in the docs or something

rkurchin commented 2 years ago

It's not even really an outer "loop" so much as a procedure for taking the self-consistent energy and generating an ensemble using some parameters that have been previously calibrated. That is, you only need to run the SCF cycle once in a BEEF calculation, so it's more like a postprocessing step in that sense.

I can prototype it independently and maybe just start a topic on the Zulip once I have something working and we can discuss where it might belong.