示例#1
0
        public static void SelectedBoundaries(List <Grain> grains, int width, int xNumOfCells, int yNumOfCells)
        {
            MainWindow.grain2Edge = getAllSelectedGrains(grains);
            List <Grain> grainsOnEdges = Inclusions.GrainOnEdges(MainWindow.grain2Edge, width, xNumOfCells, yNumOfCells);

            DrawEdges(grainsOnEdges);
        }
示例#2
0
 public static void DistributeEnergy(int EnergyDistribution, int EnergyOnEgdes, int EnergyInside)
 {
     if (EnergyDistribution == 0)
     {
         int energy = (EnergyOnEgdes + EnergyInside) / 2;
         foreach (Grain g in MainWindow.GrainTable)
         {
             g.EnergyColor = Color.FromRgb(255, (byte)(255 * energy / EnergyOnEgdes), 0);
             g.H           = energy;
         }
     }
     else
     {
         List <Grain> grainsOnEdges = Inclusions.GrainOnEdges(1, MainWindow.XNumOfCells, MainWindow.YNumOfCells);
         foreach (Grain g in MainWindow.GrainTable)
         {
             if (grainsOnEdges.Contains(g))
             {
                 g.EnergyColor = Color.FromRgb(255, (byte)(0), 0);
                 g.H           = EnergyOnEgdes;
             }
             else
             {
                 g.EnergyColor = Color.FromRgb(255, (byte)(255 - 255 * EnergyInside / EnergyOnEgdes), 0);
                 g.H           = EnergyInside;
             }
         }
     }
 }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int amount = int.Parse(AmountOfInclusionsTxtBox.Text);
                int size = int.Parse(SizeOfInclusionsTxtBox.Text);
                int type = TypeOfInclusionComboBox.SelectedIndex;
                switch (type)
                {
                    case 0:
                        Inclusions.Circular(amount,size,XNumOfCells, YNumOfCells);
                        break;
                    case 1:
                        Inclusions.Diagonal(amount, size, XNumOfCells, YNumOfCells);
                        break;
                    default:
                        Inclusions.Circular(amount, size, XNumOfCells, YNumOfCells);
                        break;
                }
                PaintPane();

            }
            catch (Exception) { }
            
        }
        public static List <Grain> GetNewMCList()
        {
            List <Grain> list = new List <Grain>();

            foreach (Grain g in MainWindow.GrainTable)
            {
                if (Inclusions.IsOnTheEdge(g, 1, MainWindow.XNumOfCells, MainWindow.YNumOfCells))
                {
                    if (g.Inclusion == false)
                    {
                        list.Add(new Grain(g));
                    }
                }
            }
            list = MonteCarlo.ShuffleList(list);
            return(list);
        }
示例#5
0
        public static void Nucleate(int number, int location)
        {
            Random rand = new Random();

            if (location == 0)
            {
                List <Grain> grainsOnEdges = Inclusions.GrainOnEdges(1, MainWindow.XNumOfCells, MainWindow.YNumOfCells);
                grainsOnEdges.RemoveAll(x => x.Recrystalized == true);

                for (int i = 0; i < number; i++)
                {
                    Grain g = grainsOnEdges.ElementAt(rand.Next(grainsOnEdges.Count));
                    g.Recrystalized = true;
                    Color color = Color.FromRgb((byte)(rand.Next(206) + 50), 0, 0);
                    g.Seed(color);
                    g.EnergyColor = Color.FromRgb(255, 255, 255);
                    g.H           = 0;
                    grainsOnEdges.Remove(g);
                }
            }
            else
            {
                for (int i = 0; i < number; i++)
                {
                    int x, y;
                    do
                    {
                        x = rand.Next(MainWindow.XNumOfCells);
                        y = rand.Next(MainWindow.YNumOfCells);
                    } while (MainWindow.GrainTable[x, y].Recrystalized);
                    MainWindow.GrainTable[x, y].Recrystalized = true;
                    Color color = Color.FromRgb((byte)(rand.Next(206) + 50), 0, 0);
                    MainWindow.GrainTable[x, y].Seed(color);
                    MainWindow.GrainTable[x, y].EnergyColor = Color.FromRgb(255, 255, 255);
                    MainWindow.GrainTable[x, y].H           = 0;
                }
            }
        }
示例#6
0
        public static void AllBoundaries(int width, int xNumOfCells, int yNumOfCells)
        {
            List <Grain> grainsOnEdges = Inclusions.GrainOnEdges(width, xNumOfCells, yNumOfCells);

            DrawEdges(grainsOnEdges);
        }