pythonjupytersimulationphysics

Displaying the spins on the links of the Ising Lattice Gauge model


I am trying to display the spins on the site of the Ising Lattice Gauge theory which has spins placed on the bonds instead of the usual sites (in the case of the Ising Theory) in 2D. Basically the idea is that instead of the spins being on the sites as in the case of the Ising Model, they reside on the link between the two sites.

Using PIL in Python one can easily display these sites for the 2D Ising model by considering the spins to be in an N x N matrix. Here is the example of a 100 x 100 grid. But I am not sure how to do this in the case of the Lattice Gauge Theory where the spins are actually on the bonds. Can someone help me? Thanks it is my first time posting here.

Ising Spins on a 500 x 500 lattice

Edit: Did not realise LaTex is not a thing here.


Solution

  • Assuming only nearest neighbour bonds (I'm not sure whether that is accurate), you have an N x (N-1) matrix for all horizontal bonds and an (N - 1) x N matrix for the vertical ones.

    Assume these matrices are each populated with entries of +1 for spin-up and -1 for spin-down.

    To visualize this structure (using PIL), you could use the following script:

    array = np.zeros((2 * N - 1, 2 * N - 1))
    for i in range(N):
        for j in range(N):
            if j < (N - 1):
                array[2 * i, 2 * j + 1] = vert_bonds[i, j]
            if i < (N - 1):
                array[2 * i + 1, 2 * j] = hori_bonds[i, j]
    

    We can then plot array using PIL, but I would actually suggest using matplotlib instead, as it is much more designed to handle this kind of data. With minimal modifications, we can get the following image:

    small ising lattice gauge model plot

    Or with a larger system:

    large ising lattice gauge model plot

    The full code for these figures is:

    import numpy as np
    import matplotlib.pyplot as plt
    
    N = 10
    
    
    if __name__ == "__main__":
    
        # Your input data
        vert_bonds = np.random.randint(2, size=(N, N - 1))
        hori_bonds = np.random.randint(2, size=(N - 1, N))
    
        # Make sure we differentiate spin-down from nodes
        vert_bonds[vert_bonds == 0] = -1
        hori_bonds[hori_bonds == 0] = -1
    
        array = np.zeros((2 * N - 1, 2 * N - 1))
        for i in range(N):
            for j in range(N):
                if j < (N - 1):
                    array[2 * i, 2 * j + 1] = vert_bonds[i, j]
                if i < (N - 1):
                    array[2 * i + 1, 2 * j] = hori_bonds[i, j]
    
        # more customiyable plotting tool
        plt.imshow(array, cmap="seismic")
        plt.savefig("ising-lattice-gauge-small.png")
        plt.show()
    

    Please let me know whether that answers your question, or whether you have any other queries!

    edit: changed alt-text for large plot