public double[] CreateInternalGlobalForcesVector() { double[] F = new double[8]; double[,] E = CalculateStressStrainMatrix(Properties.YoungMod, 0.30); //needs fixing in poisson v for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { double[] gP = GaussPoints(i, j).Item1; double[] gW = GaussPoints(i, j).Item2; Dictionary <string, double[]> localdN = CalculateShapeFunctionsLocalDerivatives(gP); double[,] J = CalculateJacobian(localdN); double[,] invJ = CalculateInverseJacobian(J).Item1; double detJ = CalculateInverseJacobian(J).Item2; Dictionary <int, double[]> globaldN = CalculateShapeFunctionsGlobalDerivatives(localdN, invJ); double[,] B = CalculateBMatrix(globaldN); double[] strainVector = CalculateStrainsVector(B); double[] stressVector = CalculateStressVector(E, strainVector); F = VectorOperations.VectorVectorAddition(F, VectorOperations.VectorScalarProductNew( VectorOperations.MatrixVectorProduct(MatrixOperations.Transpose(B), stressVector), detJ * gW[0] * gW[1] * Properties.Thickness)); } } return(F); }
public double[] CreateInternalGlobalForcesVector() { int nodesNumber = Properties.MasterSegmentPolynomialDegree + Properties.SlaveSegmentPolynomialDegree + 2; double[] internalGlobalForcesVector = new double[2 * nodesNumber]; for (int i = 0; i < Properties.IntegrationPoints; i++) { double ksi2 = GaussPoints(i).Item1; double gW = GaussPoints(i).Item2; double ksi1 = Project(0.0, ksi2); if (Math.Abs(ksi1) <= 1.05) { Tuple <double[, ], double[, ], double[, ], double[, ], double[, ]> positionMatrices = CalculatePositionMatrix(ksi1, ksi2); double[,] aMatrix = positionMatrices.Item1; double[,] daMatrix = positionMatrices.Item2; double[,] da2Matrix = positionMatrices.Item3; Tuple <double[], double, double[], double[], double> surfaceCharacteristics = MasterSegmentGeometry(daMatrix, da2Matrix); double[] n = surfaceCharacteristics.Item3; double ksi3 = CalculatePenetration(aMatrix, n); if (ksi3 <= 0) { double slaveMetricTensor = SlaveSegmentGeometry(positionMatrices.Item4, positionMatrices.Item5).Item2; double scalar = Math.Pow(slaveMetricTensor, 0.5) * gW; double[,] AT = MatrixOperations.Transpose(aMatrix); double[] AT_n = VectorOperations.MatrixVectorProduct(AT, n); double[] internalLocalForcesVector = VectorOperations.VectorScalarProductNew(VectorOperations.VectorScalarProductNew(AT_n, PenaltyFactor * ksi3), scalar); internalGlobalForcesVector = VectorOperations.VectorVectorAddition(internalGlobalForcesVector, internalLocalForcesVector); } } } return(internalGlobalForcesVector); }
public double[] CreateInternalGlobalForcesVector() { double penetration = CalculateNormalGap(); if (penetration <= 0) { double[,] A = CalculatePositionMatrix(); double[,] AT = MatrixOperations.Transpose(A); double[] n = CalculateNormalUnitVector(); double[] t = CalculateTangentUnitVector(); double[] AT_n = VectorOperations.MatrixVectorProduct(AT, n); double[] AT_t = VectorOperations.MatrixVectorProduct(AT, t); double ksi = CalculateNormalGap(); double Tr = CalculateTangentialTraction(); double[] ksi_AT_n = VectorOperations.VectorScalarProductNew(AT_n, ksi); double[] e_ksi_AT_n = VectorOperations.VectorScalarProductNew(ksi_AT_n, PenaltyFactor); double[] Tr_AT_t = VectorOperations.VectorScalarProductNew(AT_t, Tr); double[] internalForcesvector = VectorOperations.VectorVectorAddition(e_ksi_AT_n, Tr_AT_t); return(internalForcesvector); } else { double[] internalGlobalForcesVector = new double[4]; return(internalGlobalForcesVector); } }
public double[] CreateInternalGlobalForcesVector() { double[] fInt = new double[24]; double[,] E = CalculateStressStrainMatrix(Properties.YoungMod, Properties.PoissonRatio); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { for (int k = 0; k < 2; k++) { double[] gP = GaussPoints(i, j, k).Item1; double[] gW = GaussPoints(i, j, k).Item2; Dictionary <string, double[]> localdN = CalculateShapeFunctionsLocalDerivatives(gP); double[,] J = CalculateJacobian(localdN); double[,] invJ = CalculateInverseJacobian(J).Item1; double detJ = CalculateInverseJacobian(J).Item2; Dictionary <int, double[]> globaldN = CalculateShapeFunctionsGlobalDerivatives(localdN, invJ); double[,] B = CalculateBMatrix(globaldN); double[] strainVector = CalculateStrainsVector(B); double[] stressVector = CalculateStressVector(E, strainVector); fInt = VectorOperations.VectorVectorAddition(fInt, VectorOperations.VectorScalarProductNew( VectorOperations.MatrixVectorProduct(MatrixOperations.Transpose(B), stressVector), detJ * gW[0] * gW[1] * gW[2])); } } } //double[,] Kstiff = CreateGlobalStiffnessMatrix(); //double[] uDisp = DisplacementVector; //double[] fInt = VectorOperations.MatrixVectorProduct(Kstiff, uDisp); //fInt = VectorOperations.VectorScalarProductNew(fInt, 1.0); return(fInt); }
private double[] PCG(double[,] stiffnessMatrix, double[] forceVector) { double[] solutionVector = new double[forceVector.Length]; double[,] preconditioner = new double[stiffnessMatrix.GetLength(0), stiffnessMatrix.GetLength(1)]; for (int i = 0; i < preconditioner.GetLength(0); i++) { preconditioner[i, i] = 1 / stiffnessMatrix[i, i]; } double[] residual = VectorOperations.VectorVectorSubtraction( forceVector, VectorOperations.MatrixVectorProduct(stiffnessMatrix, solutionVector) ); double[] preconVector = VectorOperations.MatrixVectorProduct(preconditioner, residual); for (int iter = 0; iter < maxIterations; iter++) { double[] u = VectorOperations.MatrixVectorProduct(stiffnessMatrix, preconVector); double residualDotOld = VectorOperations.VectorDotProduct(residual, preconVector); double alpha = residualDotOld / VectorOperations.VectorDotProduct(preconVector, u); solutionVector = VectorOperations.VectorVectorAddition(solutionVector, VectorOperations.VectorScalarProductNew(preconVector, alpha)); residual = VectorOperations.VectorVectorSubtraction(residual, VectorOperations.VectorScalarProductNew(u, alpha)); if (VectorOperations.VectorDotProduct(residual, residual) < tolerance) { break; } double residualDotNew = VectorOperations.VectorDotProduct(residual, VectorOperations.MatrixVectorProduct(preconditioner, residual)); double beta = residualDotNew / residualDotOld; preconVector = VectorOperations.VectorVectorAddition( VectorOperations.MatrixVectorProduct(preconditioner, residual), VectorOperations.VectorScalarProductNew(preconVector, beta) ); } return(solutionVector); }
private double[] LoadControlledNR(double[] forceVector) { lambda = 1.0 / numberOfLoadSteps; double[] incrementDf = VectorOperations.VectorScalarProductNew(forceVector, lambda); double[] solutionVector = new double[forceVector.Length]; double[] incrementalExternalForcesVector = new double[forceVector.Length]; double[] tempSolutionVector = new double[solutionVector.Length]; double[] deltaU = new double[solutionVector.Length]; double[] internalForcesTotalVector; double[] dU; double[] residual; double residualNorm; //Assembler.UpdateAccelerations(CalculateAccelerations(InitialValues.InitialAccelerationVector)); for (int i = 0; i < numberOfLoadSteps; i++) { incrementalExternalForcesVector = VectorOperations.VectorVectorAddition(incrementalExternalForcesVector, incrementDf); Assembler.UpdateDisplacements(solutionVector); Assembler.UpdateAccelerations(explicitAcceleration.Values.Last()); internalForcesTotalVector = Assembler.CreateTotalInternalForcesVector(); double[,] tangentMatrix = CalculateHatMMatrix(); dU = LinearSolver.Solve(tangentMatrix, incrementDf); solutionVector = VectorOperations.VectorVectorAddition(solutionVector, dU); Assembler.UpdateDisplacements(solutionVector); tangentMatrix = CalculateHatMMatrix(); internalForcesTotalVector = Assembler.CreateTotalInternalForcesVector(); residual = VectorOperations.VectorVectorSubtraction(internalForcesTotalVector, incrementalExternalForcesVector); residualNorm = VectorOperations.VectorNorm2(residual); int iteration = 0; Array.Clear(deltaU, 0, deltaU.Length); while (residualNorm > tolerance && iteration < maxIterations) { tangentMatrix = CalculateHatMMatrix(); deltaU = VectorOperations.VectorVectorSubtraction(deltaU, LinearSolver.Solve(tangentMatrix, residual)); tempSolutionVector = VectorOperations.VectorVectorAddition(solutionVector, deltaU); Assembler.UpdateDisplacements(tempSolutionVector); //Assembler.UpdateAccelerations(CalculateAccelerations(solutionVector)); internalForcesTotalVector = Assembler.CreateTotalInternalForcesVector(); residual = VectorOperations.VectorVectorSubtraction(internalForcesTotalVector, incrementalExternalForcesVector); residualNorm = VectorOperations.VectorNorm2(residual); iteration = iteration + 1; } solutionVector = VectorOperations.VectorVectorAddition(solutionVector, deltaU); if (iteration >= maxIterations) { Console.WriteLine("Newton-Raphson: Solution not converged at current iterations"); } } return(solutionVector); }
private double[] LoadControlledNR(double[] forceVector) { double[] incrementDf = VectorOperations.VectorScalarProductNew(forceVector, lambda); double[] solutionVector = localSolutionVector; double[] incrementalExternalForcesVector = new double[forceVector.Length]; double[] tempSolutionVector = new double[solutionVector.Length]; double[] deltaU = new double[solutionVector.Length]; double[] internalForcesTotalVector; double[] dU; double[] residual; double residualNorm; for (int i = 0; i < numberOfLoadSteps; i++) { incrementalExternalForcesVector = VectorOperations.VectorVectorAddition(incrementalExternalForcesVector, incrementDf); discretization.UpdateDisplacements(solutionVector); internalForcesTotalVector = discretization.CreateTotalInternalForcesVector(); double[,] stiffnessMatrix = discretization.CreateTotalStiffnessMatrix(); //OnConvergenceResult("Newton-Raphson: Solution not converged at load step" + i); dU = linearSolver.Solve(stiffnessMatrix, incrementDf); solutionVector = VectorOperations.VectorVectorAddition(solutionVector, dU); residual = VectorOperations.VectorVectorSubtraction(internalForcesTotalVector, incrementalExternalForcesVector); residualNorm = VectorOperations.VectorNorm2(residual); int iteration = 0; Array.Clear(deltaU, 0, deltaU.Length); while (residualNorm > Tolerance && iteration < MaxIterations) { stiffnessMatrix = discretization.CreateTotalStiffnessMatrix(); deltaU = VectorOperations.VectorVectorSubtraction(deltaU, linearSolver.Solve(stiffnessMatrix, residual)); tempSolutionVector = VectorOperations.VectorVectorAddition(solutionVector, deltaU); discretization.UpdateDisplacements(tempSolutionVector); internalForcesTotalVector = discretization.CreateTotalInternalForcesVector(); residual = VectorOperations.VectorVectorSubtraction(internalForcesTotalVector, incrementalExternalForcesVector); residualNorm = VectorOperations.VectorNorm2(residual); if (residualNorm <= Tolerance) { OnConvergenceResult("Newton-Raphson: Load Step " + i + " - Solution converged at iteration " + iteration + " - Residual Norm = " + residualNorm); } else { OnConvergenceResult("Newton-Raphson: Load Step " + i + " - Solution not converged at iteration " + iteration + " - Residual Norm = " + residualNorm); } iteration = iteration + 1; //(Application.Current.Windows[0] as MainWindow).LogTool.Text = "ok"; //OnConvergenceResult("Newton-Raphson: Solution not converged at load step" + iteration); } InternalForces.Add(i + 1, internalForcesTotalVector); solutionVector = VectorOperations.VectorVectorAddition(solutionVector, deltaU); Solutions.Add(i + 1, solutionVector); if (iteration >= MaxIterations) { OnConvergenceResult("Newton-Raphson did not converge at Load Step " + i + ". Exiting solution."); LoadStepConvergence.Add("Solution not converged."); break; } LoadStepConvergence.Add("Solution converged."); } return(solutionVector); }
private double[] CalculatePreviousDisplacementVector() { double[] previousDisp = VectorOperations.VectorVectorAddition( VectorOperations.VectorVectorSubtraction(InitialValues.InitialDisplacementVector, VectorOperations.VectorScalarProductNew(InitialValues.InitialVelocityVector, timeStep)), VectorOperations.VectorScalarProductNew(InitialValues.InitialAccelerationVector, a3)); return(previousDisp); }
private double[] BiCGSTAB(double[,] stiffnessMatrix, double[] forceVector) { double[] solutionVector = new double[forceVector.Length]; double[] xVector = new double[forceVector.Length]; double[] pVector = new double[forceVector.Length]; double[] vVector = new double[forceVector.Length]; double[,] K = stiffnessMatrix; double[] bVector = forceVector; double[] rVector = VectorOperations.VectorVectorSubtraction(bVector, VectorOperations.MatrixVectorProduct(K, xVector)); double[] r0hatVector = rVector; double rho0 = 1.0; double w = 1.0; double a = 1.0; double rho1 = VectorOperations.VectorDotProduct(r0hatVector, rVector); double b; double[] sVector; double[] tVector; int iters = 100; double converged; for (int i = 0; i < iters; i++) { b = (rho1 / rho0) * (a / w); pVector = VectorOperations.VectorVectorAddition(rVector, VectorOperations.VectorScalarProductNew( VectorOperations.VectorVectorSubtraction(pVector, VectorOperations.VectorScalarProductNew(vVector, w)), b)); vVector = VectorOperations.MatrixVectorProduct(K, pVector); a = rho1 / VectorOperations.VectorDotProduct(r0hatVector, vVector); sVector = VectorOperations.VectorVectorSubtraction(rVector, VectorOperations.VectorScalarProductNew(vVector, a)); tVector = VectorOperations.MatrixVectorProduct(K, sVector); w = VectorOperations.VectorDotProduct(tVector, sVector) / VectorOperations.VectorDotProduct(tVector, tVector); rho0 = rho1; rho1 = -w *VectorOperations.VectorDotProduct(r0hatVector, tVector); xVector = VectorOperations.VectorVectorAddition(xVector, VectorOperations.VectorScalarProductNew(pVector, a)); xVector = VectorOperations.VectorVectorAddition(xVector, VectorOperations.VectorScalarProductNew(sVector, w)); rVector = VectorOperations.VectorVectorSubtraction(sVector, VectorOperations.VectorScalarProductNew(tVector, w)); converged = VectorOperations.VectorNorm2(rVector); if (i == iters | converged < 0.00000001) { break; } } solutionVector = xVector; return(solutionVector); }
private double[] CalculateHatRVector(int i) { double[,] hatKMatrix = CalculateHatKMatrix(); double[,] hatMMatrix = CalculateHatMMatrix(); double[] hatCurrentU = VectorOperations.MatrixVectorProduct(hatKMatrix, explicitSolution[i - 1]); double[] hatPreviousU = VectorOperations.MatrixVectorProduct(hatMMatrix, explicitSolution[i - 2]); double[] hatR = VectorOperations.VectorVectorSubtraction(ExternalForcesVector, VectorOperations.VectorVectorAddition(hatCurrentU, hatPreviousU)); return(hatR); }
//private double[] UpdatedF(double[] forceVector) //{ // lambda = 1.0 / numberOfLoadSteps; // double[] incrementDf = VectorOperations.VectorScalarProductNew(forceVector, lambda); // double[] solutionVector = new double[forceVector.Length]; // double[] incrementalExternalForcesVector = new double[forceVector.Length]; // double[] tempSolutionVector = new double[solutionVector.Length]; // double[] deltaU = new double[solutionVector.Length]; // double[] internalForcesTotalVector; // double[] dU; // double[] currentU = explicitSolution.Values.Last(); // Assembler.UpdateDisplacements(currentU); // internalForcesTotalVector = Assembler.CreateTotalInternalForcesVector(); // double[,] TotalMassMatrix = Assembler.CreateTotalMassMatrix(); // double[] a2_M_ut = VectorOperations.MatrixVectorProduct( // MatrixOperations.ScalarMatrixProductNew(a2, TotalMassMatrix), currentU); // double[] a0_M_ut = VectorOperations.MatrixVectorProduct( // MatrixOperations.ScalarMatrixProductNew(a0, TotalMassMatrix), currentU); // double[,] hatMMatrix = CalculateHatMMatrix(); // double[] hatM_utprevious = VectorOperations.MatrixVectorProduct(hatMMatrix, ) //double[,] hatK = MatrixOperations.MatrixSubtraction(TotalStiffnessMatrix, // MatrixOperations.ScalarMatrixProductNew(a2, TotalMassMatrix)); //double[] hatCurrentU = VectorOperations.MatrixVectorProduct(hatKMatrix, explicitSolution[i - 1]); // double[] hatPreviousU = VectorOperations.MatrixVectorProduct(hatMMatrix, explicitSolution[i - 2]); // double[] hatR = VectorOperations.VectorVectorSubtraction(ExternalForcesVector, // VectorOperations.VectorVectorAddition(hatCurrentU, hatPreviousU)); // double[,] tangentMatrix = CalculateHatMMatrix(); // dU = LinearSolver.Solve(tangentMatrix, incrementDf); // solutionVector = VectorOperations.VectorVectorAddition(solutionVector, dU); // Assembler.UpdateDisplacements(solutionVector); // tangentMatrix = CalculateHatMMatrix(); // internalForcesTotalVector = Assembler.CreateTotalInternalForcesVector(); // residual = VectorOperations.VectorVectorSubtraction(internalForcesTotalVector, incrementalExternalForcesVector); // residualNorm = VectorOperations.VectorNorm2(residual); // int iteration = 0; // Array.Clear(deltaU, 0, deltaU.Length); // return solutionVector; //} /// <summary> /// Calculates accelerations for time t /// </summary> /// <returns></returns> private double[] CalculateAccelerations() //Bathe page 771 { int steps = explicitSolution.Count; double[] aCurrent = VectorOperations.VectorScalarProductNew( VectorOperations.VectorVectorAddition(explicitSolution[steps - 4], VectorOperations.VectorVectorAddition( VectorOperations.VectorScalarProductNew(explicitSolution[steps - 3], -2.0), explicitSolution[steps - 2])), a0); return(aCurrent); }
private double[] CalculateVelocityNewmark(int step, List <double> aConstants) { double[] dUt = explicitVelocity[step - 1]; double[] ddUt = explicitAcceleration[step - 1]; double[] ddUtplusDt = explicitAcceleration[step]; double[] part1 = VectorOperations.VectorScalarProductNew(ddUt, aConstants[6]); double[] part2 = VectorOperations.VectorScalarProductNew(ddUtplusDt, aConstants[7]); double[] dUtplusDt = VectorOperations.VectorVectorAddition(dUt, VectorOperations.VectorVectorAddition(part1, part2)); return(dUtplusDt); }
private double[] NewtonIterationsNewmark(double[] forceVector, int stepNumber, List <double> aConstants) { lambda = 1.0 / numberOfLoadSteps; //double[] incrementDf = VectorOperations.VectorScalarProductNew(forceVector, lambda); double[] solutionVector = new double[forceVector.Length]; double[] deltaU = new double[solutionVector.Length]; double[] internalForcesTotalVector; double[] residual; double residualNorm; double[] hatR; solutionVector = explicitSolution.Values.Last(); Assembler.UpdateDisplacements(solutionVector); //Assembler.UpdateAccelerations(explicitAcceleration.Values.Last()); hatR = CalculateHatRVectorNewmarkNL(stepNumber, aConstants, solutionVector); internalForcesTotalVector = Assembler.CreateTotalInternalForcesVector(); residual = VectorOperations.VectorVectorSubtraction(hatR, internalForcesTotalVector); residual = VectorOperations.VectorVectorSubtraction(forceVector, Assembler.CreateTotalInternalForcesVector()); int iteration = 0; Array.Clear(deltaU, 0, deltaU.Length); for (int i = 0; i < maxIterations; i++) { double[,] tangentMatrix = CalculateHatKMatrixNewmark(aConstants); deltaU = LinearSolver.Solve(tangentMatrix, residual); solutionVector = VectorOperations.VectorVectorAddition(solutionVector, deltaU); Assembler.UpdateDisplacements(solutionVector); //Assembler.UpdateAccelerations(CalculateAccelerations()); hatR = CalculateHatRVectorNewmarkNL(stepNumber, aConstants, solutionVector); internalForcesTotalVector = Assembler.CreateTotalInternalForcesVector(); residual = VectorOperations.VectorVectorSubtraction(hatR, internalForcesTotalVector); residualNorm = VectorOperations.VectorNorm2(residual); if (residualNorm < tolerance) { break; } iteration = iteration + 1; } //Console.WriteLine(iteration); if (iteration >= maxIterations) { Console.WriteLine("Newton-Raphson: Solution not converged at current iterations"); } return(solutionVector); }
private double[] Project(double[] ksiVector) { double[] xUpdated = xUpdatedVector(); Tuple <double[, ], double[, ], double[, ]> aMatrices = CalculatePositionMatrix(ksiVector[0], ksiVector[1]); List <double[]> dRho = SurfaceVectors(ksiVector[0], ksiVector[1]); double[] f = Calculate_f(dRho, aMatrices.Item1, xUpdated); double e = Calculate_e(aMatrices.Item2, xUpdated); double[,] m = MetricTensor(dRho); double detm = MetricTensorDet(m); double[] deltaKsi = CalculateDeltaKsi(detm, m, f, e); ksiVector = VectorOperations.VectorVectorAddition(ksiVector, deltaKsi); return(ksiVector); }
private double[] CalculateAccelerationNewmark(int step, List <double> aConstants) { double[] dUt = explicitVelocity[step - 1]; double[] ut = explicitSolution[step - 1]; double[] utplusDt = explicitSolution[step]; double[] ddUt = explicitAcceleration[step - 1]; double[] part1 = VectorOperations.VectorScalarProductNew( VectorOperations.VectorVectorSubtraction(utplusDt, ut), aConstants[0]); double[] part2 = VectorOperations.VectorScalarProductNew(dUt, aConstants[2]); double[] part3 = VectorOperations.VectorScalarProductNew(ddUt, aConstants[3]); double[] ddUtplusDt = VectorOperations.VectorVectorSubtraction(part1, VectorOperations.VectorVectorAddition(part2, part3)); return(ddUtplusDt); }
private double[] LoadControlledNR(double[] forceVector) { double[] incrementDf = VectorOperations.VectorScalarProductNew(forceVector, lambda); double[] solutionVector = new double[forceVector.Length]; double[] incrementalExternalForcesVector = new double[forceVector.Length]; double[] tempSolutionVector = new double[solutionVector.Length]; double[] deltaU = new double[solutionVector.Length]; double[] internalForcesTotalVector; double[] dU; double[] residual; double residualNorm; for (int i = 0; i < numberOfLoadSteps; i++) { incrementalExternalForcesVector = VectorOperations.VectorVectorAddition(incrementalExternalForcesVector, incrementDf); base.UpdateDisplacements(solutionVector); internalForcesTotalVector = base.CreateTotalInternalForcesVector(); double[,] stiffnessMatrix = base.CreateTotalStiffnessMatrix(); dU = linearSolver.Solve(stiffnessMatrix, incrementDf); solutionVector = VectorOperations.VectorVectorAddition(solutionVector, dU); residual = VectorOperations.VectorVectorSubtraction(internalForcesTotalVector, incrementalExternalForcesVector); residualNorm = VectorOperations.VectorNorm2(residual); int iteration = 0; Array.Clear(deltaU, 0, deltaU.Length); while (residualNorm > tolerance && iteration < maxIterations) { stiffnessMatrix = base.CreateTotalStiffnessMatrix(); deltaU = VectorOperations.VectorVectorSubtraction(deltaU, linearSolver.Solve(stiffnessMatrix, residual)); tempSolutionVector = VectorOperations.VectorVectorAddition(solutionVector, deltaU); base.UpdateDisplacements(tempSolutionVector); internalForcesTotalVector = base.CreateTotalInternalForcesVector(); residual = VectorOperations.VectorVectorSubtraction(internalForcesTotalVector, incrementalExternalForcesVector); residualNorm = VectorOperations.VectorNorm2(residual); iteration = iteration + 1; } solutionVector = VectorOperations.VectorVectorAddition(solutionVector, deltaU); if (iteration >= maxIterations) { Console.WriteLine("Newton-Raphson: Solution not converged at current iterations"); } } return(solutionVector); }
private double[] CalculateHatRVectorNewmarkNL(int i, List <double> aConstants, double[] previousIterationSolution) { double[,] TotalMassMatrix; double[,] TotalDampingMatrix; double[,] TotalStiffnessMatrix; if (CustomMassMatrix != null) { TotalMassMatrix = CustomMassMatrix; TotalDampingMatrix = CustomDampingMatrix; TotalStiffnessMatrix = CustomStiffnessMatrix; } else { TotalMassMatrix = Assembler.CreateTotalMassMatrix(); TotalDampingMatrix = Assembler.CreateTotalDampingMatrix(); TotalStiffnessMatrix = Assembler.CreateTotalStiffnessMatrix(); } double[] currentU = explicitSolution[i - 1]; double[] currentdU = explicitVelocity[i - 1]; double[] currentddU = explicitAcceleration[i - 1]; double[] a0U = VectorOperations.VectorScalarProductNew( VectorOperations.VectorVectorSubtraction(currentU, previousIterationSolution), aConstants[0]); double[] a2dU = VectorOperations.VectorScalarProductNew(currentdU, aConstants[2]); double[] a3ddU = VectorOperations.VectorScalarProductNew(currentddU, aConstants[3]); double[] a1U = VectorOperations.VectorScalarProductNew(currentU, aConstants[1]); double[] a4dU = VectorOperations.VectorScalarProductNew(currentdU, aConstants[4]); double[] a5ddU = VectorOperations.VectorScalarProductNew(currentddU, aConstants[5]); double[] vectorSum1 = VectorOperations.VectorVectorAddition(a0U, VectorOperations.VectorVectorAddition(a2dU, a3ddU)); double[] vectorSum2 = VectorOperations.VectorVectorAddition(a1U, VectorOperations.VectorVectorAddition(a4dU, a5ddU)); double[] part1 = VectorOperations.MatrixVectorProduct(TotalMassMatrix, vectorSum1); double[] part2 = VectorOperations.MatrixVectorProduct(TotalDampingMatrix, vectorSum2); double[] hatR = VectorOperations.VectorVectorAddition(ExternalForcesVector, VectorOperations.VectorVectorAddition(part1, part2)); return(hatR); }
private double[] CalculateHatRVectorNL(int i) { Assembler.UpdateDisplacements(explicitSolution[i - 1]); double[,] totalMassMatrix = Assembler.CreateTotalMassMatrix(); double[,] totalDampingMatrix = Assembler.CreateTotalDampingMatrix(); double[,] a2M = MatrixOperations.ScalarMatrixProductNew(a2, totalMassMatrix); double[,] a0M = MatrixOperations.ScalarMatrixProductNew(a0, totalMassMatrix); double[,] a1C = MatrixOperations.ScalarMatrixProductNew(-a1, totalDampingMatrix); double[,] hutM = MatrixOperations.MatrixAddition(a0M, a1C); double[] F = Assembler.CreateTotalInternalForcesVector(); double[] hatPreviousU = VectorOperations.MatrixVectorProduct(hutM, explicitSolution[i - 2]); double[] a2Mut = VectorOperations.MatrixVectorProduct(a2M, explicitSolution[i - 1]); double[] hatR1 = VectorOperations.VectorVectorSubtraction(ExternalForcesVector, F); double[] hatR2 = VectorOperations.VectorVectorSubtraction(a2Mut, hatPreviousU); double[] hatRtotal = VectorOperations.VectorVectorAddition(hatR1, hatR2); return(hatRtotal); }
private double[] StartNewtonIterations(double[] forceVector) { lambda = 1.0 / numberOfLoadSteps; double[] solutionVector = new double[forceVector.Length]; double[] tempSolutionVector = new double[solutionVector.Length]; double[] deltaU = new double[solutionVector.Length]; double[] internalForcesTotalVector; double[] dU; double[] residual; double residualNorm; discretization.UpdateDisplacements(solutionVector); residual = VectorOperations.VectorVectorSubtraction(forceVector, discretization.CreateTotalInternalForcesVector()); int iteration = 0; Array.Clear(deltaU, 0, deltaU.Length); for (int i = 0; i < MaxIterations; i++) { double[,] tangentMatrix = discretization.CreateTotalStiffnessMatrix(); deltaU = linearSolver.Solve(tangentMatrix, residual); solutionVector = VectorOperations.VectorVectorAddition(solutionVector, deltaU); discretization.UpdateDisplacements(solutionVector); internalForcesTotalVector = discretization.CreateTotalInternalForcesVector(); residual = VectorOperations.VectorVectorSubtraction(forceVector, internalForcesTotalVector); residualNorm = VectorOperations.VectorNorm2(residual); if (residualNorm < Tolerance) { continue; } iteration = iteration + 1; } if (iteration >= MaxIterations) { Console.WriteLine("Newton-Raphson: Solution not converged at current iterations"); } return(solutionVector); }
private double[] Project(double[] ksiVectorInitial) { int maxIterations = 1000; double tol = Math.Pow(10.0, -4.0); double[] deltaKsi = new double[2]; double norm = new double(); double[] ksiVector = ksiVectorInitial; double[] xUpdated = xUpdatedVector(); for (int i = 1; i <= maxIterations; i++) { double[] oldksiVector = ksiVector; Tuple <double[, ], double[, ], double[, ]> aMatrices = CalculatePositionMatrix(ksiVector[0], ksiVector[1]); List <double[]> dRho = SurfaceVectors(ksiVector[0], ksiVector[1]); double[] f = Calculate_f(dRho, aMatrices.Item1, xUpdated); double e = Calculate_e(aMatrices.Item1, xUpdated);//double e = Calculate_e(aMatrices.Item2, xUpdated); double[,] m = MetricTensor(dRho); double detm = MetricTensorDet(m); deltaKsi = CalculateDeltaKsi(detm, m, f, e); ksiVector = VectorOperations.VectorVectorAddition(ksiVector, deltaKsi);//Iterations for the CPP? norm = VectorOperations.VectorNorm2(VectorOperations.VectorVectorSubtraction(ksiVector, oldksiVector)); if (norm <= tol) { break; } } if (norm > tol) { throw new Exception("CPP not found in current iterations"); } else { return(ksiVector); } }
public double[] CreateInternalGlobalForcesVector() { //double ksi1 = ClosestPointProjection(); Ksi1Current = ClosestPointProjection(); if (counter == 1) { Ksi1Initial = Ksi1Current; } counter = counter + 1; if (Math.Abs(Ksi1Current) <= 1.05) { Tuple <double[, ], double[, ]> positionMatrices = CalculatePositionMatrix(Ksi1Current); double[,] aMatrix = positionMatrices.Item1; double[,] daMatrix = positionMatrices.Item2; Tuple <double[], double, double[], double[], double> surfaceCharacteristics = SurfaceGeometry(daMatrix); double m11 = surfaceCharacteristics.Item2; double[] n = surfaceCharacteristics.Item3; double[] tVector = surfaceCharacteristics.Item4; double detM = surfaceCharacteristics.Item5; double ksi3 = CalculateNormalGap(aMatrix, n); if (ksi3 <= 0) { double[,] AT = MatrixOperations.Transpose(aMatrix); double[] AT_n = VectorOperations.MatrixVectorProduct(AT, n); double[] AT_t = VectorOperations.MatrixVectorProduct(AT, tVector); double deltaKsi = CalculateTangentialVelocity(Ksi1Current, Ksi1Initial); //Console.WriteLine(Ksi1Initial); double Tr1 = CalculateTangentialTraction(deltaKsi, detM); double phi = Math.Sqrt(Tr1 * Tr1 * m11) - FrictionCoef * PenaltyFactor * Math.Abs(ksi3); if (phi <= 0.0) { double T1 = Tr1; double[] internalGlobalForcesVector = VectorOperations.VectorVectorAddition( VectorOperations.VectorScalarProductNew(AT_n, PenaltyFactor * ksi3), VectorOperations.VectorScalarProductNew(AT_t, T1 * Math.Sqrt(m11))); return(internalGlobalForcesVector); } else { double T1 = (Tr1 / Math.Abs(Tr1)) * mhid * PenaltyFactor * Math.Abs(ksi3) * Math.Sqrt(detM); double[] internalGlobalForcesVector = VectorOperations.VectorVectorAddition( VectorOperations.VectorScalarProductNew(AT_n, PenaltyFactor * ksi3), VectorOperations.VectorScalarProductNew(AT_t, T1 * Math.Sqrt(m11))); return(internalGlobalForcesVector); } } else { double[] internalGlobalForcesVector = new double[6]; return(internalGlobalForcesVector); } } else { double[] internalGlobalForcesVector = new double[6]; return(internalGlobalForcesVector); } }
private double[] NewtonIterationsExplicit(int timeStep, double[] forceVector, double[,] tangentMatrix) { //lambda = 1.0 / numberOfLoadSteps; //double[] incrementDf = VectorOperations.VectorScalarProductNew(forceVector, lambda); double[] solutionVector = new double[forceVector.Length]; double[] deltaU = new double[solutionVector.Length]; //double[] internalForcesTotalVector; double[] residual; double residualNorm; double[] hatRPrevious; double[] hatRNext; solutionVector = explicitSolution.Values.Last(); Assembler.UpdateDisplacements(solutionVector); Assembler.UpdateAccelerations(explicitAcceleration.Values.Last()); hatRPrevious = CalculateHatRVectorNL(timeStep); hatRNext = hatRPrevious; //internalForcesTotalVector = Assembler.CreateTotalInternalForcesVector(); //residual = VectorOperations.VectorVectorSubtraction(hatR, internalForcesTotalVector); residual = hatRPrevious; int iteration = 0; Array.Clear(deltaU, 0, deltaU.Length); for (int i = 0; i < maxIterations; i++) { if (i == 0) { //deltaU = LinearSolver.Solve(tangentMatrix, residual); //solutionVector = VectorOperations.VectorVectorAddition(solutionVector, deltaU); solutionVector = LinearSolver.Solve(tangentMatrix, residual); Assembler.UpdateDisplacements(solutionVector); //Assembler.UpdateAccelerations(CalculateAccelerations()); hatRNext = CalculateHatRVectorNL(timeStep); //internalForcesTotalVector = Assembler.CreateTotalInternalForcesVector(); residual = VectorOperations.VectorVectorSubtraction(hatRNext, hatRPrevious); residualNorm = VectorOperations.VectorNorm2(residual); if (residualNorm < tolerance) { break; } iteration = iteration + 1; hatRPrevious = hatRNext; } else { deltaU = LinearSolver.Solve(tangentMatrix, residual); solutionVector = VectorOperations.VectorVectorAddition(solutionVector, deltaU); //solutionVector = LinearSolver.Solve(tangentMatrix, residual); Assembler.UpdateDisplacements(solutionVector); //Assembler.UpdateAccelerations(CalculateAccelerations()); hatRNext = CalculateHatRVectorNL(timeStep); //internalForcesTotalVector = Assembler.CreateTotalInternalForcesVector(); residual = VectorOperations.VectorVectorSubtraction(hatRNext, hatRPrevious); residualNorm = VectorOperations.VectorNorm2(residual); if (residualNorm < tolerance) { break; } iteration = iteration + 1; hatRPrevious = hatRNext; } } //Console.WriteLine(iteration); if (iteration >= maxIterations) { Console.WriteLine("Newton-Raphson: Solution not converged at current iterations"); } return(solutionVector); }