GPAW Calculator Interface

ciderpress.gpaw.calculator.get_cider_functional() loads a mapped model, validates its feature support and XC composition, and constructs the matching GGA or meta-GGA smooth-grid/PAW object. Exchange models receive their xmix, xkernel, and ckernel composition. Full-XC models receive the composition stored in the model.

ciderpress.gpaw.calculator.CiderGPAW extends the classic GPAW calculator with the ability to save a CIDER checkpoint state. The dictionary of the checkpoint state stores the mapped model text, XC composition, NLDF interpolation parameters, and PASDW (PAW corrections to nonlocal features) options needed to reconstruct the functional during restart. This allows CIDER calculations to be saved to disk and then restarted just like calculations with other functionals.

from ciderpress.gpaw.calculator import CiderGPAW, get_cider_functional

xc = get_cider_functional(
    "CIDER26XCSURFSCI", xmix=1.0, xkernel=None, ckernel=None)
atoms.calc = CiderGPAW(xc=xc, ...)
atoms.get_potential_energy()

For a full example, see examples/gpaw/production_calc.py and Periodic and Isolated Calculations with GPAW.

class ciderpress.gpaw.calculator.CiderGPAW(restart=None, *, label=None, timer=None, communicator=None, txt='?', parallel=None, **kwargs)

This class is equivalent to the GPAW calculator object provided in the gpaw package, except that it is able to load and save CIDER calculations. The GPAW object can run CIDER but not save/load CIDER calculations.

One can also provide CIDER XC functional in dictionary format, but this is not advised since one also has to explicitly provide by the mlfunc_data parameter, which is the str of the yaml file representing the mlfunc object.

Basic calculator implementation.

restart: str

Prefix for restart file. May contain a directory. Default is None: don’t restart.

ignore_bad_restart_file: bool

Deprecated, please do not use. Passing more than one positional argument to Calculator() is deprecated and will stop working in the future. Ignore broken or missing restart file. By default, it is an error if the restart file is missing or broken.

directory: str or PurePath

Working directory in which to read and write files and perform calculations.

label: str

Name used for all files. Not supported by all calculators. May contain a directory, but please use the directory parameter for that instead.

atoms: Atoms object

Optional Atoms object to which the calculator will be attached. When restarting, atoms will get its positions and unit-cell updated from file.

initialize(atoms=None, reading=False)

Inexpensive initialization.

ciderpress.gpaw.calculator.cider_functional_from_dict(d)

This is a function for reading CIDER functionals (and also standard functionals using the DiffPAW approach) from a dictionary that can be stored in a .gpw file. This is primarily a helper function for internal use, as it just reads the functional type and calls the from_dict() function of the respective class.

Parameters:

d – XC data

Returns:

XC Functional object for use in GPAW.

ciderpress.gpaw.calculator.get_cider_functional(mlfunc, xmix=1.0, xkernel='GGA_X_PBE', ckernel='GGA_C_PBE', mlfunc_format=None, use_paw=True, pasdw_ovlp_fit=True, pasdw_store_funcs=False, Nalpha=None, qmax=300, lambd=1.8, _force_nonlocal=False)

Initialize a CIDER surrogate hybrid XC functional of the form:

E_xc = xkernel * (1 - xmix) + ckernel + xmix * E_x^CIDER

where E_x^CIDER is the ML exchange energy contained in mlfunc. xkernel and ckernel should be strings corresponding to an exchange and correlation functional in libxc. Mapped full-XC models already contain the complete baseline and therefore require xkernel=None, ckernel=None, and xmix=1.0; other compositions are rejected.

NOTE: Do not use CIDER with ultrasoft pseudopotentials (PAW only). At your own risk, you can use CIDER with norm-conserving pseudopotentials, 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 semilocal, all the internal settings are ignored, and a simpler, more efficient class is returned to evaluate the semilocal functional.

NOTE: The parameters pasdw_ovlp_fit and pasdw_store_funcs are only used if use_paw==True. They control internal behavior of the PASDW algorithm used to evaluate the nonlocal density features in CIDER, but users might want to set them to address numerical stability or memory/performance trade-off issues.

NOTE: The arguments Nalpha, qmax, and lambd can be set but are considered internal parameters and should usually be kept as their defaults, which should be reasonable for most cases. These parameters determine the spline used to interpolate over different values of the nonlocal density feature length-scale. A fourth parameter, qmin, also influences the spline. qmin is the mininum value of q to use for kernel interpolation. Currently, qmin is set automatically based on the minimum regularized value of the kernel exponent.

Parameters:
  • mlfunc (MappedXC, MappedXC2, str) – An ML functional object or a str corresponding to the file name of a yaml or joblib file containing it.

  • xmix (float, 1.00) – Mixing parameter for CIDER exchange.

  • xkernel (str, GGA_X_PBE) – libxc code str for semi-local X functional

  • ckernel (str, GGA_C_PBE) – libxc code str for semi-local C functional

  • mlfunc_format (str, None) – ‘joblib’ or ‘yaml’, specifies the format of mlfunc if it is a string corresponding to a file name. If unspecified, infer from file extension and raise error if file type cannot be determined.

  • use_paw (bool, True) – Whether to compute PAW corrections. This should be True unless you plan to use norm-conserving pseudopotentials (NCPPs). Note, the use of NCPPs is allowed but not advised, as large errors might arise due to the use of incorrect nonlocal features.

  • pasdw_ovlp_fit (bool, True) – Whether to use overlap fitting to attempt to improve numerical precision of PASDW projections. Default to True. Impact of this parameter should be minor.

  • pasdw_store_funcs (bool, False) – Whether to store projector functions used in the PASDW routine. Defaults to False because this can be memory intensive, but if you have the space, the computational cost of the atomic corrections can be greatly reduced by setting to True.

  • Nalpha (int, None) – Number of interpolation points for the nonlocal feature kernel. If None, set automatically based on lambd, qmax, and qmin.

  • qmax (float, 300) – Maximum value of q to use for kernel interpolation on FFT grid. Default should be fine for most cases.

  • lambd (float, 1.8) – Density of interpolation points, \(q_\alpha=q_0\lambda^\alpha\), with lambd representing \(\lambda\). Smaller values are more expensive and more precise.

  • _force_nonlocal (bool, False) – Use nonlocal kernel even if nonlocal features are not required. For debugging use only. Do not adjust except for testing.

Returns:

A _CiderBase object (specific class depends on the parameters provided above, specifically on whether use_paw is True, whether the functional is GGA or MGGA form, and whether the functional is semi-local or nonlocal.)