|
| 1 | +"""Per-chain code requirements, declared as TypedDicts. |
| 2 | +
|
| 3 | +One TypedDict per chain, holding exactly the codes that chain wires: |
| 4 | +required members for what always runs, ``NotRequired`` members for codes a |
| 5 | +setting turns on. Each conditional member is annotated with a |
| 6 | +``SocketMeta(help="Needed for ...")`` phrased in input-file vocabulary — |
| 7 | +the keyword a user writes is the anchor. |
| 8 | +
|
| 9 | +These are the graph-input types of the chain entry points, and the |
| 10 | +dispatcher's source of truth for which codes to load and pass: required |
| 11 | +keys come from ``__required_keys__``, the purpose strings from |
| 12 | +``typing.get_type_hints(..., include_extras=True)``. The module imports no |
| 13 | +chain code, so that introspection stays cheap. |
| 14 | +""" |
| 15 | + |
| 16 | +# No ``from __future__ import annotations`` here: with stringified |
| 17 | +# annotations, ``TypedDict.__required_keys__`` cannot see the |
| 18 | +# ``NotRequired`` qualifiers and reports every member as required |
| 19 | +# (python/cpython#97727, still true on 3.13). |
| 20 | +from typing import Annotated, NotRequired, TypedDict |
| 21 | + |
| 22 | +from aiida import orm |
| 23 | +from node_graph.socket_meta import SocketMeta |
| 24 | + |
| 25 | +#: Annotation for the DSCF codes only the periodic Wannier route consumes. |
| 26 | +WannierRouteCode = Annotated[ |
| 27 | + orm.AbstractCode, |
| 28 | + SocketMeta(help="Needed for init_orbitals: mlwfs or projwfs."), |
| 29 | +] |
| 30 | + |
| 31 | + |
| 32 | +class PwBandsCodes(TypedDict): |
| 33 | + """Codes for the DFT bands chain (``RunPwBands``).""" |
| 34 | + |
| 35 | + pw: orm.AbstractCode |
| 36 | + |
| 37 | + |
| 38 | +class DielectricCodes(TypedDict): |
| 39 | + """Codes for the dielectric chain (``DielectricTask``).""" |
| 40 | + |
| 41 | + pw: orm.AbstractCode |
| 42 | + ph: orm.AbstractCode |
| 43 | + |
| 44 | + |
| 45 | +class WannierizeCodes(TypedDict): |
| 46 | + """Codes for the whole-manifold wannierization chain. |
| 47 | +
|
| 48 | + Shared by ``Wannierize`` and ``OptimizeWannierization``, whose |
| 49 | + upstream builders wire the same scf / nscf / pw2wannier90 / wannier90 |
| 50 | + steps. |
| 51 | + """ |
| 52 | + |
| 53 | + pw: orm.AbstractCode |
| 54 | + pw2wannier90: orm.AbstractCode |
| 55 | + wannier90: orm.AbstractCode |
| 56 | + projwfc: NotRequired[ |
| 57 | + Annotated[orm.AbstractCode, SocketMeta(help="Needed for SCDM projections.")] |
| 58 | + ] |
| 59 | + |
| 60 | + |
| 61 | +class WannierizeBlockCodes(TypedDict): |
| 62 | + """Codes for one block's wannierization (``WannierizeBlock``). |
| 63 | +
|
| 64 | + ``pw`` never runs here (the block skips scf / nscf) but the upstream |
| 65 | + ``Wannier90WorkChain`` builder still requires it to assemble the pw |
| 66 | + namespaces this graph discards. |
| 67 | + """ |
| 68 | + |
| 69 | + pw: orm.AbstractCode |
| 70 | + pw2wannier90: orm.AbstractCode |
| 71 | + wannier90: orm.AbstractCode |
| 72 | + |
| 73 | + |
| 74 | +class WannierizeBlocksCodes(TypedDict): |
| 75 | + """Codes for the block-by-block wannierization chain (``WannierizeBlocks``).""" |
| 76 | + |
| 77 | + pw: orm.AbstractCode |
| 78 | + pw2wannier90: orm.AbstractCode |
| 79 | + wannier90: orm.AbstractCode |
| 80 | + wannierjl: NotRequired[ |
| 81 | + Annotated[ |
| 82 | + orm.AbstractCode, |
| 83 | + SocketMeta(help="Needed when block_wannierization_threshold is set."), |
| 84 | + ] |
| 85 | + ] |
| 86 | + |
| 87 | + |
| 88 | +class SplitBlockCodes(TypedDict): |
| 89 | + """Codes for the wannierize-and-split path (``WannierizeAndSplitBlock``).""" |
| 90 | + |
| 91 | + pw: orm.AbstractCode |
| 92 | + pw2wannier90: orm.AbstractCode |
| 93 | + wannier90: orm.AbstractCode |
| 94 | + wannierjl: orm.AbstractCode |
| 95 | + |
| 96 | + |
| 97 | +class MlwfInitCodes(TypedDict): |
| 98 | + """Codes for the Wannier-seeded kcp.x initialisation (``MlwfInitialization``).""" |
| 99 | + |
| 100 | + pw: orm.AbstractCode |
| 101 | + pw2wannier90: orm.AbstractCode |
| 102 | + wannier90: orm.AbstractCode |
| 103 | + wann2kcp: orm.AbstractCode |
| 104 | + merge_evc: orm.AbstractCode |
| 105 | + kcp: orm.AbstractCode |
| 106 | + |
| 107 | + |
| 108 | +class FoldingCodes(TypedDict): |
| 109 | + """Codes for the fold-to-supercell chain (``FoldToSupercell``).""" |
| 110 | + |
| 111 | + wann2kcp: orm.AbstractCode |
| 112 | + merge_evc: orm.AbstractCode |
| 113 | + |
| 114 | + |
| 115 | +class DscfCodes(TypedDict): |
| 116 | + """Codes for the DSCF chain (``KoopmansDSCFWorkflow`` and the trajectory). |
| 117 | +
|
| 118 | + ``kcp`` runs every DSCF step; the remaining members exist only for the |
| 119 | + periodic Wannier-initialised route |
| 120 | + (:func:`~aiida_koopmans.workgraphs.mlwf_init.MlwfInitialization`). |
| 121 | + """ |
| 122 | + |
| 123 | + kcp: orm.AbstractCode |
| 124 | + pw: NotRequired[WannierRouteCode] |
| 125 | + pw2wannier90: NotRequired[WannierRouteCode] |
| 126 | + wannier90: NotRequired[WannierRouteCode] |
| 127 | + wann2kcp: NotRequired[WannierRouteCode] |
| 128 | + merge_evc: NotRequired[WannierRouteCode] |
| 129 | + |
| 130 | + |
| 131 | +class DfptCodes(TypedDict): |
| 132 | + """Codes for the singlepoint DFPT chain (``SinglepointDFPTWorkflow``).""" |
| 133 | + |
| 134 | + pw: orm.AbstractCode |
| 135 | + pw2wannier90: orm.AbstractCode |
| 136 | + wannier90: orm.AbstractCode |
| 137 | + kcw: orm.AbstractCode |
| 138 | + ph: NotRequired[Annotated[orm.AbstractCode, SocketMeta(help="Needed for eps_inf: auto.")]] |
| 139 | + |
| 140 | + |
| 141 | +class PdosCodes(TypedDict): |
| 142 | + """Codes for the projected-DOS chain (``RunPdos``).""" |
| 143 | + |
| 144 | + pw: orm.AbstractCode |
| 145 | + dos: orm.AbstractCode |
| 146 | + projwfc: orm.AbstractCode |
0 commit comments