site_state_modifier¶
- site_state_modifier(min_neighbors: int = 0) partial ¶
Modify the state (valid or invalid) of lattice sites, e.g. to create vacancies
- Parameters:
- min_neighborsint
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:
- statendarray 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, zndarray
Lattice site position.
- sub_id
support.alias.AliasIndex
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
. SeeSites
.
The function must return:
- ndarray
A modified
state
argument or anndarray
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) )