Modify the position of lattice sites, e.g. to apply geometric deformations


The function parameters must be a combination of any number of the following:

x, y, z : ndarray
Lattice site position.
sub_id : ndarray of int
Sublattice identifier: can be checked for equality with sublattice names specified in Lattice. For example, x[sub_id == 'A'] += 0.1 will only displace sites on sublattice A.
sites : Sites
Helper object. Can be used instead of x, y, z, sub_id. See Sites.

The function must return:

tuple of ndarray
Modified ‘x, y, z’ arguments or 3 ndarray objects of the same dtype and shape.


def triaxial_displacement(c):
    def displacement(x, y, z):
        ux = 2*c * x*y
        uy = c * (x**2 - y**2)
        return x + ux, y + uy, z
    return displacement

model = pb.Model(
    ... # lattice, shape, etc.