Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public SpinSystem(int jay, int length)
 {
     random      = new Random();
     this.Length = length;
     spins       = new Spin[length, length];
     for (int i = 0; i < length; i++)
     {
         for (int j = 0; j < length; j++)
         {
             spins[i, j] = new Spin(random.Next(1, 2));
         }
     }
     J         = new Spin(jay);
     OldEnergy = this.GetEnergySystem();
 }