diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..86199588d7 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,136 @@ +# DeePMD-kit Contributing Guide + +Welcome to [DeePMD-kit](https://github.com/deepmodeling/deepmd-kit)! + +## What you can contribute + +You can either make a code contribution, help improve our document or offer help to other users. Your help is always appreciated. Come and have fun! + +### Code contribution +You can start from any one of the following items to help improve deepmd-kit + +- Smash a bug +- Implement a feature or add a patch, whatever you think deepmd-kit is missing +- Browse [issues](https://github.com/deepmodeling/deepmd-kit/issues), find an issue labeled enhancement or bug, and help to solve it. + +See [here](#before-you-contribute) for some before-hand heads-up. + +See [here](#how-to-contribute) to learn how to contribute. + +### Document improvement +You can start from any one of the following items to help improve [DeePMD-kit Docs](https://deepmd.readthedocs.io/en/latest/?badge=latest): + +- Fix typos or format (punctuation, space, indentation, code block, etc.) +- Fix or update inappropriate or outdated descriptions +- Add missing content (sentence, paragraph, or a new document) +- Translate docs changes from English to Chinese + +### Offer help +You can help other users of deepmd-kit in the following way + +- Submit, reply to, and resolve [issues](https://github.com/deepmodeling/deepmd-kit/issues) +- (Advanced) Review Pull Requests created by others + +## Before you contribute +### Overview of DeePMD-kit +Currently, we maintain two main branch: +- master: stable branch with version tag +- devel : branch for developers + +### Developer guide +See [here](doc/development/index.md) for coding conventions, API and other needs-to-know of the code. + +## How to contribute +Please perform the following steps to create your Pull Request to this repository. If don't like to use commands, you can also use [GitHub Desktop](https://desktop.github.com/), which is easier to get started. Go to [git documentation](https://git-scm.com/doc) if you want to really master git. + +### Step 1: Fork the repository + +1. Visit the project: +2. Click the **Fork** button on the top right and wait it to finish. + +### Step 2: Clone the forked repository to local storage and set configurations + +1. Clone your own repo, not the public repo (from deepmodeling) ! And change the branch to devel. + ```bash + git clone https://github.com/$username/deepmd-kit.git + # Replace `$username` with your GitHub ID + + git checkout devel + ``` + +2. Add deepmodeling's repo as your remote repo, we can name it "upstream". And fetch upstream's latest codes to your workstation. + ```bash + git remote add upstream https://github.com/deepmodeling/deepmd-kit.git + # After you add a remote repo, your local repo will be automatically named "origin". + + git fetch upstream + + # If your current codes are behind the latest codes, you should merge latest codes first. + # Notice you should merge from "devel"! + git merge upstream/devel + ``` + +3. Modify your codes and design unit tests. + +4. Commit your changes + ```bash + git status # Checks the local status + git add ... # Adds the file(s) you want to commit. If you want to commit all changes, you can directly use `git add.` + git commit -m "commit-message: update the xx" + ``` + +5. Push the changed codes to your original repo on github. + ```bash + git push origin devel + ``` + +### Alternatively: Create a new branch + +1. Get your local master up-to-date with upstream/master. + + ```bash + cd $working_dir/deepmd-kit + git fetch upstream + git checkout master + git rebase upstream/master + ``` + +2. Create a new branch based on the master branch. + + ```bash + git checkout -b new-branch-name + ``` + +3. Modify your codes and design unit tests. + +4. Commit your changes + + ```bash + git status # Checks the local status + git add ... # Adds the file(s) you want to commit. If you want to commit all changes, you can directly use `git add.` + git commit -m "commit-message: update the xx" + ``` + +5. Keep your branch in sync with upstream/master + + ```bash + # While on your new branch + git fetch upstream + git rebase upstream/master + ``` + +6. Push your changes to the remote + + ```bash + git push -u origin new-branch-name # "-u" is used to track the remote branch from origin + ``` + +### Step 3: Create a pull request + +1. Visit your fork at (replace `$username` with your GitHub ID) +2. Click `pull requests`, followed by `New pull request` and `Compare & pull request` to create your PR. + +Now, your PR is successfully submitted! After this PR is merged, you will automatically become a contributor to DeePMD-kit. + +## Contact us +E-mail: contact@deepmodeling.org diff --git a/README.md b/README.md index a70644f9b3..162603099a 100644 --- a/README.md +++ b/README.md @@ -19,17 +19,15 @@ DeePMD-kit is a package written in Python/C++, designed to minimize the effort r For more information, check the [documentation](https://deepmd.readthedocs.io/). -## Highlights in DeePMD-kit v2.0 - -* [Model compression](doc/use-deepmd-kit.md#compress-a-model). Accelerate the efficiency of model inference for 4-15 times. -* [New descriptors](doc/use-deepmd-kit.md#write-the-input-script). Including [`se_e2_r`](doc/train-se-e2-r.md) and [`se_e3`](doc/train-se-e3.md). +# Highlights in DeePMD-kit v2.0 +* [Model compression](doc/getting-started.md#compress-a-model). Accelerate the efficiency of model inference for 4-15 times. +* [New descriptors](doc/getting-started.md#write-the-input-script). Including [`se_e2_r`](doc/train-se-e2-r.md) and [`se_e3`](doc/train-se-e3.md). * [Hybridization of descriptors](doc/train-hybrid.md). Hybrid descriptor constructed from concatenation of several descriptors. * Atom type embedding. * Training and inference the dipole (vector) and polarizability (matrix). * Split of training and validation dataset. * Optimized training on GPUs. - ## Highlighted features * **interfaced with TensorFlow**, one of the most popular deep learning frameworks, making the training process highly automatic and efficient, in addition Tensorboard can be used to visualize training procedure. * **interfaced with high-performance classical MD and quantum (path-integral) MD packages**, i.e., LAMMPS and i-PI, respectively. @@ -62,19 +60,19 @@ One may manually install DeePMD-kit by following the instuctions on [installing # Use DeePMD-kit -The typical procedure of using DeePMD-kit includes 5 steps +The typical procedure of using DeePMD-kit includes the following steps -1. [Prepare data](doc/use-deepmd-kit.md#prepare-data) -2. [Train a model](doc/use-deepmd-kit.md#train-a-model) +1. [Prepare data](doc/getting-started.md#prepare-data) +2. [Train a model](doc/getting-started.md#train-a-model) 3. [Analyze training with Tensorboard](doc/tensorboard.md) -4. [Freeze the model](doc/use-deepmd-kit.md#freeze-a-model) -5. [Test the model](doc/use-deepmd-kit.md#test-a-model) -6. [Compress the model](doc/use-deepmd-kit.md#compress-a-model) -7. [Inference the model in python](doc/use-deepmd-kit.md#model-inference) or using the model in other molecular simulation packages like [LAMMPS](doc/use-deepmd-kit.md#run-md-with-lammps), [i-PI](doc/use-deepmd-kit.md#run-path-integral-md-with-i-pi) or [ASE](doc/use-deepmd-kit.md#use-deep-potential-with-ase). +4. [Freeze the model](doc/getting-started.md#freeze-a-model) +5. [Test the model](doc/getting-started.md#test-a-model) +6. [Compress the model](doc/getting-started.md#compress-a-model) +7. [Inference the model in python](doc/getting-started.md#model-inference) or using the model in other molecular simulation packages like [LAMMPS](doc/getting-started.md#run-md-with-lammps), [i-PI](doc/getting-started.md#run-path-integral-md-with-i-pi) or [ASE](doc/getting-started.md#use-deep-potential-with-ase). -A quick-start on using DeePMD-kit can be found [here](doc/use-deepmd-kit.md). +A quick-start on using DeePMD-kit can be found [here](doc/getting-started.md). -A full [document](doc/train-input.rst) on options in the training input script is available. +A full [document](doc/train-input-auto.rst) on options in the training input script is available. # Code structure @@ -97,13 +95,17 @@ The code is organized as follows: * `source/op`: tensorflow op implementation. working with library. - # Troubleshooting -See the [troubleshooting page](doc/troubleshooting.md). +See the [troubleshooting page](doc/troubleshooting/index.md). + + +# Contributing + +See [DeePMD-kit Contributing Guide](CONTRIBUTING.md) to become a contributor! 🤓 -[1]: http://www.global-sci.com/galley/CiCP-2017-0213.pdf +[1]: https://arxiv.org/abs/1707.01478 [2]: https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.120.143001 -[3]:https://arxiv.org/abs/1805.09003 -[4]:https://aip.scitation.org/doi/full/10.1063/1.5027645 +[3]: https://arxiv.org/abs/1805.09003 +[4]: https://aip.scitation.org/doi/full/10.1063/1.5027645 diff --git a/doc/api.rst b/doc/api.rst deleted file mode 100644 index 07377d37b3..0000000000 --- a/doc/api.rst +++ /dev/null @@ -1,91 +0,0 @@ -DeePMD-kit API -=============== - -.. toctree:: - :maxdepth: 2 - :caption: Contents: - -.. automodule:: deepmd.Data - :members: - :undoc-members: - -.. automodule:: deepmd.DataModifier - :members: - :undoc-members: - -.. automodule:: deepmd.DataSystem - :members: - :undoc-members: - -.. automodule:: deepmd.DeepDipole - :members: - :undoc-members: - -.. automodule:: deepmd.DeepEval - :members: - :undoc-members: - -.. automodule:: deepmd.DeepPolar - :members: - :undoc-members: - -.. automodule:: deepmd.DeepPot - :members: - :undoc-members: - -.. automodule:: deepmd.DeepWFC - :members: - :undoc-members: - -.. automodule:: deepmd.DescrptLocFrame - :members: - :undoc-members: - -.. automodule:: deepmd.DescrptSeA - :members: - :undoc-members: - -.. automodule:: deepmd.DescrptSeAR - :members: - :undoc-members: - -.. automodule:: deepmd.DescrptSeR - :members: - :undoc-members: - -.. automodule:: deepmd.EwaldRecp - :members: - :undoc-members: - -.. automodule:: deepmd.Fitting - :members: - :undoc-members: - -.. automodule:: deepmd.LearningRate - :members: - :undoc-members: - -.. automodule:: deepmd.cluster.local - :members: - :undoc-members: - -.. automodule:: deepmd.Loss - :members: - :undoc-members: - -.. automodule:: deepmd.model - :members: - :undoc-members: - -.. automodule:: deepmd.Network - :members: - :undoc-members: - -.. automodule:: deepmd.TabInter - :members: - :undoc-members: - -.. automodule:: deepmd.trainer - :members: - :undoc-members: - diff --git a/doc/application-examples.md b/doc/application-examples.md index 4fa2674713..bfbc9472a1 100644 --- a/doc/application-examples.md +++ b/doc/application-examples.md @@ -6,3 +6,8 @@ ## MD on different hardware platforms +There is a scheme to generate doc html from python scripts provided in the ../examples/ directory, so that each case in doc has a counter part in ../examples. + +This scheme is implemented with sphinx-gallery. + +Do we want to use this ??? diff --git a/doc/conf.py b/doc/conf.py index b757da9771..98227474d1 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -10,10 +10,51 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -# import os +import os # import sys -# sys.path.insert(0, os.path.abspath('.')) +import recommonmark +from recommonmark.transform import AutoStructify +def mkindex_troubleshooting(): + oldfindex = open("troubleshooting/index.md", "r") + _oldlist = oldfindex.readlines() + oldlist = _oldlist[4:] + oldfindex.close() + + newfindex = open("troubleshooting/index.md", "a") + for root, dirs, files in os.walk("./troubleshooting/", topdown=False): + for name in files: + if (name == "index.md"): + continue + if (name[-3:] == ".md"): + longname = "- ["+name[:-3]+"]("+name+")\n" + if (longname not in oldlist): + newfindex.write(longname) + + newfindex.close() + +def mkindex_development(): + oldfindex = open("development/index.md", "r") + _oldlist = oldfindex.readlines() + oldlist = _oldlist[2:] + oldfindex.close() + + newfindex = open("development/index.md", "a") + for root, dirs, files in os.walk("./development/", topdown=False): + for name in files: + if (name == "index.md"): + continue + if (name[-3:] == ".md"): + longname = "- ["+name[:-3]+"]("+name+")\n" + if (longname not in oldlist): + newfindex.write(longname) + else: + if (name[-4:] == ".rst"): + longname = "- ["+name[:-4]+"]("+name+")\n" + if (longname not in oldlist): + newfindex.write(longname) + + newfindex.close() # -- Project information ----------------------------------------------------- @@ -27,12 +68,25 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. +# extensions = [ +# 'recommonmark', +# "sphinx_rtd_theme", +# 'myst_parser', +# 'sphinx_markdown_tables', +# 'sphinx.ext.autosummary' +# ] + +mkindex_troubleshooting() +mkindex_development() + extensions = [ - 'recommonmark', "sphinx_rtd_theme", + 'myst_parser', 'sphinx.ext.autosummary' ] +myst_heading_anchors = 4 + # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/doc/credits.rst b/doc/credits.rst new file mode 100644 index 0000000000..0db2b58f80 --- /dev/null +++ b/doc/credits.rst @@ -0,0 +1,37 @@ +******************* +Authors and Credits +******************* + +Package Contributors +========================= + +* amacadmus +* AnguseZhang +* denghuilu +* bwang-ecnu +* frankhan91 +* GeiduanLiu +* gzq942560379 +* haidi-ustc +* hlyang1992 +* hsulab +* iProzd +* JiabinYang +* marian-code +* njzjz +* tuoping +* wsyxbcl +* y1xiaoc +* YWolfeee +* zhouwei25 +* ZiyaoLi + +Other Credits +============= + +* Zhang ZiXuan for designing the Deepmodeling logo. +* Everyone on the `Deepmodeling mailing list` for contributing to many discussions and decisions! + +(If you have contributed to the ``deepmd-kit`` core package and your name is missing, +please send an email to the contributors, or +open a pull request in the `deepmd-kit repository `_) diff --git a/doc/development/api.rst b/doc/development/api.rst new file mode 100644 index 0000000000..64c3f416e3 --- /dev/null +++ b/doc/development/api.rst @@ -0,0 +1,123 @@ +API +=== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + +.. automodule:: deepmd.utils.data + :members: + :undoc-members: + +.. automodule:: deepmd.infer.data_modifier + :members: + :undoc-members: + +.. automodule:: deepmd.utils.data_system + :members: + :undoc-members: + +.. automodule:: deepmd.infer.deep_eval + :members: + :undoc-members: + +.. automodule:: deepmd.infer.deep_polar + :members: + :undoc-members: + +.. automodule:: deepmd.infer.deep_pot + :members: + :undoc-members: + +.. automodule:: deepmd.infer.deep_wfc + :members: + :undoc-members: + +.. automodule:: deepmd.descriptor.loc_frame + :members: + :undoc-members: + +.. automodule:: deepmd.descriptor.se_a + :members: + :undoc-members: + +.. automodule:: deepmd.descriptor.se_r + :members: + :undoc-members: + +.. automodule:: deepmd.descriptor.se_ar + :members: + :undoc-members: + +.. automodule:: deepmd.descriptor.se_a_ebd + :members: + :undoc-members: + +.. automodule:: deepmd.descriptor.se_t + :members: + :undoc-members: + +.. automodule:: deepmd.descriptor.se_a_ef + :members: + :undoc-members: + +.. automodule:: deepmd.descriptor.hybrid + :members: + :undoc-members: + +.. automodule:: deepmd.infer.ewald_recp + :members: + :undoc-members: + +.. automodule:: deepmd.fit.ener + :members: + :undoc-members: + +.. automodule:: deepmd.fit.dipole + :members: + :undoc-members: + +.. automodule:: deepmd.fit.polar + :members: + :undoc-members: + +.. automodule:: deepmd.fit.wfc + :members: + :undoc-members: + +.. automodule:: deepmd.utils.network + :members: + :undoc-members: + +.. automodule:: deepmd.utils.learning_rate + :members: + :undoc-members: + +.. automodule:: deepmd.cluster.local + :members: + :undoc-members: + +.. automodule:: deepmd.cluster.slurm + :members: + :undoc-members: + +.. automodule:: deepmd.loss.ener + :members: + :undoc-members: + +.. automodule:: deepmd.loss.tensor + :members: + :undoc-members: + +.. automodule:: deepmd.model.ener + :members: + :undoc-members: + +.. automodule:: deepmd.model.tensor + :members: + :undoc-members: + +.. automodule:: deepmd.train.trainer + :members: + :undoc-members: + diff --git a/doc/developement.rst b/doc/development/coding-conventions.rst similarity index 100% rename from doc/developement.rst rename to doc/development/coding-conventions.rst diff --git a/doc/development/index.md b/doc/development/index.md new file mode 100644 index 0000000000..a2ac5eb7e2 --- /dev/null +++ b/doc/development/index.md @@ -0,0 +1,4 @@ +# Developer Guide + +- [coding-conventions](coding-conventions.rst) +- [api](api.rst) diff --git a/doc/use-deepmd-kit.md b/doc/getting-started.md similarity index 78% rename from doc/use-deepmd-kit.md rename to doc/getting-started.md index 4f77972127..a1134b7fe6 100644 --- a/doc/use-deepmd-kit.md +++ b/doc/getting-started.md @@ -1,37 +1,34 @@ -- [Use DeePMD-kit](#use-deepmd-kit) - - [Prepare data](#prepare-data) - - [Train a model](#train-a-model) - - [Freeze a model](#freeze-a-model) - - [Test a model](#test-a-model) - - [Compress a model](#compress-a-model) - - [Model inference](#model-inference) - - [Run MD with Lammps](#run-md-with-lammps) - - [Include deepmd in the pair style](#include-deepmd-in-the-pair-style) - - [Long-range interaction](#long-range-interaction) - - [Run path-integral MD with i-PI](#run-path-integral-md-with-i-pi) - - [Use deep potential with ASE](#use-deep-potential-with-ase) - -# Use DeePMD-kit +# Getting Started In this text, we will call the deep neural network that is used to represent the interatomic interactions (Deep Potential) the **model**. The typical procedure of using DeePMD-kit is -1. Prepare data -2. Train a model -3. Freeze the model -4. Test the model -5. Compress the model -6. Inference with the model +1. [Prepare data](#prepare-data) +2. [Train a model](#train-a-model) + - [Write the input script](#write-the-input-script) + - [Training](#training) + - [Training analysis with Tensorboard](#training-analysis-with-tensorboard) +3. [Freeze a model](#freeze-a-model) +4. [Test a model](#test-a-model) +5. [Compress a model](#compress-a-model) +6. [Model inference](#model-inference) +7. [Run MD](#run-md) + - [Run MD with LAMMPS](#run-md-with-lammps) + - [Run path-integral MD with i-PI](#run-path-integral-md-with-i-pi) + - [Use deep potential with ASE](#use-deep-potential-with-ase) + ## Prepare data One needs to provide the following information to train a model: the atom type, the simulation box, the atom coordinate, the atom force, system energy and virial. A snapshot of a system that contains these information is called a **frame**. We use the following convention of units: -Property| Unit ---- | :---: -Time | ps -Length | Å -Energy | eV -Force | eV/Å -Virial | eV -Pressure| Bar + +Property | Unit +---|--- +Time | ps +Length | Å +Energy | eV +Force | eV/Å +Virial | eV +Pressure | Bar + The frames of the system are stored in two formats. A raw file is a plain text file with each information item written in one file and one frame written on one line. The default files that provide box, coordinate, force, energy and virial are `box.raw`, `coord.raw`, `force.raw`, `energy.raw` and `virial.raw`, respectively. *We recommend you use these file names*. Here is an example of force.raw: ```bash @@ -89,9 +86,9 @@ DeePMD-kit implements the following descriptors: 5. [`hybrid`](train-hybrid.md): Concate a list of descriptors to form a new descriptor. The fitting of the following physical properties are supported -1. [`ener`](train-se-e2-a.md#fitting) Fitting the energy of the system. The force (derivative with atom positions) and the virial (derivative with the box tensor) can also be trained. See [the example](train-se-e2-a.md#loss). -2. `dipole` The dipole moment. -3. `polar` The polarizability. +1. [`ener`](train-se-e2-a.md#fitting): Fitting the energy of the system. The force (derivative with atom positions) and the virial (derivative with the box tensor) can also be trained. See [the example](train-se-e2-a.md#loss). +2. `dipole`: The dipole moment. +3. `polar`: The polarizability. ### Training @@ -138,7 +135,7 @@ dp train input.json If enbled in json/yaml input file DeePMD-kit will create log files which can be used to analyze training procedure with Tensorboard. For a short tutorial -please read this [document](doc/tensorboard.md). +please read this [document](tensorboard.md). ## Freeze a model @@ -252,16 +249,63 @@ e, f, v = dp.eval(coord, cell, atype) where `e`, `f` and `v` are predicted energy, force and virial of the system, respectively. -## Run MD with LAMMPS -### Include deepmd in the pair style -Running an MD simulation with LAMMPS is simpler. In the LAMMPS input file, one needs to specify the pair style as follows -```bash -pair_style deepmd graph.pb -pair_coeff +## Run MD + +### Run MD with LAMMPS +Include deepmd in the pair_style + +#### Syntax +``` +pair_style deepmd models ... keyword value ... +``` +- deepmd = style of this pair_style +- models = frozen model(s) to compute the interaction. If multiple models are provided, then the model deviation will be computed +- keyword = *out_file* or *out_freq* or *fparam* or *atomic* or *relative* +
+    out_file value = filename
+        filename = The file name for the model deviation output. Default is model_devi.out
+    out_freq value = freq
+        freq = Frequency for the model deviation output. Default is 100.
+    fparam value = parameters
+        parameters = one or more frame parameters required for model evaluation.
+    atomic = no value is required. 
+        If this keyword is set, the model deviation of each atom will be output.
+    relative value = level
+        level = The level parameter for computing the relative model deviation
+
+ +#### Examples ``` -where `graph.pb` is the file name of the frozen model. The `pair_coeff` should be left blank. It should be noted that LAMMPS counts atom types starting from 1, therefore, all LAMMPS atom type will be firstly subtracted by 1, and then passed into the DeePMD-kit engine to compute the interactions. [A detailed documentation of this pair style is available.](doc/lammps-pair-style-deepmd.md). +pair_style deepmd graph.pb +pair_style deepmd graph.pb fparam 1.2 +pair_style deepmd graph_0.pb graph_1.pb graph_2.pb out_file md.out out_freq 10 atomic relative 1.0 +``` + +#### Description +Evaluate the interaction of the system by using [Deep Potential][DP] or [Deep Potential Smooth Edition][DP-SE]. It is noticed that deep potential is not a "pairwise" interaction, but a multi-body interaction. + +This pair style takes the deep potential defined in a model file that usually has the .pb extension. The model can be trained and frozen by package [DeePMD-kit](https://github.com/deepmodeling/deepmd-kit). + +The model deviation evalulate the consistency of the force predictions from multiple models. By default, only the maximal, minimal and averge model deviations are output. If the key `atomic` is set, then the model deviation of force prediction of each atom will be output. + +By default, the model deviation is output in absolute value. If the keyword `relative` is set, then the relative model deviation will be output. The relative model deviation of the force on atom `i` is defined by +```math + |Df_i| +Ef_i = ------------- + |f_i| + level +``` +where `Df_i` is the absolute model deviation of the force on atom `i`, `|f_i|` is the norm of the the force and `level` is provided as the parameter of the keyword `relative`. + + +#### Restrictions +- The `deepmd` pair style is provided in the USER-DEEPMD package, which is compiled from the DeePMD-kit, visit the [DeePMD-kit website](https://github.com/deepmodeling/deepmd-kit) for more information. + +- The `atom_style` of the system should be `atomic`. + +- When using the `atomic` key word of `deepmd` is set, one should not use this pair style with MPI parallelization. + -### Long-range interaction +#### Long-range interaction The reciprocal space part of the long-range interaction can be calculated by LAMMPS command `kspace_style`. To use it with DeePMD-kit, one writes ```bash pair_style deepmd graph.pb @@ -271,14 +315,14 @@ kspace_modify gewald 0.45 ``` Please notice that the DeePMD does nothing to the direct space part of the electrostatic interaction, because this part is assumed to be fitted in the DeePMD model (the direct space cut-off is thus the cut-off of the DeePMD model). The splitting parameter `gewald` is modified by the `kspace_modify` command. -## Run path-integral MD with i-PI +### Run path-integral MD with i-PI The i-PI works in a client-server model. The i-PI provides the server for integrating the replica positions of atoms, while the DeePMD-kit provides a client named `dp_ipi` that computes the interactions (including energy, force and virial). The server and client communicates via the Unix domain socket or the Internet socket. The client can be started by ```bash $ dp_ipi water.json ``` It is noted that multiple instances of the client is allow for computing, in parallel, the interactions of multiple replica of the path-integral MD. -`water.json` is the parameter file for the client `dp_ipi`, and [an example](./examples/ipi/water.json) is provided: +`water.json` is the parameter file for the client `dp_ipi`, and an example is provided: ```json { "verbose": false, @@ -300,7 +344,7 @@ The option **`graph_file`** provides the file name of the frozen model. The `dp_ipi` gets the atom names from an [XYZ file](https://en.wikipedia.org/wiki/XYZ_file_format) provided by **`coord_file`** (meanwhile ignores all coordinates in it), and translates the names to atom types by rules provided by **`atom_type`**. -## Use deep potential with ASE +### Use deep potential with ASE Deep potential can be set up as a calculator with ASE to obtain potential energies and forces. ```python @@ -324,3 +368,5 @@ dyn = BFGS(water) dyn.run(fmax=1e-6) print(water.get_positions()) ``` +[DP]:https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.120.143001 +[DP-SE]:https://dl.acm.org/doi/10.5555/3327345.3327356 diff --git a/doc/index.rst b/doc/index.rst index 8c1dff0071..f38e0c6689 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -3,28 +3,58 @@ You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. +========================== DeePMD-kit's documentation -====================================== +========================== + +DeePMD-kit is a package written in Python/C++, designed to minimize the effort required to build deep learning based model of interatomic potential energy and force field and to perform molecular dynamics (MD). This brings new hopes to addressing the accuracy-versus-efficiency dilemma in molecular simulations. Applications of DeePMD-kit span from finite molecules to extended systems and from metallic systems to chemically bonded systems. + +.. Important:: The project DeePMD-kit is licensed under `GNU LGPLv3.0 `_. If you use this code in any future publications, please cite this using *Han Wang, Linfeng Zhang, Jiequn Han, and Weinan E. "DeePMD-kit: A deep learning package for many-body potential energy representation and molecular dynamics." Computer Physics Communications 228 (2018): 178-184.* + +.. _user-guide: .. toctree:: :maxdepth: 2 - :caption: Contents: - + :caption: User Guide install - use-deepmd-kit - train-input - lammps-pair-style-deepmd - novel-auxiliary-options + getting-started tensorboard - api - developement - application-examples + troubleshooting/index + + +.. _data-and-parameters: + +.. toctree:: + :maxdepth: 2 + :caption: Data and Parameters + + data-conv + train-input -Indices and tables -================== +.. _developer-guide: + +.. toctree:: + :maxdepth: 2 + :caption: Developer Guide + + development/index + + +.. _project-details: + +.. toctree:: + :maxdepth: 2 + :caption: Project Details + + license + credits + * :ref:`genindex` * :ref:`modindex` * :ref:`search` + +.. _feedback: +.. _affiliated packages: diff --git a/doc/install.md b/doc/install.md index 9cbd1653bb..7eca440dee 100644 --- a/doc/install.md +++ b/doc/install.md @@ -1,27 +1,23 @@ +# Installation + - [Easy installation methods](#easy-installation-methods) - - [Offline packages](#offline-packages) - - [With Docker](#with-docker) - - [With conda](#with-conda) -- [From source code](#from-source-code) - - [Install the python interaction](#install-the-python-interface) - - [Install the Tensorflow's python interface](#install-the-tensorflows-python-interface) - - [Install the DeePMD-kit's python interface](#install-the-deepmd-kits-python-interface) - - [Install the C++ interface](#install-the-c-interface) - - [Install the Tensorflow's C++ interface](#install-the-tensorflows-c-interface) - - [Install the DeePMD-kit's C++ interface](#install-the-deepmd-kits-c-interface) - - [Install LAMMPS's DeePMD-kit module](#install-lammpss-deepmd-kit-module) - - [Hardware platforms](#hardware-platforms) - - -# Easy installation methods +- [Install from source code](#install-from-source-code) + +## Easy installation methods + There various easy methods to install DeePMD-kit. Choose one that you prefer. If you want to build by yourself, jump to the next two sections. After your easy installation, DeePMD-kit (`dp`) and LAMMPS (`lmp`) will be available to execute. You can try `dp -h` and `lmp -h` to see the help. `mpirun` is also available considering you may want to run LAMMPS in parallel. -## Offline packages +- [Install off-line packages](#install-off-line-packages) +- [Install with conda](#install-with-conda) +- [Install with docker](#install-with-docker) + + +### Install off-line packages Both CPU and GPU version offline packages are avaiable in [the Releases page](https://github.com/deepmodeling/deepmd-kit/releases). -## With conda +### Install with conda DeePMD-kit is avaiable with [conda](https://github.com/conda/conda). Install [Anaconda](https://www.anaconda.com/distribution/#download-section) or [Miniconda](https://docs.conda.io/en/latest/miniconda.html) first. To install the CPU version: @@ -34,21 +30,21 @@ To install the GPU version containing [CUDA 10.1](https://docs.nvidia.com/deploy conda install deepmd-kit=*=*gpu lammps-dp=*=*gpu -c deepmodeling ``` -## With Docker +### Install with docker A docker for installing the DeePMD-kit is available [here](https://github.com/orgs/deepmodeling/packages/container/package/deepmd-kit). To pull the CPU version: ```bash -docker pull ghcr.io/deepmodeling/deepmd-kit:1.3.1_cpu +docker pull ghcr.io/deepmodeling/deepmd-kit:2.0.0_cpu ``` To pull the GPU version: ```bash -docker pull ghcr.io/deepmodeling/deepmd-kit:1.3.1_cuda10.1_gpu +docker pull ghcr.io/deepmodeling/deepmd-kit:2.0.0_cuda10.1_gpu ``` -# From source code +## Install from source code Please follow our [github](https://github.com/deepmodeling/deepmd-kit) webpage to download the [latest released version](https://github.com/deepmodeling/deepmd-kit/tree/master) and [development version](https://github.com/deepmodeling/deepmd-kit/tree/devel). @@ -64,10 +60,17 @@ For convenience, you may want to record the location of source to a variable, sa cd deepmd-kit deepmd_source_dir=`pwd` ``` +- [Install the python interaction](#install-the-python-interface) + - [Install the Tensorflow's python interface](#install-the-tensorflows-python-interface) + - [Install the DeePMD-kit's python interface](#install-the-deepmd-kits-python-interface) +- [Install the C++ interface](#install-the-c-interface) + - [Install the Tensorflow's C++ interface](#install-the-tensorflows-c-interface) + - [Install the DeePMD-kit's C++ interface](#install-the-deepmd-kits-c-interface) +- [Install LAMMPS's DeePMD-kit module](#install-lammpss-deepmd-kit-module) -## Install the python interface -### Install the Tensorflow's python interface +### Install the python interface +#### Install the Tensorflow's python interface First, check the python version on your machine ```bash python --version @@ -102,7 +105,7 @@ python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1 ``` One should remember to activate the virtual environment every time he/she uses deepmd-kit. -### Install the DeePMD-kit's python interface +#### Install the DeePMD-kit's python interface Execute ```bash @@ -134,11 +137,11 @@ Valid subcommands: test test the model ``` -## Install the C++ interface +### Install the C++ interface If one does not need to use DeePMD-kit with Lammps or I-Pi, then the python interface installed in the previous section does everything and he/she can safely skip this section. -### Install the Tensorflow's C++ interface +#### Install the Tensorflow's C++ interface Check the compiler version on your machine @@ -150,7 +153,7 @@ The C++ interface of DeePMD-kit was tested with compiler gcc >= 4.8. It is notic First the C++ interface of Tensorflow should be installed. It is noted that the version of Tensorflow should be in consistent with the python interface. You may follow [the instruction](install-tf.2.3.md) to install the corresponding C++ interface. -### Install the DeePMD-kit's C++ interface +#### Install the DeePMD-kit's C++ interface Now goto the source code directory of DeePMD-kit and make a build place. ```bash @@ -214,6 +217,3 @@ The DeePMD-kit module can be removed from LAMMPS source code by make no-user-deepmd ``` -## Hardware platforms - - diff --git a/doc/lammps-pair-style-deepmd.md b/doc/lammps-pair-style-deepmd.md deleted file mode 100644 index 0a39e7362c..0000000000 --- a/doc/lammps-pair-style-deepmd.md +++ /dev/null @@ -1,57 +0,0 @@ -# pair_style deepmd command - -## Syntax -``` -pair_style deepmd models ... keyword value ... -``` -- deepmd = style of this pair_style -- models = frozen model(s) to compute the interaction. If multiple models are provided, then the model deviation will be computed -- keyword = *out_file* or *out_freq* or *fparam* or *atomic* or *relative* -
-    out_file value = filename
-        filename = The file name for the model deviation output. Default is model_devi.out
-    out_freq value = freq
-        freq = Frequency for the model deviation output. Default is 100.
-    fparam value = parameters
-        parameters = one or more frame parameters required for model evaluation.
-    atomic = no value is required. 
-        If this keyword is set, the model deviation of each atom will be output.
-    relative value = level
-        level = The level parameter for computing the relative model deviation
-
- -## Examples -``` -pair_style deepmd graph.pb -pair_style deepmd graph.pb fparam 1.2 -pair_style deepmd graph_0.pb graph_1.pb graph_2.pb out_file md.out out_freq 10 atomic relative 1.0 -``` - -## Description - -Evaluate the interaction of the system by using [Deep Potential][DP] or [Deep Potential Smooth Edition][DP-SE]. It is noticed that deep potential is not a "pairwise" interaction, but a multi-body interaction. - -This pair style takes the deep potential defined in a model file that usually has the .pb extension. The model can be trained and frozen by package [DeePMD-kit](https://github.com/deepmodeling/deepmd-kit). - -The model deviation evalulate the consistency of the force predictions from multiple models. By default, only the maximal, minimal and averge model deviations are output. If the key `atomic` is set, then the model deviation of force prediction of each atom will be output. - -By default, the model deviation is output in absolute value. If the keyword `relative` is set, then the relative model deviation will be output. The relative model deviation of the force on atom `i` is defined by -```math - |Df_i| -Ef_i = ------------- - |f_i| + level -``` -where `Df_i` is the absolute model deviation of the force on atom `i`, `|f_i|` is the norm of the the force and `level` is provided as the parameter of the keyword `relative`. - - -## Restrictions - -- The `deepmd` pair style is provided in the USER-DEEPMD package, which is compiled from the DeePMD-kit, visit the [DeePMD-kit website](https://github.com/deepmodeling/deepmd-kit) for more information. - -- The `atom_style` of the system should be `atomic`. - -- When using the `atomic` key word of `deepmd` is set, one should not use this pair style with MPI parallelization. - - -[DP]:https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.120.143001 -[DP-SE]:https://arxiv.org/abs/1805.09003 diff --git a/doc/license.rst b/doc/license.rst new file mode 100644 index 0000000000..366102905e --- /dev/null +++ b/doc/license.rst @@ -0,0 +1,5 @@ + +License +================== + +The project DeePMD-kit is licensed under `GNU LGPLv3.0 `_. diff --git a/doc/novel-auxiliary-options.md b/doc/novel-auxiliary-options.md deleted file mode 100644 index 9e92382d10..0000000000 --- a/doc/novel-auxiliary-options.md +++ /dev/null @@ -1,17 +0,0 @@ -# Novel Auxiliary Options -## Type embedding -Instead of training embedding net for each atom pair (regard as G_ij, and turns out to be N^2 networks), we now share a public embedding net (regard as G) and present each atom with a special vector, named as type embedding (v_i). So, our algorithm for generating a description change from G_ij(s_ij) to G(s_ij, v_i, v_j). -1. We obtain the type embedding by a small embedding net, projecting atom type to embedding vector. -2. As for the fitting net, we fix the type embedding and replace individual fitting net with shared fitting net. (while adding type embedding information to its input) - -### Training hyper-parameter -descriptor: -"type" : "se_a_ebd" # for applying share embedding algorithm -"type_filter" : list # network architecture of the small embedding net, which output type embedding -"type_one_side" : bool # when generating descriptor, whether use the centric atom type embedding (true: G(s_ij, v_i, v_j), false: G(s_ij, v_j)) - -fitting_net: -"share_fitting" : bool # if applying share fitting net, set true - - -## Interpolation with tabulated pair potentials diff --git a/doc/tensorboard.md b/doc/tensorboard.md index fdc2b00760..dafbdffb2c 100644 --- a/doc/tensorboard.md +++ b/doc/tensorboard.md @@ -1,4 +1,4 @@ -# DeePMD-kit TensorBoard usage +# TensorBoard Usage TensorBoard provides the visualization and tooling needed for machine learning experimentation. A full instruction of tensorboard can be found diff --git a/doc/train-input.rst b/doc/train-input.rst index aa6c7bd01e..0a12239597 100644 --- a/doc/train-input.rst +++ b/doc/train-input.rst @@ -1,3 +1,3 @@ -Training parameters +Training Parameters ====================================== .. include:: train-input-auto.rst diff --git a/doc/troubleshooting.md b/doc/troubleshooting.md deleted file mode 100644 index afdcdf9985..0000000000 --- a/doc/troubleshooting.md +++ /dev/null @@ -1,37 +0,0 @@ -# Troubleshooting -In consequence of various differences of computers or systems, problems may occur. Some common circumstances are listed as follows. -If other unexpected problems occur, you're welcome to contact us for help. - -## Model compatability - -When the version of DeePMD-kit used to training model is different from the that of DeePMD-kit running MDs, one has the problem of model compatability. - -DeePMD-kit guarantees that the codes with the same major and minor revisions are compatible. That is to say v0.12.5 is compatible to v0.12.0, but is not compatible to v0.11.0 nor v1.0.0. - -## Installation: inadequate versions of gcc/g++ -Sometimes you may use a gcc/g++ of version <4.9. If you have a gcc/g++ of version > 4.9, say, 7.2.0, you may choose to use it by doing -```bash -export CC=/path/to/gcc-7.2.0/bin/gcc -export CXX=/path/to/gcc-7.2.0/bin/g++ -``` - -If, for any reason, for example, you only have a gcc/g++ of version 4.8.5, you can still compile all the parts of TensorFlow and most of the parts of DeePMD-kit. i-Pi will be disabled automatically. - -## Installation: build files left in DeePMD-kit -When you try to build a second time when installing DeePMD-kit, files produced before may contribute to failure. Thus, you may clear them by -```bash -cd build -rm -r * -``` -and redo the `cmake` process. - -## MD: cannot run LAMMPS after installing a new version of DeePMD-kit -This typically happens when you install a new version of DeePMD-kit and copy directly the generated `USER-DEEPMD` to a LAMMPS source code folder and re-install LAMMPS. - -To solve this problem, it suffices to first remove `USER-DEEPMD` from LAMMPS source code by -```bash -make no-user-deepmd -``` -and then install the new `USER-DEEPMD`. - -If this does not solve your problem, try to decompress the LAMMPS source tarball and install LAMMPS from scratch again, which typically should be very fast. diff --git a/doc/troubleshooting/index.md b/doc/troubleshooting/index.md new file mode 100644 index 0000000000..04e7b31812 --- /dev/null +++ b/doc/troubleshooting/index.md @@ -0,0 +1,7 @@ +# Troubleshooting +In consequence of various differences of computers or systems, problems may occur. Some common circumstances are listed as follows. +If other unexpected problems occur, you're welcome to contact us for help. + +- [installation](installation.md) +- [md-version-compatibility](md-version-compatibility.md) +- [model-compatability](model-compatability.md) diff --git a/doc/troubleshooting/installation.md b/doc/troubleshooting/installation.md new file mode 100644 index 0000000000..6b2a7caf3f --- /dev/null +++ b/doc/troubleshooting/installation.md @@ -0,0 +1,17 @@ +# Installation +## Inadequate versions of gcc/g++ +Sometimes you may use a gcc/g++ of version <4.9. If you have a gcc/g++ of version > 4.9, say, 7.2.0, you may choose to use it by doing +```bash +export CC=/path/to/gcc-7.2.0/bin/gcc +export CXX=/path/to/gcc-7.2.0/bin/g++ +``` + +If, for any reason, for example, you only have a gcc/g++ of version 4.8.5, you can still compile all the parts of TensorFlow and most of the parts of DeePMD-kit. i-Pi will be disabled automatically. + +## Build files left in DeePMD-kit +When you try to build a second time when installing DeePMD-kit, files produced before may contribute to failure. Thus, you may clear them by +```bash +cd build +rm -r * +``` +and redo the `cmake` process. diff --git a/doc/troubleshooting/md-version-compatibility.md b/doc/troubleshooting/md-version-compatibility.md new file mode 100644 index 0000000000..dfc2e3abc2 --- /dev/null +++ b/doc/troubleshooting/md-version-compatibility.md @@ -0,0 +1,10 @@ +# MD: cannot run LAMMPS after installing a new version of DeePMD-kit +This typically happens when you install a new version of DeePMD-kit and copy directly the generated `USER-DEEPMD` to a LAMMPS source code folder and re-install LAMMPS. + +To solve this problem, it suffices to first remove `USER-DEEPMD` from LAMMPS source code by +```bash +make no-user-deepmd +``` +and then install the new `USER-DEEPMD`. + +If this does not solve your problem, try to decompress the LAMMPS source tarball and install LAMMPS from scratch again, which typically should be very fast. diff --git a/doc/troubleshooting/model-compatability.md b/doc/troubleshooting/model-compatability.md new file mode 100644 index 0000000000..3ae1338cc9 --- /dev/null +++ b/doc/troubleshooting/model-compatability.md @@ -0,0 +1,5 @@ +# Model compatability + +When the version of DeePMD-kit used to training model is different from the that of DeePMD-kit running MDs, one has the problem of model compatability. + +DeePMD-kit guarantees that the codes with the same major and minor revisions are compatible. That is to say v0.12.5 is compatible to v0.12.0, but is not compatible to v0.11.0 nor v1.0.0. diff --git a/setup.py b/setup.py index 5f7f2fa8bc..70aa026248 100644 --- a/setup.py +++ b/setup.py @@ -107,7 +107,7 @@ cmake_minimum_required_version="3.0", extras_require={ "test": ["dpdata>=0.1.9", "ase", "pytest", "pytest-cov", "pytest-sugar"], - "docs": ["sphinx", "recommonmark", "sphinx_rtd_theme"], + "docs": ["sphinx", "recommonmark", "sphinx_rtd_theme", "sphinx_markdown_tables", "myst-parser"], **extras_require, }, entry_points={"console_scripts": ["dp = deepmd.entrypoints.main:main"]},