site_state_modifier

site_state_modifier(min_neighbors=0)

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

Parameters:
min_neighbors : int

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

Notes

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:

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

Examples

def vacancy(position, radius):
    @pb.site_state_modifier
    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)
)