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

Enable direct reading of UPF version >= 2 PP files #980

Merged
merged 6 commits into from
Apr 16, 2024

Conversation

abussy
Copy link
Collaborator

@abussy abussy commented Apr 4, 2024

This PR enables the direct reading of standard pseudopotential UPF files with version >= 2, without the need for the upf_to_json tool. The pugixml library is used for this purpose.

All functions reading information from JSON PP files, namely Atom_type::read_pseudo_uspp and Atom_type::read_pseudo_paw have been overloaded with function reading from xml files (stepwise identical). The relevant function is called depending on the file termination in the SIRIUS input file.

This PR is fully backward compatible. At this stage, the dependency on the pugixml library was made a hard requirement. This would imply a change in the spack recipe for the next release.

Edit: at this stage, it is an open question whether pugixml should be a hard requirement or an option.

@abussy
Copy link
Collaborator Author

abussy commented Apr 8, 2024

The pugixml dependency was made optional with the addition of a spack variant +pugixml. Whether pugixml is enabled or not, json potential files can be parsed. This PR is fully backward compatible.

Note: for use of pgixmp with CP2K, the CP2K spack recipe (and probably the CP2K toolchain) will need to be adapted. Moreover, the CP2K code will need a slight refactorization, as it currently assumes that SIRIUS only reads JSON files, and it falls back to its own (incomplete) UPF v2 parser otherwise: https://github.com/cp2k/cp2k/blob/2ed94b8b96b2a4590f5340063d84c5d639a6fefe/src/atom_upf.F#L120-L127.

@abussy abussy marked this pull request as ready for review April 8, 2024 09:11
@simonpintarelli
Copy link
Collaborator

Just as a comment: SSSP currently still contains many UPFv1 pseudos (GRBV), but in the future it will be all UPFv2 🎉 .
The remaining GRBV UPFv1 will be converted to v2 using https://github.com/azadoks/PseudoPotentialIO.jl.

@simonpintarelli
Copy link
Collaborator

Edit: at this stage, it is an open question whether pugixml should be a hard requirement or an option.

Imho as long as QE parses the UPFs, pugixml should be a variant. The question is if we want to rely on QE to parse UPFs in q-e-sirius or not. At least until a future SSSP is released only containing UPFv2, we should keep it as an optional dependency.

@simonpintarelli
Copy link
Collaborator

Adding a test under verification would be useful too. E.g. first generate an output_ref.json using the native json format and then run the same input using UPF files directly.

Comment on lines +874 to +882
if (!nl_node.child("PP_AUGMENTATION").empty()) {
for (int i = 0; i < nbf; i++) {
std::string istr = "PP_BETA." + std::to_string(i + 1);
pugi::xml_node inode = nl_node.child(istr.data());
int li = inode.attribute("angular_momentum").as_int();

for (int j = i; j < nbf; j++) {
std::string jstr = "PP_BETA." + std::to_string(j + 1);
pugi::xml_node jnode = nl_node.child(jstr.data());
Copy link

@unkcpz unkcpz Apr 8, 2024

Choose a reason for hiding this comment

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

(@simonpintarelli redirect me to this PR. I am maintaining SSSP and working on update SSSP with some improvement to v2)
I think in order to compatible with GBRV pseudos, nqf!=0 should also be supported here. And GBRV pseudos has q_ij rather than q_ijl, https://github.com/QEF/q-e/blob/57a97fe3ac56c6862ee083bf10d27505835c092a/upflib/read_upf_v1.f90#L65-L67

Copy link
Collaborator Author

@abussy abussy Apr 9, 2024

Choose a reason for hiding this comment

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

As far as I can tell, GBRV pseudos are stored as UPF version 1 files. We are not aiming to write such a parser. If you are planing to convert to GBRV pseudos to v2, we could cover them as well. But then, I assume they would follow the UPF v2 standard?

Copy link

Choose a reason for hiding this comment

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

But then, I assume they would follow the UPF v2 standard?

Yes, but the UPF v2 standard is for the format, the non-zero nqf and q_ij are still the valid fields according to the UPF v2 schema and according to the notes provided in QEF/qeschemas#11 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

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

As far as I remember V2 UPF pseudos introduced Q_ij^\ell(r) radial functions as a hard standard. Long term it is better to conver V1 GBRV to V2.

Copy link

@unkcpz unkcpz Apr 9, 2024

Choose a reason for hiding this comment

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

https://gist.github.com/unkcpz/c3287268c84ba46b3366edb5537d65c7

Here is a Pd pseudo I convert from UPF.v1 GBRV to UPF.v2. In the QE, it will then be read by read_upf_new.f90 instead of fallback read by read_upf_v1.f90.
It is true from Giannozzi's note (QEF/qeschemas#11 (comment)) that qfcoef and rinner are to be considered obsolescent. The plan for the SSSP v2 is to provide GBRV with converting it to UPFv2 format (let me know if this is useful, I need more test on such UPFv2 file I converted), I assume in SIRIUS you still can use it? But as @toxa81 pointed, maybe in the long term should push to have use uniformed expression.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I personally think that having the whole SSSP library in UPF v2 format would be very useful, especially for people outside of QE. I also think that having a single uniform standard is important. For example, in this case, we would have to implement a special case for qfcoef and rinner, which in the end, is not very different from having 2 distinct parsers.

As far as I understand, it is possible to go from UPF v1 PP_QIJ to UPF v2 PP_QIJL seamlessly. For example, the upf_to_json tool of SIRIUS parses both UPF v1 and UPF v2 to the same JSON structure, which happens to be very close to that of UPF v2 (PP_QIJL).

Copy link

Choose a reason for hiding this comment

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

For example, the upf_to_json tool of SIRIUS parses both UPF v1 and UPF v2 to the same JSON structure

That is cool, I didn't know it actually convert not only the format but the expression as well. I'll talk to @simonpintarelli to see how it can be realize and I can probably add it to my v1 -> v2 converter.

Copy link

Choose a reason for hiding this comment

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

Just quick update from my side. The converter are ready to convert to PP_QIJL and did exactly the same as what happened in QE internally. So it will be safe with this implementation with the new SSSP 2.0 in the future.

@simonpintarelli
Copy link
Collaborator

cscs-ci run default

@simonpintarelli
Copy link
Collaborator

cscs-ci run default

@simonpintarelli
Copy link
Collaborator

cuda container is failing on non-existent +pugixml variant:
https://gitlab.com/cscs-ci/ci-testing/webhook-ci/mirrors/7415069138667150/4626796664769983/-/jobs/6591482684#L6282

🤔 the cscs-ci container takes the sirius/package.py from upstream spack, while in github-ci we use the package.py from the repository.

@simonpintarelli
Copy link
Collaborator

cscs-ci run default

(why does it keep disappearing?)

@simonpintarelli
Copy link
Collaborator

Ping @finkandreas we are running into a timeout when building the cuda base container:
https://gitlab.com/cscs-ci/ci-testing/webhook-ci/mirrors/7415069138667150/4626796664769983/-/jobs/6594225309#L6216

Should we skip it until rosa is back?

@finkandreas
Copy link
Contributor

finkandreas commented Apr 11, 2024

or increase timeout to e.g. 3h, 4h, 5h. No idea how long it takes, but the runner allows long runtimes.
Should be this line: https://github.com/electronic-structure/SIRIUS/blob/develop/ci/cscs-daint.yml#L12

@simonpintarelli
Copy link
Collaborator

cscs-ci run default

@simonpintarelli
Copy link
Collaborator

cscs-ci run default

Copy link
Collaborator Author

@abussy abussy left a comment

Choose a reason for hiding this comment

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

It's getting out of hand :)

@abussy abussy merged commit ef94cd9 into electronic-structure:develop Apr 16, 2024
3 checks passed
@abussy abussy mentioned this pull request Apr 18, 2024
abussy added a commit to abussy/SIRIUS that referenced this pull request Jun 11, 2024
…ure#980)

* Enable direct reading of UPF version >= 2 PP files

* update spack in cscs-ci

* use local spack recipe for cscs-ci

* Fix github CI

* increase timeout

* 4h -> 10h

---------

Co-authored-by: Simon Pintarelli <[email protected]>
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.

None yet

5 participants