-
Notifications
You must be signed in to change notification settings - Fork 82
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: Enable Correct Parsing of Hubbard and Magnetic Data #969
XAS: Enable Correct Parsing of Hubbard and Magnetic Data #969
Conversation
…get_xspectra_structures` This commit enables `XspectraCoreWorkChain` and `get_xspectra_structures` to correctly parse `HubbardStructureData` and magnetic moments. Currently enabled: * `get_xspectra_structures` will preserve Hubbard data if the input structure is `HubbardStructureData` node type and scale parameters to match those required for the final supercell. * the `get_builder_from_protocol` function of `XspectraCoreWorkChain` will accept `initial_magnetic_moments` as an optional input and pass this information to the `scf` namespace. To do: * Enable `get_xspectra_structures` to process incoming magnetic moments data and return correct magnetic moments for the structures returned by the function. * Update the `run_upf2plotcore` step of `XspectraCoreWorkChain` to reliably pick the correct pseudo for the ShellJob step when more than one Kind of the absorbing element is present. * Implement steps in the `XspectraCrystalWorkChain` to correctly parse both HubbardStructureData and magnetic moments.
Updates `get_xspectra_structures()` to retrieve and re-apply Kind data to output structures so that Kind names are kept. The function will now also correctly determine the list of inequivalent atom sites if `standardize_structure = False` and return the correct set of marked structures.
Removes options for `initial_magnetization` from the function, since this has been shown to be superfluous in practice.
This commit fully enables the `XspectraCrystalWorkChain` to work with `HubbardStructureData` and to apply `initial_magnetic_moments` to all sub-processes. Automatically sets `standardize_structure` to `False` in the `get_xspectra_structures` step of the `WorkChain` if the input structure is `HubbardStructureData` as required by the `CalcFunction`. Also updates `get_xspectra_structures` with a new optional parameter `use_element_types` which instructs the `CalcFunction` to treat all `Kinds` of the same element as the same for the purposes of symmetry analysis even if the `kind_name`s are different. Defaults to `False`.
Updates the `run_all_xspectra_core` step in the `XspectraCrystalWorkChain` to correctly assign the GIPAW pseudo provided for the element to all `Kind`s corresponding to the element, retaining the step to remove the GIPAW pseudo if there is only one atom of the absorbing element present in the structure (and thus, to avoid a crash due to incorrect pseudo allocation).
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.
Hi @PNOGillespie , thanks for the work.
Could you add a test for the get_xspectra_structure
using HubbardStructureData
?
src/aiida_quantumespresso/workflows/functions/get_xspectra_structures.py
Outdated
Show resolved
Hide resolved
for i in spglib_tuple[2]: | ||
if i >= 1000: | ||
new_i = int(i / 1000) | ||
else: | ||
new_i = i | ||
clean_structure_tuple[2].append(new_i) |
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.
Could you add a comment to explain the codes?
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.
There should now be a more detailed comment above this block of code to explain what's going on, let me know if this is clear enough.
Addresses requested changes in PR aiidateam#969 and refines the logic for assigning magnetic states to the absorbing atom depending on chosen core-hole treatment type, as some oversights were made in the case of magnetic systems. The absorbing atom is now always given a spin of 1 if it was 0 in the neutral system and we are using an XCH-type treatment. Otherwise, the spin is set to the value of its inherited `Kind`. Other refinements: * Fixed a typo where the core-hole treatments would override the overrides dictionary (the opposite to intended behaviour). * Removed unnecessary options for SpinType and initial_magnetic_moments in the `CoreWorkChain`. * Added tests for `get_xspectra_structures` to cover basic behaviour and correct handling of HubbardStructureData.
Hi @superstar54, I have added some tests for |
Changes: * Fixes a bug where, if `use_element_types = True`, the symmetry data of the "non-cleaned" structure would be erroneously returned in `output_parameters` * Fixes a bug where, if `use_element_types = True`, the `kind_name` for each entry in `equivalent_sites_data` would be reported incorrectly. * Changes the default setting of `use_element_types` to `True`. * Changes the logic for converting the atomic number of each `type` in `spglib_tuple` used to generate the `cleaned_structure_tuple` to use `np.trunc(int()) instead of just `int()`.
…Gillespie/aiida-quantumespresso into fix/xs-crystal-wc-structures
Updates `test_use_element_types` following changes to default function behaviour introduced in previous commit (c4701b3)
Hi @superstar54. I noted (and fixed) a bug that I spotted with the function which will be relevant for cases where different If you could give the PR another review (or ping someone with write access) that would be much appreciated. |
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 update!
I have a feeling that the get_xspectra_structures
function is too long and complex with many nested for
and if
block. Thus, it's hard for people to follow the logic. I would suggest simplifying its logic through modularization. You can create sub-functions for some key tasks, such as the generate_hubbard_supercell
function, etc.
if use_element_types: | ||
cleaned_structure_tuple = (spglib_tuple[0], spglib_tuple[1], []) | ||
for i in spglib_tuple[2]: | ||
if i >= 1000: | ||
new_i = int(np.trunc(i / 1000)) | ||
else: | ||
new_i = i | ||
cleaned_structure_tuple[2].append(new_i) | ||
cleaned_symmetry_dataset = spglib.get_symmetry_dataset(cleaned_structure_tuple, **spglib_kwargs) |
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.
I think there is no need to create a new clearned_symmetry_dataset
here. For the following reasons:
- Since the
symmetry_dataset
is used to check if standardization is needed or not.use_element_types
will affect the check. - There are too many
if use_element_types:
check, we can avoid it if use the same name.
if use_element_types: | |
cleaned_structure_tuple = (spglib_tuple[0], spglib_tuple[1], []) | |
for i in spglib_tuple[2]: | |
if i >= 1000: | |
new_i = int(np.trunc(i / 1000)) | |
else: | |
new_i = i | |
cleaned_structure_tuple[2].append(new_i) | |
cleaned_symmetry_dataset = spglib.get_symmetry_dataset(cleaned_structure_tuple, **spglib_kwargs) | |
if use_element_types: | |
cleaned_structure_tuple = (spglib_tuple[0], spglib_tuple[1], []) | |
for i in spglib_tuple[2]: | |
if i >= 1000: | |
new_i = int(np.trunc(i / 1000)) | |
else: | |
new_i = i | |
cleaned_structure_tuple[2].append(new_i) | |
symmetry_dataset = spglib.get_symmetry_dataset(cleaned_structure_tuple, **spglib_kwargs) | |
else: | |
symmetry_dataset = spglib.get_symmetry_dataset(spglib_tuple, **spglib_kwargs) |
Removes various unneeded `if` statements and re-uses information generated during the process flow to simplify steps.
Hi @superstar54. I reviewed the source code to see if I could de-convolute and consolidate some of the process logic. I have managed to reduce the number of In regards to your suggestion here:
The I reduced the number of All this behaviour should be covered by the tests, since there are test cases for c-Si using Let me know what you think of the changes. |
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.
A small change is needed.
spglib_std_types = spglib.get_symmetry_dataset(spglib_tuple, **spglib_kwargs)['std_types'] | ||
spglib_map_to_prim = spglib.get_symmetry_dataset(spglib_tuple, **spglib_kwargs)['mapping_to_primitive'] | ||
spglib_std_map_to_prim = spglib.get_symmetry_dataset(spglib_tuple, | ||
**spglib_kwargs)['std_mapping_to_primitive'] |
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.
please change it to run get_symmetry_dataset
only one time.
Changes requested for PR aiidateam#969 Replaces some uses of `spglib.get_symmetry_dataset` with a single function call.
Hi @superstar54, I've changed it to now generate a single dataset and extract the data from there instead of repeating the same function call. Let me know if you need anything else |
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.
LGTM! Thanks for the work! @PNOGillespie
Overview
In this PR, we update the various
WorkChains
andCalcFunctions
relevant for calculations with XSpectra to work with the newHubbardStructureData
data type and to handle system with magnetic data reliably, thus making calculations of systems with known magnetic and Hubbard parameter configurations possible with eachWorkChain
.Changes
get_xspectra_structures
:CalcFunction
. If a supercell is created from the input structure, then the parameters are scaled to the new supercell usingHubbardUtils.get_hubbard_for_supercell()
.CalcFunction
where the information on equivalent atomic sites was taken from the standardized structure even if the input structure was not standardized.Bool
inputuse_element_types
which instructs theCalcFunction
to treatKind
s of the same element as the same for the purposes of symmetry analysis even if theirkind_name
s differ.XspectraCrystalWorkChain
:WorkChain
to setstandardize_structure = False
if the input structure isHubbardStructureData
in order to preserve the Hubbard data during structure creation.starting_magnetization
of the absorbing atom in each subsequentXspectraCoreWorkChain
based on the magnetic moment given for theKind
that it replaces. Note that this only works ifstarting_magnetization
is provided as adict
instead of separate entries ofstarting_magnetization(n)
.XspectraCoreWorkChain
:WorkChain
so that it applies the GIPAW pseudopotential provided for the calculation to allKinds
corresponding to the absorbing element even if multiple of such exist.