Skip to content

Commit a6eb23d

Browse files
Merge pull request #88 from ZLI-afk/v1.2
V1.2.12
2 parents de12257 + 0211917 commit a6eb23d

File tree

14 files changed

+102
-33
lines changed

14 files changed

+102
-33
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
python-version: ["3.8", "3.9", "3.10"]
12+
python-version: ["3.10"]
1313

1414
steps:
1515
- uses: actions/checkout@master

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ Below are three examples (for detailed explanations of each parameter, please re
413413
| shear_deform | Float | 0.01 | The deformation in other directions, default = 1e-2 |
414414
| conventional | Bool | False | Whether adopt conventional cell for deformation |
415415
| ieee | Bool | False | Whether rotate relaxed structure into IEEE-standard format before deformation ([ref](https://ieeexplore.ieee.org/document/26560)) |
416+
| modulus_type | String | "voigt" | Bulk and shear modulus average type (default: "voigt"). Choose from "voigt", "reuss" and "vrh" |
416417

417418
##### 3.1.2.3. Surface
418419
| Key words | Data structure | Example | Description |

apex/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
__version__ = '1.2.10'
2+
__version__ = '1.2.12'
33
LOCAL_PATH = os.getcwd()
44

55

apex/core/calculator/Lammps.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
inter_snap,
1515
inter_gap,
1616
inter_rann,
17-
inter_mace
17+
inter_mace,
18+
inter_nep
1819
)
1920
from .Task import Task
2021
from dflow.python import upload_packages
@@ -55,6 +56,8 @@ def set_inter_type_func(self):
5556
self.inter_func = inter_rann
5657
elif self.inter_type == "mace":
5758
self.inter_func = inter_mace
59+
elif self.inter_type == "nep":
60+
self.inter_func = inter_nep
5861
else:
5962
self.inter_func = inter_eam_alloy
6063

apex/core/calculator/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
'gap',
99
'rann',
1010
'mace',
11+
'nep'
1112
]

apex/core/calculator/lib/abacus_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import dpdata
66
import numpy as np
7-
from pymatgen.core.structure import Structure
7+
from pymatgen.core import Structure
88

99
from . import abacus_scf
1010
from dflow.python import upload_packages

apex/core/calculator/lib/lammps_utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ def inter_mace(param):
138138
ret += line
139139
return ret
140140

141+
def inter_nep(param):
142+
ret = ""
143+
line = "pair_style nep \n"
144+
line += "pair_coeff * * %s " % param["model_name"][0]
145+
for ii in param["param_type"]:
146+
line += ii + " "
147+
line += "\n"
148+
ret += line
149+
return ret
150+
141151

142152
def inter_snap(param):
143153
ret = ""

apex/core/common_equi.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import dpdata
66
from monty.serialization import dumpfn
77
from pymatgen.core.structure import Structure
8+
from pymatgen.analysis.structure_matcher import StructureMatcher
89
from apex.core.calculator.lib import abacus_utils
910
from apex.core.lib import crys
1011
from apex.core.calculator.calculator import make_calculator
@@ -14,7 +15,7 @@
1415
from apex.core.structure import StructureInfo
1516
from dflow.python import upload_packages
1617
upload_packages.append(__file__)
17-
lammps_task_type = ['deepmd', 'eam_alloy', 'meam', 'eam_fs', 'meam_spline', 'snap', 'gap', 'rann', 'mace']
18+
lammps_task_type = ['deepmd', 'eam_alloy', 'meam', 'eam_fs', 'meam_spline', 'snap', 'gap', 'rann', 'mace', 'nep']
1819

1920

2021
def make_equi(confs, inter_param, relax_param):
@@ -201,13 +202,23 @@ def post_equi(confs, inter_param):
201202
except FileNotFoundError:
202203
logging.warning(f"No CONTCAR found in {ii}, skip")
203204
continue
205+
try:
206+
init_ss = Structure.from_file(poscar)
207+
except FileNotFoundError:
208+
logging.warning(f"No POSCAR found in {ii}, skip")
209+
continue
204210
st = StructureInfo(ss)
211+
matcher = StructureMatcher()
212+
is_match = matcher.fit(init_ss, ss)
213+
if not is_match:
214+
logging.warning(f"Structure mismatch after relaxation in {ii}")
205215
struct_info_dict = {
206216
"space_group_symbol": st.space_group_symbol,
207217
"space_group_number": st.space_group_number,
208218
"point_group_symbol": st.point_group_symbol,
209219
"crystal_system": st.crystal_system,
210220
"lattice_type": st.lattice_type,
221+
"mismatch": not is_match,
211222
}
212223

213224
dumpfn(struct_info_dict, os.path.join(ii, "structure.json"), indent=4)

apex/core/common_prop.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import glob
22
import os
33
from multiprocessing import Pool
4-
from monty.serialization import dumpfn
4+
from monty.serialization import dumpfn, loadfn
55

66
from apex.core.calculator.calculator import make_calculator
77
from apex.core.property.Elastic import Elastic
@@ -54,6 +54,12 @@ def make_property(confs, inter_param, property_list):
5454
conf_dirs.sort()
5555
for ii in conf_dirs:
5656
sepline(ch=ii, screen=True)
57+
path_to_equi = os.path.join(ii, "relaxation", "relax_task")
58+
try:
59+
structure_dict = loadfn(os.path.join(path_to_equi, "structure.json"))
60+
except FileNotFoundError:
61+
structure_dict = {}
62+
mismatch = structure_dict.get("mismatch", False)
5763
for jj in property_list:
5864
do_refine, suffix = handle_prop_suffix(jj)
5965
if not suffix:
@@ -63,8 +69,11 @@ def make_property(confs, inter_param, property_list):
6369
# determine the suffix: from scratch or refine
6470

6571
property_type = jj["type"]
66-
path_to_equi = os.path.join(ii, "relaxation", "relax_task")
6772
path_to_work = os.path.join(ii, property_type + "_" + suffix)
73+
skip_mismatch = jj.get("skip_mismatch", False)
74+
if mismatch and skip_mismatch:
75+
print("Skip mismatched structure")
76+
continue
6877

6978
create_path(path_to_work)
7079

apex/core/property/Elastic.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def __init__(self, parameter, inter_param=None):
3535
self.conventional = parameter["conventional"]
3636
parameter.setdefault("ieee", False)
3737
self.ieee = parameter["ieee"]
38+
parameter.setdefault("modulus_type", "voigt")
39+
self.modulus_type = parameter["modulus_type"]
3840
parameter.setdefault("cal_type", "relaxation")
3941
self.cal_type = parameter["cal_type"]
4042
default_cal_setting = {
@@ -272,19 +274,27 @@ def _compute_lower(self, output_file, all_tasks, all_res):
272274
res_data["elastic_tensor"].append(c_ii)
273275
ptr_data += "\n"
274276

275-
BV = et.k_voigt / 1e4
276-
GV = et.g_voigt / 1e4
277+
if self.modulus_type == "voigt":
278+
BV = et.k_voigt / 1e4
279+
GV = et.g_voigt / 1e4
280+
elif self.modulus_type == "reuss":
281+
BV = et.k_reuss / 1e4
282+
GV = et.g_reuss / 1e4
283+
elif self.modulus_type == "vrh":
284+
BV = et.k_vrh / 1e4
285+
GV = et.g_vrh / 1e4
286+
277287
EV = 9 * BV * GV / (3 * BV + GV)
278288
uV = 0.5 * (3 * BV - 2 * GV) / (3 * BV + GV)
279289

280-
res_data["BV"] = BV
281-
res_data["GV"] = GV
282-
res_data["EV"] = EV
283-
res_data["uV"] = uV
284-
ptr_data += "# Bulk Modulus BV = %.2f GPa\n" % BV
285-
ptr_data += "# Shear Modulus GV = %.2f GPa\n" % GV
286-
ptr_data += "# Youngs Modulus EV = %.2f GPa\n" % EV
287-
ptr_data += "# Poission Ratio uV = %.2f\n " % uV
290+
res_data["B"] = BV
291+
res_data["G"] = GV
292+
res_data["E"] = EV
293+
res_data["u"] = uV
294+
ptr_data += "# Bulk Modulus B = %.2f GPa\n" % BV
295+
ptr_data += "# Shear Modulus G = %.2f GPa\n" % GV
296+
ptr_data += "# Youngs Modulus E = %.2f GPa\n" % EV
297+
ptr_data += "# Poission Ratio u = %.2f\n " % uV
288298

289299
dumpfn(res_data, output_file, indent=4)
290300

0 commit comments

Comments
 (0)