BandStructure

class sisl.physics.BandStructure(parent, point, division, name=None)

Bases: sisl.physics.BrillouinZone

Create a path in the Brillouin zone for plotting band-structures etc.

Parameters
  • parent (object or array_like) – An object with associated parentcell and parent.rcell or an array of floats which may be turned into a SuperCell

  • point (array_like of float) – a list of points that are the corners of the path

  • division (int or array_like of int) – number of divisions in each segment. If a single integer is passed it is the total number of points on the path (equally separated). If it is an array_like input it must have length one less than point.

  • name (array_like of str) – the associated names of the points on the Brillouin Zone path

Examples

>>> sc = SuperCell(10)
>>> bs = BandStructure(sc, [[0] * 3, [0.5] * 3], 200)
>>> bs = BandStructure(sc, [[0] * 3, [0.5] * 3, [1.] * 3], 200)
>>> bs = BandStructure(sc, [[0] * 3, [0.5] * 3, [1.] * 3], 200, ['Gamma', 'M', 'Gamma'])

Attributes

__dict__

__doc__

__module__

__weakref__

list of weak references to the object (if defined)

_bz_attr

apply

cell

k

A list of all k-points (if available)

rcell

weight

Weight of the k-points in the BrillouinZone object

Methods

__call__(*args, **kwargs)

Calls the given attribute of the internal object and returns the quantity

__delattr__

Implement delattr(self, name).

__dir__

Default dir() implementation.

__eq__

Return self==value.

__format__

Default object formatter.

__ge__

Return self>=value.

__getattr__(attr)

__getattribute__

Return getattr(self, name).

__getstate__()

Return dictionary with the current state

__gt__

Return self>value.

__hash__

Return hash(self).

__init__(parent, point, division[, name])

Initialize self.

__init_subclass__

This method is called when a class is subclassed.

__iter__()

Iterate through the path

__le__

Return self<=value.

__len__()

__lt__

Return self<value.

__ne__

Return self!=value.

__new__

Create and return a new object.

__reduce__

Helper for pickle.

__reduce_ex__

Helper for pickle.

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

__setstate__(state)

Reset state of the object

__sizeof__

Size of object in memory, in bytes.

__str__()

String representation of the BrillouinZone

__subclasshook__

Abstract classes can override this to customize issubclass().

_bz_get_func()

Internal method to retrieve the actual function to be called

asarray()

Return self with numpy.ndarray returned quantities

asaverage()

Return self with k-averaged quantities

aslist()

Return self with list returned quantities

asnone()

Return self with None, this may be done for instance when wrapping the function calls.

assum()

Return self with summed quantities

asyield()

Return self with yielded quantities

call(func, *args, **kwargs)

Call the function func and run as though the function has been called

copy()

Create a copy of this object

in_primitive(k)

Move the k-point into the primitive point(s) ]-0.5 ; 0.5]

iter([ret_weight])

An iterator for the k-points and (possibly) the weights

lineark([ticks])

A 1D array which corresponds to the delta-k values of the path

lineartick()

The tick-marks corresponding to the linear-k values

param_circle(sc, N_or_dk, kR, normal, origo)

Create a parameterized k-point list where the k-points are generated on a circle around an origo

parametrize(sc, func, N, *args, **kwargs)

Generate a new BrillouinZone object with k-points parameterized via the function func in N separations

set_parent(parent)

Update the parent associated to this object

tocartesian(k)

Transfer a k-point in reduced coordinates to the Cartesian coordinates

toreduced(k)

Transfer a k-point in Cartesian coordinates to the reduced coordinates

write(sile, *args, **kwargs)

Writes k-points to a tableSile.

apply
asarray()

Return self with numpy.ndarray returned quantities

This forces the __call__ routine to return a single array.

Notes

Please use self.apply.array instead. This method will be deprecated >0.9.9.

All invocations of sub-methods are added these keyword-only arguments:

etabool, optional

if true a progress-bar is created, default false.

wrapcallable, optional

a function that accepts the output of the given routine and post-process it. Defaults to lambda x: x.

Examples

>>> obj = BrillouinZone(...)
>>> obj.asarray().eigh(eta=True)

To compute multiple things in one go one should use wrappers to contain the calculation

>>> E = np.linspace(-2, 2, 100)
>>> dist = get_distribution('gaussian', smearing=0.1)
>>> def wrap(es, parent, k, weight):
...    DOS = es.DOS(E, distribution=dist)
...    PDOS = es.PDOS(E, distribution=dist)
...    occ = es.occupation()
...    spin_moment = (es.spin_moment(E, distribution=dist) * occ.reshape(-1, 1)).sum(0)
...    return oplist([DOS, PDOS, spin_moment])
>>> bz = BrillouinZone(hamiltonian)
>>> DOS, PDOS, spin_moment = bz.asarray().eigenstate(wrap=wrap)

See also

asyield

all output returned through an iterator

asaverage

take the average (with k-weights) of the Brillouin zone

assum

return the sum of values in the Brillouin zone

aslist

all output returned as a Python list

asaverage()

Return self with k-averaged quantities

This forces the __call__ routine to return a single k-averaged value.

Notes

Please use self.apply.average instead. This method will be deprecated >0.9.9.

All invocations of sub-methods are added these keyword-only arguments:

etabool, optional

if true a progress-bar is created, default false.

wrapcallable, optional

a function that accepts the output of the given routine and post-process it. Defaults to lambda x: x.

Examples

>>> obj = BrillouinZone(Hamiltonian)
>>> obj.asaverage().DOS(np.linspace(-2, 2, 100))
>>> obj = BrillouinZone(Hamiltonian)
>>> obj.asaverage()
>>> obj.DOS(np.linspace(-2, 2, 100))
>>> obj.PDOS(np.linspace(-2, 2, 100), eta=True)
>>> obj = BrillouinZone(Hamiltonian)
>>> obj.asaverage()
>>> E = np.linspace(-2, 2, 100)
>>> def wrap(es):
...    return es.DOS(E), es.PDOS(E)
>>> DOS, PDOS = obj.eigenstate(wrap=wrap)

See also

asarray

all output as a single array

asyield

all output returned through an iterator

assum

return the sum of values in the Brillouin zone

aslist

all output returned as a Python list

aslist()

Return self with list returned quantities

This forces the __call__ routine to return a list with returned values.

Notes

Please use self.apply.list instead. This method will be deprecated >0.9.9.

All invocations of sub-methods are added these keyword-only arguments:

etabool, optional

if true a progress-bar is created, default false.

wrapcallable, optional

a function that accepts the output of the given routine and post-process it. Defaults to lambda x: x.

Examples

>>> obj = BrillouinZone(...)
>>> def first_ten(es):
...    return es.sub(range(10))
>>> obj.aslist().eigenstate(eta=True, wrap=first_ten)

See also

asarray

all output as a single array

asyield

all output returned through an iterator

assum

return the sum of values in the Brillouin zone

asaverage

take the average (with k-weights) of the Brillouin zone

asnone()

Return self with None, this may be done for instance when wrapping the function calls.

This forces the __call__ routine to return None. This usage is mainly intended when creating custom wrap function calls.

Notes

Please use self.apply.none instead. This method will be deprecated >0.9.9.

All invocations of sub-methods are added these keyword-only arguments:

etabool, optional

if true a progress-bar is created, default false.

wrapcallable, optional

a function that accepts the output of the given routine and post-process it. Defaults to lambda x: x.

Examples

>>> obj = BrillouinZone(...)
>>> obj.asnone().eigh(eta=True)

See also

asyield

all output returned through an iterator

asaverage

take the average (with k-weights) of the Brillouin zone

assum

return the sum of values in the Brillouin zone

aslist

all output returned as a Python list

assum()

Return self with summed quantities

This forces the __call__ routine to return all k-point values summed.

Notes

Please use self.apply.sum instead. This method will be deprecated >0.9.9.

All invocations of sub-methods are added these keyword-only arguments:

etabool, optional

if true a progress-bar is created, default false.

wrapcallable, optional

a function that accepts the output of the given routine and post-process it. Defaults to lambda x: x.

Examples

>>> obj = BrillouinZone(Hamiltonian)
>>> obj.assum().DOS(np.linspace(-2, 2, 100))
>>> obj = BrillouinZone(Hamiltonian)
>>> obj.assum()
>>> obj.DOS(np.linspace(-2, 2, 100))
>>> obj.PDOS(np.linspace(-2, 2, 100), eta=True)
>>> E = np.linspace(-2, 2, 100)
>>> dist = get_distribution('gaussian', smearing=0.1)
>>> def wrap(es, parent, k, weight):
...    DOS = es.DOS(E, distribution=dist) * weight
...    PDOS = es.PDOS(E, distribution=dist) * weight
...    occ = es.occupation()
...    spin_moment = (es.spin_moment(E, distribution=dist) * occ.reshape(-1, 1)).sum(0) * weight
...    return oplist([DOS, PDOS, spin_moment])
>>> bz = BrillouinZone(hamiltonian)
>>> DOS, PDOS, spin_moment = bz.assum().eigenstate(wrap=wrap)

See also

asarray

all output as a single array

asyield

all output returned through an iterator

asaverage

take the average (with k-weights) of the Brillouin zone

aslist

all output returned as a Python list

asyield()

Return self with yielded quantities

This forces the __call__ routine to return a an iterator which may yield the quantities calculated.

Notes

Please use self.apply.iter instead. This method will be deprecated >0.9.9.

All invocations of sub-methods are added these keyword-only arguments:

etabool, optional

if true a progress-bar is created, default false.

wrapcallable, optional

a function that accepts the output of the given routine and post-process it. Defaults to lambda x: x.

Examples

>>> obj = BrillouinZone(Hamiltonian)
>>> obj.asyield().eigh(eta=True)

See also

asarray

all output as a single array

asaverage

take the average (with k-weights) of the Brillouin zone

assum

return the sum of values in the Brillouin zone

aslist

all output returned as a Python list

call(func, *args, **kwargs)

Call the function func and run as though the function has been called

This is a wrapper to call user-defined functions not attached to the parent object.

The below example shows that the equivalence of the call.

Examples

>>> H = Hamiltonian(...)
>>> bz = BrillouinZone(H)
>>> bz.eigh() == bz.call(H.eigh)
Parameters
  • func (callable) – method used

  • *args – arguments passed to func in the call sequence

  • **kwargs – keyword arguments passed to func in the call sequence

property cell
copy()

Create a copy of this object

static in_primitive(k)

Move the k-point into the primitive point(s) ]-0.5 ; 0.5]

Parameters

k (array_like) – k-point(s) to move into the primitive cell

Returns

all k-points moved into the primitive cell

Return type

numpy.ndarray

iter(ret_weight=False)

An iterator for the k-points and (possibly) the weights

Parameters

ret_weight (bool, optional) – if true, also yield the weight for the respective k-point

Yields
  • kpt (k-point)

  • weight (weight of k-point, only if ret_weight is true.)

property k

A list of all k-points (if available)

lineark(ticks=False)[source]

A 1D array which corresponds to the delta-k values of the path

This is meant for plotting

Examples

>>> p = BandStructure(...)
>>> eigs = Hamiltonian.eigh(p)
>>> for i in range(len(Hamiltonian)):
...     plt.plot(p.lineark(), eigs[:, i])
>>> p = BandStructure(...)
>>> eigs = Hamiltonian.eigh(p)
>>> lk, kt, kl = p.lineark(True)
>>> plt.xticks(kt, kl)
>>> for i in range(len(Hamiltonian)):
...     plt.plot(lk, eigs[:, i])
Parameters

ticks (bool, optional) – if True the ticks for the points are also returned

Returns

  • linear_k (numpy.ndarray) – the positions in reciprocal space determined by the distance between points

  • ticks (numpy.ndarray) – linear k-positions of the points, only returned if ticks is True

  • ticklabels (list of str) – labels at ticks, only returned if ticks is True

lineartick()[source]

The tick-marks corresponding to the linear-k values

Returns

the positions in reciprocal space determined by the distance between points

Return type

numpy.ndarray

See also

lineark

Routine used to calculate the tick-marks.

classmethod param_circle(sc, N_or_dk, kR, normal, origo, loop=False)

Create a parameterized k-point list where the k-points are generated on a circle around an origo

The generated circle is a perfect circle in the reciprocal space (Cartesian coordinates). To generate a perfect circle in units of the reciprocal lattice vectors one can generate the circle for a diagonal supercell with side-length \(2\pi\), see example below.

Parameters
  • sc (SuperCell, or SuperCellChild) – the supercell used to construct the k-points

  • N_or_dk (int) – number of k-points generated using the parameterization (if an integer), otherwise it specifies the discretization length on the circle (in 1/Ang), If the latter case will use less than 4 points a warning will be raised and the number of points increased to 4.

  • kR (float) – radius of the k-point. In 1/Ang

  • normal (array_like of float) – normal vector to determine the circle plane

  • origo (array_like of float) – origo of the circle used to generate the circular parameterization

  • loop (bool, optional) – whether the first and last point are equal

Examples

>>> sc = SuperCell([1, 1, 10, 90, 90, 60])
>>> bz = BrillouinZone.param_circle(sc, 10, 0.05, [0, 0, 1], [1./3, 2./3, 0])

To generate a circular set of k-points in reduced coordinates (reciprocal

>>> sc = SuperCell([1, 1, 10, 90, 90, 60])
>>> bz = BrillouinZone.param_circle(sc, 10, 0.05, [0, 0, 1], [1./3, 2./3, 0])
>>> bz_rec = BrillouinZone.param_circle(2*np.pi, 10, 0.05, [0, 0, 1], [1./3, 2./3, 0])
>>> bz.k[:, :] = bz_rec.k[:, :]
Returns

with the parameterized k-points.

Return type

BrillouinZone

classmethod parametrize(sc, func, N, *args, **kwargs)

Generate a new BrillouinZone object with k-points parameterized via the function func in N separations

Generator of a parameterized Brillouin zone object that contains a parameterized k-point list.

Basically this generates a new BrillouinZone object as:

>>> def func(sc, frac):
...    return [frac, 0, 0]
>>> bz = BrillouinZone.parametrize(1, func, 10)
>>> len(bz) == 10
True
>>> np.allclose(bz.k[-1, :], [9./10, 0, 0])
True
Parameters
  • sc (SuperCell, or SuperCellChild) – the supercell used to construct the k-points

  • func (callable) – method that parameterizes the k-points, must at least accept two arguments, sc (super-cell object containing the unit-cell and reciprocal cell) and frac (current parametrization fraction, between 0 and (N-1)/N. It must return a k-point in 3 dimensions.

  • N (int) – number of k-points generated using the parameterization

  • args (list of arguments) – arguments passed directly to func

  • kwargs (dictionary of arguments) – keyword arguments passed directly to func

property rcell
set_parent(parent)

Update the parent associated to this object

Parameters

parent (object or array_like) – an object containing cell vectors

tocartesian(k)

Transfer a k-point in reduced coordinates to the Cartesian coordinates

Parameters

k (list of float) – k-point in reduced coordinates

Returns

in units of 1/Ang

Return type

numpy.ndarray

toreduced(k)

Transfer a k-point in Cartesian coordinates to the reduced coordinates

Parameters

k (list of float) – k-point in Cartesian coordinates

Returns

in units of reciprocal lattice vectors ]-0.5 ; 0.5] (if k is in the primitive cell)

Return type

numpy.ndarray

property weight

Weight of the k-points in the BrillouinZone object

write(sile, *args, **kwargs)

Writes k-points to a tableSile.

This allows one to pass a tableSile or a file-name.