The Principle of DP-GEN Generating Random Structures for Bulk
· (updated ) · Machine Learning · 5
The Principle of DP-GEN Generating Random Structures for Bulk
dpgen init_bulk PARAM [MACHINE] builds the initial DeePMD-kit training dataset across four sequential stages:
- Build: Create or import a bulk crystal structure, replicate it according to
"super_cell", and optionally perform structural relaxation. - Perturb: Apply
"scale","pert_box", and"pert_atom"to generate off-equilibrium configurations inside01.scale_pert. - Explore: Run short ab initio molecular dynamics (AIMD) trajectories in VASP or ABACUS, starting from the perturbed configurations.
- Label: Extract energies, forces, and virials from the trajectories and export them in DeePMD format.
While individual stages can be omitted depending on your setup, they must be executed in order. Running only Stages 1 and 2 produces "sys_configs" (the initial structures for exploration), whereas completing all four stages also generates "init_data_sys" (the labeled initial training data). By comparison, dpgen init_surf covers only structure generation and perturbation. Once this initial dataset is prepared, dpgen run takes over to iteratively train models, explore configuration space via classical MD, and label new structures flagged by model uncertainty.
2. Mathematical notation
I use a row-vector convention in which the three lattice vectors form the rows of the $3 \times 3$ cell matrix $\mathbf{H}$:
$$
\mathbf{H} = \begin{pmatrix} \mathbf{a}1 \\ \mathbf{a}2 \\ \mathbf{a}_3 \end{pmatrix}
$$
When a unit cell $\mathbf{H}{\text{unit}}$ is replicated by `"supercell"` $= (N1, N2, N_3)$, the resulting unperturbed supercell matrix and total atom count $N$ are
$$
\mathbf{H}0 = \operatorname{diag}(N1,N2,N3)\mathbf{H}{\text{unit}}, \qquad N=N1N2N3N_{\text{unit}}
$$
For an individual atom $i$, its fractional coordinate vector $\mathbf{s}i$ and Cartesian coordinate vector $\mathbf{r}i$ (in $\text{\AA}$) are related through $\mathbf{H}$:
$$
\mathbf{r}i=\mathbf{s}i\mathbf{H}, \qquad \mathbf{s}i=\mathbf{r}i\mathbf{H}^{-1}
$$
Stacking all $N$ atoms into $N \times 3$ matrices $\mathbf{R}$ and $\mathbf{S}$ gives the compact matrix form:
$$
\mathbf{R}=\mathbf{S}\mathbf{H}, \qquad \mathbf{S}=\mathbf{R}\mathbf{H}^{-1}
$$
From $\mathbf{H}$, the cell volume $V$, atomic number density $\rhoN$, and mass density $\rhom$ follow directly:
$$
V=\lvert\det(\mathbf{H})\rvert, \qquad \rhoN=\frac{N}{V}, \qquad \rhom=\frac{\sum{i=1}^{N}mi}{V}
$$
With the reference supercell $\mathbf{H}0$ and coordinates $\mathbf{S}0, \mathbf{R}_0$ defined, we can trace how each perturbation step in Stage 2 transforms the cell and atomic positions.
3. Lattice scaling
In Stage 2 (01.scale_pert), DP-GEN iterates over "scale" (list[float]), a list of positive dimensionless scaling factors $s > 0$ (for example, $s \in \{0.96, 0.98, 1.00, 1.02, 1.04\}$). Starting from the reference supercell $\mathbf{H}0$—with reference volume $V0 = \lvert\det \mathbf{H}0\rvert$, fractional coordinates $\mathbf{s}{i,0}$, and Cartesian coordinates $\mathbf{r}{i,0} = \mathbf{s}{i,0}\mathbf{H}_0$—an isotropic scaling factor $s$ multiplies every element of the lattice matrix uniformly:
$$
\mathbf{H}(s) = s\,\mathbf{H}0 = \mathbf{H}0 (s\mathbf{I})
$$
where $\mathbf{I}$ is the $3 \times 3$ identity matrix. Geometrically, each lattice vector $\mathbf{a}_{\alpha,0}$ is stretched ($s > 1$) or compressed ($s < 1$) by the factor $s$, while all interaxial angles remain fixed.
Linear versus volumetric scaling and coordinate behavior
As reflected in the init_bulk parameter specification and output directory naming (scale-0.970, scale-1.000), each factor $s \in \text{"scale"}$ scales linear lattice dimensions rather than volume directly, while holding fractional coordinates fixed:
$$
\mathbf{s}i(s) = \mathbf{s}{i,0}
$$
Because each atom remains anchored at its exact fractional position within the cell while $\mathbf{H}(s) = s\mathbf{H}_0$, its Cartesian coordinates scale affinely by the same linear factor:
$$
\mathbf{r}i(s) = \mathbf{s}i(s)\mathbf{H}(s) = \mathbf{s}{i,0}(s\mathbf{H}0) = s\,\mathbf{r}_{i,0}
$$
Every atom therefore shifts radially away from ($s > 1$) or toward ($s < 1$) the origin, scaling all pairwise interatomic distances $r{ij} = \lVert\mathbf{r}i - \mathbf{r}j\rVert2$ in the periodic crystal linearly as $r{ij}(s) = s\,r{ij,0}$.
Since the determinant of a $3 \times 3$ matrix scales as the cube of a scalar multiplier, $\det(s\mathbf{H}0) = s^3 \det(\mathbf{H}0)$, the supercell volume and densities scale as $s^3$ and $s^{-3}$, respectively:
$$
V(s) = \lvert\det(\mathbf{H}(s))\rvert = s^3 V0, \qquad \rhoN(s) = \frac{N}{V(s)} = s^{-3}\rho{N,0}, \qquad \rhom(s) = s^{-3}\rho_{m,0}
$$
For example, a $3\%$ linear compression ($s = 0.97$) reduces the cell volume to $0.97^3 \approx 0.9127\,V_0$ and increases both atomic and mass densities by roughly $9.57\%$.
Physical information captured by compressed and expanded cells
Sampling both compressed ($s < 1$) and expanded ($s > 1$) states allows the machine-learning interatomic potential (MLIP) to learn the volumetric equation of state $E(V)$, along with its first and second derivatives—pressure $P(V)$ and bulk modulus $B(V)$:
$$
P(V)=-\frac{\partial E}{\partial V}, \qquad B(V)=V\frac{\partial^2E}{\partial V^2}
$$
- Compression ($s < 1$): Probes short-range Pauli repulsion and high-pressure stiffness, which helps prevent unphysical atomic overlap or collapse during MD simulations.
- Expansion ($s > 1$): Samples the attractive anharmonic regime, capturing bond softening, tensile stress, and thermal-expansion behavior.
- Limitation: Because isotropic scaling preserves crystal symmetry, net atomic forces remain identically zero in ideal high-symmetry crystals. Breaking symmetry via cell and atomic perturbations is therefore essential to train force predictions and shear responses.
4. Cell-vector perturbation
To break the symmetry of the isotropically scaled box and sample anisotropic strain states, DP-GEN applies a multiplicative perturbation matrix $\mathbf{P}$:
$$
\mathbf{H}'=\mathbf{H}(s)\mathbf{P}=\mathbf{H}(s)(\mathbf{I}+\boldsymbol{\varepsilon})
$$
Here, "pert_box" ($\delta_{\text{box}}$) sets the dimensionless strain amplitude. DP-GEN and dpdata construct $\boldsymbol{\varepsilon}$ slightly differently:
- DP-GEN: Draws all 9 entries of $\boldsymbol{\varepsilon}$ independently from $\mathcal{U}(-\delta{\text{box}}, +\delta{\text{box}})$, yielding a generally asymmetric perturbation matrix.
- `dpdata`: Draws 6 independent values to build a symmetric strain matrix, where diagonal entries apply normal strain and off-diagonal entries apply pure shear.
As with isotropic scaling, fractional coordinates stay fixed during cell deformation, so atomic positions transform affinely with the distorted box:
$$
\mathbf{r}i^{\text{affine}}=\mathbf{s}{i,0}\mathbf{H}'=\mathbf{r}_i(s)\mathbf{P}
$$
To first order in $\boldsymbol{\varepsilon}$, the deformed cell volume becomes
$$
V'=V(s)\lvert\det(\mathbf{P})\rvert \approx V(s)\left[1+\operatorname{Tr}(\boldsymbol{\varepsilon})\right]
$$
By introducing normal and shear deformations around every scaled volume, cell perturbations provide the training signal needed to learn anisotropic stress tensors, elastic constants, and volume-dependent mechanical responses.
5. Atomic-position perturbation
After scaling and deforming the lattice, each atom receives an independent random Cartesian displacement $\Delta\mathbf{r}_i$:
$$
\mathbf{r}i'=\mathbf{s}{i,0}\mathbf{H}'+\Delta\mathbf{r}_i
$$
In fractional coordinates, this corresponds to
$$
\mathbf{s}i'=\mathbf{r}i'(\mathbf{H}')^{-1}=\mathbf{s}{i,0}+\Delta\mathbf{r}i(\mathbf{H}')^{-1}
$$
Sampling distributions
Both DP-GEN and dpdata sample displacements directly in Cartesian units ($\text{\AA}$) rather than fractional units, ensuring that the physical perturbation amplitude remains independent of supercell size and shape.
In DP-GEN, "pert_atom" ($d_{\text{atom}}$) defines a component-wise uniform bound:
$$
\Delta xi,\Delta yi,\Delta zi\sim\mathcal{U}(-d{\text{atom}},+d_{\text{atom}})
$$
which displaces each atom inside a cube of side length $2d_{\text{atom}}$. By contrast, dpdata offers three spherically symmetric sampling distributions:
- `normal`: Isotropic Gaussian displacements where $d_{\text{atom}}$ specifies the 3D root-mean-square width (unbounded tails).
- `uniform`: Displacements distributed uniformly within a sphere of radius $d_{\text{atom}}$.
- `const`: Random displacement directions with a fixed magnitude equal to $d_{\text{atom}}$.