pythtb.WFArray#
- class WFArray(lattice, mesh, nstates=None, spinful=False)[source]#
Wavefunction container defined on a sampling mesh.
A
WFArraystores states on a discrete mesh of k-points and/or adiabatic parameters \(\lambda\). Once populated, it can be queried for Berry connections, Berry curvature, Chern numbers, and other derived quantities, or passed toWannierwhen constructing Wannier functions or obtaining smooth gauges from the projection method.The underlying
Meshmay represent a full Monkhorst-Pack grid, a lower-dimensional path, or even a mesh that contains only parameter axes. In every case,WFArraytracks the mesh layout, the stored states, and the necessary phase conventions so downstream utilities can consume the data consistently.Wavefunctions stored in a
WFArraycan be the Hamiltonian eigenstates generated bysolve_model(), or any otherMesh-defined states in the orbital basis of the underlyingLatticethat matchspinfulsetting. Useset_states()for bulk assignments, or the[...]indexer to update the states at an individual mesh point. Periodic boundary conditions are enforced automatically on assignment.- Parameters:
- lattice
Lattice Lattice structure with orbital positions, periodic directions, and lattice vectors. Use model.lattice to keep it consistent with a
TBModel.- mesh
Mesh Sampling grid in k/parameter space. Build it before constructing the
WFArray. Its axes set the topology for enforcing periodic boundary conditions.- spinfulbool, optional
Whether the model includes spin degrees of freedom (defaults to False). If True, each orbital stores two spin components. This affects the shape of the stored wavefunction array.
- nstatesint, optional
Number of bands per mesh point to store (defaults to
WFArray.norb * WFArray.nspin).
- lattice
See also
pythtb.TBModelpythtb.Meshpythtb.Wannier- Formalism
- Berry phase and curvature in the Haldane model
For an example of using
WFArrayon a regular grid of points in k-space.- Graphene Dirac cone Berry phase
For an example of using
WFArrayon a non-regular grid of points in k-space.- Three-site Thouless pump
For an example of using
Meshwith an adiabatic dimension. This example shows how one of the directions ofWFArrayobject need not be a k-vector direction, but can instead be a Hamiltonian parameter \(\lambda\). See also discussion after equation 4.1 in Formalism.- Hybrid Wannier functions in cubic slab
For an example of using
WFArrayto store hybrid Wannier functions.
Notes
Wavefunctions are always stored with mesh axes leading, followed by bands, orbital, and (if present) spin indices. When setting the wavefunctions manually, ensure the input array matches this convention.
WFArraycooperates withWannierto construct smooth Wannier gauges: pass the populated array toWannier(wfarray)and useWannier.single_shot_projection().Some features are only defined for regular grids and/or in the energy eigenstate gauge. Check the documentation of individual methods for details.
Examples
Populate Mesh with a uniform Monkhorst-Pack grid of k-points
>>> mesh = Mesh(['k', 'k']) >>> mesh.build_grid(shape=(20, 20), gamma_centered=True) >>> wfa = WFArray(lattice, mesh, spinful=True, nstates=4) >>> wfa.shape (20, 20, ...)
The WFArray is initially empty
>>> wfa.filled False
Solve a
TBModelon the mesh and store the eigenstates>>> wfa.solve_model(tb_model) >>> wfa.energies.shape (20, 20, ...)
Now we can use downstream functions, such as computing the Berry curvature on the grid
>>> curv = wfa.berry_curvature(non_abelian=False)
We can also store states from a finite model on a parameter sweep (no k-axes)
>>> mesh = Mesh(['l']) >>> mesh.build_grid(shape=(101,), lambda_start=0.0, lambda_stop=2*np.pi)
If the parameter points in the mesh are adiabatic cycles, ensure the boundary conditions are set correctly in the Mesh
>>> mesh.loop(axis_idx=0, loop_idx=0) >>> wfa = WFArray(lattice, mesh) >>> wfa.set_states(eigenvectors_lambda, is_cell_periodic=False) >>> np.allclose(wfa[0], wfa[-1]) True # states at the endpoints match due to adiabatic cycle
Even if we set the states manually with the indexer, periodic boundary conditions are still enforced automatically using the topology of the Mesh
>>> wfa[-1] = eigvecs # shape (nstates, norb[, nspin]) >>> np.allclose(wfa[0], wfa[-1]) True # states at the endpoints still match due to adiabatic cycle
Methods#
Berry connection from parallel-transport links. |
|
Berry curvature tensor using the Fukui-Hatsugai-Suzuki plaquette method. |
|
Berry flux tensor using the Fukui-Hatsugai-Suzuki plaquette method. |
|
Berry phase accumulated along a specified mesh axis. |
|
Computes the Chern number in the specified plane. |
|
Keep only the specified states in the |
|
Create a copy of the current |
|
Create a new |
|
Compute unitary link matrices for specified axis directions. |
|
Compute the overlap matrix of the cell periodic eigenstates on nearest neighbor k-shell. |
|
Position expectation value for a given k-point and set of states. |
|
Eigenvalues and eigenvectors of the position operator in a given basis. |
|
Position matrix for a given k-point and set of states. |
|
Returns the band projectors associated with the states in the WFArray. |
|
Remove specified states from the |
|
Roll states with periodic boundary conditions. |
|
Populate the wavefunction array. |
|
Diagonalizes |
|
Return states stored in the WFArray object. |
|
Wilson loop along a specified mesh axis. |
Attributes#
The overlap matrix of the wavefunctions. |
|
The dimension of k-space in the |
|
The dimension of lambda-space in the |
|
The energies of the |
|
Whether the wavefunction array has been initialized. |
|
The Hamiltonian defined on the |
|
The k-points in the |
|
The |
|
The |
|
The |
|
The number of axes in the |
|
The number of orbitals defined in the |
|
The number of spin components. |
|
The number of states (or bands) in the state array. |
|
The parameter points in the |
|
The Bloch wavefunctions. |
|
The shape of the state array. |
|
The shape of the axes of |
|
Whether the |
|
The cell-periodic wavefunctions. |
|
The stored wavefunctions. |