API
Couplings
dataclass
A data class for representing orbital couplings.
Attributes: |
|
---|
Source code in src/granad/orbitals.py
Orbital
dataclass
Attributes: |
|
---|
Source code in src/granad/orbitals.py
OrbitalList
A class that encapsulates a list of orbitals, providing an interface similar to a standard Python list, while also maintaining additional functionalities for coupling orbitals and managing their relationships.
The class stores orbitals in a wrapped Python list and handles the coupling of orbitals using dictionaries, where the keys are tuples of orbital identifiers (orb_id), and the values are the couplings (either a float or a function representing the coupling strength or mechanism between the orbitals).
The class also stores simulation parameters like the number of electrons and temperature in a dataclass.
The class computes physical observables (energies etc) lazily on the fly, when they are needed. If there is a basis (either site or energy) to reasonably associate with a quantity, the class exposes quantity_x as an attribute for the site basis and quantity_e as an attribute for the energy basis. By default, all quantities are in site basis, so quantity_x == quantity.
The class exposes simulation methods.
Attributes: |
|
---|
Note
- Orbital Identification: Orbitals can be identified either by their group_id, a direct reference to the orbital object itself, or via a user-defined tag.
- Index Access: Orbitals can be accessed and managed by their index in the list, allowing for list-like manipulation (addition, removal, access).
- Coupling Definition: Allows for the definition and adjustment of couplings between pairs of orbitals, identified by a tuple of their respective identifiers. These couplings can dynamically represent the interaction strength or be a computational function that defines the interaction.
Source code in src/granad/orbitals.py
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 477 478 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 620 621 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 764 765 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 879 880 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 1028 1029 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 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 |
|
center_index
property
index of approximate center orbital of the structure
dipole_operator
property
Computes the dipole operator using positions and transition values. The diagonal is set by position components, and the off-diagonal elements are set by transition matrix values.
Returns: |
|
---|
oam_operator
property
Calculates the orbital angular momentum operator from the dipole \(P\) and velocity operator \(J\) as \(L_{k} = \epsilon_{ijk} P_j J_k\).
Returns: |
|
---|
quadrupole_operator
property
Calculates the quadrupole operator based on the dipole operator terms. It combines products of the dipole terms and their differences from the identity matrix scaled by the diagonal components.
Returns: |
|
---|
transition_energies
property
Computes independent-particle transition energies associated with the TB-Hamiltonian of a stack.
Returns: |
|
---|
velocity_operator
property
Calculates the velocity operator as the commutator of position with the Hamiltonian using matrix multiplications.
Returns: |
|
---|
wigner_weisskopf_transition_rates
property
Calculates Wigner-Weisskopf transition rates based on transition energies and dipole moments transformed to the energy basis.
Returns: |
|
---|
append(other)
Appends an orbital to the list, ensuring it is not already present.
Parameters: |
|
---|
Raises: |
|
---|
Source code in src/granad/orbitals.py
filter_orbs(orb_id, t)
maps a given orb_id (such as an index or tag) to a list of the required type t
Source code in src/granad/orbitals.py
get_charge(density_matrix=None)
Calculates the charge distribution from a given density matrix or from the initial density matrix if not specified.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/orbitals.py
get_dissipator(relaxation_rate=None, saturation=None)
staticmethod
Dict holding the term of the default dissipator: either decoherence time from relaxation_rate as float and ignored saturation or lindblad from relaxation_rate as array and saturation function
Source code in src/granad/orbitals.py
get_dos(omega, broadening=0.1)
Calculates the density of states (DOS) of a nanomaterial stack at a given frequency with broadening.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/orbitals.py
get_epi(density_matrix_stat, omega, epsilon=None)
Calculates the energy-based plasmonicity index (EPI) for a given density matrix and frequency.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/orbitals.py
get_expectation_value(*, operator, density_matrix, induced=True)
Calculates the expectation value of an operator with respect to a given density matrix using tensor contractions specified for different dimensionalities of the input arrays.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/orbitals.py
get_hamiltonian(illumination=None, use_rwa=False, add_induced=False)
staticmethod
Dict holding terms of the default hamiltonian: bare + coulomb + dipole gauge coupling to external field + (optional) induced field (optionally in RWA)
Source code in src/granad/orbitals.py
get_induced_field(positions, density_matrix)
Calculates the induced electric field at specified positions based on a given density matrix.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/orbitals.py
get_ip_green_function(A, B, omegas, occupations=None, energies=None, mask=None, relaxation_rate=0.1)
independent-particle greens function at the specified frequency according to
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/orbitals.py
get_ldos(omega, site_index, broadening=0.1)
Calculates the local density of states (LDOS) at a specific site and frequency within a nanomaterial stack.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/orbitals.py
get_polarizability_rpa(omegas, polarization, coulomb_strength=1.0, relaxation_rate=1 / 10, hungry=0, phi_ext=None, args=None)
Calculates the random phase approximation (RPA) polarizability of the system at given frequencies under specified conditions.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/orbitals.py
get_susceptibility_rpa(omegas, relaxation_rate=1 / 10, coulomb_strength=1.0, hungry=0, args=None)
Computes the random phase approximation (RPA) susceptibility of the system over a range of frequencies.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/orbitals.py
localization(neighbor_number=6)
Compute edge localization of eigenstates according to
Edges are identified based on the number of next-to-next-to nearest neighbors (nnn).
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/orbitals.py
master_equation(*, end_time, start_time=0.0, dt=0.0001, grid=100, max_mem_gb=0.5, initial_density_matrix=None, coulomb_strength=1.0, illumination=None, relaxation_rate=None, compute_at=None, expectation_values=None, density_matrix=None, use_rwa=False, solver=diffrax.Dopri5(), stepsize_controller=diffrax.PIDController(rtol=1e-10, atol=1e-10), hamiltonian=None, dissipator=None, postprocesses=None, rhs_args=None)
Simulates the time evolution of the density matrix, computing observables, density matrices or extracting custom information.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/orbitals.py
1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 |
|
rotate(x, phi, axis='z')
rotates all orbitals an angle phi around a point p around axis.
x : jnp.ndarray A 3D point around which to rotate. phi : float Angle by which to rotate. axis : str Axis to rotate around ('x', 'y', or 'z'). Default is 'z'.
Source code in src/granad/orbitals.py
set_coulomb_element(orb1, orb2, val)
Sets a Coulomb interaction element between two orbitals or indices.
Parameters: |
|
---|
Source code in src/granad/orbitals.py
set_coulomb_groups(orb1, orb2, func)
Sets the Coulomb coupling between two groups of orbitals.
Parameters: |
|
---|
Note
The function func
should be complex-valued.
Source code in src/granad/orbitals.py
set_dipole_element(orb1, orb2, arr)
Sets a dipole transition for specified orbital or index pairs.
Parameters: |
|
---|
Source code in src/granad/orbitals.py
set_excitation(from_state, to_state, excited_electrons)
Sets up an excitation process from one state to another with specified electrons.
Parameters: |
|
---|
Note
The states and electron indices may be specified as scalars, lists, or arrays.
Source code in src/granad/orbitals.py
set_hamiltonian_element(orb1, orb2, val)
Sets an element of the Hamiltonian matrix between two orbitals or indices.
Parameters: |
|
---|
Source code in src/granad/orbitals.py
set_hamiltonian_groups(orb1, orb2, func)
Sets the hamiltonian coupling between two groups of orbitals.
Parameters: |
|
---|
Note
The function func
should be complex-valued.
Source code in src/granad/orbitals.py
set_mean_field(**kwargs)
Configures the parameters for mean field calculations. If no other parameters are passed, a standard direct channel Hartree-Fock calculation is performed. Note that this procedure differs slightly from the self-consistent field procedure.
This function sets up the mean field parameters used in iterative calculations to update the system's density matrix until convergence is achieved.
Parameters: |
|
---|
Example
model.set_mean_field(accuracy=1e-7, mix=0.5, iterations=1000) print(model.params.mean_field_params) {'accuracy': 1e-7, 'mix': 0.5, 'iterations': 1000, 'coulomb_strength': 1.0, 'f_mean_field': None}
Source code in src/granad/orbitals.py
set_onsite_hopping(orb, val)
Sets onsite hopping element of the Hamiltonian matrix.
Parameters: |
|
---|
Source code in src/granad/orbitals.py
set_position(position, orb_id=None)
Sets the position of all orbitals with a specific tag.
Parameters: |
|
---|
Note
This operation mutates the positions of the matched orbitals.
Source code in src/granad/orbitals.py
set_self_consistent(**kwargs)
Configures the parameters for self-consistent field (SCF) calculations.
This function sets up the self-consistency parameters used in iterative calculations to update the system's density matrix until convergence is achieved.
Parameters: |
|
---|
Example
model.set_self_consistent(accuracy=1e-7, mix=0.5, iterations=1000) print(model.params.self_consistency_params) {'accuracy': 1e-7, 'mix': 0.5, 'iterations': 1000, 'coulomb_strength': 1.0}
Source code in src/granad/orbitals.py
shift_by_vector(translation_vector, orb_id=None)
Shifts all orbitals with a specific tag by a given vector.
Parameters: |
|
---|
Note
This operation mutates the positions of the matched orbitals.
Source code in src/granad/orbitals.py
transform_to_energy_basis(observable)
Transforms an observable to the energy basis using the conjugate transpose of the system's eigenvectors.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/orbitals.py
transform_to_site_basis(observable)
Transforms an observable to the site basis using eigenvectors of the system.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/orbitals.py
Params
dataclass
Stores parameters characterizing a given structure.
Attributes: |
|
---|
Note
This object should not be created directly, but is rather used to encapsulate (ephemeral) internal state of OrbitalList.
Source code in src/granad/orbitals.py
TDResult
dataclass
A data class for storing the results of time-dependent simulations.
Attributes: |
|
---|
Source code in src/granad/orbitals.py
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 |
|
add_extra_attribute(name, value)
Dynamically adds an attribute to the 'extra_attributes' field.
Parameters: |
|
---|
Source code in src/granad/orbitals.py
ft_illumination(omega_max, omega_min, return_omega_axis=True)
Calculates the Fourier transform of the time-dependent illumination function over a specified frequency range, with an option to return the frequency axis.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/orbitals.py
ft_output(omega_max, omega_min)
Computes the Fourier transform of each element in the output data across a specified frequency range.
Parameters: |
|
---|
Returns: |
|
---|
Note
This method applies a Fourier transform to each array in the output
list to analyze the frequency components
between omega_min
and omega_max
.
Source code in src/granad/orbitals.py
get_attribute(name)
Returns the value of any specified attribute, no matter the original class attributes or the extra ones.
Parameters: |
|
---|
Return
Value of the attribute.
Source code in src/granad/orbitals.py
load(name)
classmethod
Constructs a TDResult object from saved data.
Parameters: |
|
---|
Returns: |
|
---|
Note
If the 'save_only' option was used earlier, the TDResult object will be created with only the available data, and missing fields will be filled with empty values of their corresponding types.
Source code in src/granad/orbitals.py
remove_extra_attribute(name)
Dynamically deletes an attribute from 'extra_attributes'.
Parameters: |
|
---|
Source code in src/granad/orbitals.py
save(name, save_only=None)
Saves the TDResult into a .npz file
Parameters: |
|
---|
Source code in src/granad/orbitals.py
Pulse(amplitudes, frequency, peak, fwhm)
Function for computing temporally located time-harmonics electric fields. The pulse is implemented as a temporal Gaussian.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/fields.py
Ramp(amplitudes, frequency, ramp_duration, time_ramp)
Function for computing ramping up time-harmonic electric fields.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/fields.py
Wave(amplitudes, frequency)
Function for computing time-harmonic electric fields.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/fields.py
Material
Represents a material in a simulation, encapsulating its physical properties and interactions.
Attributes: |
|
---|
Note
The Material
class is used to define a material's structure and properties step-by-step.
An example is constructing the material graphene, with specific lattice properties,
orbitals corresponding to carbon's p_z orbitals, and defining hamiltonian and Coulomb interactions
among these orbitals.
graphene = (
Material("graphene")
.lattice_constant(2.46)
.lattice_basis([
[1, 0, 0],
[-0.5, jnp.sqrt(3)/2, 0]
])
.add_orbital_species("pz", atom='C')
.add_orbital(position=(0, 0), tag="sublattice_1", species="pz")
.add_orbital(position=(-1/3, -2/3), tag="sublattice_2", species="pz")
.add_interaction(
"hamiltonian",
participants=("pz", "pz"),
parameters=[0.0, -2.66],
)
.add_interaction(
"coulomb",
participants=("pz", "pz"),
parameters=[16.522, 8.64, 5.333],
expression=lambda r : 1/r + 0j
)
)
Source code in src/granad/materials.py
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 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 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 |
|
add_interaction(interaction_type, participants, parameters=None, expression=zero_coupling)
Adds an interaction between orbitals specified by an interaction type and participants.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/materials.py
add_orbital(position, species, tag='')
Sets the lattice constant for the material.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/materials.py
add_orbital_species(name, s=0, atom='')
Adds a species definition for orbitals in the material.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/materials.py
cut_flake()
Finalizes the material construction by defining a method to cut a flake of the material, according to the material's dimensions like this
1D material : materials.cut_flake_1d 2D material : materials.cut_flake_2d 3D material and higher : materials.cut_flake_generic
This method is intended to be called after all material properties (like lattice constants, basis, orbitals, and interactions) have been fully defined.
Note: This method does not take any parameters and does not return any value. Its effect is internal to the state of the Material object and is meant to prepare the material for simulation by implementing necessary final structural adjustments.
Source code in src/granad/materials.py
lattice_basis(values, periodic=None)
Defines the lattice basis vectors and specifies which dimensions are periodic.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/materials.py
lattice_constant(value)
Sets the lattice constant for the material.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/materials.py
MaterialCatalog
A class to manage and access built-in material properties within a simulation or modeling framework.
This class provides a central repository for predefined materials, allowing for easy retrieval and description of their properties.
Attributes: |
|
---|
Methods:
Name | Description |
---|---|
get |
Retrieves the data object associated with the given material name. |
describe |
Prints a description or the data object of the specified material. |
available |
Prints a list of all available materials stored in the catalog. |
Source code in src/granad/materials.py
available()
staticmethod
Prints a list of all materials available in the catalog.
Source code in src/granad/materials.py
describe(material)
staticmethod
Prints a description or the raw data of the specified material from the catalog.
Parameters: |
|
---|
Source code in src/granad/materials.py
get(material, **kwargs)
staticmethod
Retrieves the material data object for the specified material. Additional keyword arguments are given to the corresponding material function.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/materials.py
cut_flake_1d(material, unit_cells, plot=False)
Cuts a one-dimensional flake from the material based on the specified number of unit cells and optionally plots the lattice and orbital positions.
Parameters: |
|
---|
Returns: |
|
---|
Note
The function utilizes internal methods of the Material
class to compute positions and
retrieve orbital data, ensuring that the positions are unique and correctly mapped to the
material's grid.
Source code in src/granad/materials.py
cut_flake_2d(material, polygon, plot=False, minimum_neighbor_number=2)
Cuts a two-dimensional flake from the material defined within the bounds of a specified polygon. It further prunes the positions to ensure that each atom has at least the specified minimum number of neighbors. Optionally, the function can plot the initial and final positions of the atoms within the polygon.
Parameters: |
|
---|
Returns: |
|
---|
Note
The function assumes the underlying lattice to be in the xy-plane.
Source code in src/granad/materials.py
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 |
|
cut_flake_generic(material, grid_range)
Cuts a flake from the material using a specified grid range. This method is generic and can be applied to materials of any dimensionality.
The function calculates the positions of orbitals within the unit cell, projects these onto the full lattice based on the provided grid range, and ensures that each position is unique. The result is a list of orbitals that are correctly positioned within the defined grid.
Parameters: |
|
---|
Returns: |
|
---|
Note
The grid_range parameter should be aligned with the material's dimensions and lattice structure, as mismatches can lead to incorrect or inefficient slicing of the material.
Source code in src/granad/materials.py
get_chain(hopping=-2.66, lattice_const=1.42)
Generates a 1D metallic chain model with specified hopping and Coulomb interaction parameters.
Parameters: |
|
---|
Returns: |
|
---|
Example
metal_chain = get_chain() print(metal_chain)
Source code in src/granad/materials.py
get_graphene(hoppings=None)
Generates a graphene model based on parameters from David Tománek and Steven G. Louie, Phys. Rev. B 37, 8327 (1988).
Parameters: |
|
---|
Returns: |
|
---|
Example
graphene_model = get_graphene(hopping=-2.7) print(graphene_model)
Source code in src/granad/materials.py
get_hbn(lattice_constant=2.5, bb_hoppings=None, nn_hoppings=None, bn_hoppings=None)
Get a material representation for hexagonal boron nitride (hBN).
Parameters: - lattice_constant (float): The lattice constant for hBN. Default is 2.50. - bb_hoppings (list or None): Hopping parameters for B-B interactions. Default is [2.46, -0.04]. - nn_hoppings (list or None): Hopping parameters for nearest-neighbor interactions. Default is [-2.55, -0.04]. - bn_hoppings (list or None): Hopping parameters for B-N interactions. Default is [-2.16].
Default values are derived from the study of the electronic structure of hexagonal boron nitride (hBN). See Giraud et al. for more details.
Returns: - A tuple containing the lattice constant and hopping parameters.
Source code in src/granad/materials.py
get_mos2()
Generates a MoS2 model based on parameters from Bert Jorissen, Lucian Covaci, and Bart Partoens, SciPost Phys. Core 7, 004 (2024), taking into account even-parity eigenstates.
Returns: |
|
---|
Example
mos2 = get_mos2() print(mos2)
Source code in src/granad/materials.py
603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 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 764 765 766 767 768 769 770 771 772 773 774 775 776 777 |
|
get_ssh(delta=0.2, displacement=0.4, base_hopping=-2.66, lattice_const=2.84)
Generates an SSH (Su-Schrieffer-Heeger) model with specified hopping parameters and a 2-atom unit cell.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/materials.py
ohno_potential(offset=0, start=14.399)
Generates a callable that represents a regularized Coulomb-like potential.
The potential function is parameterized to provide flexibility in adjusting the starting value and an offset, which can be used to avoid singularities at zero distance.
Parameters: |
|
---|
Returns: |
|
---|
Note
Source code in src/granad/materials.py
zero_coupling(d)
Returns a zero coupling constant as a complex number.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/materials.py
Circle(radius, n_vertices=8)
Generates the vertices of a polygon that approximates a circle, given the radius and the number of vertices.
The circle approximation is created by calculating points along the circumference using the radius provided. The number of vertices specifies how many sides the polygon will have, thus controlling the granularity of the approximation. By default, an octagon is generated.
Parameters: |
|
---|
Returns: |
|
---|
Note
The accuracy of the circle approximation improves with an increase in the number of vertices. For a smoother circle, increase the number of vertices.
Source code in src/granad/shapes.py
Hexagon(length)
Generates the vertices of a regular hexagon given the side length.
The hexagon is oriented such that one vertex points upwards and the function is designed to be used with the @_edge_type decorator for positional adjustments and rotations.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/shapes.py
Rectangle(length_x, length_y)
Generates the vertices of a rectangle given the lengths along the x and y dimensions.
The rectangle is centered at the origin, and the function is designed to be used with the @_edge_type decorator, allowing for positional shifts and rotations (if specified).
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/shapes.py
Rhomboid(base, height)
Generates the vertices of a rhomboid given the base length and height.
The rhomboid is initially oriented with the base along the x-axis, and one angle being 30 degrees, designed to be adjusted for position and orientation using the @_edge_type decorator.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/shapes.py
Triangle(side_length)
Generates the vertices of an equilateral triangle given the side length.
The triangle is oriented such that one vertex points upwards and the base is horizontal. This function is designed to be used with the @_edge_type decorator, which adds functionality to shift the triangle's position or rotate it based on additional 'shift' and 'armchair' parameters passed to the function.
Parameters: |
|
---|
Returns: |
|
---|
Note
# Create a triangle with side length of 1.0 angstrom, no shift or rotation
triangle = Triangle(1.0)
# Create a triangle with side length of 1.0 angstrom, shifted by [1, 1] units
triangle_shifted = Triangle(1.0, shift=[1, 1])
# Create a triangle with side length of 1.0 angstrom, rotated by 90 degrees (armchair orientation)
triangle_rotated = Triangle(1.0, armchair=True)
Source code in src/granad/shapes.py
BareHamiltonian()
Represents the unperturbed single-particle tight-binding mean field Hamiltonian, denoted as \(h^{(0)}\).
Returns: |
|
---|
Source code in src/granad/potentials.py
Coulomb()
Calculates the induced Coulomb potential based on deviations from a stationary density matrix, represented as \(\sim \lambda C(\rho-\rho_0)\). Here, \(\lambda\) is a scaling factor.
Returns: |
|
---|
Source code in src/granad/potentials.py
Diamagnetic(vector_potential)
Diamagnetic Coulomb gauge coupling to an external vector potential represented as \(\sim \vec{A}^2\).
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/potentials.py
DipoleGauge(illumination, use_rwa=False, intra_only=False)
Dipole gauge coupling to an external electric field, represented as \(\vec{E} \cdot \hat{\vec{P}}\). The dipole / polarization operator is defined by \(P^{c}_{ij} = <i|\hat{r}_c|j>\), where \(i,j\) correspond to localized (TB) orbitals, such that \(\hat{r}^c|i> = r^c{i}|i>\) in absence of dipole transitions.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/potentials.py
DipolePulse(dipole_moment, source_location, omega=None, sigma=None, t0=0.0, kick=False, dt=None)
Function to compute the potential due to a pulsed dipole. The potential can optionally include a 'kick' which is an instantaneous spike at a specific time. If the dipole is placed at a position occupied by orbitals, its contribution will be set to zero.
Parameters: |
|
---|
Returns: |
|
---|
Note
Recommended only with solver=diffrax.Dopri8.
Source code in src/granad/potentials.py
Induced()
Calculates the induced potential, which propagates the coulomb effect of induced charges in the system according to \(\sim \sum_r q_r/|r-r'|\).
Returns: |
|
---|
Source code in src/granad/potentials.py
Paramagnetic(vector_potential)
Paramagnetic Coulomb gauge coupling to an external vector potential represented as \(\sim \vec{A} \hat{\vec{v}}\).
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/potentials.py
WavePulse(amplitudes, omega=None, sigma=None, t0=0.0, kick=False)
Function to compute the wave potential using amplitude modulation. This function creates a pulse with temporal Gaussian characteristics and can include an optional 'kick' which introduces an instantaneous amplitude peak.
Parameters: |
|
---|
Returns: |
|
---|
Note
This function, when not kicked, computes the same term as Pulse
.
Source code in src/granad/potentials.py
DecoherenceTime()
Function for modelling dissipation according to the relaxation approximation.
SaturationLindblad(saturation)
Function for modelling dissipation according to the saturated lindblad equation as detailed in Pelc et al.. The argument stands for the saturation functional. If identity is selected as the saturation functional, the model represents the canonical Lindblad relaxation.
Source code in src/granad/dissipators.py
DP54_solver(rhs_func, ts, d_ini, args, postprocesses)
Solves an ODE using the Dormand-Prince 5(4) method with JAX acceleration.
Parameters: |
|
---|
Returns: |
|
---|
Notes
Implements the Dormand-Prince 5(4) method with seven stages and 5th-order accuracy. Uses coefficients from the Dormand-Prince tableau for high precision. Optimized with JAX's JIT compilation and scan functionality.
Source code in src/granad/_numerics.py
Euler_solver(rhs_func, ts, d_ini, args, postprocesses)
Solves an ODE using the explicit Euler method with JAX acceleration.
Parameters: |
|
---|
Returns: |
|
---|
Notes
Implements the explicit Euler method: y[n+1] = y[n] + dt * rhs_func(t[n], y[n], args). Uses JAX's JIT compilation and scan for efficient computation.
Source code in src/granad/_numerics.py
RK45_solver(rhs_func, ts, d_ini, args, postprocesses)
Solves an ODE using the 4th-order Runge-Kutta (RK4) method with JAX acceleration.
Parameters: |
|
---|
Returns: |
|
---|
Notes
Implements the classical RK4 method with four stages (k1, k2, k3, k4). Next state: y[n+1] = y[n] + (dt/6) * (k1 + 2k2 + 2k3 + k4). Optimized with JAX's JIT compilation and scan functionality.
Source code in src/granad/_numerics.py
fraction_periodic(signal, threshold=0.01)
Estimates the fraction of a periodic component in a given signal by analyzing the deviation of the cumulative mean from its median value. The periodicity is inferred based on the constancy of the cumulative mean of the absolute value of the signal.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/_numerics.py
get_coulomb_field_to_from(source_positions, target_positions, compute_at=None)
Calculate the contributions of point charges located at source_positions
on points at target_positions
.
Args: - source_positions (array): An (n_source, 3) array of source positions. - target_positions (array): An (n_target, 3) array of target positions.
Returns: - array: An (n_source, n_target, 3) array where each element is the contribution of a source at a target position.
Source code in src/granad/_numerics.py
iterate(func)
A decorator that allows a function to iterate over list inputs.
Functionality: 1. If one or more of the function’s input arguments is a list, the function is executed for every combination of elements. 2. If multiple list inputs are present, the computation follows a Cartesian product pattern: - For the 1st element of list A, iterate over all elements of list B. - For the 2nd element of list A, iterate over all elements of list B. - And so on. 3. The results are reshaped into a nested structure matching the input lists. 4. If the function returns multiple values (a tuple), each return value is separately structured into its own nested list.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/_numerics.py
nest_result(result_list, shape)
Recursively reshapes a flat list into a nested list structure matching the Cartesian product shape.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/granad/_numerics.py
show_2d(orbs, show_tags=None, show_index=False, display=None, scale=False, cmap=None, circle_scale=1000.0, title=None, mode=None, indicate_atoms=False, grid=False)
Generates a 2D scatter plot representing the positions of orbitals in the xy-plane, with optional filtering, coloring, and sizing.
Parameters: |
|
---|
Notes
If display
is provided, the points are colored and sized according to the values in the display
array, and a color bar is added to the plot.
If show_index
is True
, the indices of the orbitals are annotated next to their corresponding points.
The plot is automatically adjusted to ensure equal scaling of the axes, and grid lines are displayed.
Source code in src/granad/_plotting.py
show_3d(orbs, show_tags=None, show_index=False, display=None, scale=False, cmap=None, circle_scale=1000.0, title=None)
Generates a 3D scatter plot representing the positions of orbitals in 3D space, with optional filtering, coloring, and sizing.
Parameters: |
|
---|
Notes
If display
is provided, the points are colored and sized according to the values in the display
array, and a color bar is added to the plot.
If show_index
is True
, the indices of the orbitals are annotated next to their corresponding points.
The plot is automatically adjusted to display grid lines and 3D axes labels for X, Y, and Z.
Source code in src/granad/_plotting.py
show_energies(orbs, display=None, label=None, e_max=None, e_min=None)
Depicts the energy and occupation landscape of a stack, with energies plotted on the y-axis and eigenstates ordered by size on the x-axis.
Parameters: |
|
---|
Notes
The scatter plot displays the eigenstate number on the x-axis and the corresponding energy (in eV) on the y-axis. The color of each point represents the initial state occupation, calculated as the product of the electron count and the initial density matrix diagonal element for each state. A color bar is added to indicate the magnitude of the initial state occupation for each eigenstate.
Source code in src/granad/_plotting.py
show_induced_field(orbs, x, y, z, component=0, density_matrix=None, scale='log', levels=100)
Displays a 2D plot of the normalized logarithm of the absolute value of the induced field, for a given field component.
Parameters: |
|
---|
Note
The plot visualizes the induced field's magnitude using a logarithmic scale for better representation of variations in field strength. The field is normalized before applying the logarithm, ensuring that relative differences in field strength are emphasized.
Source code in src/granad/_plotting.py
show_res(orbs, res, plot_only=None, plot_labels=None, show_illumination=False, omega_max=None, omega_min=None, xlabel=None, ylabel=None)
Visualizes the evolution of an expectation value over time or frequency, based on the given simulation results.
Parameters: |
|
---|
Notes
The function adapts automatically to display either time-dependent or frequency-dependent results based on the presence of omega_max
and omega_min
.
If show_illumination
is enabled, the function plots the illumination components (x
, y
, z
) as additional curves.
The x-axis label changes to represent time or frequency, depending on the mode of operation.