diff --git a/deepmd/nvnmd/entrypoints/wrap.py b/deepmd/nvnmd/entrypoints/wrap.py index 2e38c0d16d..d7a35b7a9f 100644 --- a/deepmd/nvnmd/entrypoints/wrap.py +++ b/deepmd/nvnmd/entrypoints/wrap.py @@ -19,8 +19,10 @@ class Wrap(): the model file can be use to run the NVNMD with lammps the pair style need set as: - | :code:`pair_style nvnmd model.pb` - | :code:`pair_coeff * *` + .. code-block:: lammps + + pair_style nvnmd model.pb + pair_coeff * * Parameters ---------- diff --git a/doc/model/dplr.md b/doc/model/dplr.md index 14db3facfc..4661cbcdf7 100644 --- a/doc/model/dplr.md +++ b/doc/model/dplr.md @@ -53,7 +53,7 @@ The training of the DPLR model is very similar to the standard short-range DP mo ``` The {ref}`model_name ` specifies which DW model is used to predict the position of WCs. {ref}`model_charge_map ` gives the amount of charge assigned to WCs. {ref}`sys_charge_map ` provides the nuclear charge of oxygen (type 0) and hydrogen (type 1) atoms. {ref}`ewald_beta ` (unit $\text{Å}^{-1}$) gives the spread parameter controls the spread of Gaussian charges, and {ref}`ewald_h ` (unit Å) assigns the grid size of Fourier transform. The DPLR model can be trained and frozen by (from the example directory) -``` +```bash dp train ener.json && dp freeze -o ener.pb ``` @@ -108,7 +108,7 @@ An example input script is provided in $deepmd_source_dir/examples/water/dplr/lmp/in.lammps ``` Here are some explanations -``` +```lammps # groups of real and virtual atoms group real_atom type 1 2 group virtual_atom type 3 @@ -124,7 +124,7 @@ special_bonds lj/coul 1 1 1 angle no ``` Type 1 and 2 (O and H) are `real_atom`s, while type 3 (WCs) are `virtual_atom`s. The model file `ener.pb` stores both the DW and DPLR models, so the position of WCs and the energy can be inferred from it. A virtual bond type is specified by `bond_style zero`. The `special_bonds` command switches off the exclusion of intramolecular interactions. -``` +```lammps # kspace_style "pppm/dplr" should be used. in addition the # gewald(1/distance) should be set the same as that used in # training. Currently only ik differentiation is supported. @@ -133,7 +133,7 @@ kspace_modify gewald ${BETA} diff ik mesh ${KMESH} ${KMESH} ${KMESH} ``` The long-range part is calculated by the `kspace` support of LAMMPS. The `kspace_style` `pppm/dplr` is required. The spread parameter set by variable `BETA` should be set the same as that used in training. The `KMESH` should be set dense enough so the long-range calculation is converged. -``` +```lammps # "fix dplr" set the position of the virtual atom, and spread the # electrostatic interaction asserting on the virtual atom to the real # atoms. "type_associate" associates the real atom type its @@ -144,7 +144,7 @@ fix_modify 0 virial yes ``` The fix command `dplr` calculates the position of WCs by the DW model and back-propagates the long-range interaction on virtual atoms to real toms. -``` +```lammps # compute the temperature of real atoms, excluding virtual atom contribution compute real_temp real_atom temp compute real_press all pressure real_temp @@ -152,12 +152,12 @@ fix 1 real_atom nvt temp ${TEMP} ${TEMP} ${TAU_T} fix_modify 1 temp real_temp ``` The temperature of the system should be computed from the real atoms. The kinetic contribution in the pressure tensor is also computed from the real atoms. The thermostat is applied to only real atoms. The computed temperature and pressure of real atoms can be accessed by, e.g. -``` +```lammps fix thermo_print all print ${THERMO_FREQ} "$(step) $(pe) $(ke) $(etotal) $(enthalpy) $(c_real_temp) $(c_real_press) $(vol) $(c_real_press[1]) $(c_real_press[2]) $(c_real_press[3])" append thermo.out screen no title "# step pe ke etotal enthalpy temp press vol pxx pyy pzz" ``` The LAMMPS simulation can be started from the example directory by -``` +```bash lmp -i in.lammps ``` If LAMMPS complains that no model file `ener.pb` exists, it can be copied from the training example directory. diff --git a/doc/third-party/lammps-command.md b/doc/third-party/lammps-command.md index c021837993..84eb5f5b99 100644 --- a/doc/third-party/lammps-command.md +++ b/doc/third-party/lammps-command.md @@ -4,7 +4,7 @@ If you are using the plugin mode, enable DeePMD-kit package in LAMMPS with `plugin` command: -``` +```lammps plugin load libdeepmd_lmp.so ``` @@ -22,7 +22,7 @@ The built-in mode doesn't need this step. The DeePMD-kit package provides the pair_style `deepmd` -``` +```lammps pair_style deepmd models ... keyword value ... ``` - deepmd = style of this pair_style @@ -44,7 +44,7 @@ and the model deviation will be computed among all models every `out_freq` times ### Examples -``` +```lammps 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 @@ -71,7 +71,7 @@ where $D_{f_i}$ is the absolute model deviation of the force on atom $i$, $f_i$ The DeePMD-kit package provide the compute `deeptensor/atom` for computing atomic tensorial properties. -``` +```lammps compute ID group-ID deeptensor/atom model_file ``` - ID: user-assigned name of the computation @@ -80,11 +80,11 @@ compute ID group-ID deeptensor/atom model_file - model_file: the name of the binary model file. ### Examples -``` +```lammps compute dipole all deeptensor/atom dipole.pb ``` The result of the compute can be dump to trajctory file by -``` +```lammps dump 1 all custom 100 water.dump id type c_dipole[1] c_dipole[2] c_dipole[3] ``` @@ -94,7 +94,7 @@ dump 1 all custom 100 water.dump id type c_dipole[1] c_dipole[2] c_di ## 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 +```lammps pair_style deepmd graph.pb pair_coeff * * kspace_style pppm 1.0e-5 @@ -111,13 +111,13 @@ $$dvatom=\sum_{m}( \mathbf{r}_n- \mathbf{r}_m) \frac{de_m}{d\mathbf{r}_n}$$ Where $\mathbf{r}_n$ is the atomic position of nth atom, $\mathbf{v}_n$ velocity of atom and $\frac{de_m}{d\mathbf{r}_n}$ the derivative of the atomic energy. In LAMMPS one can get the per-atom stress using the command `centroid/stress/atom`: -```bash +```lammps compute ID group-ID centroid/stress/atom NULL virial ``` see [LAMMPS doc page](https://docs.lammps.org/compute_stress_atom.html#thompson2) for more detailes on the meaning of the keywords. ### Examples In order of computing the 9-component per-atom stress -```bash +```lammps compute stress all centroid/stress/atom NULL virial ``` Thus `c_stress` is an array with 9 component in the order `xx,yy,zz,xy,xz,yz,yx,zx,zy`. @@ -130,7 +130,7 @@ Using per-atom stress tensor one can, for example, compute the heat flux defined $$\mathbf J = \sum_n e_n \mathbf v_n + \sum_{n,m} ( \mathbf r_m- \mathbf r_n) \frac{de_m}{d\mathbf r_n} \mathbf v_n$$ to compute the heat flux with LAMMPS: -```bash +```lammps compute ke_ID all ke/atom compute pe_ID all pe/atom compute stress_ID group-ID centroid/stress/atom NULL virial @@ -139,7 +139,7 @@ compute flux_ID all heat/flux ke_ID pe_ID stress_ID ### Examples -```bash +```lammps compute ke all ke/atom compute pe all pe/atom compute stress all centroid/stress/atom NULL virial diff --git a/doc/third-party/lammps.md b/doc/third-party/lammps.md index 78c6fc060e..0dc092c9e9 100644 --- a/doc/third-party/lammps.md +++ b/doc/third-party/lammps.md @@ -2,7 +2,7 @@ Running an MD simulation with LAMMPS is simpler. In the LAMMPS input file, one needs to specify the pair style as follows -``` +```lammps pair_style deepmd graph.pb pair_coeff * * ``` diff --git a/setup.py b/setup.py index 3df4476085..4b0ffc5e4f 100644 --- a/setup.py +++ b/setup.py @@ -155,6 +155,7 @@ "deepmodeling-sphinx>=0.1.0", "dargs>=0.3.1", "sphinx-argparse", + "pygments-lammps", ], **extras_require, },