onsite_energy_modifier¶
- onsite_energy_modifier(is_double: bool = False, phase: bool = False, **kwargs) partial ¶
Modify the onsite energy, e.g. to apply an electric field
- Parameters:
- is_doublebool
Requires the model to use double precision floating point values. Defaults to single precision otherwise.
- phasebool
Define the phase of the reciprocal space so that the different eigenvectors have the same guage.
Notes
The function parameters must be a combination of any number of the following:
- energyndarray
The onsite energy.
- 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,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) )