Skip to content

Commit bf5dbf1

Browse files
committed
More tidying
1 parent 59e6c47 commit bf5dbf1

File tree

6 files changed

+46
-86
lines changed

6 files changed

+46
-86
lines changed

src/atomate2/lobster/jobs.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ class LobsterMaker(Maker):
2626
"""
2727
LOBSTER job maker.
2828
29-
The maker copies DFT output files necessary for the LOBSTER run.
30-
It will create all lobsterin files, run LOBSTER, zip the outputs and parse the
31-
LOBSTER outputs.
29+
The maker copies DFT output files necessary for the LOBSTER run. It will create all
30+
lobsterin files, run LOBSTER, zip the outputs and parse the LOBSTER outputs.
3231
3332
Parameters
3433
----------
@@ -91,8 +90,7 @@ def make(
9190
gzip_dir(".")
9291

9392
# parse lobster outputs
94-
task_doc = LobsterTaskDocument.from_directory(
93+
return LobsterTaskDocument.from_directory(
9594
Path.cwd(),
9695
**self.task_document_kwargs,
9796
)
98-
return task_doc

src/atomate2/lobster/run.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919

2020
from atomate2 import SETTINGS
2121

22-
__all__ = [
23-
"JobType",
24-
"run_lobster",
25-
]
22+
__all__ = ["JobType", "run_lobster"]
2623

2724
_DEFAULT_VALIDATORS = (LobsterFilesValidator(), EnoughBandsValidator())
2825
_DEFAULT_HANDLERS = ()

src/atomate2/lobster/schemas.py

Lines changed: 31 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@
3131
Analysis = None
3232
Description = None
3333

34-
__all__ = ["LobsterTaskDocument"]
34+
__all__ = [
35+
"LobsterTaskDocument",
36+
"LobsteroutModel",
37+
"LobsterinModel",
38+
"CondensedBondingAnalysis",
39+
"StrongestBonds",
40+
]
3541

3642
logger = logging.getLogger(__name__)
3743

@@ -432,9 +438,9 @@ def from_directory(
432438

433439
icohplist_path = dir_name / "ICOHPLIST.lobster.gz"
434440
cohpcar_path = dir_name / "COHPCAR.lobster.gz"
441+
charge_path = dir_name / "CHARGE.lobster.gz"
435442
cobicar_path = dir_name / "COBICAR.lobster.gz"
436443
coopcar_path = dir_name / "COOPCAR.lobster.gz"
437-
charge_path = dir_name / "CHARGE.lobster.gz"
438444
doscar_path = dir_name / "DOSCAR.lobster.gz"
439445
structure_path = dir_name / "POSCAR.gz"
440446
madelung_energies_path = dir_name / "MadelungEnergies.lobster.gz"
@@ -638,72 +644,37 @@ def _get_strong_bonds(
638644
lengths.append(l)
639645

640646
bond_labels_unique = list(set(bonds))
641-
sep_blabels: List[List[str]] = [[] for _ in range(len(bond_labels_unique))]
642647
sep_icohp: List[List[float]] = [[] for _ in range(len(bond_labels_unique))]
643648
sep_lengths: List[List[float]] = [[] for _ in range(len(bond_labels_unique))]
644649

645650
for i, val in enumerate(bond_labels_unique):
646651
for j, val2 in enumerate(bonds):
647652
if val == val2:
648-
sep_blabels[i].append(val2)
649653
sep_icohp[i].append(icohp_all[j])
650654
sep_lengths[i].append(lengths[j])
651-
if not are_cobis and not are_coops:
652-
bond_dict = {}
653-
for i, lab in enumerate(bond_labels_unique):
654-
label = lab.split("-")
655-
label.sort()
656-
for rel_bnd in relevant_bonds:
657-
rel_bnd_list = rel_bnd.split("-")
658-
rel_bnd_list.sort()
659-
if label == rel_bnd_list:
660-
index = np.argmin(sep_icohp[i])
661-
bond_dict.update(
662-
{
663-
rel_bnd: {
664-
"ICOHP": min(sep_icohp[i]),
665-
"length": sep_lengths[i][index],
666-
}
667-
}
668-
)
669-
return bond_dict
670655

671656
if are_cobis and not are_coops:
672-
bond_dict = {}
673-
for i, lab in enumerate(bond_labels_unique):
674-
label = lab.split("-")
675-
label.sort()
676-
for rel_bnd in relevant_bonds:
677-
rel_bnd_list = rel_bnd.split("-")
678-
rel_bnd_list.sort()
679-
if label == rel_bnd_list:
680-
index = np.argmax(sep_icohp[i])
681-
bond_dict.update(
682-
{
683-
rel_bnd: {
684-
"ICOBI": max(sep_icohp[i]),
685-
"length": sep_lengths[i][index],
686-
}
657+
prop = "ICOBI"
658+
elif not are_cobis and are_coops:
659+
prop = "ICOOP"
660+
else:
661+
prop = "ICOHP"
662+
663+
bond_dict = {}
664+
for i, lab in enumerate(bond_labels_unique):
665+
label = lab.split("-")
666+
label.sort()
667+
for rel_bnd in relevant_bonds:
668+
rel_bnd_list = rel_bnd.split("-")
669+
rel_bnd_list.sort()
670+
if label == rel_bnd_list:
671+
index = np.argmin(sep_icohp[i])
672+
bond_dict.update(
673+
{
674+
rel_bnd: {
675+
prop: min(sep_icohp[i]),
676+
"length": sep_lengths[i][index],
687677
}
688-
)
689-
return bond_dict
690-
691-
if not are_cobis and are_coops:
692-
bond_dict = {}
693-
for i, lab in enumerate(bond_labels_unique):
694-
label = lab.split("-")
695-
label.sort()
696-
for rel_bnd in relevant_bonds:
697-
rel_bnd_list = rel_bnd.split("-")
698-
rel_bnd_list.sort()
699-
if label == rel_bnd_list:
700-
index = np.argmax(sep_icohp[i])
701-
bond_dict.update(
702-
{
703-
rel_bnd: {
704-
"ICOOP": max(sep_icohp[i]),
705-
"length": sep_lengths[i][index],
706-
}
707-
}
708-
)
709-
return bond_dict
678+
}
679+
)
680+
return bond_dict

src/atomate2/vasp/flows/lobster.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,19 @@ class VaspLobsterMaker(Maker):
4747
relax_maker : .BaseVaspMaker or None
4848
A maker to perform a relaxation on the bulk. Set to ``None`` to skip the
4949
bulk relaxation.
50-
preconverge_static_maker: .BaseVaspMaker or None
50+
preconverge_static_maker : .BaseVaspMaker or None
5151
A maker to perform a preconvergence run before the wavefunction computation
5252
without symmetry
5353
lobster_static_maker : .BaseVaspMaker
5454
A maker to perform the computation of the wavefunction before the static run.
5555
Cannot be skipped.
5656
lobster_maker : .LobsterMaker
5757
A maker to perform the Lobster run.
58-
delete_all_wavecars : bool
58+
delete_wavecars : bool
5959
If true, all WAVECARs will be deleted after the run.
6060
address_min_basis : str
6161
A path to a yaml file including basis set information.
62-
address_max_basis: str
62+
address_max_basis : str
6363
A path to a yaml file including basis set information.
6464
"""
6565

@@ -79,7 +79,7 @@ class VaspLobsterMaker(Maker):
7979
)
8080
)
8181
lobster_maker: LobsterMaker | None = field(default_factory=lambda: LobsterMaker())
82-
delete_all_wavecars: bool = True
82+
delete_wavecars: bool = True
8383
address_min_basis: str | None = None
8484
address_max_basis: str | None = None
8585

@@ -151,7 +151,6 @@ def make(
151151
lobster_jobs = get_lobster_jobs(
152152
lobster_maker=self.lobster_maker,
153153
basis_dict=basis_infos.output["basis_dict"],
154-
wavefunction_dir=lobster_static.output.dir_name,
155154
optimization_dir=optimization_dir,
156155
optimization_uuid=optimization_uuid,
157156
static_dir=lobster_static_dir,
@@ -162,7 +161,7 @@ def make(
162161
jobs.append(lobster_jobs)
163162

164163
# delete all WAVECARs that have been copied
165-
if self.delete_all_wavecars:
164+
if self.delete_wavecars:
166165
delete_wavecars = delete_lobster_wavecar(
167166
dirs=lobster_jobs.output["lobster_dirs"],
168167
lobster_static_dir=lobster_static.output.dir_name,

src/atomate2/vasp/jobs/lobster.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def get_basis_infos(
133133

134134
@job
135135
def update_user_incar_settings_maker(
136-
vasp_maker: LobsterStaticMaker,
136+
vasp_maker: BaseVaspMaker,
137137
nbands: int,
138138
structure: Structure,
139139
prev_vasp_dir: Path | str,
@@ -167,7 +167,6 @@ def update_user_incar_settings_maker(
167167
def get_lobster_jobs(
168168
lobster_maker: LobsterMaker,
169169
basis_dict: dict,
170-
wavefunction_dir: Path | str,
171170
optimization_dir: Path | str,
172171
optimization_uuid: str,
173172
static_dir: Path | str,
@@ -184,16 +183,14 @@ def get_lobster_jobs(
184183
maker for the Lobster jobs
185184
basis_dict : dict
186185
dict including basis set information.
187-
wavefunction_dir : Path or str
188-
Path to VASP calculation with WAVECAR
189186
optimization_dir : Path or str
190187
Path to optimization run.
191188
optimization_uuid : str
192189
uuid of optimization run.
193190
static_dir : Path or str
194-
Path to static VASP calculation.
191+
Path to static VASP calculation containing the WAVECAR.
195192
static_uuid : str
196-
uuid of static run.
193+
Uuid of static run.
197194
preconverge_static_dir : Path or str
198195
Path to preconvergence step.
199196
preconverge_static_uuid : str
@@ -221,9 +218,7 @@ def get_lobster_jobs(
221218
lobster_maker = LobsterMaker()
222219

223220
for i, basis in enumerate(basis_dict):
224-
lobsterjob = lobster_maker.make(
225-
wavefunction_dir=wavefunction_dir, basis_dict=basis
226-
)
221+
lobsterjob = lobster_maker.make(wavefunction_dir=static_dir, basis_dict=basis)
227222
lobsterjob.append_name(f"_run_{i}")
228223
outputs["lobster_uuids"].append(lobsterjob.output.uuid)
229224
outputs["lobster_dirs"].append(lobsterjob.output.dir_name)

tests/vasp/lobster/flows/test_lobster.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_lobstermaker(mock_vasp, mock_lobster, clean_dir, memory_jobstore):
5757
"cohpGenerator": "from 0.1 to 3.0 orbitalwise",
5858
}
5959
),
60-
delete_all_wavecars=False,
60+
delete_wavecars=False,
6161
).make(si_structure)
6262
job = update_user_incar_settings(job, {"NPAR": 4})
6363

@@ -123,7 +123,7 @@ def test_lobstermaker_delete(mock_vasp, mock_lobster, clean_dir, memory_jobstore
123123
"cohpGenerator": "from 0.1 to 3.0 orbitalwise",
124124
}
125125
),
126-
delete_all_wavecars=True,
126+
delete_wavecars=True,
127127
).make(si_structure)
128128
job = update_user_incar_settings(job, {"NPAR": 4})
129129

0 commit comments

Comments
 (0)