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

New class to handle NcICOBILIST.lobster files #2878

Merged
merged 45 commits into from
Oct 4, 2023

Conversation

QuantumChemist
Copy link
Contributor

@QuantumChemist QuantumChemist commented Mar 6, 2023

Summary

Implemented a class to handle multi-center ICOBIs via NcICBILIST.lobster files with pymatgen in pymatgen/io/lobster/outputs.py and updated some comments. Ncicobilist is similar to Icohplist but not identical because of the different format styles of NcICOBILIST.lobster and ICO**LIST.lobster output files.

Added the respective NcICOBI test files to test/files/cohp for non-spinpolarized, non-orbitalwise case etc.

Todo (if any)

Checking LOBSTER version (done)
Adapt for orbitalwise case. (will leave that out for now)

@QuantumChemist QuantumChemist changed the title \[WIP\] Implemented a class to handle NcICOBILIST.lobster files [WIP] Implemented a class to handle NcICOBILIST.lobster files Mar 6, 2023
@janosh
Copy link
Member

janosh commented Jun 13, 2023

I think the errors here should (mostly) disappear if you pull in master again.

@QuantumChemist
Copy link
Contributor Author

QuantumChemist commented Jun 13, 2023

Hi @janosh thx for looking into this :)
Might be that people cannot use it right away because in the meantime we (+ @JaGeo ) found several problems in how LOBSTER outputs the NcICOBILIST.lobster file (but my test files are not affected as I created them mostly manually).

@QuantumChemist
Copy link
Contributor Author

Hi @janosh thx for looking into this :) Might be that people cannot use it right away because in the meantime we (+ @JaGeo ) found several problems in how LOBSTER outputs the NcICOBILIST.lobster file (but my test files are not affected as I created them mostly manually).

The failing checks are caused by my implementation of the wrong format for the pytests. I will correct that within the next weeks and then I hope this can be merged, even though for now certain NcICOBILIST.lobster outputs should be handled with some caution.

@QuantumChemist
Copy link
Contributor Author

Hi @janosh :D
could you help me to figure out what is making the tests fail and how we can make this PR successful?

@QuantumChemist QuantumChemist changed the title [WIP] Implemented a class to handle NcICOBILIST.lobster files Implemented a class to handle NcICOBILIST.lobster files Sep 22, 2023
@JaGeo
Copy link
Member

JaGeo commented Sep 22, 2023

Could you do an empty commit to get another run of the tests, @QuantumChemist ?

git commit --allow-empty -m "Empty-Commit"

@QuantumChemist
Copy link
Contributor Author

Could you do an empty commit to get another run of the tests, @QuantumChemist ?

git commit --allow-empty -m "Empty-Commit"

I had to commit some changes anyways :)

.attach_pid50466 Outdated
Copy link
Member

Choose a reason for hiding this comment

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

Accidental commit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oopsie, sorry that was accidental. I created a mess when I merged the two versions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed it now :)

@@ -408,6 +409,113 @@ def icohpcollection(self):
return self._icohpcollection


class Ncicobilist:
Copy link
Member

Choose a reason for hiding this comment

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

Why not pascal case NciCobiList here? Easier to read imo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here I wanted to stick to only capitalizing the first letter like in class Icohplist
For me NciCobilist is not very readable as the method referring to is NcICOBI, so maybe we can go with NcIcobilist or ncIcobilist ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @janosh, please let me know what you think about this. If it's not ok, I'm gonna adopt your suggestion.

Copy link
Member

Choose a reason for hiding this comment

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

I still prefer consistency with the rest of pymatgen which uses PascalCase for all class names. E.g. we have PotcarSingle and not POTCARSingle for that reason. But maybe another maintainer wants to chime in here.

Copy link
Member

Choose a reason for hiding this comment

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

(It does not have to be consistent with the older Lobster class names.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@janosh, ok it's done :)))

Copy link
Member

Choose a reason for hiding this comment

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

Just to confirm, are new test files strictly necessary here? And if so, can they be compressed?

There are some that look like they could potentially be re-used:

$ ls tests/files/** | grep COBILIST
ICOBILIST.lobster
ICOBILIST.lobster.additional_case
ICOBILIST.lobster.spinpolarized
ICOBILIST.lobster.spinpolarized.additional_case
ICOBILIST.lobster.withoutorbitals

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The files mentioned here are not the ones I need. Seems that they haven't been fetched in the merge process. I gonna upload them quickly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh now I see with the merging process they have just been added to test_files/cohp (so like it was structured before). I gonna fix that now

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 the files in question are

$ ls tests/files/** | grep NcICOBI
NcICOBILIST.lobster
NcICOBILIST.lobster.gz
NcICOBILIST.lobster.nospin
NcICOBILIST.lobster.nospin.withoutorbitals
NcICOBILIST.lobster.withoutorbitals

please let me know if you see something unnecessary. From my POV this is the least user cases that should be checked.
Thank you for helping me with this PR :)


# check if orbitalwise NcICOBILIST
# include case when there is only one NcICOBI
for entry in data: # NcICOBIs orbitalwise and non-orbitalwise can be mixed
if len(data) > 2 and "s]" in str(entry.split()[3:]):
self.orbitalwise = True
warnings.warn(
"This is an orbitalwise NcICOBILIST.lobster file. Currently, the orbitalwise information is not "
"read!"
"This is an orbitalwise NcICOBILIST.lobster file. "
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to get orbital-wise interactions for multicenter ICOBIs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is and the output format can be very complex with more than 3 centers or mix of n center interactions.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks 😃

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also when Peter and I implemented the COBI, we never really thought of a high-throughput application, so the NcICOBIs are ordered as specified in the lobsterin... mixing different n center interactions up, therefore results in a very messed up NcICOBILIST.lobster file, especially when some are orbitalwise and other are not 🙈 need to check if and how that changed for lobster version 5 before implementing an orbitalwise feature here.

Copy link
Member

Choose a reason for hiding this comment

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

😅

Copy link
Member

@janosh janosh left a comment

Choose a reason for hiding this comment

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

Thanks @QuantumChemist. Left some minor comments about naming and failing test.

"""

if filename is None:
warnings.warn("Please consider using the newest LOBSTER version (4.1.0+). See http://www.cohp.de/.")
Copy link
Member

@janosh janosh Oct 1, 2023

Choose a reason for hiding this comment

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

Is this warning correctly indented? Why only warn if filename is None?

Copy link
Member

Choose a reason for hiding this comment

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

It looks like a leftover from the icohplist. I remember implementing this (with another if clause). I guess this can be removed.

Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't you still use the default naming option in such a case and then then the file wouldn't be there? Thus, shouldn't it be the warning if the default file name does not exist rather than when it is set to None?

# include case when there is only one NcICOBI
for entry in data: # NcICOBIs orbitalwise and non-orbitalwise can be mixed
if len(data) > 2 and "s]" in str(entry.split()[3:]):
self.orbitalwise = True
Copy link
Member

Choose a reason for hiding this comment

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

Is self.orbitalwise missing a default value of False? Tests are currently failing with

AttributeError: 'NciCobiList' object has no attribute 'orbitalwise'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I have to look more into this... :O

)
break # condition has only to be met once

if self.orbitalwise:
Copy link
Member

Choose a reason for hiding this comment

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

Maybe rename to self.orbital_wise for readability?

# TODO: add functions to get orbital resolved NcICOBIs

@property
def ncicobilist(self) -> dict[Any, dict[str, Any]]:
Copy link
Member

Choose a reason for hiding this comment

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

Maybe rename to def ncicobi_list()?

@QuantumChemist
Copy link
Contributor Author

Hi @janosh :D
I think I addressed all issues.

@janosh janosh changed the title Implemented a class to handle NcICOBILIST.lobster files New class to handle NcICOBILIST.lobster files Oct 4, 2023
@janosh janosh added enhancement A new feature or improvement to an existing one io Input/output functionality lobster Lobster package (Local Orbital Basis Suite Towards Electronic-Structure Reconstruction) labels Oct 4, 2023
@janosh janosh merged commit b6506dc into materialsproject:master Oct 4, 2023
@QuantumChemist
Copy link
Contributor Author

yay 🎉 thank you very much for your help @janosh!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature or improvement to an existing one io Input/output functionality lobster Lobster package (Local Orbital Basis Suite Towards Electronic-Structure Reconstruction)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants