Exemplo n.º 1
0
        public static void RunDynamicExample()
        {
            IAssembly elementsAssembly = CreateAssembly();

            elementsAssembly.CreateElementsAssembly();
            elementsAssembly.ActivateBoundaryConditions = true;

            InitialConditions initialValues = new InitialConditions();

            initialValues.InitialAccelerationVector = new double[6];
            initialValues.InitialDisplacementVector = new double[6];
            //initialValues.InitialDisplacementVector[7] = -0.02146;
            initialValues.InitialVelocityVector = new double[6];
            initialValues.InitialTime           = 0.0;

            ExplicitSolver newSolver = new ExplicitSolver(1.0, 10000);

            newSolver.Assembler = elementsAssembly;

            newSolver.InitialValues             = initialValues;
            newSolver.ExternalForcesVector      = new double[] { 0, 0, 0, 0, -50000, -50000 };
            newSolver.LinearSolver              = new CholeskyFactorization();
            newSolver.ActivateNonLinearSolution = true;
            newSolver.SolveNewmark();
            newSolver.PrintExplicitSolution();//
        }
Exemplo n.º 2
0
        public static void SolveNewmarkExample()
        {
            double[,] M = new double[, ]
            {
                { 2.0, 0.0 },
                { 0.0, 1.0 }
            };

            double[,] K = new double[, ]
            {
                { 6.0, -2.0 },
                { -2.0, 4.0 }
            };

            double[] F = new double[] { 0.0, 10.0 };

            InitialConditions initialValues = new InitialConditions();

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

            ExplicitSolver solver = new ExplicitSolver(2.8, 10);

            solver.InitialValues             = initialValues;
            solver.CustomMassMatrix          = M;
            solver.CustomStiffnessMatrix     = K;
            solver.CustomDampingMatrix       = new double[2, 2];
            solver.ExternalForcesVector      = F;
            solver.ActivateNonLinearSolution = false;
            solver.LinearSolver = new LUFactorization();
            solver.SolveNewmark();
            solver.PrintExplicitSolution();
        }
Exemplo n.º 3
0
        public static Results RunDynamicExample()
        {
            IAssembly elementsAssembly = CreateAssembly();

            elementsAssembly.CreateElementsAssembly();
            elementsAssembly.ActivateBoundaryConditions = true;

            InitialConditions initialValues = new InitialConditions();

            initialValues.InitialAccelerationVector = new double[16];
            initialValues.InitialDisplacementVector = new double[16];
            //initialValues.InitialDisplacementVector[7] = -0.02146;
            initialValues.InitialVelocityVector = new double[16];
            initialValues.InitialVelocityVector = new double[] { -5000, -5000, -5000, -5000,
                                                                 -5000, -5000, -5000, -5000, -5000, -5000, -5000, -5000, -5000, -5000, -5000, -5000 };
            initialValues.InitialTime = 0.0;

            ExplicitSolver newSolver = new ExplicitSolver(1.0, 20);

            newSolver.Assembler = elementsAssembly;

            newSolver.InitialValues = initialValues;
            //newSolver.ExternalForcesVector = new double[] { 0, 0, 0, 0, 0, -3.0 * 2200000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            newSolver.ExternalForcesVector      = new double[16];
            newSolver.LinearSolver              = new LUFactorization();
            newSolver.ActivateNonLinearSolution = true;
            newSolver.SolveNewmark();
            //newSolver.PrintExplicitSolution();
            Results finalResults = new Results()
            {
                DynamicSolution = newSolver.explicitSolution, TimeSteps = newSolver.TimeAtEachStep, SelectedDOF = 1, SelectedInterval = 1, SolutionType = "Dynamic"
            };

            return(finalResults);
        }
Exemplo n.º 4
0
        public static Results RunExample()
        {
            IAssembly elementsAssembly = CreateAssembly();

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

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

            ExplicitSolver newSolver = new ExplicitSolver(10, 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 = false;
            newSolver.SolveNewmark();
            //newSolver.PrintExplicitSolution();
            Results finalResults = new Results()
            {
                DynamicSolution = newSolver.explicitSolution, TimeSteps = newSolver.TimeAtEachStep, SelectedDOF = 1, SelectedInterval = 1, SolutionType = "Dynamic"
            };

            return(finalResults);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }