public int Neighbours(int i, int j) { Spin center = spins[i, j]; int sum = center.GetSpin() * (spins[Overflow(i + 1), Overflow(j)].GetSpin() + spins[Overflow(i - 1), Overflow(j)].GetSpin() + spins[Overflow(i), Overflow(j + 1)].GetSpin() + spins[Overflow(i), Overflow(j - 1)].GetSpin()); return(sum); }
public int GetEnergySystem() { int sum = 0; for (int i = 0; i < this.Length; i++) { for (int j = 0; j < this.Length; j++) { sum += Neighbours(i, j); } } return(-J.GetSpin() * sum); }