Exemplo n.º 1
0
        public double Solve(Settings settings, List <double> taoValues, List <double> sigmaValues, double x, double y)
        {
            double result = 0;
            var    firstMathExpression  = new MathExpression($"ln((sqrt({Math.Pow(y, 2)}+({x}-t)^2))^(0-1))");
            var    secondMathExpression = new MathExpression($"a*ln((sqrt(({x}-a*cos(t))^2+({y}-a*sin(t))^2))^(0-1))");

            for (int j = 0; j < settings.PartitionsOnCrack; j++)
            {
                result += GaussMethodForIntegrals.CalculateWithAccuracy(settings.PartitionPoints[j], settings.PartitionPoints[j + 1], firstMathExpression, Constants.Epsilon, new Var("t", 0), new Var("s", settings.ColocationPoints[j])) * taoValues[j];
            }
            for (int j = 0; j < settings.PartitionsOnBound; j++)
            {
                var partitionIndex = j + settings.PartitionsOnCrack + 1;
                result += settings.Radius.Value * GaussMethodForIntegrals.CalculateWithAccuracy(settings.PartitionPoints[partitionIndex], settings.PartitionPoints[partitionIndex + 1], secondMathExpression, Constants.Epsilon, new Var("t", 0), new Var("s", settings.ColocationPoints[j + settings.PartitionsOnCrack]), new Var("a", settings.Radius.Value)) * sigmaValues[j];
            }

            return(1 / (2 * Math.PI) * result);
        }
Exemplo n.º 2
0
        private Dictionary <EquationsEnum, Func <Settings, int, int, double> > GetMatrixAInits()
        {
            var result = new Dictionary <EquationsEnum, Func <Settings, int, int, double> >();

            result.Add(EquationsEnum.Equation_3_2, (settings, i, j) =>
            {
                j++;
                if (settings.PartitionPoints[j - 1] > settings.ColocationPoints[i])
                {
                    return(-((settings.PartitionPoints[j] - settings.ColocationPoints[i]) * Math.Log(settings.PartitionPoints[j] - settings.ColocationPoints[i]) - (settings.PartitionPoints[j - 1] - settings.ColocationPoints[i]) * Math.Log(settings.PartitionPoints[j - 1] - settings.ColocationPoints[i]) - (settings.PartitionPoints[j] - settings.PartitionPoints[j - 1])));
                }
                else
                {
                    if (settings.PartitionPoints[j] < settings.ColocationPoints[i])
                    {
                        return(-(-(-settings.PartitionPoints[j] + settings.ColocationPoints[i]) * Math.Log(-settings.PartitionPoints[j] + settings.ColocationPoints[i]) + (-settings.PartitionPoints[j - 1] + settings.ColocationPoints[i]) * Math.Log(-settings.PartitionPoints[j - 1] + settings.ColocationPoints[i]) - (settings.PartitionPoints[j] - settings.PartitionPoints[j - 1])));
                    }
                    else
                    {
                        return(-((-settings.PartitionPoints[j - 1] + settings.ColocationPoints[i]) * Math.Log(-settings.PartitionPoints[j - 1] + settings.ColocationPoints[i]) + (settings.PartitionPoints[j] - settings.ColocationPoints[i]) * Math.Log(settings.PartitionPoints[j] - settings.ColocationPoints[i]) - (settings.PartitionPoints[j] - settings.PartitionPoints[j - 1])));
                    }
                }
            });

            result.Add(EquationsEnum.Equation_3_3, (settings, i, j) =>
            {
                j++;
                if (i == (j - 1))
                {
                    return(2 * FredholmEquationFirstOrder.Calculate_Aij(settings.PartitionPoints, settings.ColocationPoints, i, j) - Math.Log(settings.Radius.Value) *
                           Math.Abs(settings.IntervalOfIntegration.Item2 - settings.IntervalOfIntegration.Item1) / settings.AmountOfPartitions +
                           GaussMethodForIntegrals.CalculateWithAccuracy(settings.PartitionPoints[j - 1], settings.PartitionPoints[j],
                                                                         new MathExpression($"{settings.Radius.Value}*ln(1/({settings.FunctionDistance}))-ln(1/({settings.Radius.Value}*abs(t-{settings.ColocationPoints[i]})))"),
                                                                         Constants.Epsilon, new Var(settings.Variables[0], 0), new Var(settings.Variables[1], settings.ColocationPoints[i]), new Var(settings.Variables[2], settings.Radius.Value)));
                }
                else
                {
                    return(GaussMethodForIntegrals.CalculateWithAccuracy(settings.PartitionPoints[j - 1], settings.PartitionPoints[j],
                                                                         new MathExpression($"{settings.Radius.Value}*ln(1/({settings.FunctionDistance}))"),
                                                                         Constants.Epsilon, new Var(settings.Variables[0], 0), new Var(settings.Variables[1], settings.ColocationPoints[i]), new Var(settings.Variables[2], settings.Radius.Value)));
                }
            });

            result.Add(EquationsEnum.Equation_3_4, (settings, i, j) =>
            {
                j++;
                return(GaussMethodForIntegrals.CalculateWithAccuracy(settings.PartitionPoints[j - 1], settings.PartitionPoints[j],
                                                                     new MathExpression($"ln(1/({settings.FunctionDistance}))*({settings.FunctionYakobian})"), Constants.Epsilon,
                                                                     new Var(settings.Variables[0], 0), new Var(settings.Variables[1], settings.ColocationPoints[i]), new Var(settings.Variables[2], settings.Radius.Value)));
            });

            result.Add(EquationsEnum.Equation_3_5, (settings, i, j) =>
            {
                j++;
                return(GaussMethodForIntegrals.CalculateWithAccuracy(settings.PartitionPoints[j - 1], settings.PartitionPoints[j],
                                                                     new MathExpression($"ln(1/({settings.FunctionDistance}))*({settings.FunctionYakobian})"), Constants.Epsilon,
                                                                     new Var(settings.Variables[0], 0), new Var(settings.Variables[1], settings.ColocationPoints[i]), new Var(settings.Variables[2], settings.Radius.Value)));
            });

            return(result);
        }