Пример #1
0
        private void parametersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            btStop_Click(sender, e); // Stop everything when user opens parameter window
            frmParameterBox frmp = new frmParameterBox();

            // Save current parameter values
            frmp.Pdata.Psetname = p.Psetname;
            frmp.Pdata.Ru       = p.Ru;
            frmp.Pdata.Rv       = p.Rv;
            frmp.Pdata.A        = p.A;
            frmp.Pdata.B        = p.B;
            frmp.Pdata.U0       = p.U0;
            frmp.Pdata.V0       = p.V0;
            frmp.Pdata.Step     = p.Step;
            frmp.Pdata.N        = p.N;
            frmp.Pdata.Maxtime  = p.Maxtime;

            // Save changed values
            // This updates quite a lot of things
            DialogResult d = frmp.ShowDialog();

            if (d == DialogResult.OK)
            {
                // Assign user-defined parameters
                p.Psetname = frmp.Pdata.Psetname;
                p.Ru       = frmp.Pdata.Ru;
                p.Rv       = frmp.Pdata.Rv;
                p.U0       = frmp.Pdata.U0;
                p.V0       = frmp.Pdata.V0;
                p.A        = frmp.Pdata.A;
                p.B        = frmp.Pdata.B;
                p.Step     = frmp.Pdata.Step;
                p.N        = frmp.Pdata.N;
                p.Maxtime  = frmp.Pdata.Maxtime;

                tbTime.Text    = "0.00";
                btJump.Enabled = true;

                // Create new state objects
                su = new State(p);
                sv = new State(p);

                // If user changes parameters, update the states & display
                su.Initialise(su, p, 0);
                sv.Initialise(sv, p, 1);

                // Truncatate states probabilistically if using random initial conditions
                rules.Initialise(p);
                rules.TruncateGeneral(su);
                rules.TruncateGeneral(sv);

                Display(su, sv);

                // Reinitialise imaging if parameters are changed
                bu             = new Bitmap(bitmapsize, bitmapsize);
                bv             = new Bitmap(bitmapsize, bitmapsize);
                pictBoxu.Image = bu;
                pictBoxv.Image = bv;
                fu             = new FastBitmapAccess(bu, p);
                fv             = new FastBitmapAccess(bv, p);

                DisplayFull(fu, su);
                DisplayFull(fv, sv);
                pictBoxu.Refresh();
                pictBoxv.Refresh();   // Refresh picture box

                // Update and display diffusion coefficients
                diffu        = p.Ru * (p.Ru + 1) * p.Step;
                diffu       /= 6;
                diffv        = p.Rv * (p.Rv + 1) * p.Step;
                diffv       /= 6;
                tbDiffu.Text = Convert.ToString(diffu);
                tbDiffv.Text = Convert.ToString(diffv);

                twu.Close();
                twv.Close();

                // Create directories for averages
                pathpset[0] = pathpics + "\\" + p.Psetname;
                pathpset[1] = pathpics + "\\" + p.Psetname;
                Directory.CreateDirectory(pathpset[0]);
                Directory.CreateDirectory(pathpset[1]);
                twu = File.CreateText(string.Format("{0}\\Average_u.csv", pathpset[0]));
                twv = File.CreateText(string.Format("{0}\\Average_v.csv", pathpset[1]));

                // Create directories for images
                pathpset[0] += "\\species_u\\";
                pathpset[1] += "\\species_v\\";
                Directory.CreateDirectory(pathpset[0]);
                Directory.CreateDirectory(pathpset[1]);
            }

            else if (d == DialogResult.Cancel)
            {
                frmp.Close();
            }
        }
Пример #2
0
        private void parametersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            btStop_Click(sender, e); // Stop everything when user opens parameter window
            frmParameterBox frmp = new frmParameterBox();

            // Save current parameter values
            frmp.Pdata.Psetname = p.Psetname;
            frmp.Pdata.Ru = p.Ru;
            frmp.Pdata.Rv = p.Rv;
            frmp.Pdata.A = p.A;
            frmp.Pdata.B = p.B;
            frmp.Pdata.U0 = p.U0;
            frmp.Pdata.V0 = p.V0;
            frmp.Pdata.Step = p.Step;
            frmp.Pdata.N = p.N;
            frmp.Pdata.Maxtime = p.Maxtime;

            // Save changed values
            // This updates quite a lot of things
            DialogResult d = frmp.ShowDialog();
            if (d == DialogResult.OK)
            {
                // Assign user-defined parameters
                p.Psetname = frmp.Pdata.Psetname;
                p.Ru = frmp.Pdata.Ru;
                p.Rv = frmp.Pdata.Rv;
                p.U0 = frmp.Pdata.U0;
                p.V0 = frmp.Pdata.V0;
                p.A = frmp.Pdata.A;
                p.B = frmp.Pdata.B;
                p.Step = frmp.Pdata.Step;
                p.N = frmp.Pdata.N;
                p.Maxtime = frmp.Pdata.Maxtime;

                tbTime.Text = "0.00";
                btJump.Enabled = true;

                // Create new state objects
                su = new State(p);
                sv = new State(p);

                // If user changes parameters, update the states & display
                su.Initialise(su, p, 0);
                sv.Initialise(sv, p, 1);

                // Truncatate states probabilistically if using random initial conditions
                rules.Initialise(p);
                rules.TruncateGeneral(su);
                rules.TruncateGeneral(sv);

                Display(su, sv);

                // Reinitialise imaging if parameters are changed
                bu = new Bitmap(bitmapsize, bitmapsize);
                bv = new Bitmap(bitmapsize, bitmapsize);
                pictBoxu.Image = bu;
                pictBoxv.Image = bv;
                fu = new FastBitmapAccess(bu, p);
                fv = new FastBitmapAccess(bv, p);

                DisplayFull(fu, su);
                DisplayFull(fv, sv);
                pictBoxu.Refresh();
                pictBoxv.Refresh();   // Refresh picture box

                // Update and display diffusion coefficients
                diffu = p.Ru * (p.Ru + 1) * p.Step;
                diffu /= 6;
                diffv = p.Rv * (p.Rv + 1) * p.Step;
                diffv /= 6;
                tbDiffu.Text = Convert.ToString(diffu);
                tbDiffv.Text = Convert.ToString(diffv);

                twu.Close();
                twv.Close();

                // Create directories for averages
                pathpset[0] = pathpics + "\\" + p.Psetname;
                pathpset[1] = pathpics + "\\" + p.Psetname;
                Directory.CreateDirectory(pathpset[0]);
                Directory.CreateDirectory(pathpset[1]);
                twu = File.CreateText(string.Format("{0}\\Average_u.csv", pathpset[0]));
                twv = File.CreateText(string.Format("{0}\\Average_v.csv", pathpset[1]));

                // Create directories for images
                pathpset[0] += "\\species_u\\";
                pathpset[1] += "\\species_v\\";
                Directory.CreateDirectory(pathpset[0]);
                Directory.CreateDirectory(pathpset[1]);
            }

            else if (d == DialogResult.Cancel)
            {
                frmp.Close();
            }
        }
Пример #3
0
        private void MACA_Load(object sender, EventArgs e)
        {
            frmParameterBox frmp = new frmParameterBox();
            DialogResult    d    = frmp.ShowDialog();

            if (d == DialogResult.OK)
            {
                // Assign user-defined parameters
                p.Psetname = frmp.Pdata.Psetname;
                p.Ru       = frmp.Pdata.Ru;
                p.Rv       = frmp.Pdata.Rv;
                p.U0       = frmp.Pdata.U0;
                p.V0       = frmp.Pdata.V0;
                p.A        = frmp.Pdata.A;
                p.B        = frmp.Pdata.B;
                p.Step     = frmp.Pdata.Step;
                p.N        = frmp.Pdata.N;
                p.Maxtime  = frmp.Pdata.Maxtime;
            }

            // Maximise the main window as default
            this.WindowState = FormWindowState.Maximized;

            // Initialise states u, v with parameters p and display them
            su = new State(p);
            sv = new State(p);
            su.Initialise(su, p, 0);
            sv.Initialise(sv, p, 1);

            // Truncatate states probabilistically if using random initial conditions
            rules.Initialise(p);
            rules.TruncateGeneral(su);
            rules.TruncateGeneral(sv);

            Display(su, sv);

            // Initial imaging
            bu             = new Bitmap(bitmapsize, bitmapsize); // New image of desired size (user specified)
            bv             = new Bitmap(bitmapsize, bitmapsize); // It's scaled acording to the size of p.N
            pictBoxu.Image = bu;                                 // Assign image to picturebox
            pictBoxv.Image = bv;
            fu             = new FastBitmapAccess(bu, p);
            fv             = new FastBitmapAccess(bv, p);

            try
            {
                // Update display
                DisplayFull(fu, su);
                DisplayFull(fv, sv);
                pictBoxu.Refresh();
                pictBoxv.Refresh();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.Close();
            }

            // Update and display diffusion coefficients
            diffu        = p.Ru * (p.Ru + 1) * p.Step;
            diffu       /= 6;
            diffv        = p.Rv * (p.Rv + 1) * p.Step;
            diffv       /= 6;
            tbDiffu.Text = Convert.ToString(diffu);
            tbDiffv.Text = Convert.ToString(diffv);

            // Create directories for images
            //  if (p.Psetname == null)
            //    p.Psetname = "Basic Configuration"; // if user hits "cancel" upon opening

            // Create the directory \p.Psetname\ & add the average_u,v.csv files to ti
            pathpset[0] = pathpics + "\\" + p.Psetname;
            pathpset[1] = pathpics + "\\" + p.Psetname;
            Directory.CreateDirectory(pathpset[0]);
            Directory.CreateDirectory(pathpset[1]);
            twu = File.CreateText(string.Format("{0}\\Average_u.csv", pathpset[0]));
            twv = File.CreateText(string.Format("{0}\\Average_v.csv", pathpset[1]));

            pathpset[0] += "\\species_u\\";
            pathpset[1] += "\\species_v\\";
            Directory.CreateDirectory(pathpset[0]);
            Directory.CreateDirectory(pathpset[1]);
        }
Пример #4
0
        private void MACA_Load(object sender, EventArgs e)
        {
            frmParameterBox frmp = new frmParameterBox();
            DialogResult d = frmp.ShowDialog();

            if (d == DialogResult.OK)
            {
                // Assign user-defined parameters
                p.Psetname = frmp.Pdata.Psetname;
                p.Ru = frmp.Pdata.Ru;
                p.Rv = frmp.Pdata.Rv;
                p.U0 = frmp.Pdata.U0;
                p.V0 = frmp.Pdata.V0;
                p.A = frmp.Pdata.A;
                p.B = frmp.Pdata.B;
                p.Step = frmp.Pdata.Step;
                p.N = frmp.Pdata.N;
                p.Maxtime = frmp.Pdata.Maxtime;
            }

            // Maximise the main window as default
            this.WindowState = FormWindowState.Maximized;

            // Initialise states u, v with parameters p and display them
            su = new State(p);
            sv = new State(p);
            su.Initialise(su, p, 0);
            sv.Initialise(sv, p, 1);

            // Truncatate states probabilistically if using random initial conditions
            rules.Initialise(p);
            rules.TruncateGeneral(su);
            rules.TruncateGeneral(sv);

            Display(su, sv);

            // Initial imaging
            bu = new Bitmap(bitmapsize, bitmapsize); // New image of desired size (user specified)
            bv = new Bitmap(bitmapsize, bitmapsize); // It's scaled acording to the size of p.N
            pictBoxu.Image = bu; // Assign image to picturebox
            pictBoxv.Image = bv;
            fu = new FastBitmapAccess(bu, p);
            fv = new FastBitmapAccess(bv, p);

            try
            {
                // Update display
                DisplayFull(fu, su);
                DisplayFull(fv, sv);
                pictBoxu.Refresh();
                pictBoxv.Refresh();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.Close();
            }

            // Update and display diffusion coefficients
            diffu = p.Ru * (p.Ru + 1) * p.Step;
            diffu /= 6;
            diffv = p.Rv * (p.Rv + 1) * p.Step;
            diffv /= 6;
            tbDiffu.Text = Convert.ToString(diffu);
            tbDiffv.Text = Convert.ToString(diffv);

            // Create directories for images
            //  if (p.Psetname == null)
            //    p.Psetname = "Basic Configuration"; // if user hits "cancel" upon opening

            // Create the directory \p.Psetname\ & add the average_u,v.csv files to ti
            pathpset[0] = pathpics + "\\" + p.Psetname;
            pathpset[1] = pathpics + "\\" + p.Psetname;
            Directory.CreateDirectory(pathpset[0]);
            Directory.CreateDirectory(pathpset[1]);
            twu = File.CreateText(string.Format("{0}\\Average_u.csv", pathpset[0]));
            twv = File.CreateText(string.Format("{0}\\Average_v.csv", pathpset[1]));

            pathpset[0] += "\\species_u\\";
            pathpset[1] += "\\species_v\\";
            Directory.CreateDirectory(pathpset[0]);
            Directory.CreateDirectory(pathpset[1]);
        }