Skip to content
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

XAS: Fix Conflict Between tot_charge Override and CH Protocol #809

Merged
merged 5 commits into from
Oct 31, 2024

Conversation

PNOGillespie
Copy link
Contributor

Addresses #807.

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. This change should restore the previous intended behaviour. For calculations of XAS or XPS with charged systems, it is recommended to instead warn the user that such calculations should be either avoided or carried out with care.

Addresses aiidalab#807.

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.
@PNOGillespie
Copy link
Contributor Author

@superstar54: No action needed here to keep XPS calculations working, though I would recommend adding a warning for users (either in documentation or in UI) to not do XPS calculations with charged cells.

Copy link

codecov bot commented Sep 24, 2024

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 67.09%. Comparing base (924ae5f) to head (7e57056).
Report is 112 commits behind head on main.

Files with missing lines Patch % Lines
src/aiidalab_qe/plugins/xas/workchain.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #809      +/-   ##
==========================================
- Coverage   67.10%   67.09%   -0.02%     
==========================================
  Files          51       51              
  Lines        4712     4713       +1     
==========================================
  Hits         3162     3162              
- Misses       1550     1551       +1     
Flag Coverage Δ
python-3.11 ?
python-3.9 67.09% <0.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +29 to +30
if adv_parameters["pw"]["parameters"]["SYSTEM"].get("tot_charge") == 0:
adv_parameters["pw"]["parameters"]["SYSTEM"].pop("tot_charge")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logic should be: if using FCH,

adv_parameters["pw"]["parameters"]["SYSTEM"]["tot_charge"] += 1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this was my thinking originally, on the basis that (nominally) FCH screens the core-hole by adding a +1 charge to the system, so it would be logical to simply do tot_charge += 1. However, there are two things to bear in mind:

  1. There aren't any cases in the literature for XAS calculations performed on already-charged systems. Everything else has been done on a system which starts out neutral (tot_charge = 0).
  2. It's safe to assume that if the user is working with the advanced options, then they should be able to play around with the options without the program interfering in a way which they cant see happening.

As said in the top comment: for charged systems, it would be better instead to let the user set things as they wish and advise them via the documentation (which I will update later when I get the time).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to add: It's safe (IMO) to let users run XAS with FCH alongside other properties for neutral systems, since we've tested that extensively by now, but we should instead advise users to run XAS separately for charged systems and test the behaviour if they're using FCH. For XCH, it's probably fine, but should ideally be tested anyway

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the documentation, if the tot_charge is not zero, we need to raise a warning in the XAS/XPS GUI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I will work on adding a warning to the GUI for XAS. In principle this should only apply to FCH XAS and molecule XPS calculations. Anything to do with XCH (XAS or XPS) should not require a serious warning, but adding a section to the documentation for XAS and XPS and pointing to the section would be the ideal solution IMO.

@PNOGillespie
Copy link
Contributor Author

Hi @superstar54. I've tried to implement something using @traitlets.observe(), but as far as I can see there is either no traitlet for the advanced settings or it's not at all clear which one corresponds to the "Advanced Settings" tab of the UI. I've tried configuration_settings and input_settings, but neither work interactively.

I see this code block in aiidalab_qe.app.configuration (lines 68-70):

        # list of trailets to link
        # if new trailets are added to the settings, they need to be added here
        trailets_list = ["input_structure", "protocol", "electronic_type", "spin_type"]

Do we need to add the advanced settings dictionary to that list as well?

@superstar54
Copy link
Member

superstar54 commented Oct 3, 2024

Hi Peter, yes, we can not link the tot_charge to the XAS/XPS setting. It needs to refactor the code to allow linking the whole advance setting (the dictionary).

You can add a trailet tot_charge in the XAS setting, and then add tot_charge to the trailets_list.

For the moment, please only update the documentation part.

@PNOGillespie
Copy link
Contributor Author

Hi @superstar54. Do you want to finish this PR and handle the documentation in a separate one?

Adds a note to the documentation for the XAS plugin regarding charged systems and provides some suggestions for how to handle them.
@PNOGillespie
Copy link
Contributor Author

@superstar54, I've made the changes to the documentation - I decided to just add an extra section to the documentation page since this should only matter to more advanced users. Let me know if anything needs changing.

I will update the issue page after we're done here, since we still would need to add a UI element at some point (once @edan-bainglass has made progress with the back-end changes).

@superstar54 superstar54 self-requested a review October 28, 2024 11:24
Copy link
Member

@superstar54 superstar54 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@superstar54 superstar54 merged commit b34e997 into aiidalab:main Oct 31, 2024
8 checks passed
@PNOGillespie PNOGillespie deleted the fix/xas/tot_charge branch November 14, 2024 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants