Skip to content

Commit

Permalink
XAS: Fix Conflict Between tot_charge Override and CH Protocol (#809)
Browse files Browse the repository at this point in the history
- Fixes a conflict between `tot_charge` being set explicitly in overrides by default and the XAS plugin assuming that `tot_charge` isn't specified in the overrides.
- Adds a note to the documentation for the XAS plugin regarding charged systems and provides some suggestions for how to handle them.
  • Loading branch information
PNOGillespie authored Oct 31, 2024
1 parent 924ae5f commit b34e997
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
13 changes: 13 additions & 0 deletions docs/source/howto/xas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,19 @@ Finally, click on the "Download CSV" button to the upper left of the plot area t
* The normalised & weighted spectrum. (with respect to ratio of site multiplicity to total multiplicity)
* The normalised & un-weighted spectrum.

Additional Note on Charged Systems
----------------------------------
Computing XANES spectra for systems where a charge has been applied (in this case using the `Total charge` advanced setting) is possible using the tools
available in the QE App, however such workflows should always be tested by the user against experimental data if possible.

When running XAS workflows for systems where a total charge has been applied, it is suggested to use the following settings for the total charge to ensure the corresponding
core-hole treatment is applied correctly:

* "xch_fixed" or "xch_smear": Set the total charge as required for the system's charged ground-state.
* "full": **Increase** the total charge by 1 *relative* to the system's charged ground-state (e.g. set total charge = 2 in the advanced settings tab if the charge is normally 1).

Note that for neutral systems (total charge = 0), the QE App will handle these settings automatically.

Summary
-------

Expand Down
7 changes: 6 additions & 1 deletion src/aiidalab_qe/plugins/xas/workchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ def update_resources(builder, codes):
def get_builder(codes, structure, parameters, **kwargs):
from copy import deepcopy

adv_parameters = deepcopy(parameters["advanced"])
# Setting `tot_charge = 0` will cause FCH calculations to fail due to
# inputs being incorrect, thus we pop this from the overrides
if adv_parameters["pw"]["parameters"]["SYSTEM"].get("tot_charge") == 0:
adv_parameters["pw"]["parameters"]["SYSTEM"].pop("tot_charge")
protocol = parameters["workchain"]["protocol"]
xas_parameters = parameters["xas"]
core_hole_treatments = xas_parameters["core_hole_treatments"]
Expand Down Expand Up @@ -61,7 +66,7 @@ def get_builder(codes, structure, parameters, **kwargs):
xs_code = codes["xspectra"]["code"]
overrides = {
"core": {
"scf": deepcopy(parameters["advanced"]),
"scf": adv_parameters,
# PG: Here, we set a "variable" broadening scheme, which actually defines a constant broadening
# The reason for this is that in "gamma_mode = constant", the Lorenzian broadening parameter
# is defined by "xgamma" (in "PLOT"), but this parameter *also* controls the broadening value
Expand Down

0 comments on commit b34e997

Please sign in to comment.