Models
This page provides the documentation for the data models used by the Application, as well as relevant factories.
TiBi.models.BandStructure
dataclass
¶
A UnitCell
attribute containing a system's band structure.
Attributes:
Name | Type | Description |
---|---|---|
path |
list[NDArray[float64]]
|
A list of point coordinates along which the bands are calculated. |
special_points |
list[NDArray[float64]]
|
A list of high-symmetry point coordinates used for the path. |
eigenvalues |
list[NDArray[float64]]
|
A list of arrays, where each array contains eigenvalues (energies) corresponding to each point on the path. |
eigenvectors |
list[NDArray[float64]]
|
A list of square 2D arrays, where each array contains the eigenvectors corresponding to each point on the path. The eigenvectors are the columns of the 2D arrays. |
Methods:
Name | Description |
---|---|
clear |
Reset the |
reset_bands |
Reset the |
add_point |
Add a point to the special points path. Reset all other fields. |
remove_point |
Remove the last point from the special points path. Reset all other fields. |
Source code in TiBi/models/band_structure.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
add_point(point)
¶
Add a point to the special points path. Reset all other fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
point
|
NDArray[float64]
|
The point to be added to the special points path. |
required |
Source code in TiBi/models/band_structure.py
58 59 60 61 62 63 64 65 66 67 68 |
|
clear()
¶
Reset the BandStructure
to the initial state.
Source code in TiBi/models/band_structure.py
44 45 46 47 |
|
remove_point()
¶
Remove the last point from the special points path. Reset all other fields.
Source code in TiBi/models/band_structure.py
70 71 72 73 74 75 76 77 |
|
reset_bands()
¶
Reset the BandStructure
by clearing the path, eigenvalues, and
eigenvectors, but keeping the special points.
Source code in TiBi/models/band_structure.py
49 50 51 52 53 54 55 56 |
|
TiBi.models.BasisVector
dataclass
¶
A basis vector in 3D space for a crystalline unit cell.
Attributes:
Name | Type | Description |
---|---|---|
x |
float
|
x-component in Cartesian coordinates |
y |
float
|
y-component in Cartesian coordinates |
z |
float
|
z-component in Cartesian coordinates |
is_periodic |
bool
|
Flag denoting whether the crystal repeats in this direction |
Methods:
Name | Description |
---|---|
as_array |
Convert the |
Source code in TiBi/models/basis_vector.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
as_array()
¶
Convert the BasisVector
to a NumPy array.
Returns:
Type | Description |
---|---|
NDArray[float64]
|
3D vector as a NumPy array [x, y, z] |
Source code in TiBi/models/basis_vector.py
33 34 35 36 37 38 39 40 41 42 |
|
TiBi.models.BrillouinZoneGrid
dataclass
¶
A UnitCell
attribute containing a system's computed Brillouin zone grid.
Attributes:
Name | Type | Description |
---|---|---|
is_gamma_centered |
bool
|
A boolean marking whether the grid is Gamma centered or Monkhorst-Pack |
grid_divs |
tuple[int, int, int]
|
Number of divisions along each reciprocal basis vector |
k_points |
list[NDArray[float64]]
|
The coordinates of the grid points. |
eigenvalues |
list[NDArray[float64]]
|
A list of arrays, where each array contains eigenvalues (energies) corresponding to each grid point. |
eigenvectors |
list[NDArray[float64]]
|
A list of square 2D arrays, where each array contains the eigenvectors corresponding to each grid point. The eigenvectors are the columns of the 2D arrays. |
Methods:
Name | Description |
---|---|
clear |
Reset the grid to the initial state. |
Source code in TiBi/models/bz_grid.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
clear()
¶
Reset the grid to the initial state.
The k points, eigenvalues, and eigenvectors are cleared, while the gamma-centered flag and the grid divisions remain unchanged.
Source code in TiBi/models/bz_grid.py
39 40 41 42 43 44 45 46 47 48 |
|
TiBi.models.Selection
¶
Bases: QObject
Currently selected item.
The item is characterized by a series of uuid.UUID's that can be viewed as a hierarchical address.
Attributes:
Name | Type | Description |
---|---|---|
unit_cell |
UUID | None
|
ID of the selected |
site |
UUID | None
|
ID of the selected |
state |
UUID | None
|
ID of the selected |
unit_cell_updated |
Signal
|
Emitted when a new |
site_updated |
Signal
|
Emitted when a new |
state_updated |
Signal
|
Emitted when a new |
selection_changed |
Signal
|
Emitted when the selection changes, in addition to the specific signal. |
Methods:
Name | Description |
---|---|
set_selection |
Update the selection and emit an appropriate signal. |
Source code in TiBi/models/selection.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
set_selection(uc_id, site_id, state_id)
¶
Update the selection and emit an appropriate signal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uc_id
|
UUID | None
|
New |
required |
site_id
|
UUID | None
|
New |
required |
state_id
|
UUID | None
|
New |
required |
Source code in TiBi/models/selection.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
TiBi.models.Site
dataclass
¶
A physical site (like an atom) within a UnitCell
.
Site
s are positioned using fractional coordinates relative to
the UnitCell
's basis vectors, where each coordinate ranges from 0 to 1.
Each Site
can contain multiple State
s.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Name of the |
c1, c2, c3 |
float
|
Fractional coordinates (0 ≤ c ≤ 1) along the unit cell's |
R |
float
|
|
color |
tuple[float, float, float, float]
|
|
states |
dict[UUID, State]
|
Dictionary mapping state UUIDs to |
id |
UUID
|
Unique identifier for the |
Source code in TiBi/models/site.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
TiBi.models.State
dataclass
¶
A quantum state (orbital) within a Site
.
Each State
has a name
and belongs to a Site
in the UnitCell
.
State
s are the fundamental entities between which hopping can occur.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Name of the |
id |
UUID
|
Unique identifier for the |
Source code in TiBi/models/state.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
TiBi.models.UnitCell
dataclass
¶
The funtamental object describing a crystal.
The UnitCell
is defined by three BasisVector
s and contains Site
s
and hopping terms between State
s. Additionally, UnitCell
carries
the calculated BandStructure
and BrillouinZoneGrid
objects.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Name of the unit cell |
v1, v2, v3 |
BasisVector
|
Basis vectors |
sites |
dict[UUID, Site]
|
Dictionary mapping site UUIDs to |
hoppings |
dict[tuple[UUID, UUID], list[tuple[tuple[int, int, int], complex128]]]
|
Dictionary of hopping terms between states. Keys are pairs of state UUIDs (destination_state_id, source_state_id). Values are lists of (displacement, amplitude) pairs where:
|
bandstructure |
BandStructure
|
Band structure object for the |
bz_grid |
BrillouinZoneGrid
|
Grid of points in the Brillouin zone |
id |
UUID
|
Unique identifier for the |
Methods:
Name | Description |
---|---|
volume |
Compute the volume of the |
is_hermitian |
Check whether the hoppings are Hermitian. |
reciprocal_vectors |
Compute the reciprocal lattice vectors for the periodic directions. |
reduced_basis |
Return a reduced set of periodic |
get_states |
Extract all |
get_BZ |
Compute the Brillouin zone vertices and faces. |
get_hamiltonian_function |
Generate a function that computes the Hamiltonian matrix for a given k-point. |
Source code in TiBi/models/unit_cell.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 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 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 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 |
|
get_BZ()
¶
Compute the Brillouin zone vertices and faces.
The Brillouin zone is the Wigner-Seitz cell of the reciprocal lattice. This method calculates the vertices and faces of the Brillouin zone using Voronoi construction. The dimensionality of the BZ depends on the number of periodic dimensions in the unit cell (0-3).
For 1D, bz_vertices contains two points defining the BZ boundary. For 2D, bz_faces contains the edges of the 2D BZ polygon. For 3D, bz_faces contains the polygonal faces of the 3D BZ polyhedron.
Returns:
Type | Description |
---|---|
tuple[NDArray[NDArray[float64]], NDArray[NDArray[NDArray[float64]]]]
|
The first element of the tuple gives the BZ vertex coordinates. The second element gives a list of faces, where each face is defined by vertex points. In 2D, the "faces" are edges. |
Source code in TiBi/models/unit_cell.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
|
get_hamiltonian_function()
¶
Generate a function that computes the Hamiltonian matrix.
This method creates a closure that precomputes all k-independent data needed for the Hamiltonian, and returns a function that builds the Hamiltonian matrix for any k-point in the Brillouin zone.
The dimension of the k-point must match the number of periodic dimensions in the unit cell (1D, 2D, or 3D).
Returns:
Type | Description |
---|---|
function
|
A function that takes k-points (numpy array) and returns a complex Hamiltonian matrix. |
Source code in TiBi/models/unit_cell.py
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 |
|
get_states()
¶
Extract all State
s and their information from a UnitCell
.
This is a helper function used by UI components to get a flattened list of all states in the unit cell, regardless of which site they belong to. It makes it easier to display states in UI components like dropdown menus or lists.
Returns:
Type | Description |
---|---|
tuple[list[State], list[tuple[str, UUID, str, UUID]]]
|
A tuple containing a list of |
Source code in TiBi/models/unit_cell.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
|
is_hermitian()
¶
Check whether the hoppings are Hermitian.
For each key (destination_state_id, source_state_id) in the hoppings dictionary, check if there is a key (source_state_id, destination_state_id). If so, check that the entries are related by Hermitian conjugation.
Returns:
Type | Description |
---|---|
bool
|
|
Source code in TiBi/models/unit_cell.py
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 |
|
reciprocal_vectors()
¶
Compute the reciprocal lattice vectors for the periodic directions.
Calculates the reciprocal lattice vectors corresponding to the
periodic directions in the UnitCell
.
The number of reciprocal vectors depends on the number of
periodic dimensions (0-3).
Returns:
Type | Description |
---|---|
list[NDArray[float64]]
|
List of 3D reciprocal vectors (0 to 3 items depending on periodicity) |
Source code in TiBi/models/unit_cell.py
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 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
reduced_basis(scale=1000000.0)
¶
Return a reduced set of periodic BasisVector
s using LLL algorithm.
Applies the Lenstra-Lenstra-Lovász (LLL) lattice reduction algorithm to find a more orthogonal set of basis vectors that spans the same lattice.
Only the periodic BasisVector
s are reduced.
Non-periodic vectors are left unchanged.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scale
|
float = 1e6
|
A float to scale the vectors for integer reduction. Used because the LLL algorithm works with integer matrices. |
1000000.0
|
Returns:
Type | Description |
---|---|
list[BasisVector]
|
A list of BasisVector objects representing the reduced basis |
Source code in TiBi/models/unit_cell.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
|
volume()
¶
Compute the volume of the UnitCell
using the scalar triple product.
Returns:
Type | Description |
---|---|
float64
|
Volume of the unit cell in arbitrary units |
Source code in TiBi/models/unit_cell.py
86 87 88 89 90 91 92 93 94 95 96 |
|
TiBi.models.factories.bz_point_selection_init()
¶
Initialize the selection dictonary for points in the Brillouin zone.
Each key corresponds to a point type (vertex, edge, face), while the entries give the cardinal indices of the selected points.
Returns:
Type | Description |
---|---|
dict
|
A dictionary with keys 'vertex', 'edge', and 'face', each initialized to None. During use, the entries are set to the indices of the selected points. |
Source code in TiBi/models/factories.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
TiBi.models.factories.bz_point_lists_init()
¶
Initialize the dictonary of points in the Brillouin zone.
Each key corresponds to a point type (vertex, edge, face), while the entries are lists of high-symmetry points in the Brillouin zone.
Returns:
Type | Description |
---|---|
dict
|
A dictionary with keys 'vertex', 'edge', and 'face', each initialized to empty lists. During use, the entries are set to the lists of of the high-symmetry points. |
Source code in TiBi/models/factories.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
TiBi.models.factories.mk_new_site()
¶
Create a new site with default values.
Returns:
Type | Description |
---|---|
Site
|
A new |
Source code in TiBi/models/factories.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
TiBi.models.factories.mk_new_state()
¶
Create a new state with default values.
Returns:
Type | Description |
---|---|
State
|
A new |
Source code in TiBi/models/factories.py
89 90 91 92 93 94 95 96 97 98 99 |
|
TiBi.models.factories.mk_new_unit_cell()
¶
Create a new unit cell with default values.
Returns:
Type | Description |
---|---|
UnitCell
|
A new |
Source code in TiBi/models/factories.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|