aiida_cif2j.workflows.wannier module

AiiDA WorkChain for combining Wannier90 and TB2J into a single workflow.

class aiida_cif2j.workflows.wannier.WannierTB2JWorkChain(*args: Any, **kwargs: Any)

Bases: WorkChain

WorkChain linking Wannier90BandsWorkChain and TB2J.

auto_detect_magnetic_elements()

Auto-detect magnetic elements from the resolved input structure.

Returns:

ERROR_MISSING_MAGNETIC_ELEMENTS if the resolved structure is not a MagneticStructureData, or no magnetic elements could be detected on it; None otherwise.

Return type:

ExitCode or None

collate_results()

Bring together the outputs from the full WorkChain.

Returns:

ERROR_TB2J_PLUGIN if the TB2J calculation failed, ExitCode(0) otherwise.

Return type:

ExitCode

classmethod define(spec)

Define the inputs, outputs and outline of the WorkChain.

Parameters:

spec (WorkChainSpec) – The AiiDA Process specification object for the WorkChain.

classmethod get_builder_from_protocol(codes: Mapping[str, str | int | Code], structure: StructureData | MagneticStructureData | SinglefileData, pseudo_family: str | None = None, *, protocol: str | None = None, spin_type: SpinType = SpinType.COLLINEAR, electronic_type: ElectronicType = ElectronicType.METAL, projection_type: WannierProjectionType = WannierProjectionType.ANALYTIC, wannier90_withmpi: bool = False, magnetic_elements: list[str] | None = None, tb2j_parameters: dict | None = None, tb2j_options: dict | None = None, **kwargs) → ProcessBuilder

Return a builder prepopulated for a magnetic-exchange Wannier90 + TB2J run.

electronic_type defaults to METAL (not INSULATOR) so QE reports a single fermi_energy, which run_tb2j’s auto-fill requires; projection_type defaults to ANALYTIC (not SCDM/ATOMIC_PROJECTORS_QE) since some wannier90.x builds reject the dis_proj_min/dis_proj_max keywords those need.

Parameters:
  • codes (Mapping[str, str or int or orm.Code]) – Codes for each step, keyed by ‘pw’, ‘pw2wannier90’, ‘wannier90’, ‘tb2j’, and optionally ‘projwfc’/’open_grid’. String/int values are resolved with orm.load_code.

  • structure (StructureData or MagneticStructureData or SinglefileData) – The input structure, or a ‘CIF’/’MCIF’ file to parse into one first.

  • pseudo_family (str, optional) – The pseudopotential family to use for the Wannier90/QE steps.

  • protocol (str, optional) – The protocol to use, forwarded to Wannier90BandsWorkChain.get_builder_from_protocol.

  • spin_type (SpinType, optional) – The spin treatment for the calculation. Defaults to SpinType.COLLINEAR.

  • electronic_type (ElectronicType, optional) – The electronic treatment for the calculation. Defaults to ElectronicType.METAL.

  • projection_type (WannierProjectionType, optional) – The Wannier90 projection type. Defaults to WannierProjectionType.ANALYTIC.

  • wannier90_withmpi (bool, optional) – Whether to run wannier90.x under MPI. Defaults to False, which also forces single-task resources, to avoid a known file-locking crash from an unintentionally-serial binary launched under mpirun -n N.

  • magnetic_elements (list of str, optional) – Elements for which the exchange interaction is considered. If not given, the WorkChain auto-detects them at runtime.

  • tb2j_parameters (dict, optional) – Parameters for the TB2J calculation (tb2j.parameters).

  • tb2j_options (dict, optional) – metadata.options for the TB2J calculation (tb2j.metadata.options). If not given, WannierTB2JCalculation’s own defaults apply.

  • **kwargs – Forwarded to Wannier90BandsWorkChain.get_builder_from_protocol.

Returns:

A builder ready to submit, pending any further caller customisation.

Return type:

ProcessBuilder

Raises:
  • ValueError – If codes does not contain a ‘tb2j’ entry.

  • TypeError – If spin_type is SpinType.COLLINEAR, no initial_magnetic_moments was given, and structure does not resolve to a MagneticStructureData.

parse_structure_from_file() → None

Parse the input CIF/MCIF structure file into ctx.structure.

run_tb2j()

Build the TB2J calculation inputs from the Wannier90 outputs and submit.

Returns:

Stores the submitted process under the tb2j_step context key, or one of ERROR_WANNIER90_WC, ERROR_MISSING_WANNIER_OUTPUTS, ERROR_MISSING_FERMI_ENERGY if a prerequisite check fails.

Return type:

ToContext or ExitCode

run_wannier90()

Submit the Wannier90BandsWorkChain step of the workflow.

Returns:

Stores the submitted process under the wannier90 context key.

Return type:

ToContext