예제 #1
0
        public static void RunExample()
        {
            IAssembly elementsAssembly = CreateAssembly();

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


            InitialConditions initialValues = new InitialConditions();

            initialValues.InitialAccelerationVector    = new double[1];
            initialValues.InitialDisplacementVector    = new double[1];
            initialValues.InitialDisplacementVector[0] = 0.2146;
            initialValues.InitialVelocityVector        = new double[1];
            initialValues.InitialTime = 0.0;

            ExplicitSolver newSolver = new ExplicitSolver(1.0, 10);

            newSolver.Assembler = elementsAssembly;

            newSolver.InitialValues             = initialValues;
            newSolver.ExternalForcesVector      = new double[] { 0.0 };
            newSolver.LinearSolver              = new LUFactorization();
            newSolver.ActivateNonLinearSolution = true;
            newSolver.SolveExplicit();
            newSolver.PrintExplicitSolution();
        }
예제 #2
0
        public static void RunDynamicExample()
        {
            IAssembly elementsAssembly = CreateAssembly();

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



            InitialConditions initialValues = new InitialConditions();

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

            ExplicitSolver newSolver = new ExplicitSolver(1.0, 1000000);

            newSolver.Assembler = elementsAssembly;

            newSolver.InitialValues        = initialValues;
            newSolver.ExternalForcesVector = new double[462];
            for (int i = 441; i <= 462; i += 2)
            {
                newSolver.ExternalForcesVector[i] = -10000.0;
            }
            newSolver.LinearSolver = new CholeskyFactorization();
            newSolver.ActivateNonLinearSolution = true;
            newSolver.SolveExplicit();
            //newSolver.PrintExplicitSolution();
        }
예제 #3
0
        public static void SolveExample()
        {
            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.SolveExplicit();
            solver.PrintExplicitSolution();
        }
예제 #4
0
        public static void 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[5] = 0.1146;
            initialValues.InitialVelocityVector        = new double[16];
            initialValues.InitialTime = 0.0;

            ExplicitSolver newSolver = new ExplicitSolver(0.3, 100000);

            newSolver.Assembler = elementsAssembly;

            newSolver.InitialValues             = initialValues;
            newSolver.ExternalForcesVector      = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };//{ 0, 0, 0, 0, 0, -4 * 22000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            newSolver.LinearSolver              = new CholeskyFactorization();
            newSolver.ActivateNonLinearSolution = true;
            newSolver.SolveExplicit();
            newSolver.PrintExplicitSolution();
        }
예제 #5
0
        public static Results RunExample()
        {
            IAssembly elementsAssembly = CreateAssembly();

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


            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 newSolver = new ExplicitSolver(1.0, 10);

            newSolver.Assembler = elementsAssembly;

            newSolver.InitialValues             = initialValues;
            newSolver.ExternalForcesVector      = new double[] { 50.0, 0 };
            newSolver.LinearSolver              = new LUFactorization();
            newSolver.ActivateNonLinearSolution = true;
            newSolver.SolveExplicit();
            newSolver.PrintExplicitSolution();
            Results finalResults = new Results()
            {
                DynamicSolution = newSolver.explicitSolution, TimeSteps = newSolver.TimeAtEachStep, SelectedDOF = 1, SelectedInterval = 1, SolutionType = "Dynamic"
            };

            return(finalResults);
        }
예제 #6
0
        public static void RunExample()
        {
            IAssembly elementsAssembly = CreateAssembly();

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


            InitialConditions initialValues = new InitialConditions();

            initialValues.InitialAccelerationVector = new double[40];
            initialValues.InitialDisplacementVector = new double[40];
            initialValues.InitialVelocityVector     = new double[40];
            initialValues.InitialTime = 0.0;

            ExplicitSolver newSolver = new ExplicitSolver(1.0, 100);

            newSolver.Assembler = elementsAssembly;

            Dictionary <int, double> externalLoads = new Dictionary <int, double>()
            {
                { 34, -50000.0 },
                { 39, 500000.0 }
            };

            newSolver.InitialValues             = initialValues;
            newSolver.ExternalForcesVector      = CreateExternalForcesVector(externalLoads);
            newSolver.LinearSolver              = new LUFactorization();
            newSolver.ActivateNonLinearSolution = false;
            newSolver.SolveExplicit();
            newSolver.PrintExplicitSolution();
        }
예제 #7
0
        public static void RunDynamicExample()
        {
            IAssembly elementsAssembly = CreateAssembly();

            InitialConditions initialValues = new InitialConditions();

            initialValues.InitialAccelerationVector = new double[60];
            initialValues.InitialDisplacementVector = new double[60];
            initialValues.InitialVelocityVector     = new double[60];
            initialValues.InitialTime = 0.0;

            ExplicitSolver newSolver = new ExplicitSolver(1.0, 100);

            newSolver.Assembler = elementsAssembly;

            double[] externalForces = new double[60];
            externalForces[28] = -5000.0;

            newSolver.InitialValues             = initialValues;
            newSolver.ExternalForcesVector      = externalForces;
            newSolver.LinearSolver              = new LUFactorization();
            newSolver.ActivateNonLinearSolution = true;
            newSolver.SolveExplicit();
            newSolver.PrintExplicitSolution();
        }
예제 #8
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);
        }