public static AntennasRadiationPatternProblemResult Calculate(Problem problem) { M = problem.M1; N = problem.M2; c1 = problem.C1; c2 = problem.C2; eps = problem.Eps; Inm.Clear(); matrixF.Clear(); matrixFNext.Clear(); ///////////////////////////////////////////////////////////////////////////////////////////////////////////// Splitting(); InitializeF(); GetNextF(); int ci = 0; while (!checkForСonvergence(matrixF, matrixFNext)) { ci++; GetNextF(); if (ci == 10) { break; } } //find Inm /////////////////////////////////////////////////////////////////////////// for (int n = 0; n <= 2 * N + 1; n++) { Inm.Add(new List <ComplexNumbers>()); for (int m = 0; m <= 2 * M + 1; m++) { Inm[n].Add(CalculateIntegralI(n - N, m - M)); } } NormalizeI(); //////////////////////////////////////////////////////////////////////////////////////////////////////////// double[][] arF = new double[SplitNumberForIntegral + 1][]; for (int i = 0; i <= SplitNumberForIntegral; i++) { arF[i] = new double[SplitNumberForIntegral + 1]; } for (int i = 0; i <= SplitNumberForIntegral; i++) { for (int j = 0; j <= SplitNumberForIntegral; j++) { arF[i][j] = matrixF[i][j].Re; } } double[][] arI = new double[2 * N + 1][]; for (int i = 0; i < 2 * N + 1; i++) { arI[i] = new double[2 * M + 1]; } double[] Ix = new double[2 * N + 1]; double[] Iy = new double[2 * M + 1]; for (int i = 0; i < 2 * N + 1; i++) { Ix[i] = i - N; for (int j = 0; j < 2 * M + 1; j++) { arI[i][j] = Inm[i][j].Re; } } for (int i = 0; i < 2 * M + 1; i++) { Iy[i] = i - M; } return(new AntennasRadiationPatternProblemResult { F = arF, Fx = ksi1, Fy = ksi2, Ix = Ix, Iy = Iy, I = arI }); }
public static AntennasRadiationPatternProblemResult Calculate(Problem problem) { _m = problem.M1; _n = problem.M2; _c1 = problem.C1; _c2 = problem.C2; _modF = Convert.ToDouble(problem.FModule.Replace(".", ",")); _argF = Convert.ToDouble(problem.FArgument.Replace(".", ",")); /*****************************************************************************************/ List <List <ComplexNumbers> > I = new List <List <ComplexNumbers> >(); for (int i = 0; i < 11; i++) { I.Add(new List <ComplexNumbers>()); } ComplexNumbers alpha = new ComplexNumbers(Math.Pow(2 * Math.PI, 2) / (_c1 * _c2), 0); ComplexNumbers p = new ComplexNumbers(1, 0); double limitWidth = 1; double limitHeight = 1; List <List <ComplexNumbers> > lastF = new List <List <ComplexNumbers> >(); ComplexNumbers maxF = new ComplexNumbers(); double step = problem.Eps < 0.01 ? problem.Eps : 0.01;//limitHeight / M; for (double i = -limitWidth; i <= limitWidth; i += step) { lastF.Add(new List <ComplexNumbers>()); for (double j = -limitHeight; j <= limitHeight; j += step) { ComplexNumbers fPrev = new ComplexNumbers(_modF * Math.Cos(_argF), _modF * Math.Sin(_argF)); ComplexNumbers F; ComplexNumbers D; double amountStepsForKsi1 = 10; double amountStepsForKsi2 = 10; double hksi1 = (limitHeight * 2) / (2 * amountStepsForKsi1); // (b-a)/2N double hksi2 = (limitWidth * 2) / (2 * amountStepsForKsi2); // (d-c)/2M ComplexNumbers kFor2 = new ComplexNumbers(); for (int k = 0; k < amountStepsForKsi1; k++) { for (int l = 0; l < amountStepsForKsi2; l++) { kFor2 += (ComputeIntegralForKsiInPow(2 * k * hksi1, 2 * l * hksi2) + ComputeIntegralForKsiInPow((2 * k + 2) * hksi1, 2 * l * hksi2) + ComputeIntegralForKsiInPow(2 * k * hksi1, (2 * l + 2) * hksi2) + ComputeIntegralForKsiInPow((2 * k + 2) * hksi1, (2 * l + 2) * hksi2) + new ComplexNumbers(4.0, 0) * (ComputeIntegralForKsiInPow((2 * k + 1) * hksi1, 2 * l * hksi2) + ComputeIntegralForKsiInPow(2 * k * hksi1, (2 * l + 1) * hksi2) + ComputeIntegralForKsiInPow((2 * k + 2) * hksi1, (2 * l + 1) * hksi2) + ComputeIntegralForKsiInPow((2 * k + 1) * hksi1, (2 * l + 2) * hksi2)) + new ComplexNumbers(16.0, 0) * ComputeIntegralForKsiInPow((2 * k + 1) * hksi1, (2 * l + 1) * hksi2)); } } kFor2 *= new ComplexNumbers((hksi1 * hksi2) / 9.0, 0); var ab = kFor2 * (p - fPrev.GetModule().GetPow()) * fPrev.GetPow(); var a2 = kFor2 * (p - fPrev.GetModule().GetPow()).GetPow() * fPrev.GetPow(); var b2 = kFor2 * fPrev.GetPow(); D = new ComplexNumbers(16, 0) * ab.GetPow() - new ComplexNumbers(4, 0) * b2 * (a2 - alpha.GetPow() * p); ComplexNumbers l1 = (new ComplexNumbers(-4, 0) * ab + D.GetSqrt()) / (new ComplexNumbers(2, 0) * b2); ComplexNumbers l2 = (new ComplexNumbers(-4, 0) * ab - D.GetSqrt()) / (new ComplexNumbers(2, 0) * b2); ComplexNumbers lambda; if (l2.GetModule() > l1.GetModule()) { lambda = l1; } else { lambda = l2; } ComplexNumbers a = ComputeIntegralForKsi(i, j) * (p - fPrev.GetModule().GetPow()) * fPrev; ComplexNumbers b = ComputeIntegralForKsi(i, j) * fPrev; F = (new ComplexNumbers(2, 0) * a + lambda * b) / alpha; if (i >= -1.1 && i <= 1.1 && j >= -1.1 && j <= 1.1) { ComplexNumbers kForI = new ComplexNumbers(); for (int k = 0; k < amountStepsForKsi1; k++) { for (int l = 0; l < amountStepsForKsi2; l++) { kForI += (ComputeIntegralForI(2 * k * hksi1, 2 * l * hksi2) + ComputeIntegralForI((2 * k + 2) * hksi1, 2 * l * hksi2) + ComputeIntegralForI(2 * k * hksi1, (2 * l + 2) * hksi2) + ComputeIntegralForI((2 * k + 2) * hksi1, (2 * l + 2) * hksi2) + new ComplexNumbers(4.0, 0) * (ComputeIntegralForI((2 * k + 1) * hksi1, 2 * l * hksi2) + ComputeIntegralForI(2 * k * hksi1, (2 * l + 1) * hksi2) + ComputeIntegralForI((2 * k + 2) * hksi1, (2 * l + 1) * hksi2) + ComputeIntegralForI((2 * k + 1) * hksi1, (2 * l + 2) * hksi2)) + new ComplexNumbers(16.0, 0) * ComputeIntegralForI((2 * k + 1) * hksi1, (2 * l + 1) * hksi2)); } } kForI *= new ComplexNumbers((hksi1 * hksi2) / 9.0, 0); int index = Convert.ToInt32((1.0 + i) / 0.2); I[index].Add((p - F.GetModule().GetPow()) * F * kForI + lambda * F * kForI); } if (F > maxF) { maxF = F; } lastF[lastF.Count - 1].Add(F); } } var maxI = I[0][0]; for (int i = 0; i < I.Count; i++) { for (int j = 0; j < I[i].Count; j++) { if (maxI < I[i][j]) { maxI = I[i][j]; } } } var result = new AntennasRadiationPatternProblemResult(); result.I = new double[I.Count][]; for (int i = 0; i < I.Count; i++) { result.I[i] = new double[I[i].Count]; for (int j = 0; j < I[i].Count; j++) { result.I[i][j] = (I[i][j] / maxI).GetModule().Re; } } result.F = new double[lastF.Count][]; for (int i = 0; i < lastF.Count; i++) { result.F[i] = new double[lastF.Count]; for (int j = 0; j < lastF[i].Count; j++) { result.F[i][j] = (lastF[i][j] / maxF).GetModule().Re; } } return(result); }
public static BranchingPointsProblemResult Calculate(Problem problem) { M = problem.M1; N = problem.M2; eps = problem.Eps; Splitting(); double c1 = 2.3; double c2 = 0.1; List <double> C1 = new List <double>(); List <double> C2 = new List <double>(); List <List <KeyValuePair <double, double> > > list = new List <List <KeyValuePair <double, double> > >(); c1 = 0.1; var c1Step = 2.0 / problem.NumberPartitionsC1; var c2Step = 2.0 / problem.NumberPartitionsC2; while (c1 <= 2.0) { c2 = 0.1; List <KeyValuePair <double, double> > res = new List <KeyValuePair <double, double> >(); while (c2 <= 2) { double prev = c2; double next = 10; int count = 0; double temp = 0; while (true) { double x1 = FxNewton(c1, prev).Re; double x2 = FxNewtonPox(c1, prev).Re; next = prev - ((x2 == 0) ? 0 : (x1 / x2)); count++; Console.Write(count + " "); if ((Math.Abs(next - prev) < eps || count == 200)) { res.Add(new KeyValuePair <double, double>(c1, next)); temp = next; break; } prev = next; } c2 = c2 + c2Step; } list.Add(res); c1 = c1 + c1Step; } BranchingPointsProblemResult result = new BranchingPointsProblemResult(); result.BranchingLines = new List <BranchingPointsProblemResult.Line>(); for (int i = 0; i < list[0].Count; i++) { BranchingPointsProblemResult.Line line = new BranchingPointsProblemResult.Line(); line.x = new double[list.Count]; line.y = new double[list.Count]; for (int j = 0; j < list.Count; j++) { line.x[j] = list[j][i].Key; line.y[j] = list[j][i].Value; } result.BranchingLines.Add(line); } return(result); }