3
$\begingroup$

I am trying to solve the Ising model for $4 \times 4$ square lattice without a magnetic field. The calculation involved evaluating the expression below, enter image description here

After writing the code as

Z = (1+ t sigma_1 sigma_2)(1+ t sigma_2 sigma_3)(1+ t sigma_3 sigma_4)....(1+ t sigma_12 sigma_16)

I evaluate

Expand[Z]

Which gives a polynomial in t, which contains roughly 8 million terms. According to the Ising construction, only 512 terms should give non-zero contributions to the final result. The way to identify the non-zero contributions is to find coefficients of the even power of t such that all the sigma's in a given product have even power. For example

t^4 (sigma_1 sigma_2 sigma_5 sigma_6)^2

Simply put, the expression I am looking for looks like below enter image description here

Where $\cdots$ are the terms containing even power in various $\sigma$. The problem is writing a piece of code which do this sorting.

I am not quite used to coding. Hope someone can help me to write code for this problem. Thanks in advance.

$\endgroup$

1 Answer 1

2
$\begingroup$

I may have misunderstood what you are requesting - I propose the following. I use a 2D indexing scheme, which may not be what you intended.

z = Product[
    1 + σ[i, j] σ[i + 1, j] t, {i, 1, 3}, {j, 1, 4}]*
   Product[1 + σ[i, j] σ[i, j + 1] t, {i, 1, 4}, {j, 1, 
     3}];

As you say there are about 8 million terms

Length[Expand[z]]
(* 8790016 *)

Define a rule that retains the even power terms, while eliminating the odd power terms. You should ensure that this does what you require.

rule = {u : σ[_, _]^n_ /; EvenQ[n] -> 
    u, σ[_, _]^n_. /; OddQ[n] -> 0};

If I have followed your question, Z takes a values given by

Z = Sum[t^(2 i) Expand[Coefficient[z, t, 2 i]], {i, 1, 10}] /. rule;

I count 384 terms rather than 512, but you might well be able to identify where the discrepancy originates.

Length[Expand[Z]]
(* 384 *)

Hope this helps!

$\endgroup$
2
  • $\begingroup$ Thanks for your answer. I may need to look at the number of terms one more time anyway. Considering $\sigma_{1,1}$ and $\sigma_{1,2}$ as two vertices, one can connect them by an edge. In this way, connecting all the vertices for a given power of t will give polygons with different lengths. Will it be possible to turn each term of your answer into such a polygon by writing some code in Mathematica? Thank you! $\endgroup$ Commented Aug 27, 2022 at 23:53
  • 1
    $\begingroup$ If you need further help, I suggest that you ask another question. $\endgroup$ Commented Aug 28, 2022 at 7:58

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.