Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            Console.WriteLine("Computational Lab 4. Variant 1. Task 2. (c) 2019 Nekhaev Alexander\n");
            //Берем начальные данные
            TaskData inputs = new TaskData();

            inputs.PrintTask();
            AnalyticSolver analyticSolver = new AnalyticSolver(inputs);

            Console.WriteLine("Analytic solution");
            analyticSolver.PrintEquation();
            Console.WriteLine();
            Console.WriteLine("Solutions");
            DifferModelSolver differModelSolver = new DifferModelSolver(inputs)
            {
                Knots = points
            };
            VariableCoefsNumericalSolver variableCoefsNumerical = new VariableCoefsNumericalSolver(inputs)
            {
                Knots = points
            };

            double[] analyticSolve = analyticSolver.GetSolution(points);
            double[] differSolve   = differModelSolver.GetSolution();
            double[] variableSolve = variableCoefsNumerical.GetSolution();
            double[] differ        = new double[points];
            for (int i = 0; i < points; i++)
            {
                differ[i] = (analyticSolve[i] - differSolve[i]);
            }
            double maxDiffer = differ[0];

            for (int i = 1; i < points; i++)
            {
                if (maxDiffer < differ[i])
                {
                    maxDiffer = differ[i];
                }
            }
            //double[] answer = new double[points];
            //for(int i = 0; i<points; i++)
            //{
            //    answer[i] = maxDiffer + variableSolve[i];
            //}
            PrintEvaluatedValues(new string[] { "X", "Analytic Solution", "Thomas algorithm", "Variable Coeffitients", "Differ Analytic-Thomas" }, MakeNet(), analyticSolve, differSolve, variableSolve, differ);
            Console.WriteLine("Max differ: " + maxDiffer);
            Console.ReadLine();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            Console.WriteLine("Computational Lab 4. Variant 1. Task 2. (c) 2019 Nekhaev Alexander\n");
            //Берем начальные данные
            TaskData inputs = new TaskData();

            inputs.PrintTask();
            AnalyticSolver analyticSolver = new AnalyticSolver(inputs);

            Console.WriteLine("Analytic solution");
            analyticSolver.PrintEquation();
            Console.WriteLine();
            Console.WriteLine("Analytic solution evaluated points");
            PrintEvaluatedValues(analyticSolver.GetSolutions(points));
            NumericalSolver numericalSolver = new NumericalSolver(inputs);

            Console.ReadLine();
        }
Exemplo n.º 3
0
        public AnalyticSolver(TaskData task)
        {
            this.task = task;
            double lambda = Math.Sqrt(task.Mqx / task.Mkx);

            lambda1  = lambda;
            lambda2  = -lambda;
            uPrivate = task.Mfx / task.Mqx;

            double AA = Math.Sqrt(task.Mqx * task.Mkx);
            double A1 = AA - task.B1;
            double A2 = AA * Math.Exp(lambda) + (task.B2 * Math.Exp(lambda));
            double D1 = AA + task.B1;
            double D2 = -AA *Math.Exp(-lambda) + (task.B2 * Math.Exp(-lambda));

            double G1   = (task.B1 * uPrivate) - task.E1;
            double G2   = -task.E2 + (task.B2 * uPrivate);
            double num2 = (A1 * D2) + (A2 * D1);

            C1 = ((G1 * D2) - (G2 * D1)) / num2;
            C2 = -((A1 * G2) + (A2 * G1)) / num2;
        }
Exemplo n.º 4
0
 public NumericalSolver(TaskData task) : base(task)
 {
 }