Skip to content

Commit

Permalink
rename analysis -> descriptors and integrate with new feature settings
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebystrom committed Jun 24, 2024
1 parent d48e1a6 commit 5cf5788
Show file tree
Hide file tree
Showing 6 changed files with 683 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ def _get_paw_helper2(
dydf_obg = dFdf_oag
Nalpha = self.Nalpha

# TODO consts should be removed to make use of feat normalizers
x_sig = np.zeros((nspin, nfeat, ngrid))
dxdf_oig = np.zeros((norb, nfeat, ngrid))
for s in range(nspin):
Expand All @@ -406,7 +405,7 @@ def _get_paw_helper2(
C_pg = self.C_aip[a, i_g].T
pa_g = C_pg[0] + dq0_g * (C_pg[1] + dq0_g * (C_pg[2] + dq0_g * C_pg[3]))
x_sig[s, i] += pa_g * y_sbg[s, a]
x_sig[s, i] *= ((self.consts[i, 1] + self.consts[-1, 1]) / 2) ** 1.5
# x_sig[s, i] *= ((self.consts[i, 1] + self.consts[-1, 1]) / 2) ** 1.5
for o in range(norb):
s = p_o[o][0]
for i in range(nfeat):
Expand All @@ -425,7 +424,7 @@ def _get_paw_helper2(
dpa_g = 0.5 * (C_pg[1] + dq0_g * (2 * C_pg[2] + dq0_g * 3 * C_pg[3]))
dxdf_oig[o, i] += dpa_g * dadf_g * y_sbg[s, a]
dxdf_oig[o, i] += pa_g * dydf_obg[o, a]
dxdf_oig[o, i] *= ((self.consts[i, 1] + self.consts[-1, 1]) / 2) ** 1.5
# dxdf_oig[o, i] *= ((self.consts[i, 1] + self.consts[-1, 1]) / 2) ** 1.5

return x_sig, dxdf_oig

Expand Down
18 changes: 10 additions & 8 deletions ciderpress/gpaw/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_cider_functional(
_force_nonlocal=False,
):
"""
Initialize a CIDER surrogate hybrid exchange function of the form
Initialize a CIDER surrogate hybrid XC functional of the form
E_xc = E_x^sl * (1 - xmix) + E_c^sl + xmix * E_x^CIDER
where E_x^sl is given by the xkernel parameter, E_c^sl is given by the ckernel
parameter, and E_x^CIDER is the ML exchange energy contains in mlfunc.
Expand All @@ -50,9 +50,9 @@ def get_cider_functional(
but correctness is not guaranteed because the nonlocal features will
not be correct due to the lack of core electrons.
NOTE: If the mlfunc is determined to be semi-local, all the
NOTE: If the mlfunc is determined to be semilocal, all the
internal settings are ignored, and a simpler, more efficient
class is returned to evaluate the semi-local functional.
class is returned to evaluate the semilocal functional.
Args:
mlfunc (MappedXC, str): An ML functional object or a str
Expand Down Expand Up @@ -162,7 +162,7 @@ class is returned to evaluate the semi-local functional.
msg = "Only implemented for b and d version, found {}"
raise ValueError(msg.format(mlfunc.desc_version))

const_list = _get_const_list(mlfunc)
const_list = get_const_list(mlfunc.settings.nldf_settings)
nexp = 4

if use_paw:
Expand Down Expand Up @@ -299,19 +299,21 @@ def cider_functional_from_dict(d):
else:
# xc_params should have Nalpha, lambd, encut.
# For PAW, it should also have pasdw_ovlp_fit, pasdw_store_funcs.
const_list = _get_const_list(mlfunc)
const_list = get_const_list(mlfunc.settings.nldf_settings)
xc = cls(cider_kernel, nexp, const_list, **(d["xc_params"]))
else:
xc = cls(LibXC(d["name"]))

return xc


def _get_const_list(mlfunc):
settings = mlfunc.settings.nldf_settings
def get_const_list(settings):
"""
settings should be NLDFSettings object
"""
thetap = 2 * np.array(settings.theta_params)
vvmul = thetap[0] / (2 * settings.feat_params[1][0])
fac_mul = thetap[2] if mlfunc.settings.sl_settings.level == "MGGA" else thetap[1]
fac_mul = thetap[2] if settings.sl_level == "MGGA" else thetap[1]
consts = np.array([0.00, thetap[0], fac_mul, thetap[0] / 64]) / vvmul
const_list = np.stack([0.5 * consts, 1.0 * consts, 2.0 * consts, consts * vvmul])
return const_list
9 changes: 4 additions & 5 deletions ciderpress/gpaw/cider_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,8 +1237,8 @@ def from_mlfunc(

class CiderGGA(_CiderBase, GGA):
def __init__(self, cider_kernel, nexp, consts, **kwargs):
if cider_kernel.mlfunc.desc_version != "d":
raise ValueError("Wrong mlfunc version")
if cider_kernel.mlfunc.settings.sl_settings.level != "GGA":
raise ValueError("CiderGGA only supports GGA functionals!")
_CiderBase.__init__(self, cider_kernel, nexp, consts, **kwargs)

GGA.__init__(self, LibXC("PBE"), stencil=2)
Expand Down Expand Up @@ -1335,9 +1335,8 @@ def integrate(a1_g, a2_g=None):

class CiderMGGA(_CiderBase, MGGA):
def __init__(self, cider_kernel, nexp, consts, **kwargs):

if cider_kernel.mlfunc.desc_version != "b":
raise ValueError("Wrong mlfunc version")
if cider_kernel.mlfunc.settings.sl_settings.level != "MGGA":
raise ValueError("CiderMGGA only supports MGGA functionals!")
_CiderBase.__init__(self, cider_kernel, nexp, consts, **kwargs)

MGGA.__init__(self, LibXC("PBE"), stencil=2)
Expand Down
Loading

0 comments on commit 5cf5788

Please sign in to comment.