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

V1.2.12 #88

Merged
merged 15 commits into from
Jan 9, 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 .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.10"]

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

##### 3.1.2.3. Surface
| Key words | Data structure | Example | Description |
Expand Down
2 changes: 1 addition & 1 deletion apex/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
__version__ = '1.2.10'
__version__ = '1.2.12'
LOCAL_PATH = os.getcwd()


Expand Down
5 changes: 4 additions & 1 deletion apex/core/calculator/Lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
inter_snap,
inter_gap,
inter_rann,
inter_mace
inter_mace,
inter_nep
)
from .Task import Task
from dflow.python import upload_packages
Expand Down Expand Up @@ -55,6 +56,8 @@
self.inter_func = inter_rann
elif self.inter_type == "mace":
self.inter_func = inter_mace
elif self.inter_type == "nep":
self.inter_func = inter_nep

Check warning on line 60 in apex/core/calculator/Lammps.py

View check run for this annotation

Codecov / codecov/patch

apex/core/calculator/Lammps.py#L59-L60

Added lines #L59 - L60 were not covered by tests
else:
self.inter_func = inter_eam_alloy

Expand Down
1 change: 1 addition & 0 deletions apex/core/calculator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
'gap',
'rann',
'mace',
'nep'
]
2 changes: 1 addition & 1 deletion apex/core/calculator/lib/abacus_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import dpdata
import numpy as np
from pymatgen.core.structure import Structure
from pymatgen.core import Structure

from . import abacus_scf
from dflow.python import upload_packages
Expand Down
10 changes: 10 additions & 0 deletions apex/core/calculator/lib/lammps_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@
ret += line
return ret

def inter_nep(param):
ret = ""
line = "pair_style nep \n"
line += "pair_coeff * * %s " % param["model_name"][0]
for ii in param["param_type"]:
line += ii + " "
line += "\n"
ret += line
return ret

Check warning on line 149 in apex/core/calculator/lib/lammps_utils.py

View check run for this annotation

Codecov / codecov/patch

apex/core/calculator/lib/lammps_utils.py#L142-L149

Added lines #L142 - L149 were not covered by tests


def inter_snap(param):
ret = ""
Expand Down
13 changes: 12 additions & 1 deletion apex/core/common_equi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import dpdata
from monty.serialization import dumpfn
from pymatgen.core.structure import Structure
from pymatgen.analysis.structure_matcher import StructureMatcher
from apex.core.calculator.lib import abacus_utils
from apex.core.lib import crys
from apex.core.calculator.calculator import make_calculator
Expand All @@ -14,7 +15,7 @@
from apex.core.structure import StructureInfo
from dflow.python import upload_packages
upload_packages.append(__file__)
lammps_task_type = ['deepmd', 'eam_alloy', 'meam', 'eam_fs', 'meam_spline', 'snap', 'gap', 'rann', 'mace']
lammps_task_type = ['deepmd', 'eam_alloy', 'meam', 'eam_fs', 'meam_spline', 'snap', 'gap', 'rann', 'mace', 'nep']


def make_equi(confs, inter_param, relax_param):
Expand Down Expand Up @@ -201,13 +202,23 @@
except FileNotFoundError:
logging.warning(f"No CONTCAR found in {ii}, skip")
continue
try:
init_ss = Structure.from_file(poscar)
except FileNotFoundError:
logging.warning(f"No POSCAR found in {ii}, skip")
continue

Check warning on line 209 in apex/core/common_equi.py

View check run for this annotation

Codecov / codecov/patch

apex/core/common_equi.py#L207-L209

Added lines #L207 - L209 were not covered by tests
st = StructureInfo(ss)
matcher = StructureMatcher()
is_match = matcher.fit(init_ss, ss)
if not is_match:
logging.warning(f"Structure mismatch after relaxation in {ii}")

Check warning on line 214 in apex/core/common_equi.py

View check run for this annotation

Codecov / codecov/patch

apex/core/common_equi.py#L214

Added line #L214 was not covered by tests
struct_info_dict = {
"space_group_symbol": st.space_group_symbol,
"space_group_number": st.space_group_number,
"point_group_symbol": st.point_group_symbol,
"crystal_system": st.crystal_system,
"lattice_type": st.lattice_type,
"mismatch": not is_match,
}

dumpfn(struct_info_dict, os.path.join(ii, "structure.json"), indent=4)
Expand Down
13 changes: 11 additions & 2 deletions apex/core/common_prop.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import glob
import os
from multiprocessing import Pool
from monty.serialization import dumpfn
from monty.serialization import dumpfn, loadfn

from apex.core.calculator.calculator import make_calculator
from apex.core.property.Elastic import Elastic
Expand Down Expand Up @@ -54,6 +54,12 @@
conf_dirs.sort()
for ii in conf_dirs:
sepline(ch=ii, screen=True)
path_to_equi = os.path.join(ii, "relaxation", "relax_task")
try:
structure_dict = loadfn(os.path.join(path_to_equi, "structure.json"))
except FileNotFoundError:
structure_dict = {}
mismatch = structure_dict.get("mismatch", False)
for jj in property_list:
do_refine, suffix = handle_prop_suffix(jj)
if not suffix:
Expand All @@ -63,8 +69,11 @@
# determine the suffix: from scratch or refine

property_type = jj["type"]
path_to_equi = os.path.join(ii, "relaxation", "relax_task")
path_to_work = os.path.join(ii, property_type + "_" + suffix)
skip_mismatch = jj.get("skip_mismatch", False)
if mismatch and skip_mismatch:
print("Skip mismatched structure")
continue

Check warning on line 76 in apex/core/common_prop.py

View check run for this annotation

Codecov / codecov/patch

apex/core/common_prop.py#L75-L76

Added lines #L75 - L76 were not covered by tests

create_path(path_to_work)

Expand Down
30 changes: 20 additions & 10 deletions apex/core/property/Elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
self.conventional = parameter["conventional"]
parameter.setdefault("ieee", False)
self.ieee = parameter["ieee"]
parameter.setdefault("modulus_type", "voigt")
self.modulus_type = parameter["modulus_type"]
parameter.setdefault("cal_type", "relaxation")
self.cal_type = parameter["cal_type"]
default_cal_setting = {
Expand Down Expand Up @@ -272,19 +274,27 @@
res_data["elastic_tensor"].append(c_ii)
ptr_data += "\n"

BV = et.k_voigt / 1e4
GV = et.g_voigt / 1e4
if self.modulus_type == "voigt":
BV = et.k_voigt / 1e4
GV = et.g_voigt / 1e4
elif self.modulus_type == "reuss":
BV = et.k_reuss / 1e4
GV = et.g_reuss / 1e4
elif self.modulus_type == "vrh":
BV = et.k_vrh / 1e4
GV = et.g_vrh / 1e4

Check warning on line 285 in apex/core/property/Elastic.py

View check run for this annotation

Codecov / codecov/patch

apex/core/property/Elastic.py#L277-L285

Added lines #L277 - L285 were not covered by tests

EV = 9 * BV * GV / (3 * BV + GV)
uV = 0.5 * (3 * BV - 2 * GV) / (3 * BV + GV)

res_data["BV"] = BV
res_data["GV"] = GV
res_data["EV"] = EV
res_data["uV"] = uV
ptr_data += "# Bulk Modulus BV = %.2f GPa\n" % BV
ptr_data += "# Shear Modulus GV = %.2f GPa\n" % GV
ptr_data += "# Youngs Modulus EV = %.2f GPa\n" % EV
ptr_data += "# Poission Ratio uV = %.2f\n " % uV
res_data["B"] = BV
res_data["G"] = GV
res_data["E"] = EV
res_data["u"] = uV
ptr_data += "# Bulk Modulus B = %.2f GPa\n" % BV
ptr_data += "# Shear Modulus G = %.2f GPa\n" % GV
ptr_data += "# Youngs Modulus E = %.2f GPa\n" % EV
ptr_data += "# Poission Ratio u = %.2f\n " % uV

Check warning on line 297 in apex/core/property/Elastic.py

View check run for this annotation

Codecov / codecov/patch

apex/core/property/Elastic.py#L290-L297

Added lines #L290 - L297 were not covered by tests

dumpfn(res_data, output_file, indent=4)

Expand Down
24 changes: 24 additions & 0 deletions apex/op/property_ops.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os, glob, pathlib, shutil, subprocess, logging
from pathlib import Path
from monty.serialization import loadfn
from typing import List
from dflow.python import (
OP,
Expand Down Expand Up @@ -65,7 +66,23 @@
create_path(str(abs_path_to_prop))
conf_path = abs_path_to_prop.parent
prop_name = abs_path_to_prop.name

# break subworkflow if mismatch stop is set
path_to_equi = conf_path / "relaxation" / "relax_task"
try:
structure_dict = loadfn(os.path.join(path_to_equi, "structure.json"))
except FileNotFoundError:
structure_dict = {}
mismatch = structure_dict.get("mismatch", False)
skip_mismatch = prop_param.get("skip_mismatch", False)
if mismatch and skip_mismatch:
print("Skipped due to mismatched relaxed structure")
return OPIO({

Check warning on line 80 in apex/op/property_ops.py

View check run for this annotation

Codecov / codecov/patch

apex/op/property_ops.py#L79-L80

Added lines #L79 - L80 were not covered by tests
'output_work_path': abs_path_to_prop,
'task_names': [],
'njobs': 0,
'task_paths': []
})

inter_param_prop = inter_param
if "cal_setting" in prop_param and "overwrite_interaction" in prop_param["cal_setting"]:
Expand Down Expand Up @@ -141,6 +158,13 @@
task_names = op_in["task_names"]
path_to_prop = op_in["path_to_prop"]
inter_type = inter_param["type"]

if len(task_names) == 0:
print("Skip post property")
return OPIO({

Check warning on line 164 in apex/op/property_ops.py

View check run for this annotation

Codecov / codecov/patch

apex/op/property_ops.py#L162-L164

Added lines #L162 - L164 were not covered by tests
'retrieve_path': []
})

copy_dir_list_input = [path_to_prop.split('/')[0]]
os.chdir(input_all)
copy_dir_list = []
Expand Down
26 changes: 13 additions & 13 deletions apex/reporter/property_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,17 @@ def plotly_graph(res_data: dict, name: str, **kwargs):
c44 = elastic_tensor[3][3]
c55 = elastic_tensor[4][4]
c66 = elastic_tensor[5][5]
BV = res_data['BV']
GV = res_data['GV']
EV = res_data['EV']
uV = res_data['uV']
BV = res_data['B']
GV = res_data['G']
EV = res_data['E']
uV = res_data['u']

polar = go.Scatterpolar(
name=name,
r=[c11, c12, c13, c22, c23, c33,
c44, c55, c66, BV, GV, EV, uV],
theta=['C11', 'C12', 'C13', 'C22', 'C23', 'C33',
'C44', 'C55', 'C66', 'BV', 'GV', 'EV', 'uV'],
'C44', 'C55', 'C66', 'B', 'G', 'E', 'u'],
fill='none'
)

Expand All @@ -156,15 +156,15 @@ def plotly_graph(res_data: dict, name: str, **kwargs):
def dash_table(res_data: dict, decimal: int = 3, **kwargs) -> dash_table.DataTable:
ph = '-'
et = res_data['elastic_tensor']
BV = res_data['BV']
GV = res_data['GV']
EV = res_data['EV']
uV = res_data['uV']
BV = res_data['B']
GV = res_data['G']
EV = res_data['E']
uV = res_data['u']
null_t = [' '] * 6
BV_t = ['BV', BV, ph, ph, ph, ph]
GV_t = ['GV', GV, ph, ph, ph, ph]
EV_t = ['EV', EV, ph, ph, ph, ph]
uV_t = ['uV', uV, ph, ph, ph, ph]
BV_t = ['B', BV, ph, ph, ph, ph]
GV_t = ['G', GV, ph, ph, ph, ph]
EV_t = ['E', EV, ph, ph, ph, ph]
uV_t = ['u', uV, ph, ph, ph, ph]
table_tensor = [et[0], et[1], et[2], et[3], et[4], et[5],
null_t, BV_t, GV_t, EV_t, uV_t]

Expand Down
2 changes: 1 addition & 1 deletion examples/lammps_demo/global_bohrium.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
"run_command":"lmp -in in.lammps",
"batch_type": "Bohrium",
"context_type": "Bohrium",
"scass_type":"c16_m62_1 * NVIDIA T4"
"scass_type":"1 * NVIDIA P100_16g"
}
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="apex-flow",
version="1.2.10",
version="1.2.12",
author="Zhuoyuan Li, Tongqi Wen",
author_email="zhuoyli@outlook.com",
description="Alloy Properties EXplorer using simulations",
Expand Down Expand Up @@ -34,7 +34,7 @@
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Operating System :: OS Independent",
],
python_requires='>=3.8',
python_requires='>=3.10',
entry_points={'console_scripts': [
'apex = apex.__main__:main',
]}
Expand Down
Loading