dftd3 / simple-dftd3

reimplementation of the DFT-D3 program
https://dftd3.readthedocs.io
GNU Lesser General Public License v3.0
51 stars 24 forks source link

Disable contribution from specific atoms #75

Open tgmaxson opened 1 month ago

tgmaxson commented 1 month ago

According to this paper ( https://pubs.acs.org/doi/10.1021/acs.jpclett.3c00856 ) it seems that it may be reasonable to disable the D3 contributions arising from cations in some cases. This is implemented in CP2K by removing the energy, force, and stress terms involving the cation (but keeping the ion in the CN calculation I think) but not generally implemented anywhere else that I can find. Is this something that can be enabled for the ASE calculator of dftd3?

awvwgk commented 1 month ago

One option for implementing this would be to give a zero C6 coefficient to atoms marked as "ghost atom" in this case they would be fully accounted for in the CN calculation, but don't contribute to the energy, forces and stress directly.

tgmaxson commented 1 month ago

Is there a straightforward way to do this using the ASE calculator?

In VASP it looks like we can set the C6 per species, but I see no similar keyword for the ASE calculator.

awvwgk commented 1 month ago

The way for approaching this would add an option for the dispersion model to set C6 coefficients to zero, maybe here

https://github.com/dftd3/simple-dftd3/blob/d9b9c7bf31e263c7ec26da8d1da2beb8fef26c7d/src/dftd3/model.f90#L128-L140

The option could be added a logical / bool array which is initialized from a list of indices or by directly using a list of indices.

For usage in the ASE calculator we need to define the export in the C API first, maybe in a similar way like we set the real space cutoff in the model:

https://github.com/dftd3/simple-dftd3/blob/d9b9c7bf31e263c7ec26da8d1da2beb8fef26c7d/src/dftd3/api.f90#L309-L310 https://github.com/dftd3/simple-dftd3/blob/d9b9c7bf31e263c7ec26da8d1da2beb8fef26c7d/include/s-dftd3.h#L119-L125

This gets forwarded to Python via the dftd3.library implementation, probably with a simple decoration of the C function as in

https://github.com/dftd3/simple-dftd3/blob/d9b9c7bf31e263c7ec26da8d1da2beb8fef26c7d/python/dftd3/library.py#L108

And than added as method for the DispersionModel defined in dftd3.interface

https://github.com/dftd3/simple-dftd3/blob/d9b9c7bf31e263c7ec26da8d1da2beb8fef26c7d/python/dftd3/interface.py#L410-L413

With this we can include it in the ASE calculator for the default_parameters and set method implementation

https://github.com/dftd3/simple-dftd3/blob/d9b9c7bf31e263c7ec26da8d1da2beb8fef26c7d/python/dftd3/ase.py#L143-L148 https://github.com/dftd3/simple-dftd3/blob/d9b9c7bf31e263c7ec26da8d1da2beb8fef26c7d/python/dftd3/ase.py#L180-L189

It does involve all parts of the dftd3 library, so probably a good issue for somebody who would like to get started (when I have time in the coming weeks I might pick it up myself, but no promises on the estimated time of arrival).