def site(coord, size, xperiodic):
    """
    numbering the square lattice sites

    Parameters
    --------------
    site : (x, y)
        (x, y) coordinate of the site
    size : (int, int) -> (nx, ny)
        linear size of the square lattice
    xperiodic : boolean
        indicates PBC along x
    """
    nx, ny = size[0], size[1]
    x, y = coord[0], coord[1]
    if xperiodic == False:
        return y * nx + x
    else:
        if x == nx - 1:
            return y * (nx - 1)
        else:
            return y * (nx - 1) + x