Source code for gpaw.extensions

from __future__ import annotations

from gpaw.core import UGArray
from gpaw.new.ibzwfs import IBZWaveFunctions
from gpaw.new.poisson import PoissonSolver


[docs] class Extension: """Extension object. Used for jellium, solvation, solvated jellium model, D3, ... """ name = 'unnamed extension' # XXX: Careful charge has opposite sign here then in base GPAW charge = 0.0
[docs] def get_energy_contributions(self) -> dict[str, float]: return {}
[docs] def force_contribution(self, nt_r, vHt_r): return 0.0
[docs] def stress_contribution(self): return 0.0
[docs] def move_atoms(self, relpos_ac) -> None: return
[docs] def update_non_local_hamiltonian(self, D_sii, setup, atom_index, dH_sii) -> float: return 0.0
[docs] def build(self, builder): return self
[docs] def create_poisson_solver(self, grid, pw, *, charge, xp) -> PoissonSolver | None: return None
[docs] def post_scf_convergence(self, ibzwfs: IBZWaveFunctions, nelectrons: float, occ_calc, mixer, energies, log) -> bool: """Allow for environment to "converge".""" return True
[docs] def update1(self, nt_r) -> None: """Hook called right before solving the Poisson equation."""
[docs] def update1pw(self, nt_g) -> None: """PW-mode hook called right before solving the Poisson equation."""
[docs] def update2(self, nt_r, vHt_r, vt_sr) -> None: """Hook called right after solving the Poisson equation."""
[docs] def update2pw(self, nt_g, vHt_h, vt_sr) -> None: """PW-mode hook called right after solving the Poisson equation."""
[docs] def post_converged(self, dft) -> None: """Hook called after the SCF-loop has converged. Called from :meth:`gpaw.dft.DFT.calculate_energy` once the energies have been logged and put into ``dft.results``. Can be used to write to ``dft.log`` and to add or replace entries in ``dft.results`` (which are handed on to ASE). Any new key must have a unit-conversion factor in ``gpaw.new.calculation.units``. """
[docs] def update_potential(self, vt_sR: UGArray, density) -> float: return 0.0
# Allow importing import SJM from gpaw.extensions while keeping a tidy code. # More extension could, in principle be added. def __getattr__(name): if name == 'SJM': from gpaw.extensions.electrochemistry import SJM return SJM raise AttributeError(f'module {__name__!r} has no attribute {name!r}')