-
Notifications
You must be signed in to change notification settings - Fork 875
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
Changes from 17 commits
63951e3
44b802d
37e4101
2b98329
a3f476d
0aa3c96
a08b88b
4a56dc4
fdb2be2
c49dda1
da8a14f
6c3079c
9a94cf1
55a1b10
f00b4eb
08c6afd
8a42381
e0e3376
450215d
5b120c0
438c21c
42486dc
3bbd292
348c3c7
362df3e
75dcb67
97c94c3
0d61600
6fe669a
90bbec7
9c2cf1e
bfe4d99
6b7343d
ca017b2
30a27db
dfb137d
518ab48
f3fa91d
1bd53b4
25f703b
1227781
d2e4df0
97df4aa
84e5e48
df6c5ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
Icohplist, | ||
Lobsterout, | ||
MadelungEnergies, | ||
Ncicobilist, | ||
SitePotential, | ||
Wavefunction, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,8 @@ | |
|
||
|
||
class Cohpcar: | ||
"""Class to read COHPCAR/COOPCAR files generated by LOBSTER. | ||
""" | ||
Class to read COHPCAR/COOPCAR/COBICAR files generated by LOBSTER. | ||
|
||
Attributes: | ||
cohp_data (dict[str, Dict[str, Any]]): A dictionary containing the COHP data of the form: | ||
|
@@ -76,7 +77,7 @@ def __init__(self, are_coops: bool = False, are_cobis: bool = False, filename: s | |
Args: | ||
are_coops: Determines if the file is a list of COHPs or COOPs. | ||
Default is False for COHPs. | ||
are_cobis: Determines if the file is a list of COHPs or COOPs. | ||
are_cobis: Determines if the file is a list of COHPs or COBIs. | ||
Default is False for COHPs. | ||
|
||
filename: Name of the COHPCAR file. If it is None, the default | ||
|
@@ -408,6 +409,113 @@ def icohpcollection(self): | |
return self._icohpcollection | ||
|
||
|
||
class Ncicobilist: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not pascal case There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still prefer consistency with the rest of There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @janosh, ok it's done :))) |
||
""" | ||
Class to read NcICOBILIST (multi-center ICOBI) files generated by LOBSTER. | ||
|
||
Attributes: | ||
is_spin_polarized (bool): Boolean to indicate if the calculation is spin polarized. | ||
Ncicobilist (dict): Dict containing the listfile data of the form: | ||
{bond: "number_of_atoms": number of atoms involved in the multi-center interaction, | ||
"ncicobi": {Spin.up: Nc-ICOBI(Ef) spin up, Spin.down: ...}}, | ||
"interaction_type": type of the multi-center interaction | ||
""" | ||
|
||
def __init__(self, filename: str | None = None): | ||
QuantumChemist marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
Args: | ||
filename: Name of the NcICOBILIST file. | ||
""" | ||
|
||
if filename is None: | ||
warnings.warn("Please consider using the newest LOBSTER version (4.1.0+). See http://www.cohp.de/.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this warning correctly indented? Why only warn if There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
filename = "NcICOBILIST.lobster" | ||
|
||
# LOBSTER list files have an extra trailing blank line | ||
# and we don't need the header. | ||
with zopen(filename, "rt") as f: | ||
data = f.read().split("\n")[1:-1] | ||
if len(data) == 0: | ||
raise OSError("NcICOBILIST file contains no data.") | ||
|
||
# If the calculation is spin polarized, the line in the middle | ||
# of the file will be another header line. | ||
if "spin" in data[len(data) // 2]: | ||
# TODO: adapt this for orbitalwise stuff | ||
self.is_spin_polarized = True | ||
else: | ||
self.is_spin_polarized = False | ||
|
||
# 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I have to look more into this... :O |
||
warnings.warn( | ||
"This is an orbitalwise NcICOBILIST.lobster file. Currently, the orbitalwise information is not " | ||
"read!" | ||
) | ||
break # condition has only to be met once | ||
|
||
if self.orbitalwise: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe rename to |
||
data_without_orbitals = [] | ||
for line in data: | ||
if "_" not in str(line.split()[3:]) and "s]" not in str(line.split()[3:]): | ||
data_without_orbitals.append(line) | ||
else: | ||
data_without_orbitals = data | ||
|
||
if "spin" in data_without_orbitals[len(data_without_orbitals) // 2]: | ||
# TODO: adapt this for orbitalwise stuff | ||
num_bonds = len(data_without_orbitals) // 2 | ||
if num_bonds == 0: | ||
raise OSError("NcICOBILIST file contains no data.") | ||
else: | ||
num_bonds = len(data_without_orbitals) | ||
|
||
self.list_labels = [] | ||
self.list_numofatoms = [] | ||
self.list_ncicobi = [] | ||
self.list_interactiontype = [] | ||
self.list_num = [] | ||
|
||
for bond in range(num_bonds): | ||
line = data_without_orbitals[bond].split() | ||
ncicobi = {} | ||
|
||
label = f"{line[0]}" | ||
numofatoms = str(line[1]) | ||
ncicobi[Spin.up] = float(line[2]) | ||
interactiontype = str(line[3:]).replace("'", "").replace(" ", "") | ||
num = 1 | ||
|
||
if self.is_spin_polarized: | ||
ncicobi[Spin.down] = float(data_without_orbitals[bond + num_bonds + 1].split()[2]) | ||
|
||
self.list_labels.append(label) | ||
self.list_numofatoms.append(numofatoms) | ||
self.list_ncicobi.append(ncicobi) | ||
self.list_interactiontype.append(interactiontype) | ||
self.list_num.append(num) | ||
|
||
# TODO: add functions to get orbital resolved NcICOBIs | ||
|
||
@property | ||
def ncicobilist(self) -> dict[Any, dict[str, Any]]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe rename to |
||
""" | ||
Returns: ncicobilist. | ||
""" | ||
ncicobilist = {} | ||
for key, _entry in enumerate(self.list_labels): | ||
ncicobilist[str(key + 1)] = { | ||
"number_of_atoms": int(self.list_numofatoms[key]), | ||
"ncicobi": self.list_ncicobi[key], | ||
"interaction_type": self.list_interactiontype[key], | ||
} | ||
|
||
return ncicobilist | ||
|
||
|
||
class Doscar: | ||
""" | ||
Class to deal with Lobster's projected DOS and local projected DOS. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so the files in question are
please let me know if you see something unnecessary. From my POV this is the least user cases that should be checked. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
COBI# No. of atoms Nc-ICOBI (at) eF for spin 1 Atoms for Nc-ICOBI | ||
1 2 0.00000 X1[0 0 0]->X20 0 0] | ||
2 3 0.00009 X22[0 0 0]->Xs42[0 0 0]->X31[0 0 0] | ||
2 3 0.00116 X22[5s]->Xs42[3s]->X31[5s] | ||
2 3 0.00001 X22[5s]->Xs42[3s]->X31[4d_xy] | ||
2 3 -0.00003 X22[5s]->Xs42[3s]->X31[4d_yz] | ||
2 3 -0.00000 X22[5s]->Xs42[3s]->X31[4d_z^2] | ||
2 3 0.00000 X22[5s]->Xs42[3s]->X31[4d_xz] | ||
2 3 0.00001 X22[5s]->Xs42[3s]->X31[4d_x^2-y^2] | ||
2 3 0.00117 X22[5s]->Xs42[3p_y]->X31[5s] | ||
2 3 -0.00002 X22[5s]->Xs42[3p_y]->X31[4d_xy] | ||
2 3 -0.00003 X22[5s]->Xs42[3p_y]->X31[4d_yz] | ||
2 3 0.00001 X22[5s]->Xs42[3p_y]->X31[4d_z^2] | ||
2 3 -0.00000 X22[5s]->Xs42[3p_y]->X31[4d_xz] | ||
2 3 0.00003 X22[5s]->Xs42[3p_y]->X31[4d_x^2-y^2] | ||
2 3 -0.00071 X22[5s]->Xs42[3p_z]->X31[5s] | ||
2 3 -0.00000 X22[5s]->Xs42[3p_z]->X31[4d_xy] | ||
2 3 0.00004 X22[5s]->Xs42[3p_z]->X31[4d_yz] | ||
2 3 -0.00002 X22[5s]->Xs42[3p_z]->X31[4d_z^2] | ||
2 3 0.00000 X22[5s]->Xs42[3p_z]->X31[4d_xz] | ||
2 3 -0.00002 X22[5s]->Xs42[3p_z]->X31[4d_x^2-y^2] | ||
2 3 -0.00149 X22[5s]->Xs42[3p_x]->X31[5s] | ||
2 3 0.00000 X22[4d_x^2-y^2]->Xs42[3p]->X31[4d_x^2-y^2] | ||
2 3 -0.00007 X22[4d_x^2-y^2]->Xs42[3p_y]->X31[5s] | ||
2 3 0.00016 X22[4d_x^2-y^2]->Xs42[3p_x]->X31[5s] | ||
COBI# No. of atoms Nc-ICOBI (at) eF for spin 2 Atoms for Nc-ICOBI | ||
1 2 0.00000 X1[0 0 0]->X2[0 0 0] | ||
2 3 0.00009 X22[0 0 0]->Xs42[0 0 0]->X31[0 0 0] | ||
2 3 0.00116 X22[5s]->Xs42[3s]->X31[5s] | ||
2 3 0.00001 X22[5s]->Xs42[3s]->X31[4d_xy] | ||
2 3 -0.00003 X22[5s]->Xs42[3s]->X31[4d_yz] | ||
2 3 -0.00000 X22[5s]->Xs42[3s]->X31[4d_z^2] | ||
2 3 0.00000 X22[5s]->Xs42[3s]->X31[4d_xz] | ||
2 3 0.00001 X22[5s]->Xs42[3s]->X31[4d_x^2-y^2] | ||
2 3 0.00117 X22[5s]->Xs42[3p_y]->X31[5s] | ||
2 3 -0.00002 X22[5s]->Xs42[3p_y]->X31[4d_xy] | ||
2 3 -0.00003 X22[5s]->Xs42[3p_y]->X31[4d_yz] | ||
2 3 0.00001 X22[5s]->Xs42[3p_y]->X31[4d_z^2] | ||
2 3 -0.00000 X22[5s]->Xs42[3p_y]->X31[4d_xz] | ||
2 3 0.00003 X22[5s]->Xs42[3p_y]->X31[4d_x^2-y^2] | ||
2 3 -0.00071 X22[5s]->Xs42[3p_z]->X31[5s] | ||
2 3 -0.00000 X22[5s]->Xs42[3p_z]->X31[4d_xy] | ||
2 3 0.00004 X22[5s]->Xs42[3p_z]->X31[4d_yz] | ||
2 3 -0.00002 X22[5s]->Xs42[3p_z]->X31[4d_z^2] | ||
2 3 0.00000 X22[5s]->Xs42[3p_z]->X31[4d_xz] | ||
2 3 -0.00002 X22[5s]->Xs42[3p_z]->X31[4d_x^2-y^2] | ||
2 3 -0.00149 X22[5s]->Xs42[3p_x]->X31[5s] | ||
2 3 0.00000 X22[4d_x^2-y^2]->Xs42[3p]->X31[4d_x^2-y^2] | ||
2 3 -0.00007 X22[4d_x^2-y^2]->Xs42[3p_y]->X31[5s] | ||
2 3 0.00016 X22[4d_x^2-y^2]->Xs42[3p_x]->X31[5s] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
COBI# No. of atoms Nc-ICOBI (at) eF for spin 1 Atoms for Nc-ICOBI | ||
1 2 0.00000 X1[0 0 0]->X20 0 0] | ||
2 3 0.00018 X22[0 0 0]->Xs42[0 0 0]->X31[0 0 0] | ||
2 3 0.00232 X22[5s]->Xs42[3s]->X31[5s] | ||
2 3 0.00002 X22[5s]->Xs42[3s]->X31[4d_xy] | ||
2 3 -0.00006 X22[5s]->Xs42[3s]->X31[4d_yz] | ||
2 3 -0.00000 X22[5s]->Xs42[3s]->X31[4d_z^2] | ||
2 3 0.00000 X22[5s]->Xs42[3s]->X31[4d_xz] | ||
2 3 0.00002 X22[5s]->Xs42[3s]->X31[4d_x^2-y^2] | ||
2 3 0.00234 X22[5s]->Xs42[3p_y]->X31[5s] | ||
2 3 -0.00004 X22[5s]->Xs42[3p_y]->X31[4d_xy] | ||
2 3 -0.00006 X22[5s]->Xs42[3p_y]->X31[4d_yz] | ||
2 3 0.00002 X22[5s]->Xs42[3p_y]->X31[4d_z^2] | ||
2 3 -0.00000 X22[5s]->Xs42[3p_y]->X31[4d_xz] | ||
2 3 0.00006 X22[5s]->Xs42[3p_y]->X31[4d_x^2-y^2] | ||
2 3 -0.00142 X22[5s]->Xs42[3p_z]->X31[5s] | ||
2 3 -0.00000 X22[5s]->Xs42[3p_z]->X31[4d_xy] | ||
2 3 0.00008 X22[5s]->Xs42[3p_z]->X31[4d_yz] | ||
2 3 -0.00004 X22[5s]->Xs42[3p_z]->X31[4d_z^2] | ||
2 3 0.00000 X22[5s]->Xs42[3p_z]->X31[4d_xz] | ||
2 3 -0.00004 X22[5s]->Xs42[3p_z]->X31[4d_x^2-y^2] | ||
2 3 -0.00298 X22[5s]->Xs42[3p_x]->X31[5s] | ||
2 3 0.00000 X22[4d_x^2-y^2]->Xs42[3p]->X31[4d_x^2-y^2] | ||
2 3 -0.00014 X22[4d_x^2-y^2]->Xs42[3p_y]->X31[5s] | ||
2 3 0.00032 X22[4d_x^2-y^2]->Xs42[3p_x]->X31[5s] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
COBI# No. of atoms Nc-ICOBI (at) eF for spin 1 Atoms for Nc-ICOBI | ||
1 2 0.00000 X1[0 0 0]->X20 0 0] | ||
2 3 0.00018 X22[0 0 0]->Xs42[0 0 0]->X31[0 0 0] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
COBI# No. of atoms Nc-ICOBI (at) eF for spin 1 Atoms for Nc-ICOBI | ||
1 2 0.00000 X1[0 0 0]->X20 0 0] | ||
2 3 0.00009 X22[0 0 0]->Xs42[0 0 0]->X31[0 0 0] | ||
COBI# No. of atoms Nc-ICOBI (at) eF for spin 2 Atoms for Nc-ICOBI | ||
1 2 0.00000 X1[0 0 0]->X2[0 0 0] | ||
2 3 0.00009 X22[0 0 0]->Xs42[0 0 0]->X31[0 0 0] |
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.
Accidental commit?
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.
oopsie, sorry that was accidental. I created a mess when I merged the two versions
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 removed it now :)