Skip to content
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
6 changes: 5 additions & 1 deletion doc/model/dplr.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ fix ID group-ID style_name keyword value ...
- three or more keyword/value pairs may be appended

```
keyword = *model* or *type_associate* or *bond_type* or *efield*
keyword = *model* or *type_associate* or *bond_type* or *efield* or *pair_deepmd_index*
*model* value = name
name = name of DPLR model file (e.g. frozen_model.pb) (not DW model)
*type_associate* values = NR1 NW1 NR2 NW2 ...
Expand All @@ -208,6 +208,8 @@ keyword = *model* or *type_associate* or *bond_type* or *efield*
NBi = bond type of i-th (real atom, Wannier centroid) pair
*efield* (optional) values = Ex Ey Ez
Ex/Ey/Ez = electric field along x/y/z direction
*pair_deepmd_index* (optional) values = idx
idx = The index of pair_style deepmd, starting from 1, if more than one is used
```

**Examples**
Expand All @@ -223,6 +225,8 @@ 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.
The fix command must be used after [pair_style `deepmd`](../third-party/lammps-command.md#pair_style-deepmd).
If there are more than 1 pair_style `deepmd`, `pair_deepmd_index` (starting from 1) must be set to assign the index of the pair_style `deepmd`.
The atom names specified in [pair_style `deepmd`](../third-party/lammps-command.md#pair_style-deepmd) will be used to determine elements.
If it is not set, the training parameter {ref}`type_map <model/type_map>` will be mapped to LAMMPS atom types.

Expand Down
9 changes: 8 additions & 1 deletion source/lmp/fix_dplr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ FixDPLR::FixDPLR(LAMMPS *lmp, int narg, char **arg)
size_vector = 3;
qe2f = force->qe2f;
xstyle = ystyle = zstyle = NONE;
pair_deepmd_index = 0;
Comment thread
wanghan-iapcm marked this conversation as resolved.

if (strcmp(update->unit_style, "lj") == 0) {
error->all(FLERR,
Expand Down Expand Up @@ -125,6 +126,12 @@ FixDPLR::FixDPLR(LAMMPS *lmp, int narg, char **arg)
}
sort(bond_type.begin(), bond_type.end());
iarg = iend;
} else if (string(arg[iarg]) == string("pair_deepmd_index")) {
if (iarg + 1 >= narg) {
error->all(FLERR, "Illegal pair_deepmd_index, not provided");
}
pair_deepmd_index = atoi(arg[iarg + 1]);
iarg += 2;
} else {
break;
}
Expand All @@ -141,7 +148,7 @@ FixDPLR::FixDPLR(LAMMPS *lmp, int narg, char **arg)
error->one(FLERR, e.what());
}

pair_deepmd = (PairDeepMD *)force->pair_match("deepmd", 1);
pair_deepmd = (PairDeepMD *)force->pair_match("deepmd", 1, pair_deepmd_index);
if (!pair_deepmd) {
error->all(FLERR, "pair_style deepmd should be set before this fix\n");
}
Expand Down
3 changes: 3 additions & 0 deletions source/lmp/fix_dplr.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class FixDPLR : public Fix {
void update_efield_variables();
enum { NONE, CONSTANT, EQUAL };
std::vector<int> type_idx_map;
/* The index of deepmd pair index, which starts from 1. By default 0, which
* works only when there is one deepmd pair. */
int pair_deepmd_index;
};
} // namespace LAMMPS_NS

Expand Down