Modify the state (valid or invalid) of lattice sites, e.g. to create vacancies

min_neighbors : int

After modification, remove dangling sites with less than this number of neighbors.


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

state : ndarray of bool
Indicates if a lattice site is valid. Invalid sites will be removed from the model after all modifiers have been applied.
x, y, z : ndarray
Lattice site position.
sub_id : ndarray
Sublattice identifier: Can be checked for equality with sublattice names specified in Lattice. For example, state[sub_id == 'A'] = False will invalidate only sites on sublattice A.
sites : Sites
Helper object. Can be used instead of x, y, z, sub_id. See Sites.

The function must return:

A modified state argument or an ndarray of the same dtype and shape.


def vacancy(position, radius):
    def f(state, x, y):
        x0, y0 = position
        state[(x-x0)**2 + (y-y0)**2 < radius**2] = False
        return state
    return f

model = pb.Model(
    ... # lattice, shape, etc.
    vacancy(position=[0, 0], radius=0.1)