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

merge devel to master to release v0.13.1 #1721

Merged
merged 13 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repos:

# Python
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.4
rev: v0.9.6
hooks:
- id: ruff
args: ["--fix"]
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# -- Project information -----------------------------------------------------

project = "DP-GEN"
copyright = "2020-%d, DeepModeling" % date.today().year
copyright = "2020-%d, DeepModeling" % date.today().year # noqa: UP031
author = "DeepModeling"


Expand Down
6 changes: 3 additions & 3 deletions dpgen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ def info():
]:
try:
mm = __import__(modui)
print("%10s %10s %s" % (modui, mm.__version__, mm.__path__[0]))
print("%10s %10s %s" % (modui, mm.__version__, mm.__path__[0])) # noqa: UP031
except ImportError:
print("%10s %10s Not Found" % (modui, ""))
print("%10s %10s Not Found" % (modui, "")) # noqa: UP031
except AttributeError:
print("%10s %10s unknown version or path" % (modui, ""))
print("%10s %10s unknown version or path" % (modui, "")) # noqa: UP031
print()

# reference
Expand Down
2 changes: 1 addition & 1 deletion dpgen/auto_test/EOS.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
# vol = vol / 100.0
vol = self.vol_start + task_num * self.vol_step
# task_num = int((vol - self.vol_start) / self.vol_step)
output_task = os.path.join(path_to_work, "task.%06d" % task_num)
output_task = os.path.join(path_to_work, "task.%06d" % task_num) # noqa: UP031
os.makedirs(output_task, exist_ok=True)
os.chdir(output_task)
if self.inter_param["type"] == "abacus":
Expand Down
2 changes: 1 addition & 1 deletion dpgen/auto_test/Elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
print("gen with norm " + str(norm_strains))
print("gen with shear " + str(shear_strains))
for ii in range(n_dfm):
output_task = os.path.join(path_to_work, "task.%06d" % ii)
output_task = os.path.join(path_to_work, "task.%06d" % ii) # noqa: UP031
os.makedirs(output_task, exist_ok=True)
os.chdir(output_task)
for jj in [
Expand Down
21 changes: 12 additions & 9 deletions dpgen/auto_test/Gamma.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
os.symlink(os.path.relpath(equi_contcar), POSCAR)
# task_poscar = os.path.join(output, 'POSCAR')
for ii in range(len(all_slabs)):
output_task = os.path.join(path_to_work, "task.%06d" % ii)
output_task = os.path.join(path_to_work, "task.%06d" % ii) # noqa: UP031
os.makedirs(output_task, exist_ok=True)
os.chdir(output_task)
for jj in ["INCAR", "POTCAR", POSCAR, "conf.lmp", "in.lammps"]:
Expand All @@ -232,9 +232,9 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
task_list.append(output_task)
# print("# %03d generate " % ii, output_task)
print(
"# %03d generate " % ii,
"# %03d generate " % ii, # noqa: UP031
output_task,
" \t %d atoms" % self.atom_num,
" \t %d atoms" % self.atom_num, # noqa: UP031
)
# make confs
all_slabs[ii].to("POSCAR.tmp", "POSCAR")
Expand Down Expand Up @@ -472,12 +472,15 @@ def _compute_lower(self, output_file, all_tasks, all_res):
)

miller_index = loadfn(os.path.join(ii, "miller.json"))
ptr_data += "%-25s %7.2f %7.3f %8.3f %8.3f\n" % (
str(miller_index) + "-" + structure_dir + ":",
int(ii[-4:]) / self.n_steps,
sfe,
epa,
equi_epa_slab,
ptr_data += (
"%-25s %7.2f %7.3f %8.3f %8.3f\n" # noqa: UP031
% (
str(miller_index) + "-" + structure_dir + ":",
int(ii[-4:]) / self.n_steps,
sfe,
epa,
equi_epa_slab,
)
)
res_data[int(ii[-4:]) / self.n_steps] = [sfe, epa, equi_epa]

Expand Down
25 changes: 15 additions & 10 deletions dpgen/auto_test/Interstitial.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
# task_poscar = os.path.join(output, 'POSCAR')

for ii in range(len(dss)):
output_task = os.path.join(path_to_work, "task.%06d" % ii)
output_task = os.path.join(path_to_work, "task.%06d" % ii) # noqa: UP031
os.makedirs(output_task, exist_ok=True)
os.chdir(output_task)
for jj in [
Expand Down Expand Up @@ -262,7 +262,7 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):

super_latt_param = float(pos_line[2].split()[0])

output_task1 = os.path.join(path_to_work, "task.%06d" % (len(dss)))
output_task1 = os.path.join(path_to_work, "task.%06d" % (len(dss))) # noqa: UP031
os.makedirs(output_task1, exist_ok=True)
os.chdir(output_task1)
task_list.append(output_task1)
Expand All @@ -283,7 +283,8 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
os.chdir(cwd)

output_task2 = os.path.join(
path_to_work, "task.%06d" % (len(dss) + 1)
path_to_work,
"task.%06d" % (len(dss) + 1), # noqa: UP031
)
os.makedirs(output_task2, exist_ok=True)
os.chdir(output_task2)
Expand All @@ -305,7 +306,8 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
os.chdir(cwd)

output_task3 = os.path.join(
path_to_work, "task.%06d" % (len(dss) + 2)
path_to_work,
"task.%06d" % (len(dss) + 2), # noqa: UP031
)
os.makedirs(output_task3, exist_ok=True)
os.chdir(output_task3)
Expand Down Expand Up @@ -346,7 +348,8 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
replace_label = idx

output_task4 = os.path.join(
path_to_work, "task.%06d" % (len(dss) + 3)
path_to_work,
"task.%06d" % (len(dss) + 3), # noqa: UP031
)
os.makedirs(output_task4, exist_ok=True)
os.chdir(output_task4)
Expand Down Expand Up @@ -380,7 +383,8 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
os.chdir(cwd)

output_task5 = os.path.join(
path_to_work, "task.%06d" % (len(dss) + 4)
path_to_work,
"task.%06d" % (len(dss) + 4), # noqa: UP031
)
os.makedirs(output_task5, exist_ok=True)
os.chdir(output_task5)
Expand Down Expand Up @@ -414,7 +418,8 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
os.chdir(cwd)

output_task6 = os.path.join(
path_to_work, "task.%06d" % (len(dss) + 5)
path_to_work,
"task.%06d" % (len(dss) + 5), # noqa: UP031
)
os.makedirs(output_task6, exist_ok=True)
os.chdir(output_task6)
Expand Down Expand Up @@ -453,7 +458,7 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):

if self.inter_param["type"] == "abacus":
for ii in range(total_task):
output_task = os.path.join(path_to_work, "task.%06d" % ii)
output_task = os.path.join(path_to_work, "task.%06d" % ii) # noqa: UP031
os.chdir(output_task)
abacus.poscar2stru("POSCAR", self.inter_param, "STRU")
os.remove("POSCAR")
Expand All @@ -478,8 +483,8 @@ def post_process(self, task_list):
type_num = type_map[insert_ele] + 1
conf_line[2] = str(len(type_map_list)) + " atom types"
conf_line[-2] = (
"%6.d" % int(insert_line.split()[0])
+ "%7.d" % type_num
"%6.d" % int(insert_line.split()[0]) # noqa: UP031
+ "%7.d" % type_num # noqa: UP031
+ f"{float(insert_line.split()[2]):16.10f}"
+ f"{float(insert_line.split()[3]):16.10f}"
+ f"{float(insert_line.split()[4]):16.10f}"
Expand Down
8 changes: 4 additions & 4 deletions dpgen/auto_test/Surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
os.symlink(os.path.relpath(equi_contcar), POSCAR)
# task_poscar = os.path.join(output, 'POSCAR')
for ii in range(len(all_slabs)):
output_task = os.path.join(path_to_work, "task.%06d" % ii)
output_task = os.path.join(path_to_work, "task.%06d" % ii) # noqa: UP031
os.makedirs(output_task, exist_ok=True)
os.chdir(output_task)
for jj in [
Expand All @@ -213,9 +213,9 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
os.remove(jj)
task_list.append(output_task)
print(
"# %03d generate " % ii,
"# %03d generate " % ii, # noqa: UP031
output_task,
" \t %d atoms" % len(all_slabs[ii].sites),
" \t %d atoms" % len(all_slabs[ii].sites), # noqa: UP031
)
# make confs
all_slabs[ii].to("POSCAR.tmp", "POSCAR")
Expand Down Expand Up @@ -270,7 +270,7 @@ def _compute_lower(self, output_file, all_tasks, all_res):
evac = (task_result["energies"][-1] - equi_epa * natoms) / AA * Cf

miller_index = loadfn(os.path.join(ii, "miller.json"))
ptr_data += "%-25s %7.3f %8.3f %8.3f\n" % (
ptr_data += "%-25s %7.3f %8.3f %8.3f\n" % ( # noqa: UP031
str(miller_index) + "-" + structure_dir + ":",
evac,
epa,
Expand Down
6 changes: 3 additions & 3 deletions dpgen/auto_test/VASP.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def make_input_file(self, output_dir, task_type, task_param):
isif = 2
if not ("NSW" in incar and incar.get("NSW") == nsw):
dlog.info(
"%s setting NSW to %d"
"%s setting NSW to %d" # noqa: UP031
% (self.make_input_file.__name__, nsw)
)
incar["NSW"] = nsw
Expand All @@ -121,15 +121,15 @@ def make_input_file(self, output_dir, task_type, task_param):

if not ("ISIF" in incar and incar.get("ISIF") == isif):
dlog.info(
"%s setting ISIF to %d" % (self.make_input_file.__name__, isif)
"%s setting ISIF to %d" % (self.make_input_file.__name__, isif) # noqa: UP031
)
incar["ISIF"] = isif

elif cal_type == "static":
nsw = 0
if not ("NSW" in incar and incar.get("NSW") == nsw):
dlog.info(
"%s setting NSW to %d" % (self.make_input_file.__name__, nsw)
"%s setting NSW to %d" % (self.make_input_file.__name__, nsw) # noqa: UP031
)
incar["NSW"] = nsw

Expand Down
2 changes: 1 addition & 1 deletion dpgen/auto_test/Vacancy.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
# task_poscar = os.path.join(output, 'POSCAR')

for ii in range(len(dss)):
output_task = os.path.join(path_to_work, "task.%06d" % ii)
output_task = os.path.join(path_to_work, "task.%06d" % ii) # noqa: UP031
os.makedirs(output_task, exist_ok=True)
os.chdir(output_task)
for jj in [
Expand Down
6 changes: 3 additions & 3 deletions dpgen/auto_test/common_prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def run_property(confs, inter_param, property_list, mdata):
# conf_dirs.sort()
processes = len(property_list)
pool = Pool(processes=processes)
print("Submit job via %d processes" % processes)
print("Submit job via %d processes" % processes) # noqa: UP031
conf_dirs = []
for conf in confs:
conf_dirs.extend(glob.glob(conf))
Expand Down Expand Up @@ -181,8 +181,8 @@ def run_property(confs, inter_param, property_list, mdata):
for ii in range(len(multiple_ret)):
if not multiple_ret[ii].successful():
print("ERROR:", multiple_ret[ii].get())
raise RuntimeError("Job %d is not successful!" % ii)
print("%d jobs are finished" % len(multiple_ret))
raise RuntimeError("Job %d is not successful!" % ii) # noqa: UP031
print("%d jobs are finished" % len(multiple_ret)) # noqa: UP031


def worker(
Expand Down
22 changes: 11 additions & 11 deletions dpgen/auto_test/lib/abacus.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import dpdata
import numpy as np
from dpdata.abacus.scf import make_unlabeled_stru
from dpdata.abacus.stru import make_unlabeled_stru
from dpdata.utils import uniq_atom_names
from dpdata.vasp import poscar as dpdata_poscar

Expand Down Expand Up @@ -161,25 +161,25 @@ def poscar2stru(poscar, inter_param, stru="STRU"):
else:
atom_mass_dict = inter_param["atom_masses"]
for atom in stru_data["atom_names"]:
assert (
atom in atom_mass_dict
), f"the mass of {atom} is not defined in interaction:atom_masses"
assert atom in atom_mass_dict, (
f"the mass of {atom} is not defined in interaction:atom_masses"
)
atom_mass.append(atom_mass_dict[atom])

if "potcars" in inter_param:
pseudo = []
for atom in stru_data["atom_names"]:
assert (
atom in inter_param["potcars"]
), f"the pseudopotential of {atom} is not defined in interaction:potcars"
assert atom in inter_param["potcars"], (
f"the pseudopotential of {atom} is not defined in interaction:potcars"
)
pseudo.append("./pp_orb/" + inter_param["potcars"][atom].split("/")[-1])

if "orb_files" in inter_param:
orb = []
for atom in stru_data["atom_names"]:
assert (
atom in inter_param["orb_files"]
), f"orbital file of {atom} is not defined in interaction:orb_files"
assert atom in inter_param["orb_files"], (
f"orbital file of {atom} is not defined in interaction:orb_files"
)
orb.append("./pp_orb/" + inter_param["orb_files"][atom].split("/")[-1])

if "deepks_desc" in inter_param:
Expand Down Expand Up @@ -333,7 +333,7 @@ def final_stru(abacus_path):
if lines[-i][1:27] == "STEP OF MOLECULAR DYNAMICS":
max_step = int(lines[-i].split()[-1])
break
return "OUT.%s/STRU_MD_%d" % (suffix, max_step)
return "OUT.%s/STRU_MD_%d" % (suffix, max_step) # noqa: UP031
elif calculation == "scf":
return "STRU"
else:
Expand Down
Loading