onsite_energy_modifier¶
-
onsite_energy_modifier
(is_double=False, **kwargs)¶ Modify the onsite energy, e.g. to apply an electric field
Parameters: - is_double : bool
Requires the model to use double precision floating point values. Defaults to single precision otherwise.
Notes
The function parameters must be a combination of any number of the following:
- energy : ndarray
- The onsite energy.
- 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,energy[sub_id == 'A'] = 0
will set the onsite energy only for sublattice A sites. - sites :
Sites
- Helper object. Can be used instead of
x, y, z, sub_id
. SeeSites
.
The function must return:
- ndarray
- A modified
potential
argument or anndarray
of the same dtype and shape.
Examples
def wavy(a, b): @pb.onsite_energy_modifier def f(x, y): return np.sin(a * x)**2 + np.cos(b * y)**2 return f model = pb.Model( ... # lattice, shape, etc. wavy(a=0.6, b=0.9) )