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

Modify post_fp_cp2k, adapt to SCF not converged situation. #1562

Open
wants to merge 5 commits into
base: devel
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions dpgen/generator/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4469,14 +4469,22 @@
sys_output = glob.glob(os.path.join(work_path, f"task.{ss}.*/output"))
sys_output.sort()
tcount += len(sys_output)
log_file_path = os.path.join(work_path, f"{ss}.fp-fail.log")
all_sys = dpdata.MultiSystems(type_map=jdata["type_map"])
for oo in sys_output:
with open(oo) as file:
content = file.read()
if "SCF run NOT converged" in content:
with open(log_file_path, "a") as log_file:
log_file.write(f"Skipping file {oo} due to SCF run NOT converged\n")
continue

Check warning on line 4480 in dpgen/generator/run.py

View check run for this annotation

Codecov / codecov/patch

dpgen/generator/run.py#L4478-L4480

Added lines #L4478 - L4480 were not covered by tests
Comment on lines +4503 to +4508
Copy link
Collaborator

Choose a reason for hiding this comment

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

move these lines after _sys=dpdata.LabeledSystem

Suggested change
with open(oo) as file:
content = file.read()
if "SCF run NOT converged" in content:
with open(log_file_path, "a") as log_file:
log_file.write(f"Skipping file {oo} due to SCF run NOT converged\n")
continue
if len(_sys) == 0:
with open(log_file_path, "a") as log_file:
log_file.write(f"Skipping file {oo} due to SCF run NOT converged\n")
continue

Comment on lines +4505 to +4508
Copy link

Choose a reason for hiding this comment

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

Move SCF check and logging after _sys instantiation

To ensure _sys is only instantiated if SCF converges, move these lines after _sys=dpdata.LabeledSystem.

-            if "SCF run NOT converged" in content:
-                with open(log_file_path, "a") as log_file:
-                    log_file.write(f"Skipping file {oo} due to SCF run NOT converged\n")
-                continue
            _sys = dpdata.LabeledSystem(
                oo, fmt="cp2kdata/e_f", type_map=jdata["type_map"]
            )
+            if "SCF run NOT converged" in content:
+                with open(log_file_path, "a") as log_file:
+                    log_file.write(f"Skipping file {oo} due to SCF run NOT converged\n")
+                continue
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if "SCF run NOT converged" in content:
with open(log_file_path, "a") as log_file:
log_file.write(f"Skipping file {oo} due to SCF run NOT converged\n")
continue
_sys = dpdata.LabeledSystem(
oo, fmt="cp2kdata/e_f", type_map=jdata["type_map"]
)
if "SCF run NOT converged" in content:
with open(log_file_path, "a") as log_file:
log_file.write(f"Skipping file {oo} due to SCF run NOT converged\n")
continue

_sys = dpdata.LabeledSystem(
oo, fmt="cp2kdata/e_f", type_map=jdata["type_map"]
)
all_sys.append(_sys)
icount += 1

icount += len(all_sys)
Copy link

Choose a reason for hiding this comment

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

Duplicate icount increment

icount is incremented twice. Remove the duplicate increment.

-        icount += len(all_sys)

Committable suggestion was skipped due to low confidence.

if (all_sys is not None) and (len(all_sys) > 0):
sys_data_path = os.path.join(work_path, f"data.{ss}")
all_sys.to_deepmd_raw(sys_data_path)
Expand Down
Loading