def checkEnergyDiff(row, col, lattice, temp, J=1, B=0, mu=1):
    """Calculates the energy difference of a specified site in a lattice
    assuming periodic boundary conditions. The difference is between being
    flipped and not being flipped.

    Inputs:
    row        row number of the chosen site
    col        column number of the chosen site
    lattice    the current lattice
    temp       the value for kT in our simulation
    J          coupling constant between neighboring sites
    B          external magnetic field
    mu         magnetic moment of the lattice site

    Output:
    energy    the energy difference at the given site
    """

    # Get number of rows and columns from lattice

    rows, cols = (lattice.shape[0], lattice.shape[1])

    # Calculate the energy

    energy = 2 * J * lattice[row][col] * (lattice[(row + rows - 1) % rows][col]
                                          + lattice[row][(col + 1) % cols]
                                          + lattice[(row + 1) % rows][col]
                                          + lattice[row][(col + cols - 1) % cols]) + (
                                          2 * B * mu * lattice[row][col])

    return energy