From 260f7f56852267dcc443c7ad67846e8e02f651b7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 22 Aug 2023 05:38:51 +0000 Subject: [PATCH 1/3] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.284 → v0.0.285](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.284...v0.0.285) - [github.com/asottile/blacken-docs: 1.15.0 → 1.16.0](https://github.com/asottile/blacken-docs/compare/1.15.0...1.16.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9038db4a8f..91e9935143 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,7 +33,7 @@ repos: files: \.py$ - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.0.284 + rev: v0.0.285 hooks: - id: ruff args: ["--fix"] @@ -45,7 +45,7 @@ repos: args: ["--write"] # Python inside docs - repo: https://github.com/asottile/blacken-docs - rev: 1.15.0 + rev: 1.16.0 hooks: - id: blacken-docs # C++ From ff8e7acfb5578a7e0e3a754b5f8f4442058bc5a2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 22 Aug 2023 05:39:33 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- doc/development/create-a-model.md | 10 ++-- doc/model/dprc.md | 17 ++++++- doc/third-party/out-of-deepmd-kit.md | 71 ++++++++++++++-------------- doc/train/training.md | 10 ++-- 4 files changed, 63 insertions(+), 45 deletions(-) diff --git a/doc/development/create-a-model.md b/doc/development/create-a-model.md index 69a93973aa..6634403021 100644 --- a/doc/development/create-a-model.md +++ b/doc/development/create-a-model.md @@ -16,6 +16,7 @@ After implementation, you need to register the component with a key: ```py from deepmd.descriptor import Descriptor + @Descriptor.register("some_descrpt") class SomeDescript(Descriptor): def __init__(self, arg1: bool, arg2: float) -> None: @@ -32,6 +33,7 @@ from typing import List from dargs import Argument from deepmd.utils.argcheck import descrpt_args_plugin + @descrpt_args_plugin.register("some_descrpt") def descrpt_some_args() -> List[Argument]: return [ @@ -57,11 +59,13 @@ The arguments here should be consistent with the class arguments of your new com You may use `setuptools` to package new codes into a new Python package. It's crucial to add your new component to `entry_points['deepmd']` in `setup.py`: ```py - entry_points={ - 'deepmd': [ - 'some_descrpt=deepmd_some_descrtpt:SomeDescript', +entry_points = ( + { + "deepmd": [ + "some_descrpt=deepmd_some_descrtpt:SomeDescript", ], }, +) ``` where `deepmd_some_descrtpt` is the module of your codes. It is equivalent to `from deepmd_some_descrtpt import SomeDescript`. diff --git a/doc/model/dprc.md b/doc/model/dprc.md index b665facace..284ea15ab6 100644 --- a/doc/model/dprc.md +++ b/doc/model/dprc.md @@ -57,10 +57,23 @@ As described in the paper, the DPRc model only corrects $E_\text{QM}$ and $E_\te {ref}`exclude_types ` can be generated by the following Python script: ```py from itertools import combinations_with_replacement, product + qm = (0, 1, 3, 5) mm = (2, 4) -print("QM/QM:", list(map(list, list(combinations_with_replacement(mm, 2)) + list(product(qm, mm))))) -print("QM/MM:", list(map(list, list(combinations_with_replacement(qm, 2)) + list(combinations_with_replacement(mm, 2))))) +print( + "QM/QM:", + list(map(list, list(combinations_with_replacement(mm, 2)) + list(product(qm, mm)))), +) +print( + "QM/MM:", + list( + map( + list, + list(combinations_with_replacement(qm, 2)) + + list(combinations_with_replacement(mm, 2)), + ) + ), +) ``` Also, DPRc assumes MM atom energies ({ref}`atom_ener `) are zero: diff --git a/doc/third-party/out-of-deepmd-kit.md b/doc/third-party/out-of-deepmd-kit.md index 6cd5769fbf..3d46b53578 100644 --- a/doc/third-party/out-of-deepmd-kit.md +++ b/doc/third-party/out-of-deepmd-kit.md @@ -1,35 +1,36 @@ -# Interfaces out of DeePMD-kit - -The codes of the following interfaces are not a part of the DeePMD-kit package and maintained by other repositories. We list these interfaces here for user convenience. - -## dpdata - -[dpdata](https://github.com/deepmodeling/dpdata) provides the `predict` method for `System` class: - -```py -import dpdata -dsys = dpdata.LabeledSystem('OUTCAR') -dp_sys = dsys.predict("frozen_model_compressed.pb") -``` - -By inferring with the DP model `frozen_model_compressed.pb`, dpdata will generate a new labeled system `dp_sys` with inferred energies, forces, and virials. - -## OpenMM plugin for DeePMD-kit - -An [OpenMM](https://github.com/openmm/openmm) plugin is provided from [JingHuangLab/openmm_deepmd_plugin](https://github.com/JingHuangLab/openmm_deepmd_plugin), written by the [Huang Lab](http://www.compbiophysics.org/) at Westlake University. - -## AMBER interface to DeePMD-kit - -An [AMBER](https://ambermd.org/) interface to DeePMD-kit is written by the [York [Lab](https://theory.rutgers.edu/) from Rutgers University. It is open-source at [GitLab RutgersLBSR/AmberDPRc](https://gitlab.com/RutgersLBSR/AmberDPRc/). Details can be found in [this paper](https://doi.org/10.1021/acs.jctc.1c00201). - -## DP-GEN - -[DP-GEN](https://github.com/deepmodeling/dpgen) provides a workflow to generate accurate DP models by calling DeePMD-kit's command line interface (CLI) in the local or remote server. Details can be found in [this paper](https://doi.org/10.1016/j.cpc.2020.107206). - -## MLatom - -[Mlatom](http://mlatom.com/) provides an interface to the DeePMD-kit within MLatom's workflow by calling DeePMD-kit's CLI. Details can be found in [this paper](https://doi.org/10.1007/s41061-021-00339-5). - -## ABACUS - -[ABACUS](https://github.com/deepmodeling/abacus-develop/) can run molecular dynamics with a DP model. User is required to [build ABACUS with DeePMD-kit](https://abacus.deepmodeling.com/en/latest/advanced/install.html#build-with-deepmd-kit). +# Interfaces out of DeePMD-kit + +The codes of the following interfaces are not a part of the DeePMD-kit package and maintained by other repositories. We list these interfaces here for user convenience. + +## dpdata + +[dpdata](https://github.com/deepmodeling/dpdata) provides the `predict` method for `System` class: + +```py +import dpdata + +dsys = dpdata.LabeledSystem("OUTCAR") +dp_sys = dsys.predict("frozen_model_compressed.pb") +``` + +By inferring with the DP model `frozen_model_compressed.pb`, dpdata will generate a new labeled system `dp_sys` with inferred energies, forces, and virials. + +## OpenMM plugin for DeePMD-kit + +An [OpenMM](https://github.com/openmm/openmm) plugin is provided from [JingHuangLab/openmm_deepmd_plugin](https://github.com/JingHuangLab/openmm_deepmd_plugin), written by the [Huang Lab](http://www.compbiophysics.org/) at Westlake University. + +## AMBER interface to DeePMD-kit + +An [AMBER](https://ambermd.org/) interface to DeePMD-kit is written by the [York [Lab](https://theory.rutgers.edu/) from Rutgers University. It is open-source at [GitLab RutgersLBSR/AmberDPRc](https://gitlab.com/RutgersLBSR/AmberDPRc/). Details can be found in [this paper](https://doi.org/10.1021/acs.jctc.1c00201). + +## DP-GEN + +[DP-GEN](https://github.com/deepmodeling/dpgen) provides a workflow to generate accurate DP models by calling DeePMD-kit's command line interface (CLI) in the local or remote server. Details can be found in [this paper](https://doi.org/10.1016/j.cpc.2020.107206). + +## MLatom + +[Mlatom](http://mlatom.com/) provides an interface to the DeePMD-kit within MLatom's workflow by calling DeePMD-kit's CLI. Details can be found in [this paper](https://doi.org/10.1007/s41061-021-00339-5). + +## ABACUS + +[ABACUS](https://github.com/deepmodeling/abacus-develop/) can run molecular dynamics with a DP model. User is required to [build ABACUS with DeePMD-kit](https://abacus.deepmodeling.com/en/latest/advanced/install.html#build-with-deepmd-kit). diff --git a/doc/train/training.md b/doc/train/training.md index a4afda73c2..c1e5b89a84 100644 --- a/doc/train/training.md +++ b/doc/train/training.md @@ -46,12 +46,12 @@ import matplotlib.pyplot as plt data = np.genfromtxt("lcurve.out", names=True) for name in data.dtype.names[1:-1]: - plt.plot(data['step'], data[name], label=name) + plt.plot(data["step"], data[name], label=name) plt.legend() -plt.xlabel('Step') -plt.ylabel('Loss') -plt.xscale('symlog') -plt.yscale('log') +plt.xlabel("Step") +plt.ylabel("Loss") +plt.xscale("symlog") +plt.yscale("log") plt.grid() plt.show() ``` From 124f93a11d243af6df2cbd1a07d6babd8c2400af Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Tue, 22 Aug 2023 14:51:24 -0400 Subject: [PATCH 3/3] fix E721 Do not compare types, use `isinstance()` Signed-off-by: Jinzhe Zeng --- deepmd/fit/polar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deepmd/fit/polar.py b/deepmd/fit/polar.py index 11e80c6641..0a6f7d4242 100644 --- a/deepmd/fit/polar.py +++ b/deepmd/fit/polar.py @@ -107,7 +107,7 @@ def __init__( self.scale = [1.0 for ii in range(self.ntypes)] # if self.diag_shift is None: # self.diag_shift = [0.0 for ii in range(self.ntypes)] - if type(self.sel_type) is not list: + if not isinstance(self.sel_type, list): self.sel_type = [self.sel_type] self.sel_type = sorted(self.sel_type) self.constant_matrix = np.zeros( @@ -115,7 +115,7 @@ def __init__( ) # self.ntypes x 1, store the average diagonal value # if type(self.diag_shift) is not list: # self.diag_shift = [self.diag_shift] - if type(self.scale) is not list: + if not isinstance(self.scale, list): self.scale = [self.scale for ii in range(self.ntypes)] self.scale = np.array(self.scale) self.dim_rot_mat_1 = descrpt.get_dim_rot_mat_1()