qten.bands
Module reference for qten.bands.
bands
Band-structure helpers for momentum-resolved QTen tensors.
This module provides utilities for transforming, folding, unfolding, filling,
and selecting bands represented as Tensor
objects. The common convention is that a band tensor has dimensions
(MomentumSpace, HilbertSpace, HilbertSpace): the
MomentumSpace axis indexes
crystal momenta and the two
HilbertSpace axes form the
Hamiltonian or operator matrix at each momentum.
Mathematical convention
A band tensor represents a family of matrices indexed by crystal momentum: \(H : k \mapsto H(k)\), with \(H(k)_{ab} = \langle a | H(k) | b \rangle\).
In code this is stored as a rank-3 Tensor with
dims (K, B_left, B_right), where K is a
MomentumSpace and the two
Hilbert-space axes provide the row and column basis labels for each matrix
block.
Geometry transformations act on both parts of this object: \(k \mapsto k'\) and \(H(k) \mapsto U(k)\,H(k)\,U(k)^\dagger\).
where the \(k\)-dependent change-of-basis matrix \(U(k)\) is assembled from symbolic Hilbert-space relabeling and finite Fourier transforms.
Repository usage
The functions here sit between geometry, symbolic Hilbert-space labels, and linear algebra. Geometry objects provide real and reciprocal lattice structure, symbolic state spaces label tensor axes, and linear algebra routines diagonalize the momentum-sector matrices when filling or selecting bands.
interpolate_path
interpolate_path(
recip: ReciprocalLattice,
waypoints: Sequence[Union[Tuple[float, ...], str]],
n_points: int = 100,
labels: Optional[Sequence[str]] = None,
points: Optional[Dict[str, Tuple[float, ...]]] = None,
) -> BzPath
Build a sampled Brillouin-zone path in a reciprocal lattice.
This is a backward-compatible wrapper around
interpolate_reciprocal_path.
New code may call that symbolic helper directly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recip
|
ReciprocalLattice
|
Reciprocal lattice in which waypoint coordinates are interpreted. |
required |
waypoints
|
Sequence[Union[Tuple[float, ...], str]]
|
Sequence of explicit fractional coordinates or names looked up in
|
required |
n_points
|
int
|
Number of samples used along the full interpolated path. |
100
|
labels
|
Sequence[str] | None
|
Optional display labels for the waypoint ticks.
For example, |
None
|
points
|
Dict[str, Tuple[float, ...]] | None
|
Optional mapping from waypoint names to fractional reciprocal
coordinates. For example,
|
None
|
Returns:
| Type | Description |
|---|---|
BzPath
|
Sampled Brillouin-zone path with momentum space, waypoint labels, and path-order metadata. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If fewer than two waypoints are supplied, if a named waypoint is not
present in |
See Also
interpolate_reciprocal_path(recip, waypoints, n_points, labels, points)
Canonical implementation used by this compatibility wrapper.
Examples:
path = interpolate_path(
recip,
waypoints=[(0.0, 0.0), (0.5, 0.0), (0.5, 0.5)],
labels=["Γ", "X", "M"],
)
path = interpolate_path(
recip,
waypoints=["G", "X", "M"],
labels=["Γ", "X", "M"],
points={"G": (0.0, 0.0), "X": (0.5, 0.0), "M": (0.5, 0.5)},
)
Source code in src/qten/bands.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
bandtransform
bandtransform(t: Opr, tensor: Tensor) -> Tensor
Apply a basis transform to a momentum-resolved operator tensor.
The expected tensor shape is (K, B_left, B_right) where K is a
MomentumSpace and
B_left, B_right are
HilbertSpace axes. This
function applies the operator-induced basis transform on both
Hilbert-space legs of the band tensor.
For each transformed side, a k-dependent matrix is built from the action of
t on the Hilbert-space basis and Fourier transforms that connect Bloch and
real-space sectors.
Mathematical action
Let \(B\) be the input Hilbert-space basis and \(tB\) the transformed basis.
After wrapping transformed sites back to the home unit cell, the finite
Fourier transform contributes a momentum-dependent phase. The resulting
basis-change matrix is denoted \(U_t(k)\). The transformed band block is
\(H'(t k) = U_t(k)\,H(k)\,U_t(k)^\dagger\). In code, left_fourier and right_fourier are the two \(U_t(k)\)-style
maps, and the products are left_fourier @ tensor and
tensor @ right_fourier.h(-2, -1).
Momentum handling
- The action on
Momentumis treated as a relabeling/permutation of sectors. - The output tensor carries the transformed momentum axis
mapped_kspace = {t @ k | k in kspace}. - Each output k-block is populated from the preimage source block before the Hilbert-space conjugation is applied.
Notes
This function accepts a general Opr, but not every Opr is valid here.
In practice, t must act coherently across the real-space and
momentum-space labels carried by the tensor:
t @ kmust be defined for eachMomentumin the first tensor axis.t @ psimust be defined for eachU1Basisin the Hilbert-space axes, in particular for theOffsetirrep stored inside each basis state.- The Hilbert-space action and momentum action must be dual-compatible, so
that the Fourier transform remains consistent after applying
t. - After applying
FuncOpr(Offset, Offset.fractional), the transformed Hilbert space must have the same rays as the original one; otherwise the transformed basis does not close on the input band space and this function raisesValueError.
Operators that only act on abstract U1Basis values or only on Momentum
values are not sufficient. The operator must provide matching actions on
site offsets and crystal momentum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
Opr
|
Operator to apply. It must satisfy the compatibility conditions described in the notes below. |
required |
tensor
|
Tensor
|
Momentum-space tensor with dims
|
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Transformed tensor with a transformed
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/qten/bands.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | |
bandfold
bandfold(
transform: BasisTransform, tensor: Tensor
) -> Tensor
Fold a momentum-resolved band tensor into the Brillouin zone of a transformed lattice basis.
The input tensor is expected to have dimensions
(MomentumSpace, HilbertSpace, HilbertSpace). The basis transformation is
applied to the direct lattice underlying the
MomentumSpace axis, which
produces a new Brillouin zone and a corresponding momentum remapping. One
HilbertSpace leg is enlarged
to match the transformed unit cell, a Fourier-space change of basis is
applied, and the momentum sectors are then gathered into the new momentum
grid.
Mathematical action
A forward basis transform coarsens the direct lattice basis, so the
reciprocal Brillouin zone shrinks and multiple old momenta fold onto one
new momentum sector. If \(F(k)\) is the Fourier map from the old cell basis
into the enlarged transformed-cell basis, each block is transformed as
\(H_{\mathrm{fold}}(k') \mathrel{+}= F(k)^\dagger H(k) F(k)\), with
\(k' = \mathrm{fold}(k)\). The code-level implementation uses fh @ tensor @ f for the block
transform and index_add(0, k_indices, transformed) to accumulate old
sectors into the folded momentum axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transform
|
BasisTransform
|
Basis change applied to the direct lattice associated with the momentum axis. |
required |
tensor
|
Tensor
|
Rank-3 tensor with dimensions
|
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Folded tensor on the transformed
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the tensor is not rank-3, if the momentum space is empty, or if the momentum axis does not belong to a single Brillouin zone. |
TypeError
|
If the momentum axis is not a
|
Source code in src/qten/bands.py
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 | |
bandunfold
bandunfold(
inverse_transform: InverseBasisTransform, tensor: Tensor
) -> Tensor
Unfold a folded momentum-resolved band tensor using an inverse basis transform.
The input is expected to have dimensions (MomentumSpace, HilbertSpace,
HilbertSpace) where the
MomentumSpace axis lives on a
transformed (folded) Brillouin zone. The inverse transform maps that folded
lattice back to the primitive one and recovers dimensions
(K_primitive, B_primitive, B_primitive).
Mathematical action
Unfolding routes each primitive momentum \(k\) to its parent folded
momentum \(\bar{k}\), gathers \(H_{\mathrm{fold}}(\bar{k})\), and then
projects it back to the primitive-cell basis with a Fourier map \(F(k)\):
\(H_{\mathrm{unfold}}(k)
= F(k)\,H_{\mathrm{fold}}(\bar{k})\,F(k)^\dagger\). In code, the parent-sector lookup is tensor.data[k_indices.data], and the
final basis projection is f @ gathered @ f.h(-2, -1).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inverse_transform
|
InverseBasisTransform
|
Inverse basis transform that maps the folded direct lattice back to the primitive lattice. |
required |
tensor
|
Tensor
|
Rank-3 folded band tensor with dimensions
|
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Unfolded tensor on the primitive Brillouin-zone
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
Source code in src/qten/bands.py
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 | |
bandfillings
bandfillings(tensor: Tensor, frac: float) -> Tensor
Return eigenvectors for occupied bands up to a filling fraction.
The input tensor is expected to have dimensions
(MomentumSpace, HilbertSpace, HilbertSpace), where the
MomentumSpace axis indexes
momentum sectors and the two
HilbertSpace axes form the
Hamiltonian matrix at each momentum. The tensor is diagonalized at each
momentum, then eigenvectors with energies below the global filling
threshold are packed into an output
IndexSpace.
Mathematical convention
Each momentum block is diagonalized as \(H(k) V(k) = V(k) E(k)\), and the eigenvectors whose energies fall below the global filling threshold
are retained. If frac = f, the target number of occupied states is
\(N_{\mathrm{occ}} = \left\lfloor f\,N_k\,N_b \right\rfloor\), where \(N_k\) is the number of momentum sectors and \(N_b\) is the number of bands per sector. Degenerate states at the threshold are included together.
Degenerate threshold behavior
If one state in a degenerate set is filled, all states in that set are filled. The output index dimension is therefore the maximum number of filled states over all momentum sectors, and sectors with fewer filled states are padded with zeros.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tensor
|
Tensor
|
Band-resolved tensor with dimensions
|
required |
frac
|
float
|
Filling fraction in the inclusive range |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Eigenvector tensor with dimensions |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the tensor axes are not |
ValueError
|
If |
Source code in src/qten/bands.py
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 | |
bandselect
bandselect(
tensor: Tensor,
**kwargs: Dict[
str,
Union[
slice,
Tuple[int, ...],
Tuple[float, float],
Callable[[float], bool],
],
],
) -> Dict[str, Tensor]
Select specific bands from a band-resolved Tensor based on criteria provided in kwargs.
The input Tensor is diagonalized at each
MomentumSpace sector. Each
keyword argument defines one named selection criterion, and the returned
dictionary maps each name to a tensor containing the matching eigenvectors.
Outputs have dimensions (MomentumSpace, HilbertSpace, IndexSpace), where
HilbertSpace labels the band
basis and IndexSpace labels the
selected states for each criterion.
Mathematical convention
For each momentum sector, \(H(k) v_n(k) = \epsilon_n(k) v_n(k)\), and each criterion selects a subset of band labels \(n\). The returned
tensor packs the matching eigenvectors \(v_n(k)\) into an
IndexSpace, padding sectors with
fewer matches by zero columns.
Supported criteria
slice: select bands by sorted energy index, such asslice(0, 2)for the two lowest-energy bands.Tuple[int, ...]: select explicit sorted band indices, such as(0, 2)for the lowest and third-lowest bands.Tuple[float, float]: select an inclusive energy range.Callable[[float], bool]: select energies for which the callable returnsTrue.
If a criterion matches no bands in all momentum sectors, the corresponding
output tensor has an IndexSpace of dimension zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tensor
|
Tensor
|
Band-resolved tensor with dimensions
|
required |
kwargs
|
Dict[str, Union[slice, Tuple[int, ...], Tuple[float, float], Callable[[float], bool]]]
|
Named band-selection criteria. |
{}
|
Returns:
| Type | Description |
|---|---|
Dict[str, Tensor]
|
Mapping from criterion name to selected eigenvector tensor with
dimensions |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the tensor axes are not |
ValueError
|
If |
IndexError
|
If an explicit integer band index is outside the available band range. |
Source code in src/qten/bands.py
881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 | |
nearest_bands
nearest_bands(
h_k: Tensor,
point: Union[str, Sequence[float]] = "Gamma",
close_to: float = 0.0,
tol: float = 1e-06,
points: Optional[Dict[str, Sequence[float]]] = None,
) -> Tensor
Project a momentum-resolved Hamiltonian onto bands selected at one k-point.
The input h_k is diagonalized at a single anchor momentum \(k_0\).
Eigenvectors whose anchor eigenvalues lie within tol of close_to are
collected into a rectangular matrix \(V\). If the input Hilbert dimension is
\(N\) and \(S\) bands are selected, then V has shape (N, S) and the
returned tensor stores \(V^\dagger H(k) V\) for every momentum \(k\).
Projection convention
At the selected anchor sector, the code computes
eigenvalues, eigenvectors = torch.linalg.eigh(H_anchor). The columns of
eigenvectors with \(|\epsilon_n(k_0) - \mathrm{close\_to}| \le \mathrm{tol}\)
form \(V\). The projected block at each momentum is
\(H_{\mathrm{proj}}(k) = V^\dagger H(k) V\).
In implementation terms, this projection is the einsum
torch.einsum("ia,kab,bj->kij", V_dag, h_k.data, V).
Anchor selection
- A string
pointis looked up inpoints. "Gamma"defaults to the fractional origin when absent frompoints.- A coordinate sequence is interpreted directly as fractional coordinates.
- Fractional-coordinate differences are wrapped by subtracting the nearest integer, so equivalent periodic coordinates select the same anchor.
If no eigenvalue falls inside the tolerance window, the result has two
zero-dimensional IndexSpace axes
and data shape (len(kspace), 0, 0).
Notes
The selected subspace is fixed by the anchor momentum only. The same anchor eigenvector matrix \(V\) is applied to every \(H(k)\); this is a projection onto an anchor-defined subspace, not a separately diagonalized band selection at each momentum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
h_k
|
Tensor
|
Hamiltonian tensor with dims
( |
required |
point
|
str or Sequence[float]
|
Anchor k-point. String labels are resolved through |
"Gamma"
|
close_to
|
float
|
Target eigenvalue for the subspace selection. |
0.0
|
tol
|
float
|
Half-width of the eigenvalue window around |
1e-6
|
points
|
dict[str, Sequence[float]]
|
Mapping from labels to fractional coordinates. |
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Projected Hamiltonian with dims
( |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
TypeError
|
If the input dimensions are not
|
KeyError
|
If |
Source code in src/qten/bands.py
1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 | |