示例#1
0
 public DynamicScheme(InitialConditions initialValues, double totalTime, int timeStepsNumber)
 {
     totalDOFs                 = stiffnessMatrix.GetLength(0);
     this.totalTime            = totalTime;
     this.timeStepsNumber      = timeStepsNumber;
     timeStep                  = totalTime / timeStepsNumber;
     this.massMatrix           = massMatrix;
     this.stiffnessMatrix      = stiffnessMatrix;
     dampingMatrix             = new double[totalDOFs, totalDOFs];
     this.externalForcesVector = externalForcesVector;
     initialDisplacementVector = initialValues.InitialDisplacementVector;
     initialVelocityVector     = initialValues.InitialVelocityVector;
     initialAccelerationVector = initialValues.InitialAccelerationVector;
     initialTime               = initialValues.InitialTime;
     a0 = 1.0 / (timeStep * timeStep);
     a1 = 1.0 / (2.0 * timeStep);
     a2 = 2.0 * a0;
     a3 = 1.0 / a2;
 }
示例#2
0
 public CentralDifferences(ILinearSolution linearSolver, InitialConditions initialValues, double totalTime, int timeStepsNumber, double[,] stiffnessMatrix, double[,] massMatrix, double[] externalForcesVector)
 {
     totalDOFs                 = stiffnessMatrix.GetLength(0);
     this.totalTime            = totalTime;
     this.timeStepsNumber      = timeStepsNumber;
     timeStep                  = totalTime / timeStepsNumber;
     this.massMatrix           = massMatrix;
     this.stiffnessMatrix      = stiffnessMatrix;
     dampingMatrix             = new double[totalDOFs, totalDOFs];
     this.externalForcesVector = externalForcesVector;
     initialDisplacementVector = initialValues.InitialDisplacementVector;
     initialVelocityVector     = initialValues.InitialVelocityVector;
     initialAccelerationVector = initialValues.InitialAccelerationVector;
     initialTime               = initialValues.InitialTime;
     this.linearSolver         = linearSolver;
     a0 = 1.0 / (timeStep * timeStep);
     a1 = 1.0 / (2.0 * timeStep);
     a2 = 2.0 * a0;
     a3 = 1.0 / a2;
 }
示例#3
0
        public static Results RunExample()
        {
            IAssembly elementsAssembly = CreateAssembly();

            elementsAssembly.CreateElementsAssembly();
            elementsAssembly.ActivateBoundaryConditions = true;
            ShowToGUI.PlotInitialGeometry(elementsAssembly);
            InitialConditions initialValues = new InitialConditions();

            initialValues.InitialAccelerationVector = new double[] { 10.0, 0.0, 10.0, 0.0 };
            initialValues.InitialDisplacementVector = new double[] { 0.0, 0.0, 0.0, 0.0 };
            initialValues.InitialVelocityVector     = new double[] { 0.0, 0.0, 0.0, 0.0 };
            initialValues.InitialTime = 0.0;

            ExplicitSolver newSolver = new ExplicitSolver(1, 100);

            newSolver.Assembler = elementsAssembly;
            double[] externalForces = externalForcesStructuralVector;
            foreach (var dof in loadedStructuralDOFs)
            {
                externalForces[dof - 1] = externalForce;
            }
            newSolver.InitialValues             = initialValues;
            newSolver.ExternalForcesVector      = BoundaryConditionsImposition.ReducedVector(externalForces, elementsAssembly.BoundedDOFsVector);
            newSolver.LinearSolver              = new LUFactorization();
            newSolver.ActivateNonLinearSolution = true;
            newSolver.SolveNewmark();
            Tuple <Dictionary <int, double[]>, Dictionary <int, double> > solvectors = newSolver.GetResults();
            int max = solvectors.Item1.OrderByDescending(m => m.Key).FirstOrDefault().Key;

            elementsAssembly.UpdateDisplacements(solvectors.Item1.Single(m => m.Key == max).Value);
            ShowToGUI.PlotFinalGeometry(elementsAssembly);
            //newSolver.PrintExplicitSolution();
            Results finalResults = new Results()
            {
                DynamicSolution = newSolver.explicitSolution, TimeSteps = newSolver.TimeAtEachStep, SelectedDOF = 1, SelectedInterval = 1, SolutionType = "Dynamic"
            };

            return(finalResults);
        }
示例#4
0
        public static Results RunExample()
        {
            IAssembly elementsAssembly = CreateAssembly();

            elementsAssembly.CreateElementsAssembly();
            elementsAssembly.ActivateBoundaryConditions = true;
            ShowToGUI.PlotInitialGeometry(elementsAssembly);
            var AccelerationVector = new double[nodesNumber * 2];
            var DisplacementVector = new double[nodesNumber * 2];
            var VelocityVector     = new double[nodesNumber * 2];

            for (int i = 1; i <= 2 * (nodesInPerimeter * 4 + 13) - 1; i += 2)
            {
                VelocityVector[i] = -30.0;
            }
            InitialConditions initialValues = new InitialConditions();

            initialValues.InitialAccelerationVector = BoundaryConditionsImposition.ReducedVector(AccelerationVector, elementsAssembly.BoundedDOFsVector);
            initialValues.InitialDisplacementVector = BoundaryConditionsImposition.ReducedVector(DisplacementVector, elementsAssembly.BoundedDOFsVector);
            initialValues.InitialVelocityVector     = BoundaryConditionsImposition.ReducedVector(VelocityVector, elementsAssembly.BoundedDOFsVector);
            initialValues.InitialTime = 0.0;
            //ExplicitSolver newSolver = new ExplicitSolver(0.0534, 100);
            ExplicitSolver newSolver = new ExplicitSolver(0.002906, 6000);

            newSolver.Assembler = elementsAssembly;
            double[] externalForces = externalForcesStructuralVector;
            foreach (var dof in loadedStructuralDOFs)
            {
                externalForces[dof - 1] = externalForce;
            }
            newSolver.InitialValues             = initialValues;
            newSolver.ExternalForcesVector      = BoundaryConditionsImposition.ReducedVector(externalForces, elementsAssembly.BoundedDOFsVector);
            newSolver.LinearSolver              = new LUFactorization();
            newSolver.ActivateNonLinearSolution = true;
            newSolver.SolveExplicit();
            Tuple <Dictionary <int, double[]>, Dictionary <int, double> > solvectors = newSolver.GetResults();
            //int max = solvectors.Item1.OrderByDescending(m => m.Key).FirstOrDefault().Key;
            //elementsAssembly.UpdateDisplacements(solvectors.Item1.Single(m => m.Key == max).Value);
            Dictionary <int, double[]> allStepsSolutions = solvectors.Item1;

            //for (int i = 1; i < allStepsSolutions.Count; i++)
            for (int i = 0; i < allStepsSolutions.Count - 1; i++)
            {
                elementsAssembly.UpdateDisplacements(allStepsSolutions[i]);
            }
            ShowToGUI.PlotFinalGeometry(elementsAssembly);
            double[] fullDynamicSol1  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[510], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol2  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[520], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol3  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[530], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol4  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[540], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol5  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[550], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol6  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[560], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol7  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[570], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol8  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[580], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol9  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[590], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol10 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[599], elementsAssembly.BoundedDOFsVector);
            VectorOperations.PrintVectorToFile(fullDynamicSol1, @"C:\Users\Public\Documents\Results1.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol2, @"C:\Users\Public\Documents\Results2.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol3, @"C:\Users\Public\Documents\Results3.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol4, @"C:\Users\Public\Documents\Results4.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol5, @"C:\Users\Public\Documents\Results5.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol6, @"C:\Users\Public\Documents\Results6.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol7, @"C:\Users\Public\Documents\Results7.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol8, @"C:\Users\Public\Documents\Results8.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol9, @"C:\Users\Public\Documents\Results9.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol10, @"C:\Users\Public\Documents\Results10.dat");
            //newSolver.PrintExplicitSolution();
            Results finalResults = new Results()
            {
                DynamicSolution = newSolver.explicitSolution, TimeSteps = newSolver.TimeAtEachStep, SelectedDOF = 1, SelectedInterval = 1, SolutionType = "Dynamic"
            };

            return(finalResults);
        }
示例#5
0
        public static Results RunExample()
        {
            IAssembly elementsAssembly = CreateAssembly();

            elementsAssembly.CreateElementsAssembly();
            elementsAssembly.ActivateBoundaryConditions = true;
            ShowToGUI.PlotInitialGeometry(elementsAssembly);
            var AccelerationVector = new double[nodesNumber * 2];
            var DisplacementVector = new double[nodesNumber * 2];
            var VelocityVector     = new double[nodesNumber * 2];

            for (int i = 1; i <= 2 * (3 * circles - 1) * steps - 1; i += 2)
            {
                VelocityVector[i] = -50.0;
            }
            InitialConditions initialValues = new InitialConditions();

            initialValues.InitialAccelerationVector = BoundaryConditionsImposition.ReducedVector(AccelerationVector, elementsAssembly.BoundedDOFsVector);
            initialValues.InitialDisplacementVector = BoundaryConditionsImposition.ReducedVector(DisplacementVector, elementsAssembly.BoundedDOFsVector);
            initialValues.InitialVelocityVector     = BoundaryConditionsImposition.ReducedVector(VelocityVector, elementsAssembly.BoundedDOFsVector);
            initialValues.InitialTime = 0.0;
            //ExplicitSolver newSolver = new ExplicitSolver(0.0035, 3500);
            ExplicitSolver newSolver = new ExplicitSolver(0.003, 300);

            newSolver.Assembler = elementsAssembly;
            double[] externalForces = externalForcesStructuralVector;
            foreach (var dof in loadedStructuralDOFs)
            {
                externalForces[dof - 1] = externalForce;
            }
            newSolver.InitialValues             = initialValues;
            newSolver.ExternalForcesVector      = BoundaryConditionsImposition.ReducedVector(externalForces, elementsAssembly.BoundedDOFsVector);
            newSolver.LinearSolver              = new LUFactorization();
            newSolver.ActivateNonLinearSolution = true;
            newSolver.SolveNewmark();
            Tuple <Dictionary <int, double[]>, Dictionary <int, double> > solvectors = newSolver.GetResults();
            //int max = solvectors.Item1.OrderByDescending(m => m.Key).FirstOrDefault().Key;
            //elementsAssembly.UpdateDisplacements(solvectors.Item1.Single(m => m.Key == max).Value);
            Dictionary <int, double[]>         allStepsSolutions = solvectors.Item1;
            Dictionary <int, List <double[]> > stress            = new Dictionary <int, List <double[]> >();
            Dictionary <int, List <double[]> > strain            = new Dictionary <int, List <double[]> >();
            Dictionary <int, List <double[]> > gPoints           = new Dictionary <int, List <double[]> >();
            Dictionary <int, List <double[]> > nodesStress       = new Dictionary <int, List <double[]> >();
            Dictionary <int, List <double[]> > nodesStrain       = new Dictionary <int, List <double[]> >();

            //for (int i = 1; i < allStepsSolutions.Count; i++)
            for (int i = 0; i <= allStepsSolutions.Count - 1; i++)
            {
                elementsAssembly.UpdateDisplacements(allStepsSolutions[i]);
                if (i == allStepsSolutions.Count - 1)
                {
                    stress      = elementsAssembly.GetElementsStresses(allStepsSolutions[i]);
                    strain      = elementsAssembly.GetElementsStains(allStepsSolutions[i]);
                    gPoints     = elementsAssembly.GetElementsGaussPoints(allStepsSolutions[i]);
                    nodesStress = elementsAssembly.GetElementsNodesStresses(allStepsSolutions[i]);
                    nodesStrain = elementsAssembly.GetElementsNodesStains(allStepsSolutions[i]);
                    ExportToFile.ExportMatlabFinalGeometry(elementsAssembly, BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[i], elementsAssembly.BoundedDOFsVector));
                }
            }
            ShowToGUI.PlotFinalGeometry(elementsAssembly);
            double[] fullDynamicSol1  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[200], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol2  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[210], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol3  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[220], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol4  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[230], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol5  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[240], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol6  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[250], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol7  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[260], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol8  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[270], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol9  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[280], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol10 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[285], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol11 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[290], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol12 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[291], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol13 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[292], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol14 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[293], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol15 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[294], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol16 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[295], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol17 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[296], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol18 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[297], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol19 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[298], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol20 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[299], elementsAssembly.BoundedDOFsVector);
            VectorOperations.PrintVectorToFile(fullDynamicSol1, @"C:\Users\Public\Documents\Results1.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol2, @"C:\Users\Public\Documents\Results2.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol3, @"C:\Users\Public\Documents\Results3.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol4, @"C:\Users\Public\Documents\Results4.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol5, @"C:\Users\Public\Documents\Results5.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol6, @"C:\Users\Public\Documents\Results6.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol7, @"C:\Users\Public\Documents\Results7.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol8, @"C:\Users\Public\Documents\Results8.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol9, @"C:\Users\Public\Documents\Results9.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol10, @"C:\Users\Public\Documents\Results10.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol11, @"C:\Users\Public\Documents\Results11.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol12, @"C:\Users\Public\Documents\Results12.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol13, @"C:\Users\Public\Documents\Results13.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol14, @"C:\Users\Public\Documents\Results14.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol15, @"C:\Users\Public\Documents\Results15.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol16, @"C:\Users\Public\Documents\Results16.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol17, @"C:\Users\Public\Documents\Results17.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol18, @"C:\Users\Public\Documents\Results18.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol19, @"C:\Users\Public\Documents\Results19.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol20, @"C:\Users\Public\Documents\Results20.dat");
            VectorOperations.PrintDictionaryofListsofVectorsToFile(stress, @"C:\Users\Public\Documents\Stress.dat");
            VectorOperations.PrintDictionaryofListsofVectorsToFile(strain, @"C:\Users\Public\Documents\Strain.dat");
            VectorOperations.PrintDictionaryofListsofVectorsToFile(gPoints, @"C:\Users\Public\Documents\GaussPoints.dat");
            VectorOperations.PrintDictionaryofListsofVectorsToFile(nodesStress, @"C:\Users\Public\Documents\StressNodes.dat");
            VectorOperations.PrintDictionaryofListsofVectorsToFile(nodesStrain, @"C:\Users\Public\Documents\StrainNodes.dat");
            //newSolver.PrintExplicitSolution();
            Results finalResults = new Results()
            {
                DynamicSolution = newSolver.explicitSolution, TimeSteps = newSolver.TimeAtEachStep, SelectedDOF = 1, SelectedInterval = 1, SolutionType = "Dynamic"
            };

            return(finalResults);
        }