-1
$\begingroup$

For the 1D Quantum Heisenberg Spin Model:

$\displaystyle {\hat H = -\frac{1}{2} \sum_{j=1}^{N} (J_x \sigma_j^x \sigma_{j+1}^x + J_y \sigma_j^y \sigma_{j+1}^y + J_z \sigma_j^z \sigma_{j+1}^z + h\sigma_j^{z})}$

Where ${\sigma_{j}^x}, {\sigma_{j}^y}, {\sigma_{j}^z}$ are pauli matrices.

Are there any open source library to calculate its partition functions for any number of spins and $J$ ? (prefer in Python, C or C++).

Above expression is only for nearest neighbor interaction. We are also interested in interactions between any spin.

$\endgroup$
0

1 Answer 1

1
+50
$\begingroup$

I am not aware of any publicly available code but it seems hardly necessary, this system is very easy to implement. Here is some Mathematica code that I wrote in a couple of minutes:

Σ[a_][1, 1] := PauliMatrix[a];
Σ[a_][n_, i_] /; 1 <= i < n := KroneckerProduct[Σ[a][n - 1, i], IdentityMatrix[2]];
Σ[a_][n_, n_] := KroneckerProduct[IdentityMatrix[2^(n - 1)], PauliMatrix[a]];

With[{n = 4},
    -1/2 Sum[jx Σ[1][n, j].Σ[1][n, Mod[j, n] + 1] + jy Σ[2][n, j].Σ[2][n, Mod[j, n] + 1] + jz Σ[3][n, j].Σ[3][n, Mod[j, n] + 1] + h Σ[3][n, j], {j, 1, n}]
]

You can easily compute the spectrum of $H$ numerically for small $n$. For example take $n=8$ and $h=0$, and work in units where $J_x=1$. Then, the gap of the system as a function of $J_y,J_z$ is obtained via

Flatten[Table[{jy, jz, #[[2]] - #[[1]] &@Sort[Eigenvalues[%]]}, {jy, 0, 2, .01}, {jz, 0, 2, .01}], 1]
ListDensityPlot[%, Axes -> True, AxesLabel -> {"jy", "jz"}, PlotLegends -> Automatic]

enter image description here

so we clearly see transitions across points and lines of enhanced symmetry, $J_y=1$ and $J_z=1$.

The partition function is also very easy to evaluate, you just use Tr[MatrixExp[-β H]].

For larger $n$ it becomes very costly to construct (let alone, diagonalize) the Hamiltonian so you need to be cleverer. The code above has a lot of room for improvement but in the end, if you want really large $n$, there are no exact methods available, you need approximations (some smart truncation, a statistical approach, or even using hardware specifically designed for such calculations...)

If you insist on using C/python/etc you'll have to translate the code above to your preferred language. It should be self-explanatory so I am sure you will succeed.

$\endgroup$
15
  • $\begingroup$ Doesn't this scale exponentially in $n$? $\endgroup$ Commented Aug 27, 2023 at 21:10
  • 1
    $\begingroup$ @NorbertSchuch It very much does, indeed. Not as much as a problem with the algorithm itself: the Hilbert space of the theory is $2^n$ dimensional. Hence, my second-to-last paragraph: it is not feasible to solve the problem exactly (with my code, or in any other way) unless $n$ is relatively small (or you are capable of making a quantum computer, with a large number of qubits, of course) $\endgroup$ Commented Aug 27, 2023 at 22:37
  • $\begingroup$ Thank you for posting the answer. I can work with the Mathematica code. In your code, why do we need Mod[j, n] ?Plus, what do you plot ? What is the x-axis ? y-axis ? and what does the color mean ? Can you also post the code that you used to calculate the spectrum and plotting ? Thank you. $\endgroup$
    – david
    Commented Aug 28, 2023 at 1:55
  • $\begingroup$ @AccidentalFourierTransform, One thing confused me is that, we have $\sigma_1^x \sigma_{2}^x$, which is $4 \times 4$ matrix, $\sigma_2^y \sigma_{3}^y$ is also a $4 \times 4$ matrix. When we put them into a $8 \times 8$ matrix, where to put them ? If we allow interaction between Spin 1 and Spin 3, then we will also have $\sigma_1^x \sigma_{3}^x$, where to put this matrix in to the $8 \times 8$ matrix ? $\endgroup$
    – david
    Commented Aug 28, 2023 at 2:26
  • $\begingroup$ @AccidentalFourierTransform I strongly disagree that it is clear that "it is not feasible to solve the problem exactly" -- for instance, at least without field this should be solvable by Bethe ansatz. There's plenty of problems where one can find simpler (e.g. transfer matrix formulation for classical 1D statmech) or even closed (e.g. Bethe ansatz) solutions. Ruling this out categorically would require a proof. $\endgroup$ Commented Aug 28, 2023 at 14:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.