Solid–liquid classification#
find_solids labels each atom as solid or liquid.
It compares the orientation of the neighbor shell of an atom with those of its neighbors, using the vectors \(q_{6m}\) of the Steinhardt parameters [1, 2].
In a crystal, neighboring atoms have similar neighbor shells, and in a liquid they do not.
find_clusters then groups the solid atoms, or any other selection of atoms, into connected clusters.
Together they are used to follow crystal nucleation and growth, for example by measuring the size of the largest crystalline cluster in a liquid.
The disorder parameter is built from the same comparison, and the entropy parameter and the averaged Steinhardt parameters are other ways to separate solid from liquid.
Definition#
For each atom \(i\), the vector \(q_{lm}(i)\), \(m = -l, \dots, l\), is the average of the spherical harmonics over the bonds to its neighbors, as defined in Steinhardt parameters. The bond correlation between atom \(i\) and its neighbor \(j\) is the normalised scalar product of their vectors:
where the asterisk denotes the complex conjugate. \(s_{ij}\) lies between \(-1\) and 1, and it is 1 when the neighbor shells of \(i\) and \(j\) have the same orientation. pyscal uses \(l = 6\) by default.
A bond is solid if \(s_{ij}\) is larger than a threshold \(s_\mathrm{c}\). Atom \(i\) is solid if both of the following hold:
The number \(n_\mathrm{s}(i)\) of its solid bonds is larger than a minimum \(n_\mathrm{c}\), or the fraction \(n_\mathrm{s}(i) / N(i)\) is larger than a minimum \(f_\mathrm{c}\), where \(N(i)\) is the number of neighbors of \(i\) [1].
The average bond correlation is larger than a second threshold \(\bar{s}_\mathrm{c}\) [2]:
The second condition improves the classification at the boundary between solid and liquid [2]. All comparisons are strict.
Two solid atoms belong to the same cluster if they are connected by a chain of neighbor bonds between solid atoms.
Usage#
Find the neighbors first, then classify the atoms:
import pyscal
from ase.io import read
atoms = read("conf.fcc.dump", format="lammps-dump-text")
pyscal.find_neighbors(atoms, method="cutoff", cutoff=0)
largest = pyscal.find_solids(atoms, bonds=0.5, threshold=0.5, avgthreshold=0.6)
largest
1005
The arguments are those of the definition:
Argument |
Default |
Meaning |
|---|---|---|
|
6 |
the order \(l\) of the vectors \(q_{lm}\) |
|
0.5 |
\(s_\mathrm{c}\), a bond is solid if \(s_{ij} >\) |
|
0.5 |
an |
|
0.6 |
\(\bar{s}_\mathrm{c}\) |
|
|
cluster the solid atoms and return the size of the largest cluster |
|
0 |
the cluster cutoff, see below |
|
|
with |
With cluster=True, find_solids returns the number of atoms in the largest solid cluster, and None otherwise.
It stores these keys on atoms:
Key |
Shape |
Content |
|---|---|---|
|
\((N,)\) |
1.0 for solid atoms, 0.0 for liquid atoms |
|
\((N,)\) |
number of solid bonds \(n_\mathrm{s}(i)\) |
|
\((N,)\) |
\(\langle s_{ij} \rangle\) |
|
\((N, k)\), or a list of lists |
\(s_{ij}\) for each neighbor, in the order of the neighbor list |
|
\((N,)\), \((N, 13)\) |
\(q_6\) and the parts of \(q_{6m}\), as in Steinhardt parameters |
|
\((N,)\) |
cluster number, starting at 1, and \(-1\) for liquid atoms |
|
\((N,)\) |
|
pyscal_sij is in atoms.arrays when every atom has the same number \(k\) of neighbors, and in atoms.info otherwise.
The two cluster keys are written only with cluster=True.
find_clusters clusters any selection of atoms.
It takes one boolean per atom and stores the same two cluster keys:
solid = atoms.arrays["pyscal_solid"] > 0
pyscal.find_clusters(atoms, condition=solid)
1005
By default, clusters follow every bond of the neighbor list.
With cutoff \(r > 0\), in find_solids or find_clusters, only bonds shorter than or equal to \(r\) are followed.
Separating solid and liquid#
How well do the default thresholds separate solid from liquid atoms?
We classify three MD snapshots from the examples folder: an fcc crystal and a bcc crystal at finite temperature, and a liquid.
import numpy as np
snapshots = {
"fcc": read("conf.fcc.dump", format="lammps-dump-text"),
"bcc": read("conf.bcc.dump", format="lammps-dump-text"),
"liquid": read("conf.lqd.Al.dump", format="lammps-dump-text"),
}
results = {}
for name, snapshot in snapshots.items():
pyscal.find_neighbors(snapshot, method="cutoff", cutoff=0)
pyscal.find_solids(snapshot, cluster=False)
n_neighbors = np.diff(snapshot.info["pyscal_bond_offsets"])
sij = snapshot.arrays.get("pyscal_sij", snapshot.info.get("pyscal_sij"))
results[name] = {
"sij": np.concatenate([np.asarray(row) for row in sij]),
"fraction": snapshot.arrays["pyscal_bonds"] / n_neighbors,
"average": snapshot.arrays["pyscal_avg_sij"],
"solid": snapshot.arrays["pyscal_solid"] > 0,
}
The dashed lines mark the default thresholds. Panel (a) shows that most bonds in the crystals have \(s_{ij}\) close to 1. In the liquid, \(s_{ij}\) is spread over a wide range, and 17 % of the bonds are solid bonds. A single solid bond therefore says little. Panel (b) shows the fraction of solid bonds of each atom, which is larger than 0.5 for only np.float64(2.4) % of the liquid atoms. Panel (c) shows the average \(\langle s_{ij} \rangle\). Its largest value in the liquid is np.float64(0.56), below the threshold of 0.6, and only 3 atoms of the two crystals lie below the threshold.
With both conditions, 1005 of the 1008 fcc atoms, all 1024 bcc atoms and none of the 500 liquid atoms are labelled solid.
A crystal nucleus in a liquid#
find_solids is most often used for a crystal that grows from its liquid.
As a model, we take the liquid aluminium snapshot, repeated twice in each direction, and replace its centre by a sphere of fcc aluminium with a radius of 9 Å.
The liquid atoms are removed up to 10 Å from the centre, so that liquid and crystal atoms do not overlap.
The crystal atoms get random displacements with a standard deviation of 0.15 Å in each direction, a rough model of thermal vibrations.
from ase.build import bulk
liquid = read("conf.lqd.Al.dump", format="lammps-dump-text").repeat(2)
liquid.wrap()
centre = liquid.cell.lengths() / 2
radius = 9.0
crystal = bulk("Al", "fcc", a=4.05, cubic=True).repeat(6)
crystal.positions += centre - crystal.cell.lengths() / 2
crystal = crystal[np.linalg.norm(crystal.positions - centre, axis=1) < radius]
crystal.rattle(0.15, seed=1)
liquid = liquid[np.linalg.norm(liquid.positions - centre, axis=1) > radius + 1.0]
system = liquid + crystal
inserted = np.arange(len(system)) >= len(liquid)
pyscal.find_neighbors(system, method="cutoff", cutoff=0)
pyscal.find_solids(system)
153
The system has 3968 atoms, 177 of them in the crystal. The largest solid cluster has 153 atoms. No liquid atom is labelled solid, and the 24 crystal atoms labelled liquid all lie more than np.float64(8.3) Å from the centre, at the surface of the sphere.
Panel (a) shows the atoms within 2 Å of a plane through the centre, and the dashed circle marks the surface of the crystal. Panel (b) shows the fraction of atoms labelled solid in shells 1 Å thick around the centre. The shells between 1 and 2 Å and between 9 and 10 Å contain no atoms. Every crystal atom within 8 Å of the centre is labelled solid, but only 41 % of the crystal atoms farther out. These atoms at the surface have many liquid neighbors, and they fail the conditions. The classification therefore places the boundary of the crystal slightly inside its true surface.
find_clusters works with any condition.
For example, the cluster of atoms with an averaged Steinhardt parameter \(\bar{q}_6 > 0.4\):
q6_averaged = pyscal.steinhardt_parameter(system, l=6, averaged=True)[0]
pyscal.find_clusters(system, condition=q6_averaged > 0.4)
133
With 133 atoms, this cluster is smaller than the one from find_solids.
\(\bar{q}_6\) averages over the neighbors of an atom, and near the surface these include liquid atoms.
Things to watch#
bondsis a number or a fraction. Anintis a number of bonds and afloatis a fraction. The comparison is strict.bonds=6requires at least 7 solid bonds, andbonds=1.0labels no atom as solid.The thresholds depend on the neighbors. \(s_{ij}\) is computed from the \(q_{lm}\) of the current neighbor list, and the distributions above change with the neighbor method. In the model of a nucleus above, SANN neighbors instead of the adaptive cutoff label 7 liquid atoms as solid, and the largest cluster has 138 atoms instead of 153. Check the distributions, as in the figure above, before using the default thresholds for a new system.
Interfaces. Atoms at the surface of a crystal are often labelled liquid. Cluster sizes are therefore smaller than the number of atoms in the crystal.
The cluster cutoff only removes bonds. Clusters follow the bonds of the neighbor list. A cluster cutoff larger than the neighbor cutoff adds no bonds.
Stored \(q_6\).
find_solidsrecomputes \(q_{6m}\) from the current neighbors and overwritespyscal_q6,pyscal_q6_realandpyscal_q6_imag.
References#
S. Auer and D. Frenkel, Numerical simulation of crystal nucleation in colloids, in Advanced Computer Simulation, edited by C. Holm and K. Kremer, Advances in Polymer Science, pp. 149–208 (Springer, Berlin, 2005). doi:10.1007/b99429
J. Bokeloh, G. Wilde, R. E. Rozas, R. Benjamin and J. Horbach, Nucleation barriers for the liquid-to-crystal transition in simple metals: Experiment vs. simulation, Eur. Phys. J. Spec. Top. 223, 511 (2014). doi:10.1140/epjst/e2014-02106-2