Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable contribution from specific atoms #75

Open
tgmaxson opened this issue Jul 30, 2024 · 3 comments
Open

Disable contribution from specific atoms #75

tgmaxson opened this issue Jul 30, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@tgmaxson
Copy link

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 awvwgk added the enhancement New feature or request label Jul 31, 2024
@awvwgk awvwgk changed the title [Feature] Disable contribution from specific atoms Disable contribution from specific atoms Jul 31, 2024
@awvwgk
Copy link
Member

awvwgk commented Jul 31, 2024

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
Copy link
Author

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
Copy link
Member

awvwgk commented Jul 31, 2024

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

allocate(self%c6(mref, mref, mol%nid, mol%nid), source=0.0_wp)
do isp = 1, mol%nid
izp = mol%num(isp)
do jsp = 1, isp
jzp = mol%num(jsp)
do iref = 1, self%ref(isp)
do jref = 1, self%ref(jsp)
self%c6(jref, iref, jsp, isp) = get_c6(jref, iref, jzp, izp)
self%c6(iref, jref, isp, jsp) = self%c6(jref, iref, jsp, isp)
end do
end do
end do
end do

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:

subroutine set_model_realspace_cutoff(verror, vdisp, disp2, disp3, cn) &
& bind(C, name=namespace//"set_model_realspace_cutoff")

/// Set realspace cutoffs (quantities in Bohr)
SDFTD3_API_ENTRY void SDFTD3_API_CALL
dftd3_set_model_realspace_cutoff(dftd3_error /* error */,
dftd3_model /* model */,
double /* disp2 */,
double /* disp3 */,
double /* cn */) SDFTD3_API_SUFFIX__V_0_5;

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

set_model_realspace_cutoff = error_check(lib.dftd3_set_model_realspace_cutoff)

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

def set_realspace_cutoff(self, disp2: float, disp3: float, cn: float):
"""Set realspace cutoff for evaluation of interactions"""
library.set_model_realspace_cutoff(self._disp, disp2, disp3, cn)

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

default_parameters = {
"method": None,
"damping": None,
"params_tweaks": {},
"cache_api": True,
}

def set(self, **kwargs) -> dict:
"""Set new parameters to dftd3"""
changed_parameters = Calculator.set(self, **kwargs)
# Always reset the calculation if parameters change
if changed_parameters:
self.reset()
return changed_parameters

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants