Exemple #1
0
        private void RunTemplates()
        {
            switch (template)
            {
            case Template.None:
                break;

            case Template.DLA:
            {
            }
            break;

            case Template.Isle_Royale:
                break;

            case Template.Ant_Sim:
                break;

            case Template.Gas:
            {
                GasTemplateUC gasUC = new GasTemplateUC();
                templatePanel.Controls.Add(gasUC);
                templateUC = gasUC;
            }
            break;

            case Template.Random_Walk:
            {
                RandomTemplateUC ranUC = new RandomTemplateUC();
                templatePanel.Controls.Add(ranUC);
                templateUC = ranUC;
            }
            break;
            }
        }
Exemple #2
0
        private void FinalizeTemplates()
        {
            switch (template)
            {
            case Template.Random_Walk:
            {
                RandomTemplateUC ranUC = templateUC as RandomTemplateUC;
                bool             _1d   = ranUC.radio1D.Checked;
                controllerScript.UpdateMainTemplateInfo(template_reset);
                int    hori  = 51;
                double up    = _1d? 0 : 0.25;
                double down  = _1d ? 0 : 0.25;
                double left  = _1d ? 0.50 : 0.25;
                double right = _1d ? 0.50 : 0.25;
                if (int.TryParse(gridSizeHori.Text, out int result1))
                {
                    hori = result1;
                }
                int vert = _1d ? 1 : 51;
                if (int.TryParse(gridSizeVert.Text, out int result2))
                {
                    vert = result2;
                }
                int statenum = int.Parse(stateNumberBox.Text);
                controllerScript.MainPageNext(statenum, hori, vert, Template.Random_Walk);
                int halfHori = (int)(hori / 2.0);
                int halfVert = (int)(vert / 2.0);
                List <List <List <double> > > immobile_probs = new List <List <List <double> > >();
                List <List <List <double> > > tempProbs      = new List <List <List <double> > >();
                controllerScript.StateInfoDirectEdit(0, NType.None, GridType.Box, Color.White,
                                                     new List <Tuple <int, int> >()
                    {
                        new Tuple <int, int>(halfHori, halfVert)
                    }, 0, 1,
                                                     tempProbs, true, 0, new List <double>()
                    {
                        up, right, down, left
                    },
                                                     true, new List <double>()
                    {
                        0
                    }, false, false, false, new List <Tuple <string, double> >());
            }
            break;

            case Template.Gas:
            {
                GasTemplateUC gasUC            = (GasTemplateUC)templateUC;
                List <double> template_storage = new List <double>();
                string        m_name           = gasUC.name;
                double        mol_vol          = gasUC.GetVolume();
                double        vrms             = gasUC.GetVRMS();
                double        mm        = gasUC.GetMM();
                double        t         = gasUC.temperature;
                double        cross_sec = gasUC.GetCross(mol_vol);
                int           hori      = 1000;
                if (int.TryParse(gridSizeHori.Text, out int result1))
                {
                    hori = result1;
                }
                int vert = 1000;
                if (int.TryParse(gridSizeVert.Text, out int result2))
                {
                    vert = result2;
                }
                controllerScript.MainPageNext(1, hori, vert, Template.Gas);
                controllerScript.StateInfoDirectEdit(0, NType.None, GridType.Box, Color.White,
                                                     new List <Tuple <int, int> >(), 0, 0, new List <List <List <double> > >(), true, MoveType.VonNeumann, new List <double>()
                    {
                        0.25, 0.25, 0.25, 0.25
                    },
                                                     false, new List <double>(), false, false, false, new List <Tuple <string, double> >());
                double full_vol = ((hori) * (vert) * mol_vol);
                template_storage.Add(t);
                template_storage.Add(full_vol);
                template_storage.Add(mm);
                template_storage.Add(Math.Pow(mol_vol, (1.0 / 3.0)));
                template_storage.Add(cross_sec);
                template_storage.Add(gasUC.k);
                template_storage.Add(vrms);
                template_storage.Add(gasUC.avagodro);
                template_storage.Add(gasUC.resolution);
                controllerScript.GetStatePage(0).template_objects = new List <object>();
                for (int i = 0; i < template_storage.Count; i++)
                {
                    controllerScript.GetStatePage(0).template_objects.Add(template_storage[i]);
                }
            }
            break;

            case Template.DLA:
            {
                controllerScript.UpdateMainTemplateInfo(template_reset);
                int hori = 101;
                if (int.TryParse(gridSizeHori.Text, out int result1))
                {
                    hori = result1;
                }
                int vert = 101;
                if (int.TryParse(gridSizeVert.Text, out int result2))
                {
                    vert = result2;
                }
                controllerScript.MainPageNext(2, hori, vert, Template.DLA);
                int halfHori = (int)((double)hori / 2);
                List <List <List <double> > > immobile_probs = new List <List <List <double> > >();
                for (int i = 0; i < 2; i++)
                {
                    immobile_probs.Add(new List <List <double> >());
                    for (int j = 0; j < 2; j++)
                    {
                        immobile_probs[i].Add(new List <double>());

                        for (int l = 0; l < 4 + 1; l++)
                        {
                            immobile_probs[i][j].Add(0);
                            // add labels and text fields
                        }
                    }
                }
                controllerScript.StateInfoDirectEdit(0, NType.VonNeumann, GridType.Box, Color.Gray,
                                                     new List <Tuple <int, int> >()
                    {
                        new Tuple <int, int>((int)((double)hori / 2), (int)((double)vert / 2))
                    },
                                                     4, 1, immobile_probs, false, 0, new List <double>(), false, new List <double>(),
                                                     false, false, false, new List <Tuple <string, double> >());
                List <List <List <double> > > tempProbs = new List <List <List <double> > >();
                for (int i = 0; i < 2; i++)
                {
                    tempProbs.Add(new List <List <double> >());
                    for (int j = 0; j < 2; j++)
                    {
                        tempProbs[i].Add(new List <double>());

                        for (int l = 0; l < 4 + 1; l++)
                        {
                            tempProbs[i][j].Add(0);
                            // add labels and text fields
                        }
                    }
                }
                tempProbs[0][0][0] = 0;
                tempProbs[0][0][1] = 1;
                tempProbs[0][0][2] = 1;
                tempProbs[0][0][3] = 1;
                tempProbs[0][0][4] = 1;
                controllerScript.StateInfoDirectEdit(1, NType.VonNeumann, GridType.Box, Color.White,
                                                     new List <Tuple <int, int> >(), 4, 0, tempProbs, true, 0, new List <double>()
                    {
                        0.25, 0.25, 0.25, 0.25
                    },
                                                     true, new List <double>()
                    {
                        0, 0
                    }, false, false, false, new List <Tuple <string, double> >());
            }
            break;
            }
        }