aiida_quantumespresso.workflows.xspectra.core
#
Workchain to compute the X-ray absorption spectrum for a given structure.
Uses QuantumESPRESSO pw.x and xspectra.x, requires aiida-shell
to run upf2plotcore.sh
.
Module Contents#
Classes#
Workchain to compute X-ray absorption spectra for a given structure using Quantum ESPRESSO. |
Attributes#
- class aiida_quantumespresso.workflows.xspectra.core.XspectraCoreWorkChain(inputs: dict | None = None, logger: logging.Logger | None = None, runner: aiida.engine.runners.Runner | None = None, enable_persistence: bool = True)[source]#
Bases:
aiida_quantumespresso.workflows.protocols.utils.ProtocolMixin
,aiida.engine.WorkChain
Workchain to compute X-ray absorption spectra for a given structure using Quantum ESPRESSO.
The workflow follows the process required to compute the XAS of an input structure: an SCF calculation is performed using the provided structure, which is then followed by the calculation of the XAS itself by XSpectra. The calculations performed by the WorkChain in a typical run will be:
PwSCF calculation with pw.x of the input structure with a core-hole present.
Generation of core-wavefunction data with upf2plotcore.sh (if requested).
XAS calculation with xspectra.x to compute the Lanczos coefficients and print the XANES spectra for the polarisation vectors requested in the input.
Collation of output data from pw.x and xspectra.x calculations, including a combination of XANES dipole spectra based on polarisation vectors to represent the powder spectrum of the structure (if requested).
If
run_replot = True
is set in the inputs (defaults to False), the WorkChain will run a second xspectra.x calculation which replots the spectra produced from thexs_prod
step. This option can be very useful for obtaining a final spectrum at low levels of broadening (relative to the default of 0.5 eV), particularly as higher levels of broadening significantly speed up the convergence of the Lanczos procedure. Inputs for the replot calculation are found in thexs_plot
namespace.The core-wavefunction plot derived from the ground-state of the absorbing element can be provided as a top-level input or produced by the WorkChain. If left to the WorkChain, the ground-state pseudopotential assigned to the absorbing element will be used to generate this data using the upf2plotcore.sh utility script (via the
aiida-shell
plugin).In its current stage of development, the workflow requires the following:
An input structure where the desired absorbing atom in the system is marked as a separate Kind. The default behaviour for the WorkChain is to set the Kind name as ‘X’, however this can be changed via the overrides dictionary.
A code node for
upf2plotcore
, configured for theaiida-shell
plugin (sphuber/aiida-shell). Alternatively, aSinglefileData
node from a previousShellJob
run can be supplied underinputs.core_wfc_data
.A suitable pair of pseudopotentials for the element type of the absorbing atom, one for the ground-state occupancy which contains GIPAW informtation for the core level of interest for the XAS (e.g. 1s in the case of a K-edge calculation) and the other containing a core hole. (For the moment this can be passed either via the
core_hole_pseudos
field inget_builder_from_protocol
or via the overrides, but will be changed later once full families of core-hole pseudopotentials become available).
- classmethod get_protocol_filepath()[source]#
Return
pathlib.Path
to the.yaml
file that defines the protocols.
- classmethod get_treatment_filepath() pathlib.Path [source]#
Return
pathlib.Path
to the.yaml
file that defines the core-hole treatments for the SCF step.
- classmethod get_default_treatment() str [source]#
Return the default core-hole treatment.
- Parameters:
cls – the workflow class.
- Returns:
the default core-hole treatment
- classmethod get_available_treatments() dict [source]#
Return the available core-hole treatments.
- Parameters:
cls – the workflow class.
- Returns:
dictionary of available treatments, where each key is a treatment and value is another dictionary that contains at least the key description and optionally other keys with supplimentary information.
- classmethod get_treatment_inputs(treatment: dict | None = None, overrides: dict | pathlib.Path | None = None) dict [source]#
Return the inputs for the given workflow class and core-hole treatment.
- Parameters:
cls – the workflow class.
treatment – optional specific treatment, if not specified, the default will be used
overrides – dictionary of inputs that should override those specified by the treatment. The mapping should maintain the exact same nesting structure as the input port namespace of the corresponding workflow class.
- Returns:
mapping of inputs to be used for the workflow class.
- classmethod _load_treatment_file() dict [source]#
Return the contents of the core-hole treatment file.
- classmethod get_builder_from_protocol(pw_code, xs_code, structure, upf2plotcore_code=None, core_wfc_data=None, core_hole_pseudos=None, core_hole_treatment=None, protocol=None, overrides=None, options=None, **kwargs)[source]#
Return a builder prepopulated with inputs selected according to the chosen protocol.
- Parameters:
pw_code – the
Code
instance configured for thequantumespresso.pw
plugin.xs_code – the
Code
instance configured for thequantumespresso.xspectra
plugin.structure – the
StructureData
instance to use.upf2plotcore_code – the aiida-shell
Code
instance configured for the upf2plotcore.sh shell script, used to generate the core wavefunction data.core_wfc_data –
core_hole_pseudos – the core-hole pseudopotential pair (ground-state and excited-state) for the chosen absorbing atom.
protocol – the protocol to use. If not specified, the default will be used.
core_hole_treatment – the core-hole treatment desired for the SCF calculation, using presets found in
core_hole_treatments.yaml
. Defaults to “full”. Overrides the settings derived from thePwBaseWorkChain
protocol, but is itself overriden by theoverrides
dictionary.overrides – optional dictionary of inputs to override the defaults of the XspectraBaseWorkChain itself.
options – a dictionary of options that will be recursively set for the #
metadata.options
input of all theCalcJobs
that are nested in this work chain.run_replot – a bool parameter to request inputs for the re-plot step.
kwargs – additional keyword arguments that will be passed to the
get_builder_from_protocol
of all the sub processes that are called by this workchain.
- Returns:
a process builder instance with all inputs defined ready for launch.
- setup()[source]#
Initialize context variables that are used during the logical flow of the workchain.
- should_run_upf2plotcore()[source]#
Don’t calculate the core wavefunction data if one has already been provided.
- should_run_replot()[source]#
Run the WorkChain as a two-step production + replot process if requested.
- run_upf2plotcore()[source]#
Generate the core-wavefunction data on-the-fly, if no data is given in the inputs.
This will determine which pseudopotential is assigned to the atomic species of the same element as the absorbing atom, though not the absorbing atom itself, thus the corresponding species must use a pseudopotential which contains the correct GIPAW information required by the upf2plotcore.sh helper script.
As this uses the AiiDA-Shell plugin, we assume that this is already installed.
- inspect_upf2plotcore()[source]#
Check that the output from the upf2plotcore step has yielded a meaningful result.
This will simply check that the core wavefunction data returned contains at least one core state and return an error if this is not the case.
- inspect_all_xspectra_prod()[source]#
Verify that the XspectraBaseWorkChain Lanczos production sub-processes finished successfully.
- run_all_xspectra_plot()[source]#
Run an XspectraBaseWorkChain for each 3-vector given for epsilon to plot the final spectra.
This part simply convolutes and plots the spectra from the already-computed Lanczos of
run_all_xspectra_plot
. Only run if requested viarun_replot
in the inputs.
- inspect_all_xspectra_plot()[source]#
Verify that the XspectraBaseWorkChain re-plot sub-processes finished successfully.