Skip to content

Expose the scf/nscf recipe as get_scf_nscf_builders_from_protocol - #93

Open
elinscott wants to merge 5 commits into
aiidateam:mainfrom
elinscott:scf-nscf-protocol-builders
Open

Expose the scf/nscf recipe as get_scf_nscf_builders_from_protocol#93
elinscott wants to merge 5 commits into
aiidateam:mainfrom
elinscott:scf-nscf-protocol-builders

Conversation

@elinscott

Copy link
Copy Markdown
Collaborator

Problem

Wannier90WorkChain.get_builder_from_protocol encodes a number of settings into its scf and nscf builders:

  • nosym/noinv so the nscf produces the full unshifted k-grid that wannier90 and pw2wannier90 require
  • diago_full_acc for well-converged empty states
  • an explicit k-point list generated with wannier90's own kmesh.pl ordering so the k-points cannot drift between pw.x and wannier90
  • the nbnd = num_bands + len(exclude_bands) bookkeeping.

External orchestrators that run their own scf & nscf — in my case, a workflow that wannierises several projection blocks off one shared nscf — currently have to copy these settings by hand, and would silently drift if/when the protocol changes

Change

The scf/nscf section of get_builder_from_protocol moves into a new public classmethod, Wannier90WorkChain.get_scf_nscf_builders_from_protocol(code, *, structure, nbnd=None, kpoints=None, protocol=None, overrides=None, ...), which returns the two PwBaseWorkChain builders. The main builder now delegates to it, so the recipe exists in exactly one place and cannot diverge.

Notes

  • No behaviour change for get_builder_from_protocol callers: the delegation reproduces the previous inputs.
  • overrides takes the same {'scf': ..., 'nscf': ...} shape as the main builder.

elinscott and others added 2 commits July 8, 2026 11:33
External callers that orchestrate their own wannierisation (e.g. one
shared nscf reused by several per-block Wannier90 runs) previously had
to copy the protocol's nscf invariants (nosym/noinv, diago_full_acc,
the wannier90-ordered explicit k-list, the nbnd bookkeeping) by hand -
and silently drifted when they changed. The scf/nscf section of
get_builder_from_protocol now lives in a standalone classmethod that
the main builder delegates to, so there is exactly one copy of the
recipe.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@elinscott

Copy link
Copy Markdown
Collaborator Author

Note: tests expected to fail until #95 is merged

elinscott and others added 3 commits July 17, 2026 09:53
get_builder_from_protocol delegated scf/nscf construction to
get_scf_nscf_builders_from_protocol without forwarding the resolved
pseudo_family, and the new method wrote pseudo_family=None into both
sub-builder overrides unconditionally. Symptom: get_builder_from_protocol
callers and any direct caller at the method's own defaults raised
"ValueError: required pseudo family `None` is not installed" (seen across
test_bands, test_open_grid, test_optimize, test_protocols).

Forward pseudo_family in the delegation call and only set the override
when it is not None so the standalone API falls back to the protocol
default. Add a test exercising get_scf_nscf_builders_from_protocol
directly without pseudo_family.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
get_scf_nscf_builders_from_protocol already pops kpoints_distance and
assigns the explicit wannier90 k-list it is passed, so the main method
re-popping and re-assigning the same object afterwards was dead work.
The wannier builder supplies an explicit KpointsData, which the new
method uses as-is, so the net nscf.kpoints is unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@elinscott elinscott added this to the v2.9.0 milestone Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant