aiidateam / aiida-quantumespresso

The official AiiDA plugin for Quantum ESPRESSO
https://aiida-quantumespresso.readthedocs.io
Other
53 stars 78 forks source link

Add Feature: `XspectraCrystalWorkChain` #888

Closed PNOGillespie closed 1 year ago

PNOGillespie commented 1 year ago

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 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.

Process Flow

The steps of the WorkChain are:

  1. Perform a vc-relax of the input structure using the PwRelaxWorkChain (optional)
  2. Analyse the symmetry of the input/relaxed structure using 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.
  3. Collect the core wavefunction data from each GIPAW pseudopotential provided as input (optional).
  4. Launch an XspectraCoreWorkChain sub-process for each marked structure
  5. Collect the powder spectra generated by each XspectraCoreWorkChain 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 and PwRelaxWorkChain, other inputs to take notice of are:

PNOGillespie commented 1 year ago

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.

superstar54 commented 1 year ago

@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. When caching is enabled. I got this:

XspectraCalculation               ⏸ Waiting        Pausing after failed transport task: upload_calculation failed 5 times consecutively

The error are:

| Traceback (most recent call last):
 |   File "/opt/conda/lib/python3.9/site-packages/aiida/engine/utils.py", line 186, in exponential_backoff_retry
 |     result = await coro()
 |   File "/opt/conda/lib/python3.9/site-packages/aiida/engine/processes/calcjobs/tasks.py", line 90, in do_upload
 |     execmanager.upload_calculation(node, transport, calc_info, folder)
 |   File "/opt/conda/lib/python3.9/site-packages/aiida/engine/daemon/execmanager.py", line 254, in upload_calculation
 |     transport.copy(remote_abs_path, dest_rel_path)
 |   File "/opt/conda/lib/python3.9/site-packages/aiida/transports/plugins/local.py", line 560, in copy
 |     raise OSError('Source not found')
 | OSError: Source not found

This only happens when using upf2plotcore. It seems that the shell job upf2plotcore does not work with caching. I am not sure if this is special to upf2plotcore or is common for all ShellJob.