pythtb.WFArray.solve_model#

WFArray.solve_model(model, use_tensorflow=False)[source]#

Diagonalizes model on every point of the internal Mesh.

The method calls TBModel.solve_ham() passing the k-points and model parameters defined in the Mesh and populates the WFArray with the eigenstates and eigenergies of the Hamiltonian.

Note

For meshes that include \(\lambda\)-axes, the axis names are interpreted as TBModel parameter names. The names and values along each \(\lambda\)-axis are passed as keyword arguments to TBModel.solve_ham(). These parameter names must match those used in the model definition when using TBModel.set_onsite() and TBModel.set_hop().

Added in version 2.0.0: Replaces solve_on_one_point() and solve_on_grid().

Parameters:
modelTBModel

The tight-binding model to diagonalize on the mesh. Its Lattice and the same spinful configuration must match those of the WFArray.

use_tensorflowbool, optional

If True, uses TensorFlow for diagonalization. This can be beneficial for large systems where GPU acceleration is available. This requires TensorFlow to be installed. Default is False.

Notes

  • The samples along each \(\lambda\)-axis are obtained from Mesh.get_axis_range() and passed to TBModel.solve_ham() as keyword arguments, so it is essential that the mesh axis names exactly match the symbolic/callable parameter names in the model.

  • Eigenstates stored by solve_model are chosen to obey a periodic gauge \(\psi_{n,{\bf k+G}}=\psi_{n {\bf k}}\), so the cell-periodic states satisfy \(u_{n,{\bf k_0+G}}=e^{-i{\bf G}\cdot{\bf r}} u_{n {\bf k_0}}\). See Formalism section 4.4 and equation 4.18 for more detail.

  • If the mesh includes Brillouin zone boundary points along any k-axis, or a looping axis is marked as both Brillouin zone winding and closed, solve_model applies the periodic-gauge phase to the states along that axis.

Examples

Say we have a parametric model function defined as follows:

>>> model = TBModel(lattice=lat, spinful=False)
>>> model.set_onsite(['param_1'], mode='set')

The model will be 2D in k-space for this example. We want to vary param_1, and store the energy eigenvalues and eigenstates on a 3D mesh: 2 dimensions in k-space and 1 dimension for the parameter param_1. This means we will have a Mesh with 2 k-axes and 1 lambda-axis corresponding to param_1. We can create the mesh as follows:

>>> mesh = Mesh(
... dim_k=2,
... dim_lambda=1,
... axis_types=['k','k','l'],
... axis_names=['k1', 'k2', 'param_1']
... )

Note that we must name the last axis as param_1 to follow the name we set in the model function. We build the mesh values by using build_grid. We will construct a uniform 2D grid in k-space of shape (20, 20) and a uniform 1D grid for param_1 with 5 points going from 0 to \(2\pi\).

>>> mesh.build_grid(shape=(20, 20, 5), lambda_start=0, lambda_end=2*np.pi)

To initialize the WFArray, we specify the same lattice as the model, and the mesh we just created. If the model were spinful, we would need to set spinful=True.

>>> wfa = WFArray(model.lattice, mesh)

Now, the parameter values are stored in the mesh, and we can diagonalize the model on the mesh using solve_model():

>>> wfa.solve(model=model)

The eigenvalues and eigenstates are stored in the .energies and .wfs attributes, respectively. They can be accessed as follows:

>>> wfa.energies.shape
(20, 20, 5, 2)
>>> wfa.wfs.shape
(20, 20, 5, 2, 2)