Skip to content

Commit 2e511f6

Browse files
jmmshnesoteric-ephemera
authored andcommitted
fixed names for insertion jobs
The old way was pretty messy. Refactored to be cleaner.
1 parent 6f541f7 commit 2e511f6

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
lines changed

src/atomate2/common/flows/electrode.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ def make(
120120
relax = self.bulk_relax_maker.make(structure)
121121
else:
122122
relax = self.relax_maker.make(structure)
123+
124+
_shown_steps = str(n_steps) if n_steps else "inf"
125+
relax.append_name(f" 0/{_shown_steps}")
126+
123127
# add ignored_species to the structure matcher
124128
sm = _add_ignored_species(self.structure_matcher, inserted_element)
125129
# Get the inserted structure
@@ -131,7 +135,7 @@ def make(
131135
relax_maker=self.relax_maker,
132136
get_charge_density=self.get_charge_density,
133137
n_steps=n_steps,
134-
insertions_per_step=insertions_per_step,
138+
n_inserted=1,
135139
)
136140
relaxed_summary = RelaxJobSummary(
137141
structure=relax.output.structure,

src/atomate2/common/jobs/electrode.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,14 @@ def get_stable_inserted_results(
8686
"""
8787
if structure is None:
8888
return []
89-
if n_steps is not None and n_steps <= 0:
89+
if n_inserted > n_steps if n_steps is not None else float("inf"):
9090
return []
9191
# append job name
92-
add_name = f"{n_inserted}"
92+
_shown_steps = str(n_steps) if n_steps else "inf"
93+
add_name = f"{n_inserted}/{_shown_steps}"
9394

9495
static_job = static_maker.make(structure=structure)
96+
static_job.append_name(f" {n_inserted - 1}/{_shown_steps}")
9597
insertion_job = get_inserted_structures(
9698
static_job.output.dir_name,
9799
get_charge_density,
@@ -107,7 +109,6 @@ def get_stable_inserted_results(
107109
ref_structure=structure,
108110
structure_matcher=structure_matcher,
109111
)
110-
nn_step = n_steps - 1 if n_steps is not None else None
111112
next_step = get_stable_inserted_results(
112113
structure=min_en_job.output[0],
113114
inserted_element=inserted_element,
@@ -116,12 +117,12 @@ def get_stable_inserted_results(
116117
relax_maker=relax_maker,
117118
get_charge_density=get_charge_density,
118119
insertions_per_step=insertions_per_step,
119-
n_steps=nn_step,
120+
n_steps=n_steps,
120121
n_inserted=n_inserted + 1,
121122
)
122123

123-
for job_ in [static_job, insertion_job, min_en_job, relax_jobs, next_step]:
124-
job_.append_name(f" {add_name}")
124+
# for job_ in [static_job, insertion_job, min_en_job, relax_jobs, next_step]:
125+
# job_.append_name(f" {add_name}")
125126
combine_job = get_computed_entries(next_step.output, min_en_job.output)
126127
replace_flow = Flow(
127128
jobs=[

tests/vasp/flows/test_electrode.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,26 @@ def test_electrode_makers(mock_vasp, clean_dir, test_dir):
1717

1818
# mapping from job name to directory containing test files
1919
ref_paths = {
20-
"relax": "H_Graphite/relax",
21-
"relax 0 (0) 0": "H_Graphite/relax_0_(0)",
22-
"relax 1 (0) 1 0": "H_Graphite/relax_1_(0)",
23-
"relax 1 (1) 1 0": "H_Graphite/relax_1_(1)",
24-
"relax 1 (2) 1 0": "H_Graphite/relax_1_(2)",
25-
"static 0": "H_Graphite/static_0",
26-
"static 1 0": "H_Graphite/static_1",
20+
"relax 0/2": "H_Graphite/relax",
21+
"relax 1/2 (0)": "H_Graphite/relax_0_(0)",
22+
"relax 2/2 (0)": "H_Graphite/relax_1_(0)",
23+
"relax 2/2 (1)": "H_Graphite/relax_1_(1)",
24+
"relax 2/2 (2)": "H_Graphite/relax_1_(2)",
25+
"static 0/2": "H_Graphite/static_0",
26+
"static 1/2": "H_Graphite/static_1",
2727
}
2828

2929
fake_run_vasp_kwargs = {
30-
"relax": {
30+
"relax 0/2": {
3131
"incar_settings": ["NSW", "ISIF"],
3232
"check_inputs": ["incar", "poscar"],
3333
},
34-
"relax 0 (0) 0": {"incar_settings": ["NSW"], "check_inputs": ["incar"]},
35-
"relax 1 (0) 1 0": {"incar_settings": ["NSW"], "check_inputs": ["incar"]},
36-
"relax 1 (1) 1 0": {"incar_settings": ["NSW"], "check_inputs": ["incar"]},
37-
"relax 1 (2) 1 0": {"incar_settings": ["NSW"], "check_inputs": ["incar"]},
38-
"static 0": {"incar_settings": ["NSW"], "check_inputs": ["incar"]},
39-
"static 1 0": {"incar_settings": ["NSW"], "check_inputs": ["incar"]},
34+
"relax 1/2 (0)": {"incar_settings": ["NSW"], "check_inputs": ["incar"]},
35+
"relax 2/2 (0)": {"incar_settings": ["NSW"], "check_inputs": ["incar"]},
36+
"relax 2/2 (1)": {"incar_settings": ["NSW"], "check_inputs": ["incar"]},
37+
"relax 2/2 (2)": {"incar_settings": ["NSW"], "check_inputs": ["incar"]},
38+
"static 0/2": {"incar_settings": ["NSW"], "check_inputs": ["incar"]},
39+
"static 1/2": {"incar_settings": ["NSW"], "check_inputs": ["incar"]},
4040
}
4141

4242
# automatically use fake VASP and write POTCAR.spec during the test

0 commit comments

Comments
 (0)