Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 15, 2024
1 parent f64e160 commit dfbe2e7
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 25 deletions.
6 changes: 4 additions & 2 deletions dpgen2/entrypoint/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import os
import pickle
import re
from copy import deepcopy
from copy import (
deepcopy,
)
from pathlib import (
Path,
)
Expand Down Expand Up @@ -71,9 +73,9 @@
ExplorationScheduler,
)
from dpgen2.exploration.selector import (
conf_filter_styles,
ConfFilters,
ConfSelectorFrames,
conf_filter_styles,
)
from dpgen2.exploration.task import (
CustomizedLmpTemplateTaskGroup,
Expand Down
3 changes: 1 addition & 2 deletions dpgen2/exploration/selector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
ConfSelectorFrames,
)
from .distance_conf_filter import (
DistanceConfFilter
DistanceConfFilter,
)


conf_filter_styles = {
"distance": DistanceConfFilter,
}
144 changes: 128 additions & 16 deletions dpgen2/exploration/selector/distance_conf_filter.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,111 @@
import dpdata
import numpy as np
import os
import shutil
from . import ConfFilter

import dpdata
import numpy as np

from . import (
ConfFilter,
)

safe_dist_dict = {
"H": 1.2255, "He": 0.936, "Li": 1.8, "Be": 1.56, "B": 1.32, "C": 1.32, "N": 1.32, "O": 1.32, "F": 1.26, "Ne": 1.92,
"Na": 1.595, "Mg": 1.87, "Al": 1.87, "Si": 1.76, "P": 1.65, "S": 1.65, "Cl": 1.65, "Ar": 2.09,
"K": 2.3, "Ca": 2.3, "Sc": 2.0, "Ti": 2.0, "V": 2.0, "Cr": 1.9, "Mn": 1.95, "Fe": 1.9, "Co": 1.9, "Ni": 1.9, "Cu": 1.9, "Zn": 1.9, "Ga": 2.0, "Ge": 2.0, "As": 2.0, "Se": 2.1, "Br": 2.1, "Kr": 2.3,
"Rb": 2.5, "Sr": 2.5, "Y": 2.1, "Zr": 2.1, "Nb": 2.1, "Mo": 2.1, "Tc": 2.1, "Ru": 2.1, "Rh": 2.1, "Pd": 2.1, "Ag": 2.1, "Cd": 2.1, "In": 2.0, "Sn": 2.0, "Sb": 2.0, "Te": 2.0, "I": 2.0, "Xe": 2.0,
"Cs": 2.5, "Ba": 2.8, "La": 2.5, "Ce": 2.55, "Pr": 2.7, "Nd": 2.8, "Pm": 2.8, "Sm": 2.8, "Eu": 2.8, "Gd": 2.8, "Tb": 2.8, "Dy": 2.8, "Ho": 2.8, "Er": 2.6, "Tm": 2.8, "Yb": 2.8, "Lu": 2.8, "Hf": 2.4, "Ta": 2.5, "W": 2.3, "Re": 2.3, "Os": 2.3, "Ir": 2.3,
"Pt": 2.3, "Au": 2.3, "Hg": 2.3, "Tl": 2.3, "Pb": 2.3, "Bi": 2.3, "Po": 2.3, "At": 2.3, "Rn": 2.3, "Fr": 2.9, "Ra": 2.9, "Ac": 2.9, "Th": 2.8, "Pa": 2.8, "U": 2.8, "Np": 2.8, "Pu": 2.8, "Am": 2.8, "Cm": 2.8, "Cf": 2.3
"H": 1.2255,
"He": 0.936,
"Li": 1.8,
"Be": 1.56,
"B": 1.32,
"C": 1.32,
"N": 1.32,
"O": 1.32,
"F": 1.26,
"Ne": 1.92,
"Na": 1.595,
"Mg": 1.87,
"Al": 1.87,
"Si": 1.76,
"P": 1.65,
"S": 1.65,
"Cl": 1.65,
"Ar": 2.09,
"K": 2.3,
"Ca": 2.3,
"Sc": 2.0,
"Ti": 2.0,
"V": 2.0,
"Cr": 1.9,
"Mn": 1.95,
"Fe": 1.9,
"Co": 1.9,
"Ni": 1.9,
"Cu": 1.9,
"Zn": 1.9,
"Ga": 2.0,
"Ge": 2.0,
"As": 2.0,
"Se": 2.1,
"Br": 2.1,
"Kr": 2.3,
"Rb": 2.5,
"Sr": 2.5,
"Y": 2.1,
"Zr": 2.1,
"Nb": 2.1,
"Mo": 2.1,
"Tc": 2.1,
"Ru": 2.1,
"Rh": 2.1,
"Pd": 2.1,
"Ag": 2.1,
"Cd": 2.1,
"In": 2.0,
"Sn": 2.0,
"Sb": 2.0,
"Te": 2.0,
"I": 2.0,
"Xe": 2.0,
"Cs": 2.5,
"Ba": 2.8,
"La": 2.5,
"Ce": 2.55,
"Pr": 2.7,
"Nd": 2.8,
"Pm": 2.8,
"Sm": 2.8,
"Eu": 2.8,
"Gd": 2.8,
"Tb": 2.8,
"Dy": 2.8,
"Ho": 2.8,
"Er": 2.6,
"Tm": 2.8,
"Yb": 2.8,
"Lu": 2.8,
"Hf": 2.4,
"Ta": 2.5,
"W": 2.3,
"Re": 2.3,
"Os": 2.3,
"Ir": 2.3,
"Pt": 2.3,
"Au": 2.3,
"Hg": 2.3,
"Tl": 2.3,
"Pb": 2.3,
"Bi": 2.3,
"Po": 2.3,
"At": 2.3,
"Rn": 2.3,
"Fr": 2.9,
"Ra": 2.9,
"Ac": 2.9,
"Th": 2.8,
"Pa": 2.8,
"U": 2.8,
"Np": 2.8,
"Pu": 2.8,
"Am": 2.8,
"Cm": 2.8,
"Cf": 2.3,
}
for k in safe_dist_dict:
safe_dist_dict[k] *= 0.441
Expand All @@ -23,7 +118,9 @@ def check_multiples(a, b, c, multiple):
for j in range(len(values)):
if i != j:
if values[i] > multiple * values[j]:
print(f"Value {values[i]} is {multiple} times greater than {values[j]}")
print(
f"Value {values[i]} is {multiple} times greater than {values[j]}"
)
return True
return False

Expand All @@ -39,15 +136,28 @@ def check(
atom_types: np.ndarray,
nopbc: bool,
):
from ase import Atoms
from ase.build import make_supercell
from ase import (
Atoms,
)
from ase.build import (
make_supercell,
)

atom_names = list(safe_dist_dict)
structure = Atoms(positions=coords, numbers=[atom_names.index(n)+1 for n in atom_types], cell=cell, pbc=(not nopbc))
structure = Atoms(
positions=coords,
numbers=[atom_names.index(n) + 1 for n in atom_types],
cell=cell,
pbc=(not nopbc),
)

cell = structure.get_cell()

Check failure on line 154 in dpgen2/exploration/selector/distance_conf_filter.py

View workflow job for this annotation

GitHub Actions / pyright

Expression of type "Cell" cannot be assigned to declared type "ndarray[Unknown, Unknown]"   "Cell" is incompatible with "ndarray[Unknown, Unknown]" (reportGeneralTypeIssues)

if (cell[1][0]>1.732*cell[1][1] or cell[2][0]>1.732*cell[2][2] or cell[2][1]>1.732*cell[2][2]):
if (
cell[1][0] > 1.732 * cell[1][1]
or cell[2][0] > 1.732 * cell[2][2]
or cell[2][1] > 1.732 * cell[2][2]
):
print("Inclined box")
return False

Expand All @@ -67,14 +177,16 @@ def check(

num_atoms = len(coords)
for i in range(num_atoms):
for j in range(i+1, num_atoms):
for j in range(i + 1, num_atoms):
dist = extended_structure.get_distance(i, j, mic=True)
type_i = symbols[i]
type_j = symbols[j]
dr = safe_dist_dict[type_i] + safe_dist_dict[type_j]

if dist < dr:
print(f"Dangerous close for {type_i} - {type_j}, {dist:.5f} less than {dr:.5f}")
print(
f"Dangerous close for {type_i} - {type_j}, {dist:.5f} less than {dr:.5f}"
)
return False

print("Valid structure")
Expand Down
11 changes: 6 additions & 5 deletions tests/exploration/test_distance_conf_filter.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import dpdata
import os
import numpy as np
import unittest

from .context import (
dpgen2,
)
import dpdata
import numpy as np

from dpgen2.exploration.selector import (
DistanceConfFilter,
)

from .context import (
dpgen2,
)

POSCAR_1 = """ Er
1.0
Expand Down

0 comments on commit dfbe2e7

Please sign in to comment.