The Settings Module

ciderpress.dft.settings.ALLOWED_I_SPECS_L0 = ['se', 'se_r2', 'se_apr2', 'se_ap', 'se_ap2r2', 'se_lapl']

Allowed spec strings for version i l=0 features.

se: squared-exponential

se_r2: squared-exponential times r^2

se_apr2: squared-exponential times the exponent of the r’ coordinate times r^2

se_ap: squared-exponential times the exponent of the r’ coordinate.

se_ap2r2: squared-exponential times exponent^2 times r^2

se_lapl: laplacian of squared-exponential

ciderpress.dft.settings.ALLOWED_I_SPECS_L1 = ['se_grad', 'se_rvec']

Allowed spec strings for version i l=1 features

se_grad: gradient of squared-exponential

se_rvec: squared-exponential times vector (r’-r)

ciderpress.dft.settings.ALLOWED_J_SPECS = ['se', 'se_ar2', 'se_a2r4', 'se_erf_rinv']

Allowed spec strings for version j features. Version k features have the same allowed spec strings

se: squared-exponential

se_ar2: squared-exponential * a * r^2

se_a2r4: squared-exponential * a^2 * r^4

se_erf_rinv: squared-exponential * 1/r with short-range erf damping

ciderpress.dft.settings.ALLOWED_K_SPECS = ['se', 'se_ar2', 'se_a2r4', 'se_erf_rinv']

See ALLOWED_J_SPECS

ciderpress.dft.settings.ALLOWED_RHO_DAMPS = ['exponential']

These strings specify the allowed options for how to “damp” the density for the version k features. Currently the only allowed option is “exponential”, which results in the integral \(\int g[n](|r-r'|) n(r') exp(-3 a_0[n](r') / 2 a_i[n](r))\), where \(a_0\) is the exponent given by theta_params and \(a_i\) is an exponet given by feat_params.

ciderpress.dft.settings.ALLOWED_RHO_MULTS = ['one', 'expnt']

These strings specify the allowed options for what value to multiply the density by before integrating it to construct NLDF features. The options are:

one: Identity, i.e. multiply density by 1

expnt: Multiply the density by the NLDF exponent specified by the theta_params. (NOTE: Experimental, not thoroughly tested.)

class ciderpress.dft.settings.BaseSettings

This is a base class for storing the settings for different types of density/density matrix feature in CiderPress. Settings objects indicate which features must be evaluated, and with which hyperparameters, to use as input to an ML functional.

abstract get_feat_usps()
Returns:

A list of floats with the uniform scaling power for each feature.

get_reasonable_normalizer()
Returns:

list of normalizers for these features

Return type:

norms (list[FeatNormalizer])

property is_empty

Return true of this settings object specifies zero features.

abstract property nfeat

Returns: Number of features in this feature set.

abstract ueg_vector(rho=1.0)

Return the feature vector for the uniform electron gas as a function of the density rho

Parameters:

rho (float) – Value of the density

Returns:

UEG feature vector

Return type:

np.ndarray(float)

class ciderpress.dft.settings.EmptySettings

The EmptySettings class is a representation of a feature set containing zero features. It is used when a certain type of feature is not present in a model. (For example, if a model does not use SDMX features, that model’s FeatureSettings.sdmx_settings will be an EmptySettings instance.)

get_feat_usps()
Returns:

A list of floats with the uniform scaling power for each feature.

get_reasonable_normalizer()
Returns:

list of normalizers for these features

Return type:

norms (list[FeatNormalizer])

property nfeat

Returns: Number of features in this feature set.

ueg_vector(rho=1.0)

Return the feature vector for the uniform electron gas as a function of the density rho

Parameters:

rho (float) – Value of the density

Returns:

UEG feature vector

Return type:

np.ndarray(float)

class ciderpress.dft.settings.FeatureSettings(sl_settings=None, nldf_settings=None, nlof_settings=None, sdmx_settings=None, hyb_settings=None, normalizers=None)

The FeatureSettings object is a container for the settings of each type of feature in the model.

Initialize FeatureSettings.

Parameters:
  • sl_settings (SemilocalSettings or EmptySettings) – Semilocal feature settings

  • nldf_settings (NLDFSettings or EmptySettings) – Nonlocal density feature settings

  • nlof_settings (FracLaplSettings or EmptySettings) – Nonlocal orbital feature settings

  • sdmx_settings (SDMXBaseSettings or EmptySettings) – Spherically averaged EXX settings

  • hyb_settings (HybridSettings or EmptySettings) – (Local) hybrid DFT settings

  • normalizers (FeatNormalizerList) – List of normalizers for features

get_feat_usps(with_normalizers=False)
Returns:

A list of floats with the uniform scaling power for each feature.

get_reasonable_normalizer()
Returns:

list of normalizers for these features

Return type:

norms (list[FeatNormalizer])

property nfeat

Returns: Number of features in this feature set.

ueg_vector(rho=1.0, with_normalizers=False)

Return the feature vector for the uniform electron gas as a function of the density rho

Parameters:

rho (float) – Value of the density

Returns:

UEG feature vector

Return type:

np.ndarray(float)

class ciderpress.dft.settings.FracLaplSettings(slist, nk0, nk1, l1_dots, nd1=0, ld_dots=None, ndd=0)

Settings for Fractional Laplacian feature set.

Initialize FracLaplSettings object. Note, in the documentation below on the indexing of the features, fl_rho is the part of the density ingredient vector AFTER the semilocal part.

Note on the l=1 feature indexing. If l1_dots[i] = (j, k), then:

fl_feat[i+nk0] = einsum(
    'xg,xg->g',
    fl_rho[3*j+nk0 : 3*j+3+nk0],
    fl_rho[3*k+nk0 : 3*k+3+nk0],
)

If ld_dots[i] = (j, k), then:

nstart = nk0 + 3 * nk1
fl_feat[i + nk0 + len(l1_dots)] = einsum(
    'xg,xg->g',
    fl_rho[3*j+nstart : 3*j+3+nstart],
    fl_rho[3*k+nstart : 3*k+3+nstart],
)
nstart = nk0 + 3 * nk1 + 3 * nd1
fl_feat[i + nk0 + len(l1_dots) + len(ld_dots)] = fl_rho[i + nstart]
Parameters:
  • slist (list of float) – s parameters for the fractional Laplacian. For each s, \((-\Delta)^s \phi_i\) is computed for each single-particle orbital.

  • nk0 (int) – Number of scalar (l=0) features. Must be <= len(slist). fl_feat[i] = fl_rho[i] = \((-\Delta')^s \rho(r, r') |_{r'=r}\), with s=slist[i].

  • nk1 (int) – Number of vector (l=1) features F_s^1. Must be <= len(slist). fl_rho[3*i+nk0 : 3*i+3+nk0] = \(\nabla'' (-\Delta')^s \rho(r'', r') |_{r'=r,r''=r}\), with s=slist[i].

  • l1_dots (list of (int, int)) – List of index tuples for contracting the l=1 F_s^1 features. -1 indicates to use the semilocal density gradient.

  • nd1 (int) – Number of vector features F_s^d. Must be <= len(slist) With nstart = nk0 + 3 * nk1, fl_rho[i * 3 + nstart : (i+1) * 3 + nstart] = \(\nabla' (-\Delta')^s \rho(r, r') |_{r'=r}\), with s=slist[i].

  • ld_dots (list of (int, int)) – Same as l1_dots but for the F_s^d features. -1 indicates to use the semilocal density gradient.

  • ndd (int) – Numer of dot product features \(F_s^{dd}\). Must be <= nd1

get_feat_usps()
Returns:

A list of floats with the uniform scaling power for each feature.

get_reasonable_normalizer()
Returns:

list of normalizers for these features

Return type:

norms (list[FeatNormalizer])

property nfeat

Returns: Number of features in this feature set.

ueg_vector(rho=1.0)

Return the feature vector for the uniform electron gas as a function of the density rho

Parameters:

rho (float) – Value of the density

Returns:

UEG feature vector

Return type:

np.ndarray(float)

class ciderpress.dft.settings.HybridSettings(alpha, beta, local)

TODO very rough draft of hybrid settings, to be fully implemented later.

property get_feat_usps

Returns: A list of floats with the uniform scaling power for each feature.

get_reasonable_normalizer()
Returns:

list of normalizers for these features

Return type:

norms (list[FeatNormalizer])

property nfeat

Returns: Number of features in this feature set.

property ueg_vector

Return the feature vector for the uniform electron gas as a function of the density rho

Parameters:

rho (float) – Value of the density

Returns:

UEG feature vector

Return type:

np.ndarray(float)

class ciderpress.dft.settings.NLDFSettings(sl_level, theta_params, rho_mult)

NLDFSettings contains the settings for the nonlocal density features, which form the core of the CIDER framework. This is an abstract class since the feature settings depend on the version. Subclasses are available for versions i, j, ij, and k features.

Initialize NLDFSettings.

Parameters:
  • sl_level (str) – “GGA” or “MGGA”, the level of semilocal ingredients used to construct the length-scale exponent.

  • theta_params (np.ndarray(2 or 3)) – Settings for the squared-exponential kernel exponent for the r’ (integrated) coordinate of the features. For version ‘k’, this ‘exponent’ is not used in the squared-exponential but rather within the density damping scheme (see rho_damp). Should be an array of 3 floats [a0, grad_mul, tau_mul]. tau_mul is ignored if sl_level=”GGA” and may therefore be excluded.

  • rho_mult (str) – Multiply the density that gets integrated by a prefactor. Options: See ALLOWED_RHO_MULTS.

abstract property feat_spec_list

Return a list containing feature specs in appropriate order.

abstract get_feat_usps()

Returns a list containing the usp of each contracted feature.

abstract get_reasonable_normalizer()
Returns:

list of normalizers for these features

Return type:

norms (list[FeatNormalizer])

property nfeat

Number of contracted, scale-invariant features.

property nldf_type

Same as version, represents type of NLDFs being computed.

abstract property num_feat_param_sets

Number of unique feature parameter sets

Type:

Returns

abstract property num_vi_feats

Return the number of version i-type features.

class ciderpress.dft.settings.NLDFSettingsVI(sl_level, theta_params, rho_mult, l0_feat_specs, l1_feat_specs, l1_feat_dots)

Initialize NLDFSettingsVI object

Parameters:
  • sl_level (str) – “GGA” or “MGGA”, the level of semilocal ingredients used to construct the length-scale exponent.

  • theta_params (np.ndarray) – Settings for the squared-exponential kernel exponent for the r’ (integrated) coordinate of the features. For version ‘k’, this ‘exponent’ is not used in the squared-exponential but rather within the density damping scheme (see rho_damp).

  • rho_mult (str) – Multiply the density that gets integrated by a prefactor. Options: See ALLOWED_RHO_MULTS.

  • l0_feat_specs (list of str) – Each item in the list is a str specifying the formula to be used for the scalar (l=0) features. See ALLOWED_I_SPECS_L0 for allowed values.

  • l1_feat_specs (list of str) – Each item in the list is a str specifying the formula for the vector (l=1) features. See ALLOWED_I_SPECS_L1 for allowed values.

  • l1_feat_dots (list of (int, int)) – The vector features must be contracted with each other (via dot product) to form scalar features for the ML model. Each item i in the list is a 2-tuple with indexes j,k for features to contract. -1 refers to the semilocal density gradient. l1feat_ig = einsum(‘xg,xg->g’, l1ints_jg, l1ints_kg)

property feat_spec_list

Return a list containing feature specs in appropriate order.

get_feat_usps()

Returns a list containing the usp of each contracted feature.

get_reasonable_normalizer()
Returns:

list of normalizers for these features

Return type:

norms (list[FeatNormalizer])

property num_feat_param_sets

Number of unique feature parameter sets

Type:

Returns

property num_vi_feats

Return the number of version i-type features.

ueg_vector(rho=1.0)

Return the feature vector for the uniform electron gas as a function of the density rho

Parameters:

rho (float) – Value of the density

Returns:

UEG feature vector

Return type:

np.ndarray(float)

class ciderpress.dft.settings.NLDFSettingsVIJ(sl_level, theta_params, rho_mult, l0_feat_specs_i, l1_feat_specs_i, l1_feat_dots_i, feat_specs_j, feat_params_j)

Note

When storing features in array, j should go first, followed by i.

Initialize NLDFSettingsVIJ object

Parameters:
  • sl_level (str) – “GGA” or “MGGA”, the level of semilocal ingredients used to construct the length-scale exponent.

  • theta_params (np.ndarray) – Settings for the squared-exponential kernel exponent for the r’ (integrated) coordinate of the features. For version ‘k’, this ‘exponent’ is not used in the squared-exponential but rather within the density damping scheme (see rho_damp).

  • rho_mult (str) – Multiply the density that gets integrated by a prefactor. Options: See ALLOWED_RHO_MULTS.

  • l0_feat_specs_i (list of str) – Each item in the list is a str specifying the formula to be used for the scalar (l=0) features. See ALLOWED_I_SPECS_L0 for allowed values.

  • l1_feat_specs_i (list of str) – Each item in the list is a str specifying the formula for the vector (l=1) features. See ALLOWED_I_SPECS_L1 for allowed values.

  • l1_feat_dots_i (list of (int, int)) – The vector features must be contracted with each other (via dot product) to form scalar features for the ML model. Each item i in the list is a 2-tuple with indexes j,k for features to contract. -1 refers to the semilocal density gradient. l1feat_ig = einsum(‘xg,xg->g’, l1ints_jg, l1ints_kg)

  • feat_specs_j (list of str) – Each item in the list is a string specifying the formula to be used for a feature (see ALLOWED_J_SPECS for options). feat_specs[i] uses the parameterization of feat_params[i]. feat_specs and feat_params must be the same length.

  • feat_params_j (list of np.ndarray) – Each item in the list is an array with the parameters for the feature corresponding to the feat_specs above. Typically, each array has three numbers [a0, grad_mul, tau_mul], except erf_rinv which has an additional parameter erf_mul for the ratio of the erf / rinv exponent to the squared-exponential exponent. tau_mul is ignored if sl_level=”GGA” and may therefore be excluded.

property feat_spec_list

Return a list containing feature specs in appropriate order.

get_feat_usps()

Returns a list containing the usp of each contracted feature.

get_reasonable_normalizer()
Returns:

list of normalizers for these features

Return type:

norms (list[FeatNormalizer])

property num_feat_param_sets

Number of unique feature parameter sets

Type:

Returns

property num_vi_feats

Return the number of version i-type features.

ueg_vector(rho=1.0)

Return the feature vector for the uniform electron gas as a function of the density rho

Parameters:

rho (float) – Value of the density

Returns:

UEG feature vector

Return type:

np.ndarray(float)

class ciderpress.dft.settings.NLDFSettingsVJ(sl_level, theta_params, rho_mult, feat_specs, feat_params)

Initialize NLDFSettingsVJ

Parameters:
  • sl_level (str) – “GGA” or “MGGA”, the level of semilocal ingredients used to construct the length-scale exponent.

  • theta_params (np.ndarray) – Settings for the squared-exponential kernel exponent for the r’ (integrated) coordinate of the features. For version ‘k’, this ‘exponent’ is not used in the squared-exponential but rather within the density damping scheme (see rho_damp).

  • rho_mult (str) – Multiply the density that gets integrated by a prefactor. Options: See ALLOWED_RHO_MULTS.

  • feat_specs (list of str) – Each item in the list is a string specifying the formula to be used for a feature (see ALLOWED_J_SPECS for options). feat_specs[i] uses the parameterization of feat_params[i]. feat_specs and feat_params must be the same length.

  • feat_params (list of np.ndarray) – Each item in the list is an array with the parameters for the feature corresponding to the feat_specs above. Typically, each array has three numbers [a0, grad_mul, tau_mul], except erf_rinv which has an additional parameter erf_mul for the ratio of the erf / rinv exponent to the squared-exponential exponent. tau_mul is ignored if sl_level=”GGA” and may therefore be excluded.

property feat_spec_list

Return a list containing feature specs in appropriate order.

get_feat_usps()

Returns a list containing the usp of each contracted feature.

get_reasonable_normalizer()
Returns:

list of normalizers for these features

Return type:

norms (list[FeatNormalizer])

property num_feat_param_sets

Number of unique feature parameter sets

Type:

Returns

property num_vi_feats

Return the number of version i-type features.

ueg_vector(rho=1.0)

Return the feature vector for the uniform electron gas as a function of the density rho

Parameters:

rho (float) – Value of the density

Returns:

UEG feature vector

Return type:

np.ndarray(float)

class ciderpress.dft.settings.NLDFSettingsVK(sl_level, theta_params, rho_mult, feat_params, rho_damp)

Initialize NLDFSettingsVK

Parameters:
  • sl_level (str) – “GGA” or “MGGA”, the level of semilocal ingredients used to construct the length-scale exponent.

  • theta_params (np.ndarray) – Settings for the squared-exponential kernel exponent for the r’ (integrated) coordinate of the features. For version ‘k’, this ‘exponent’ is not used in the squared-exponential but rather within the density damping scheme (see rho_damp).

  • rho_mult (str) – Multiply the density that gets integrated by a prefactor. Options: See ALLOWED_RHO_MULTS.

  • feat_params (list of np.ndarray) – Each item in the list is an array with the parameters for the feature corresponding to the feat_specs above. Typically, each array has three numbers [a0, grad_mul, tau_mul], except erf_rinv which has an additional parameter erf_mul for the ratio of the erf / rinv exponent to the squared-exponential exponent. tau_mul is ignored if sl_level=”GGA” and may therefore be excluded.

  • rho_damp (str) – Specifies the damping for the density. Options: ‘none’, ‘exponential’, ‘asymptotic_const’

property feat_spec_list

Return a list containing feature specs in appropriate order.

get_feat_usps()

Returns a list containing the usp of each contracted feature.

get_reasonable_normalizer()
Returns:

list of normalizers for these features

Return type:

norms (list[FeatNormalizer])

property num_feat_param_sets

Number of unique feature parameter sets

Type:

Returns

property num_vi_feats

Return the number of version i-type features.

ueg_vector(rho=1.0)

Return the feature vector for the uniform electron gas as a function of the density rho

Parameters:

rho (float) – Value of the density

Returns:

UEG feature vector

Return type:

np.ndarray(float)

class ciderpress.dft.settings.SADMSettings(mode)

Settings for Spherically Averaged Density Matrix descriptor, i.e. the self-repulsion of the exchange hole constructed only from the spherically averaged density matrix at a point.

WARNING: DEPRECATED, especially ‘exact’ which is not numerically accurate. Use SDMXSettings and its variants instead.

get_feat_usps()
Returns:

A list of floats with the uniform scaling power for each feature.

get_reasonable_normalizer()
Returns:

list of normalizers for these features

Return type:

norms (list[FeatNormalizer])

property nfeat

Returns: Number of features in this feature set.

ueg_vector(rho=1.0)

Return the feature vector for the uniform electron gas as a function of the density rho

Parameters:

rho (float) – Value of the density

Returns:

UEG feature vector

Return type:

np.ndarray(float)

class ciderpress.dft.settings.SDMX1Settings(pows, n1)

Initialize SDMX1Settings

Parameters:
  • pows (list of int) – list of 0, 1, 2, see SDMXSettings docstring.

  • n1 (int) – Number of gradient features H_n^1. Will compute features for the first n1 values of n in pows.

get_feat_usps()
Returns:

A list of floats with the uniform scaling power for each feature.

get_reasonable_normalizer()
Returns:

list of normalizers for these features

Return type:

norms (list[FeatNormalizer])

property nfeat

Returns: Number of features in this feature set.

ueg_vector(rho=1.0)

Return the feature vector for the uniform electron gas as a function of the density rho

Parameters:

rho (float) – Value of the density

Returns:

UEG feature vector

Return type:

np.ndarray(float)

class ciderpress.dft.settings.SDMXBaseSettings

Base object for the SDMX-like settings.

class ciderpress.dft.settings.SDMXFullSettings(settings_dict=None)
Parameters:

settings_dict (dict) – Each key is float. Each value is a 2-tuple. The first item is a list of pows. The second item is a 4-list/tuple with the number of pows for 0, d, 1, and 1d features.

get_feat_usps()
Returns:

A list of floats with the uniform scaling power for each feature.

get_reasonable_normalizer()
Returns:

list of normalizers for these features

Return type:

norms (list[FeatNormalizer])

property nfeat

Returns: Number of features in this feature set.

ueg_vector(rho=1.0)

Return the feature vector for the uniform electron gas as a function of the density rho

Parameters:

rho (float) – Value of the density

Returns:

UEG feature vector

Return type:

np.ndarray(float)

class ciderpress.dft.settings.SDMXG1Settings(pows, nd, n1)

Initialize SDMXG1Settings

Parameters:
  • pows (list of int) – list of 0, 1, 2, see SDMXSettings docstring.

  • nd (int) – Number of gradient features H_n^d. Will compute features for the first nd values of n in pows.

  • n1 (int) – Number of gradient features H_n^1. Will compute features for the first n1 values of n in pows.

get_feat_usps()
Returns:

A list of floats with the uniform scaling power for each feature.

get_reasonable_normalizer()
Returns:

list of normalizers for these features

Return type:

norms (list[FeatNormalizer])

property nfeat

Returns: Number of features in this feature set.

ueg_vector(rho=1.0)

Return the feature vector for the uniform electron gas as a function of the density rho

Parameters:

rho (float) – Value of the density

Returns:

UEG feature vector

Return type:

np.ndarray(float)

class ciderpress.dft.settings.SDMXGSettings(pows, ndt)

Initialize SDMXGSettings

Parameters:
  • pows (list of int) – list of 0, 1, 2, see SDMXSettings docstring.

  • ndt (int) – Number of gradient features H_n^d. Will compute features for the first ndt values of n in pows.

get_feat_usps()
Returns:

A list of floats with the uniform scaling power for each feature.

get_reasonable_normalizer()
Returns:

list of normalizers for these features

Return type:

norms (list[FeatNormalizer])

property nfeat

Returns: Number of features in this feature set.

ueg_vector(rho=1.0)

Return the feature vector for the uniform electron gas as a function of the density rho

Parameters:

rho (float) – Value of the density

Returns:

UEG feature vector

Return type:

np.ndarray(float)

class ciderpress.dft.settings.SDMXSettings(pows)

Initialize SDMX settings.

Parameters:

pows (list of int) – for each number n in pows, int dR R^{2-n} rho_smooth(R) is computed. Technically, n can be any float, but it should be 0, 1, or 2 for normalizability and ability to compute UEG values. If not 0, 1, or 2, UEG limit cannot be computed, and features might be poorly defined/numerically inaccurate.

get_feat_usps()
Returns:

A list of floats with the uniform scaling power for each feature.

get_reasonable_normalizer()
Returns:

list of normalizers for these features

Return type:

norms (list[FeatNormalizer])

property nfeat

Returns: Number of features in this feature set.

ueg_vector(rho=1.0)

Return the feature vector for the uniform electron gas as a function of the density rho

Parameters:

rho (float) – Value of the density

Returns:

UEG feature vector

Return type:

np.ndarray(float)

ciderpress.dft.settings.SPEC_USPS = {'grad_rho': 4, 'se': 0, 'se_a2r4': 0, 'se_ap': 2, 'se_ap2r2': 2, 'se_apr2': 0, 'se_ar2': 0, 'se_erf_rinv': 0, 'se_grad': 1, 'se_lapl': 2, 'se_r2': -2, 'se_rvec': -1}

Uniform-scaling powers (USPs) descibe how features scale as the density is scaled by n_lambda(r) = lambda^3 n(lambda r). If the USP of a functional F is u, then F[n_lambda](r) = lambda^u F[n](lambda r)

class ciderpress.dft.settings.SemilocalSettings(mode='nst')

Semilocal feature set. Currently only supports meta-GGA. Should not be edited from default in general.

get_feat_usps()
Returns:

A list of floats with the uniform scaling power for each feature.

get_reasonable_normalizer()
Returns:

list of normalizers for these features

Return type:

norms (list[FeatNormalizer])

property nfeat

Returns: Number of features in this feature set.

ueg_vector(rho=1.0)

Return the feature vector for the uniform electron gas as a function of the density rho

Parameters:

rho (float) – Value of the density

Returns:

UEG feature vector

Return type:

np.ndarray(float)

ciderpress.dft.settings.get_cider_exponent(rho, sigma, tau, a0=1.0, grad_mul=0.0, tau_mul=0.03125, rhocut=1e-10, nspin=1)

Evaluate an NLDF length-scale exponent at the MGGA level.

ciderpress.dft.settings.get_cider_exponent_gga(rho, sigma, a0=1.0, grad_mul=0.03125, rhocut=1e-10, nspin=1)

Evaluate an NLDF length-scale exponent at the GGA level.