コード例 #1
0
 private void StartSRXMCBtn_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (SRXMC)
         {
             SRXMC = false;
             StartSRXMCBtn.Content = "Start RSXMC";
             timer.Stop();
         }
         else
         {
             NumberOfIterationFromGUI = int.Parse(NUmberOfIterationsSRXMCTxtBox.Text);
             if (NumberOfIterationFromGUI > 0)
             {
                 SRXMC = true;
                 StartSRXMCBtn.Content = "Stop RSXMC";
                 int numberofnucleons = int.Parse(NUmberOfNucleonsTxtBox.Text);
                 int location = LocationCmbBox.SelectedIndex;
                 int nucleationtype = NucleationTypeCmbBox.SelectedIndex;
                 RSXMC.Nucleate(numberofnucleons, location);
                 RSXMCList = RSXMC.NewRSXMCList();
                 PaintPane();
                 timer.Start();
             }
         }
     }
     catch (Exception) { }
  
 }
コード例 #2
0
        private void Update(object sender, EventArgs e)
        {
            if (!monteCarlo && !SRXMC)
            {
                for (int i = 0; i < XNumOfCells; i++)
                {
                    for (int j = 0; j < YNumOfCells; j++)
                    {
                        if (!Growth.Moore(i, j, XNumOfCells, YNumOfCells))
                        {
                            if (!Growth.NearestMoore(i, j, XNumOfCells, YNumOfCells))
                            {
                                if (!Growth.FutherMoore(i, j, XNumOfCells, YNumOfCells))
                                {
                                    Growth.RuleFour(i, j, XNumOfCells, YNumOfCells);
                                }
                            }
                        }
                    }
                }
                Growth.Replace(GrainTable, TempGrainTable, XNumOfCells, YNumOfCells);
            }
            else if(monteCarlo)
            {
                while (grainMCList.Any())
                {
                    MonteCarlo.ChangeGrains();
                }
                grainMCList = MonteCarlo.GetNewMCList();
                NumberOfMCIterations++;
                NumberOfIterationsTextBox.Text = (NumberOfIterationFromGUI - NumberOfMCIterations).ToString();

                if (NumberOfMCIterations >= NumberOfIterationFromGUI)
                {
                    monteCarlo = false;
                    StartMCBtn.Content = "START MC";
                    timer.Stop();
                    NumberOfMCIterations = 0;
                }
            }
            else
            {
                while (RSXMCList.Any())
                {
                    MonteCarlo.ChangeRSXGrains();
                }
                RSXMCList = RSXMC.NewRSXMCList();
                NumberOfMCIterations++;
                NumberOfIterationsTextBox.Text = (NumberOfIterationFromGUI - NumberOfMCIterations).ToString();

                if (NumberOfMCIterations >= NumberOfIterationFromGUI)
                {
                    monteCarlo = false;
                    StartMCBtn.Content = "START MC";
                    timer.Stop();
                    NumberOfMCIterations = 0;
                }
            }

            
            PaintPane();
        }