Bath
Bath
Calculations and visualizations related to the electron bath coupled to the spin system.
This module provides functions to calculates various physical quantities based on the second order tunneling theory. It most importantly calculates the tunneling rates and matrix elements. From this various physical quantities can be derived, such as magnetization, lifetimes, tunneling current, and population distributions.
Functions:
| Name | Description |
|---|---|
calc_Magnetization |
Calculate the magnetization of the given |
calc_Lifetimes |
Calculate the lifetimes (T1) for each state of the given |
calc_TunnelCurrent |
Calculate the tunneling current of the given |
calc_Populations |
Calculate the population distribution of spin states of the given |
calc_Rates |
Calculate transition rates of the given |
calc_RateIntegrals |
Calculate rate integrals of the given |
calc_TunnelingMatrixElements |
Calculate the tunneling matrix elements for the |
calc_TunnelingElectronMatrixElements |
Calculate tunneling electron matrix elements of the given |
plot_Populations |
Plot the thermal and steady state populations of the given |
plot_RateContributions |
Plot the contributions of the highest N transition rates between spin states. |
plot_RatesTo |
Plot the rate contributions to a specified state of the given |
plot_RatesFrom |
Plot the rate contributions from a specified state of the given |
Dependencies
- Uses
spinfinity.SpinSys.SpinSysclass to represent the spin system and its properties. - Uses
spinfinity.SpinHamiltonianfor eigenvalue and eigenvector calculations.
References
- Ternes, M., Spin excitations and correlations in scanning tunneling spectroscopy. New J. Phys. 17, 063016 (2015). https://dx.doi.org/10.1088/1367-2630/17/6/063016
- Loth, S., von Bergmann, K., Ternes, M. et al. Controlling the state of quantum spins with electric currents. Nature Phys 6, 340–344 (2010). https://doi.org/10.1038/nphys1616
calc_Lifetimes(spinsys)
Calculate the lifetimes (T1) for each state of the given SpinSys object.
This function computes the total and natural lifetimes for each state in the given spin system by summing the transition rates out of each state. If the rate matrix is not already calculated, it will be computed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spinsys
|
SpinSys
|
The spin system object containing state information and rate matrices. |
required |
Notes
The function updates the following attributes of spinsys:
spinsys.T1_tot: The total lifetime for each state, considering all possible transitions.spinsys.T1_ss: The natural lifetime for each state, considering only sample-sample scattering.
Source code in spinfinity/Bath.py
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 | |
calc_Magnetization(spinsys, type='z', AllowPumping=True)
Calculate the magnetization of the given SpinSys object along a specified axis.
This function calculates the magnetization of a spin system by projecting the spin operators onto the eigenstates of the system and weighting them by the population of each state. The magnetization can be calculated along the 'x', 'y', or 'z' axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spinsys
|
SpinSys
|
The spin system object containing eigenvectors, spin operators, and populations. |
required |
type
|
str
|
The axis along which to calculate magnetization ('x', 'y', or 'z'). Default is 'z'. |
'z'
|
AllowPumping
|
bool
|
Whether to allow population pumping during calculation. Default is True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
Mag |
ndarray
|
A 1D array containing the magnetization for each individual spin. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Notes
The function updates the following attributes of spinsys:
- Mag_tot: The total magnetization of the system.
- Mag_tot_max: The maximum possible total magnetization.
- Mag: The magnetization for each individual spin.
- Mag_max: The maximum possible magnetization for each spin.
- Magtype: The axis along which magnetization was calculated.
Source code in spinfinity/Bath.py
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 | |
calc_Populations(spinsys, AllowPumping=True)
Calculate the population distribution of spin states of the given SpinSys object.
Computes the thermal population distribution based on Boltzmann statistics. If pumping is allowed, calculates the non-thermal population by solving the steady-state of the rate equations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spinsys
|
SpinSys
|
The spin system object containing energy levels, temperature, and other relevant parameters. |
required |
AllowPumping
|
bool
|
If True, calculates the non-thermal population considering pumping. Default is True. |
True
|
Notes
If pumping is not allowed or no valid solution is found for the non-thermal
population, the thermal population is used.
The function updates the following attributes of spinsys:
spinsys.pop_0: The normalized thermal population distribution.spinsys.Populations: The final population distribution considering pumping if allowed, otherwise the thermal population.spinsys.K: The rate matrix used for solving the steady-state population.
Source code in spinfinity/Bath.py
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 | |
calc_RateIntegrals(spinsys, type)
Calculate rate integrals of the given SpinSys object and scattering parameters.
The function calculates the rate integrals for tip-to-sample (ts), sample-to-tip (st), sample-to-sample (ss), and tip-to-tip (tt) scattering processes based on the energy levels of the spin system, the bias voltage, and the temperature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spinsys
|
SpinSys
|
An instance of the SpinSys class containing system parameters such as energy levels, Boltzmann constant, temperature, and matrix dimension. |
required |
type
|
str
|
The type of transition to calculate. Must be one of: - 'ts': tip to sample - 'st': sample to tip - 'ss': sample to sample - 'tt': tip to tip |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RateIntegrals |
ndarray
|
A 2D numpy array of shape (dimensionOfMatrix, dimensionOfMatrix) containing the calculated rate integrals for each pair of energy levels. |
Notes
The function avoids division by zero by substituting a small value for V_DC if it is zero.
Source code in spinfinity/Bath.py
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 | |
calc_Rates(spinsys)
Calculate transition rates of the given SpinSys object and tunnel parameters.
The function calculates the transition rates for tip-to-sample (ts), sample-to-tip
(st),sample-to-sample (ss), and tip-to-tip (tt) scattering processes based on the
tunneling matrix elements and rate integrals. It uses the tunnel parameters defined
in the spinsys object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spinsys
|
SpinSys
|
The spin system object containing all relevant parameters and matrices. |
required |
Notes
The function updates the following attributes of spinsys:
spinsys.Rates: A 3D array containing the calculated transition rates for each scattering process and state pair.spinsys.Rates_Summed: A 2D array containing the sum of all transition rates for each state pair.spinsys.MatrixST: The tunneling matrix elements for tip-sample scattering.spinsys.MatrixTS: The tunneling matrix elements for sample-tip scattering.spinsys.MatrixSS: The tunneling matrix elements for sample-sample scattering.spinsys.MatrixTT: The tunneling matrix elements for tip-tip scattering.
Source code in spinfinity/Bath.py
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 | |
calc_TunnelCurrent(spinsys, AllowPumping=True)
Calculate the tunneling current of the given SpinSys object.
The tunneling current is calculated using the populations of the spin states. If the populations are not already calculated, they will be computed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spinsys
|
SpinSys
|
The spin system object containing energy levels, populations, rates, and other relevant parameters. |
required |
AllowPumping
|
bool
|
If True, allows for non-thermal population effects (default is True). |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
Current |
float
|
The calculated tunneling current. |
Source code in spinfinity/Bath.py
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 | |
calc_TunnelingElectronMatrixElements(spinsys, scattertype)
Calculate tunneling electron matrix elements of the given SpinSys object.
This function computes the matrix elements associated with tunneling electrons between tip and sample, considering their spin polarizations. It normalizes the tip and sample polarizations if necessary, constructs the corresponding density matrices, and calculates the matrix elements for the specified scattering type ('st', 'tt', or 'ss').
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spinsys
|
SpinSys
|
An object representing the spin system, containing tip and sample polarizations. |
required |
scattertype
|
str
|
The type of scattering to calculate matrix elements for. Options are: - 'st': tip-to-sample scattering - 'tt': tip-to-tip scattering - 'ss': sample-to-sample scattering |
required |
Returns:
| Name | Type | Description |
|---|---|---|
x |
ndarray
|
Matrix elements for the x-component of spin. |
y |
ndarray
|
Matrix elements for the y-component of spin. |
z |
ndarray
|
Matrix elements for the z-component of spin. |
u |
ndarray
|
Matrix elements for the identity component. |
Source code in spinfinity/Bath.py
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 | |
calc_TunnelingMatrixElements(spinsys, scattertype)
Calculate the tunneling matrix elements for the SpinSys and scattering type.
This function computes the tunneling matrix elements for the specified scattering type ('st', 'ts', 'ss', or 'tt') by combining the electron tunneling matrix elements with the spin operators of the system. The resulting matrix elements are calculated in the eigenbasis of the spin system and are used to determine the transition rates for different scattering processes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spinsys
|
SpinSys
|
An instance of the SpinSys class containing the spin system properties, eigenvectors, and spin operators (Sx, Sy, Sz, U). |
required |
scattertype
|
str
|
Type of scattering process. If "ss", calculations are performed for all spins; otherwise, calculations are performed for the readout spin only. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RateMatrix |
ndarray
|
Array containing the calculated tunneling rate matrix elements. The shape is (NSpins, dimensionOfMatrix, dimensionOfMatrix) for "ss" scattertype, and (1, dimensionOfMatrix, dimensionOfMatrix) otherwise. |
Source code in spinfinity/Bath.py
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 | |
plot_Populations(spinsys, AllowPumping=True)
Plot the thermal and steady state populations of the given SpinSys object.
The function generates a horizontal bar plot comparing the thermal population (calculated from Boltzmann statistics) and the steady-state population (calculated from the rate equation) for each eigenstate of the spin system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spinsys
|
SpinSys
|
The spin system object containing the necessary parameters and methods. |
required |
AllowPumping
|
bool
|
Whether to allow pumping effects in the calculation (default is True). |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
return_dict |
dict
|
A dictionary containing: - 'fig': plotly.graph_objects.Figure The plotly figure object containing the plot. |
Source code in spinfinity/Bath.py
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 | |
plot_RateContributions(spinsys, yscale='linear', N=None, ylim=None)
Plot the contributions of the highest N transition rates between spin states.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spinsys
|
SpinSys
|
The spin system object containing the states, rates, and matrix dimension. |
required |
yscale
|
str
|
The scale for the y-axis ('linear' or 'log'). Default is 'linear'. |
'linear'
|
N
|
int
|
The number of highest rate transitions to display. If None, all transitions are shown (default is None). |
None
|
ylim
|
list of float
|
The limits for the y-axis as [ymin, ymax]. If None, no limits are set (default is None). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
return_dict |
dict
|
A dictionary containing: - 'fig': plotly.graph_objects.Figure The plotly figure object containing the plot. |
Source code in spinfinity/Bath.py
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 | |
plot_RatesFrom(spinsys, state, yscale='linear', N=None)
Plot the rate contributions from a specified state of the given SpinSys object.
This function calculates and visualizes the transition rates to all other states from a given initial state in the provided spin system. The rates are displayed as stacked bar plots, with each bar representing the contributions from different rate components (e.g., 'ts', 'st', 'ss', 'tt').
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spinsys
|
SpinSys
|
The spin system object containing state information and rate matrices. |
required |
state
|
int
|
The index of the target state to which rates are plotted. |
required |
yscale
|
str
|
The scale for the y-axis of the plot. Can be 'linear' or 'log'. Default is 'linear'. |
'linear'
|
N
|
int
|
The number of highest rate transitions to display. If None, all transitions are shown. Default is None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
return_dict |
dict
|
A dictionary containing: - 'fig': plotly.graph_objects.Figure The plotly figure object containing the plot. |
Source code in spinfinity/Bath.py
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 | |
plot_RatesTo(spinsys, state, yscale='linear', N=None)
Plot the rate contributions to a specified state of the given SpinSys object.
This function calculates and visualizes the transition rates from all other states to a given target state in the provided spin system. The rates are displayed as stacked bar plots, with each bar representing the contributions from different rate components ('ts', 'st', 'ss', 'tt').
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spinsys
|
SpinSys
|
The spin system object containing state information and rate matrices. |
required |
state
|
int
|
The index of the target state to which rates are plotted. |
required |
yscale
|
str
|
The scale for the y-axis of the plot. Can be 'linear' or 'log'. Default is 'linear'. |
'linear'
|
N
|
int
|
The number of highest rate transitions to display. If None, all transitions are shown. Default is None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
return_dict |
dict
|
A dictionary containing: - 'fig': plotly.graph_objects.Figure The plotly figure object containing the plot. |
Source code in spinfinity/Bath.py
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 | |