Skip to content

Commit

Permalink
fixing gw2wannier90.py to work with exclude bands.
Browse files Browse the repository at this point in the history
  • Loading branch information
Miki Bonacci committed Jan 22, 2024
1 parent 696c6c2 commit 74ddcde
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions examples/example_complete_Cu.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ def submit(group: orm.Group = None, run: bool = False, projections="atomic_proje
# SKIP the yambo QP step:
# this will skip yambo_qp, but be sure to provide QP_DB and parent_folder to ypp inputs.
# In general, you can do this if you have already the yambo results.
#builder.pop('yambo_qp')
#builder.ypp.ypp.QP_DB = orm.load_node(13233)
#builder.ypp.parent_folder = orm.load_node(13069).outputs.remote_folder
builder.pop('yambo_qp')
builder.ypp.ypp.QP_DB = orm.load_node(15785)
builder.ypp.parent_folder = orm.load_node(15693).outputs.remote_folder

# SET custom K-MESH:
kpoints = orm.KpointsData() # to skip the convergence
Expand Down
6 changes: 5 additions & 1 deletion utils/gw2wannier90.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,18 +774,21 @@ def gw2wannier90(
corrections_mask = np.zeros_like(corrections_val, dtype=bool)
idx_b = corrections[:, 0].astype(int) - 1

print(idx_b)
# We may have negative band index:

if len(np.where(idx_b<0)[0])>2:
idx_b = idx_b - np.min(idx_b)

# end negative handling.
print(idx_b)

idx_k = corrections[:, 1].astype(int) - 1
corrections_val[idx_k, idx_b] = corrections[:, 2]
corrections_mask[idx_k, idx_b] = True
# Strip excluded bands
if len(exbands) > 0:
if len(exbands) > 0 and max(idx_b) > nbndDFT:
# The above second condition is imposed in case we do have some QP DB in which we have idx_b larger than the required dft bands.
corrections_val = np.delete(corrections_val, exbands, axis=1)
corrections_mask = np.delete(corrections_mask, exbands, axis=1)
print("G0W0 QP corrections read from ", seedname + ".gw.unsorted.eig")
Expand All @@ -796,6 +799,7 @@ def gw2wannier90(
# if all((ik, ib) in list(corrections.keys()) for ik in range(NKPT))
# ]
providedGW = [ib for ib in range(nbndDFT) if np.all(corrections_mask[:, ib])]
print(providedGW)
# print(providedGW)
f_raw.write("------------------------------\n")
f_raw.write("List of provided GW corrections (bands indexes)\n")
Expand Down

0 comments on commit 74ddcde

Please sign in to comment.