Example #1
0
        private void Cell_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox textBox = (TextBox)sender;
            string  text    = textBox.Text;

            try
            {
                Complex parsed = ComplexUtils.Parse(text);
                int     i      = Grid.GetRow(textBox) - 1;
                int     j      = Grid.GetColumn(textBox) - 1;
                Filter[i, j] = parsed;
                if (parsed == 0)
                {
                    textBox.Background = COLOR_EMPTY;
                }
                else
                {
                    textBox.Background = COLOR_VALUE;
                }
            }
            catch
            {
                textBox.Background = COLOR_ERROR;
            }
        }
Example #2
0
        public void UpdateFromGrid()
        {
            int fullSize = cells.GetLength(0);

            Complex[,] P = new Complex[fullSize, fullSize];
            for (int i = 0; i < fullSize; i++)
            {
                for (int j = 0; j < fullSize; j++)
                {
                    P[i, j] = ComplexUtils.Parse(cells[i, j].Text);
                }
            }
            Filter = new Filter(P);
        }
Example #3
0
        private void BuildSolver()
        {
            SolutionInput input = BuildInput();
            Filter        P     = input.Filter;

            Solver newSolver;
            string errorElem = "";

            try
            {
                int n = P.Size;
                errorElem = "D";
                double D = double.Parse(input.D);
                errorElem = "A0";
                Complex A0 = ComplexUtils.Parse(input.A_0);
                errorElem = "K";
                double K = double.Parse(input.K);
                errorElem = "T";
                double T = double.Parse(input.T);
                errorElem = "M";
                int M = int.Parse(input.t_count);
                errorElem = "N";
                int N = int.Parse(input.x_count);

                double chi = Solver.GetChi(K, P[n, n], A0);
                Dependencies.Set(MathAliases.ConvertName("chi"), chi);

                errorElem = "u0";
                IExpression expr = MainParser.Parse(input.u_0);
                textBlock_u0.Text = "u0 = " + expr.AsString();

                string[] deps = MainParser.GetDependencies(expr);
                double[] u0   = MainParser.EvalArrayD(expr, Dependencies, deps, "x", 2 * Math.PI, N);

                errorElem = "solver";
                newSolver = new Solver(P, T, N, M);
                ModelParams param = new ModelParams(A0, K, u0, D);
                newSolver.SetParams(param);
                curSolver = newSolver;
            }
            catch (Exception ex)
            {
                Logger.Write(errorElem + ": " + ex.Message);
                return;
            }
        }