-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Feature: XspectraCrystalWorkChain
#888
Add Feature: XspectraCrystalWorkChain
#888
Conversation
Added CalcJob implementations of the xspectra.x executable and upf2plotcore.sh shell script from the Quantum ESPRESSO library
Added Parser classes for the xspectra.x executable and upf2plotcore.sh shell script from the Quantum ESPRESSO library
Added entry points for both CalcJob and Parser classes required for XSpectra post-processing calculations
Change 'spectra_data' output to 'spectra' Co-authored-by: Sebastiaan Huber <mail@sphuber.net>
Change the caplitalization for XSpectraCalculation to XspectraCalculation Co-authored-by: Sebastiaan Huber <mail@sphuber.net>
Correct the capitalization of XSpectraParser to XspectraParser Co-authored-by: Sebastiaan Huber <mail@sphuber.net>
Correct the capitalization of XSpectraCalculation to XspectraCalculation Co-authored-by: Sebastiaan Huber <mail@sphuber.net>
Correct the capitalization of XSpectraParser to XspectraParser Co-authored-by: Sebastiaan Huber <mail@sphuber.net>
…ved redundant file loop, and added new error code
Fixed the terms used in the XSpectra-specific error codes in order to make them easier to read.
Changed filename assigned to `_Plotcore_FILENAME` from `plotcore.out` to `stdout` in order to work properly with the `aiida-shell` plugin.
Made corrections to the parsing of various output parameters (e.g. energy levels and associated units) in both spin-polarised and unpolarised cases. An additional parameter `lsda` is also added to report explicitly the case of spin polarisation.
Adds tests of the `XspectraParser`, covering spin-polarised and non-spin-polarised cases, interrupted calculations, and XSpectra-specific error codes 313 and 314.
Adds the following features to the `XspectraCalculation` and `XspectraParser` classes: - A save file ('xanes.sav') is now reserved by default and is printed at the end of each calculation run or after a designated time limit. The file can then be used for re-starting halted calculations or re-plotting spectra from previously-finished calculations. - The `XspectraCalculation` class now copies the save file from a parent calculation if the calculation type is itself an XspectraCalculation, thus re-starts and re-plot runs are handled automatically. - An error code has been added (315) for calculations which safely exit after reaching their time limit, thus enabiling a restart. - Additional information is now included in the `output_parameters` node (e.g. the polarisation vectors used and whether the calculation was set to "xonly_plot").
Updates `XspectraParser` tests to work with changes made in a previous commit (commit 875fa58) and adds a new test for error code 315 (job exceeded time limit)
Addresses aiidateam#837 Co-authored-by: Sebastiaan Huber <mail@sphuber.net>
Addresses PR aiidateam#837 Co-authored-by: Sebastiaan Huber <mail@sphuber.net>
Addresses PR aiidateam#837 Changes error code from 315 to 400 to match conventions Co-authored-by: Sebastiaan Huber <mail@sphuber.net>
Addresses PR aiidateam#837 Required for commit aiidateam@746770e Co-authored-by: Sebastiaan Huber <mail@sphuber.net>
Addresses PR aiidateam#837 Required with commit aiidateam@746770e Co-authored-by: Sebastiaan Huber <mail@sphuber.net>
Adds a new WorkChain for `xspectra.x` calculations to compute a complete K-edge XANES for each element of a given structure using `pw.x` and `xspectra.x`. The WorkChain uses the following process flow: * Relax the given input structure using the `PwRelaxWorkChain` (optional). * Generate the core wavefunction of each ground-state pseudopotential for each absorbing element considered (requires AiiDA-Shell plugin). * Analyse the symmetry of the relaxed structure using `spglib`. Use the outputs of the analysis to prepare inputs for `XspectraCoreWorkChain` sub-processes. * Call the `XspectraCoreWorkChain` for each structure prepared in the previous step to generate the powder sample XANES for each identified absorbing atom site in the structure. * Compile all outputs from the `XspectraCoreWorkChain` sub-processes and return a single XANES spectrum for each element considered in the analysis. Excited-state and ground-state pseudopotentials presently must be provided using the input namespaces `core_hole_pseudos` and `gipaw_pseudos` respectively, taking the form of a Dict node with the format: {'{element} : {'core_hole' : {upf}, 'gipaw' : {upf}}} In addition to the final XANES spectra for each element, the powder spectrum of each absorbing atom calculated can be returned as output to the head WorkChain node with the optional input `return_all_powder_spectra` (`False` by default).
Adds an input namespace `core_wfc_data` which can be used to provide already-computed core wavefunction data files for each element. Must use the format: {core_wfc_data : {"{element}" : {node}}}
Adds tests for the `get_builder_from_protocol` method of the `XspectraCrystalWorkChain`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PNOGillespie Thanks for the PR! Nice work. I added a few comments.
src/aiida_quantumespresso/calculations/functions/xspectra/get_spectra_by_element.py
Outdated
Show resolved
Hide resolved
Removes redundant code in `setup` and `get_xspectra_structures` Co-authored-by: Xing Wang <xingwang1991@gmail.com>
Co-authored-by: Xing Wang <xingwang1991@gmail.com>
Addresses changes requested for PR aiidateam#888 (1): * Expands the docstring for `get_spectra_by_element` to describe input parameters and usage. * Fixes an oversight in `get_xspectra_structures` where the `standardized_structure` value was returned regardless of whether the structure was actually standardized by the CalcFunction. * Add a check for the `core_wfc_data` input to check for improperly-formatted file content. * Modify the `elements_list` input to be a required input and correct all instances where data provenance was lost. Changes `get_builder_from_protocol()` to set `elements_list` automatically based on `pseudos` input if no `elements_list` is given * Correct all instances of `optimized_structure` and `relaxed_structure` to all be `optimized_structure` * Change from simply using `append_` to add all CoreWorkChains to the context and instead assign each their site indexes as keys (i.e. `self.ctx.site_{i}`) * Add a step to unassign the pseudopotential for the element of the absorbing atom if the element does not exist in the structure (e.g. for the case where only one atomic site of the element exists). * Change the `structure_preparation_settings` input to be a dynamic namespace instead of a single Dict node, thus ensuring data provenance is maintained.
Updates the `test_crystal.yaml` to include the required `elements_list` input generated by the protocol.
Ok @superstar54, I've applied the suggested changes. I am planning to look into re-factoring the Core and Crystal WorkChains to properly maintain data provenance, but I think this would be too time-consuming to finish at the moment - especially considering the other plans we have going on with AiiDALab. Rest assured, I have a list of potential improvements that I want to investigate and implement once time allows for it. |
@sphuber Thanks for the explanation. @PNOGillespie thanks for the implementation and changes. Considering the need for our parallel work with AiiDAlab, I agree that we can merge this PR first, then add improvements in the future PR. For the improvement, please also consider this issue.
The error are:
This only happens when using |
use the mapping of {"element" : {"core_hole" : <upf>, | ||
"gipaw" : <upf>}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs check failed because of ERROR: Unexpected indentation.
This should fix the error.
use the mapping of {"element" : {"core_hole" : <upf>, | |
"gipaw" : <upf>}} | |
use the mapping of {"element" : {"core_hole" : <upf>, "gipaw" : <upf>}} |
I will merge this PR after you fix it.
In the future, please run the docs locally and check the error. You can do it by:
pip install -e .[docs]
# then go to docs folder and run
make
In this PR we propose to implement a new WorkChain intended to fully automate the calculation of K-edge XANES spectra for each element in a given input structure. This new WorkChain essentially automates the generation of input structures for XspectraCoreWorkChain sub-processes, as well as handling generation and setting of inputs for each sub-process, in order to compute a complete K-edge XANES spectrum for each element requested. The workflow process defined herein applies specifically to periodic systems as it uses the get_xspectra_structures CalcFunction to prepare input structures under the assumption that the input structure is not molecular. Due to the lack of pseudopotentials currently available which either contain GIPAW information or define a core-hole state, such pseudopotentials are presently required to be given as input. A code node to calculate the core wavefunction using upf2plotcore.sh in AiiDA-Shell can be provided to produce the core wavefunction data for each pseudopotential on-the-fly if desired, however pre-computed core wavefunction files can also be provided as input, either directly or via get_builder_from_protocol.
Overview
In this PR we propose to implement a new WorkChain intended to fully automate the calculation of K-edge XANES spectra for each element in a given input structure. This new WorkChain essentially automates the generation of input structures for
XspectraCoreWorkChain
sub-processes, as well as handling generation and setting of inputs for each sub-process, in order to compute a complete K-edge XANES spectrum for each element requested. The workflow process defined herein applies specifically to periodic systems as it uses theget_xspectra_structures
CalcFunction to prepare input structures under the assumption that the input structure is not molecular. Due to the lack of pseudopotentials currently available which either contain GIPAW information or define a core-hole state, such pseudopotentials are presently required to be given as input. A code node to calculate the core wavefunction usingupf2plotcore.sh
in AiiDA-Shell can be provided to produce the core wavefunction data for each pseudopotential on-the-fly if desired, however pre-computed core wavefunction files can also be provided as input, either directly or viaget_builder_from_protocol
.Process Flow
The steps of the WorkChain are:
PwRelaxWorkChain
(optional)get_xspectra_structures
and return a marked structure for each symmetrically inequivalent absorbing atom site. Use the spacegroup number obtained to determine the list of polarisation vectors to calculate for each marked structure.XspectraCoreWorkChain
sub-process for each marked structureXspectraCoreWorkChain
sub-process and compile a final spectrum for each element using a weighted average, based on the multiplicity of each absorbing atom site of the same element.Inputs
In addition to inputs for the
XspectraCoreWorkChain
andPwRelaxWorkChain
, other inputs to take notice of are:gipaw_pseudos
- an input namespace forUpfData
nodes, taking the form{{element} : {upf}}
, which defines the ground-state pseudopotential for the associated element.core_hole_pseudos
- an input namespace analagous togipaw_pseudos
, used to define each pseudopotential containing the core-hole. The namespace keys must be those of their associated element, not the marker to be used for the absorbing atom.core_wfc_data
- an optional input namespace forSinglefileData
nodes, taking the form{{element} : {singlefile}}
. The WorkChain will automatically skip theupf2plotcore.sh
step if this input is provided. Note that this input must be complete for all elements to be calculated.core_hole_treatments
- an optionalDict
input which defines the core-hole treatment (approximation) to be used in theXspectraCoreWorkChain
for each element. Note that this does not need to be complete as any elements not defined in this input will use the default full-core-hole (FCH) approximation instead.spglib_settings
- an optionalDict
input which defines symmetry tolerances to be used byspglib
. Must contain valid options used byspglib.get_symmetry_dataset()
andspglib.standardize_structure()
, though not all options must be defined.structure_preparation_settings
- an optionalDict
input which defines parameters to be used byget_xspectra_structures()
. Must contain valid options used byget_xspectra_structures
, though not all options must be defined.return_all_powder_spectra
- an optionalBool
input which requests that all powder spectra generated during the runtime of the entire WorkChain be returned as output to the main WorkChain. Optional and set toFalse
by default in order to keep the terminal display of the WorkChain's outputs in a condensed format, though potentially useful if spectra for each absorbing atom site are of interest.