示例#1
0
        private static void SolveBuildingInNoSoilSmallVRFStochastic()
        {
            VectorExtensions.AssignTotalAffinityCount();
            Model model = new Model();

            model.SubdomainsDictionary.Add(1, new Subdomain()
            {
                ID = 1
            });
            BeamBuildingBuilder.MakeBeamBuilding(model, 20, 20, 20, 5, 4, model.NodesDictionary.Count + 1,
                                                 model.ElementsDictionary.Count + 1, 1, 4, false, false);
            model.Loads.Add(new Load()
            {
                Amount = -100, Node = model.Nodes[21], DOF = DOFType.X
            });
            model.ConnectDataStructures();

            PowerSpectrumTargetEvaluatorCoefficientsProvider stochasticProvider = new PowerSpectrumTargetEvaluatorCoefficientsProvider(10, 0.1, 1.2, 20, 200, DOFType.X,
                                                                                                                                       0.1, 200, 1e-10);


            SolverSkyline     solver        = new SolverSkyline(model);
            ProblemStructural provider      = new ProblemStructural(model, solver.SubdomainsDictionary);
            LinearAnalyzer    analyzer      = new LinearAnalyzer(solver, solver.SubdomainsDictionary);
            StaticAnalyzer    childAnalyzer = new StaticAnalyzer(provider, analyzer, solver.SubdomainsDictionary);
            VRFMonteCarloAnalyzerWithStochasticMaterial stochasticAnalyzer = new VRFMonteCarloAnalyzerWithStochasticMaterial(model, provider, childAnalyzer, solver.SubdomainsDictionary,
                                                                                                                             stochasticProvider, stochasticProvider, 1, 20, "monteCarlo");


            analyzer.LogFactories[1] = new LinearAnalyzerLogFactory(new int[] { 420 });

            //stochasticAnalyzer.BuildMatrices();
            //childAnalyzer.Initialize();
            stochasticAnalyzer.Solve();
        }
示例#2
0
        private static void SolveBuildingInNoSoilSmall()
        {
            VectorExtensions.AssignTotalAffinityCount();
            Model model = new Model();

            model.SubdomainsDictionary.Add(1, new Subdomain()
            {
                ID = 1
            });
            BeamBuildingBuilder.MakeBeamBuilding(model, 20, 20, 20, 5, 4, model.NodesDictionary.Count + 1,
                                                 model.ElementsDictionary.Count + 1, 1, 4, false, false);
            model.Loads.Add(new Load()
            {
                Amount = -100, Node = model.Nodes[21], DOF = DOFType.X
            });
            model.ConnectDataStructures();

            SolverSkyline     solver         = new SolverSkyline(model);
            ProblemStructural provider       = new ProblemStructural(model, solver.SubdomainsDictionary);
            LinearAnalyzer    analyzer       = new LinearAnalyzer(solver, solver.SubdomainsDictionary);
            StaticAnalyzer    parentAnalyzer = new StaticAnalyzer(provider, analyzer, solver.SubdomainsDictionary);

            analyzer.LogFactories[1] = new LinearAnalyzerLogFactory(new int[] { 420 });

            parentAnalyzer.BuildMatrices();
            parentAnalyzer.Initialize();
            parentAnalyzer.Solve();
        }
示例#3
0
        public void TestEulerBeam2DLinearBendingExample()
        {
            // Model and node creation
            var model = new Model();

            model.NodesDictionary.Add(1, new Node {
                ID = 1, X = 0.0, Y = 0.0, Z = 0.0
            });
            model.NodesDictionary.Add(2, new Node {
                ID = 2, X = 100.0, Y = 0.0, Z = 0.0
            });
            model.NodesDictionary.Add(3, new Node {
                ID = 3, X = 200.0, Y = 0.0, Z = 0.0
            });
            // Constrain bottom node and add nodal load value
            model.NodesDictionary[1].Constraints.AddRange(new[] { DOFType.X, DOFType.Y, DOFType.Z, DOFType.RotZ });
            model.Loads.Add(new Load()
            {
                Amount = 2000, Node = model.NodesDictionary[3], DOF = DOFType.Y
            });

            // Generate elements of the structure
            for (int iElem = 0; iElem < 2; iElem++)
            {
                // Create new Beam2D section and element
                var element = new EulerBeam2D(2.1e4)
                {
                    ID = iElem + 1, Density = 7.85, SectionArea = 91.04, MomentOfInertia = 8091.00
                };
                element.ElementType = element;
                // Add nodes to the created element
                element.AddNode(model.NodesDictionary[iElem + 1]);
                element.AddNode(model.NodesDictionary[iElem + 2]);
                // Add Hexa element to the element and subdomains dictionary of the model
                model.ElementsDictionary.Add(element.ID, element);
            }
            // Needed in order to make all the required data structures
            model.ConnectDataStructures();

            // Setup
            var linearSystem   = new SkylineLinearSystem(model.Forces);
            var solver         = new SolverSkyline(linearSystem);
            var provider       = new ProblemStructural(model);
            var childAnalyzer  = new LinearAnalyzer(solver);
            var parentAnalyzer = new StaticAnalyzer(provider, childAnalyzer, linearSystem);

            parentAnalyzer.BuildMatrices();
            parentAnalyzer.Initialize();
            parentAnalyzer.Solve();

            // Tests if calculated solution meets expected
            var expectedSolution = new double[] { 0, 9.80905689841542, 0.17656302417147754, 0, 31.388982074929341, 0.23541736556197002 };

            for (int i = 0; i < expectedSolution.Length; i++)
            {
                Assert.Equal(expectedSolution[i], linearSystem.Solution[i], 12);
            }
        }
示例#4
0
        private static Vector RunAnalysis(Model model)
        {
            // Setup analysis
            var linearSystem   = new SkylineLinearSystem(model.Forces);
            var solver         = new SolverSkyline(linearSystem);
            var provider       = new ProblemStructural(model);
            var childAnalyzer  = new LinearAnalyzer(solver);
            var parentAnalyzer = new StaticAnalyzer(provider, childAnalyzer, linearSystem);

            parentAnalyzer.BuildMatrices();
            parentAnalyzer.Initialize();
            parentAnalyzer.Solve();

            return(linearSystem.Solution);
        }
示例#5
0
        public void TestQuad4LinearCantileverExample()
        {
            // Model and node creation
            var model = new Model();

            model.NodesDictionary.Add(1, new Node {
                ID = 1, X = 0.0, Y = 0.0, Z = 0.0
            });
            model.NodesDictionary.Add(2, new Node {
                ID = 2, X = 10.0, Y = 0.0, Z = 0.0
            });
            model.NodesDictionary.Add(3, new Node {
                ID = 3, X = 10.0, Y = 10.0, Z = 0.0
            });
            model.NodesDictionary.Add(4, new Node {
                ID = 4, X = 0.0, Y = 10.0, Z = 0.0
            });
            // Constrain bottom nodes of the model and add loads
            model.NodesDictionary[1].Constraints.AddRange(new[] { DOFType.X, DOFType.Y });
            model.NodesDictionary[4].Constraints.AddRange(new[] { DOFType.X, DOFType.Y });
            model.Loads.Add(new Load()
            {
                Amount = 500, Node = model.NodesDictionary[2], DOF = DOFType.X
            });
            model.Loads.Add(new Load()
            {
                Amount = 500, Node = model.NodesDictionary[3], DOF = DOFType.X
            });

            // Create Quad4 element and its material
            var material = new ElasticMaterial2D(StressState2D.PlaneStress)
            {
                YoungModulus = 3.76, PoissonRatio = 0.3779
            };
            var quad = new Quad4(material)
            {
                Thickness = 1
            };
            // Create the element connectivity
            var element = new Element()
            {
                ID = 1, ElementType = quad
            };

            element.AddNode(model.NodesDictionary[1]);
            element.AddNode(model.NodesDictionary[2]);
            element.AddNode(model.NodesDictionary[3]);
            element.AddNode(model.NodesDictionary[4]);
            // Add quad element to the element and subdomains dictionary of the model
            model.ElementsDictionary.Add(element.ID, element);

            model.ConnectDataStructures();

            // Setup
            var linearSystem   = new SkylineLinearSystem(model.Forces);
            var solver         = new SolverSkyline(linearSystem);
            var provider       = new ProblemStructural(model);
            var childAnalyzer  = new LinearAnalyzer(solver);
            var parentAnalyzer = new StaticAnalyzer(provider, childAnalyzer, linearSystem);

            parentAnalyzer.BuildMatrices();
            parentAnalyzer.Initialize();
            parentAnalyzer.Solve();

            var expectedSolution = new double[] { 253.13237596153559, 66.567582057178811, 253.13237596153553, -66.567582057178811 };

            for (int i = 0; i < expectedSolution.Length; i++)
            {
                Assert.Equal(expectedSolution[i], linearSystem.Solution[i], 12);
            }
        }
示例#6
0
        private static void TestLinearTrussExample()
        {
            // Model and node creation
            Model model = new Model();

            model.NodesDictionary.Add(1, new Node {
                ID = 1, X = 0, Y = 0
            });
            model.NodesDictionary.Add(2, new Node {
                ID = 2, X = 0, Y = 40
            });
            model.NodesDictionary.Add(3, new Node {
                ID = 3, X = 40, Y = 40
            });
            // Constrain bottom nodes of the model and add loads
            model.NodesDictionary[1].Constraints.AddRange(new[] { DOFType.X, DOFType.Y });
            model.NodesDictionary[2].Constraints.AddRange(new[] { DOFType.X, DOFType.Y });
            model.Loads.Add(new Load()
            {
                Amount = 500, Node = model.NodesDictionary[3], DOF = DOFType.X
            });
            model.Loads.Add(new Load()
            {
                Amount = 300, Node = model.NodesDictionary[3], DOF = DOFType.Y
            });

            var element1 = new Truss2D(1e7)
            {
                ID = 1, Density = 1, SectionArea = 1.5
            };

            element1.ElementType = element1;
            var element2 = new Truss2D(1e7)
            {
                ID = 2, Density = 1, SectionArea = 1.5
            };

            element2.ElementType = element2;

            element1.AddNode(model.NodesDictionary[1]);
            element1.AddNode(model.NodesDictionary[3]);

            element2.AddNode(model.NodesDictionary[2]);
            element2.AddNode(model.NodesDictionary[3]);

            model.ElementsDictionary.Add(element1.ID, element1);
            model.ElementsDictionary.Add(element2.ID, element2);

            model.ConnectDataStructures();

            // Setup
            var linearSystem   = new SkylineLinearSystem(model.Forces);
            var solver         = new SolverSkyline(linearSystem);
            var provider       = new ProblemStructural(model);
            var childAnalyzer  = new LinearAnalyzer(solver);
            var parentAnalyzer = new StaticAnalyzer(provider, childAnalyzer, linearSystem);

            parentAnalyzer.BuildMatrices();
            parentAnalyzer.Initialize();
            parentAnalyzer.Solve();

            Assert.Equal(0.00053333333333333336, linearSystem.Solution[0], 10);
            Assert.Equal(0.0017294083664636196, linearSystem.Solution[1], 10);
        }
示例#7
0
 /// <summary>
 /// Creates an instance that uses a specific solver for the solution of a linear system of equations
 /// </summary>
 /// <param name="solver">Instance of the solver that will solve the linear system of equations</param>
 public LinearAnalyzer(SolverSkyline solver) => this.Solver = solver;
示例#8
0
        static void Main(string[] args)
        {
            VectorExtensions.AssignTotalAffinityCount();
            double youngModulus = 200.0e06;
            double poissonRatio = 0.3;
            double nodalLoad    = 25.0;

            // Create a new elastic 3D material
            ElasticMaterial3D material = new ElasticMaterial3D()
            {
                YoungModulus = youngModulus,
                PoissonRatio = poissonRatio,
            };

            // Node creation
            IList <Node> nodes = CreateNodes();

            // Model creation
            Model model = new Model();

            // Add a single subdomain to the model
            model.SubdomainsDictionary.Add(1, new Subdomain()
            {
                ID = 1
            });

            // Add nodes to the nodes dictonary of the model
            for (int i = 0; i < nodes.Count; ++i)
            {
                model.NodesDictionary.Add(i + 1, nodes[i]);
            }

            // Constraint bottom nodes of the model
            model.NodesDictionary[1].Constraints.Add(DOFType.X);
            model.NodesDictionary[1].Constraints.Add(DOFType.Y);
            model.NodesDictionary[1].Constraints.Add(DOFType.Z);
            model.NodesDictionary[2].Constraints.Add(DOFType.X);
            model.NodesDictionary[2].Constraints.Add(DOFType.Y);
            model.NodesDictionary[2].Constraints.Add(DOFType.Z);
            model.NodesDictionary[3].Constraints.Add(DOFType.X);
            model.NodesDictionary[3].Constraints.Add(DOFType.Y);
            model.NodesDictionary[3].Constraints.Add(DOFType.Z);
            model.NodesDictionary[4].Constraints.Add(DOFType.X);
            model.NodesDictionary[4].Constraints.Add(DOFType.Y);
            model.NodesDictionary[4].Constraints.Add(DOFType.Z);


            // Create a new Hexa8 element
            var element = new Element()
            {
                ID          = 1,
                ElementType = new Hexa8(material)
            };

            // Add nodes to the created element
            element.AddNode(model.NodesDictionary[1]);
            element.AddNode(model.NodesDictionary[2]);
            element.AddNode(model.NodesDictionary[3]);
            element.AddNode(model.NodesDictionary[4]);
            element.AddNode(model.NodesDictionary[5]);
            element.AddNode(model.NodesDictionary[6]);
            element.AddNode(model.NodesDictionary[7]);
            element.AddNode(model.NodesDictionary[8]);

            // Add Hexa element to the element and subdomains dictionary of the model
            model.ElementsDictionary.Add(element.ID, element);
            model.SubdomainsDictionary[1].ElementsDictionary.Add(element.ID, element);

            // Add nodal load values at the top nodes of the model
            model.Loads.Add(new Load()
            {
                Amount = -nodalLoad, Node = model.NodesDictionary[5], DOF = DOFType.Z
            });
            model.Loads.Add(new Load()
            {
                Amount = -nodalLoad, Node = model.NodesDictionary[6], DOF = DOFType.Z
            });
            model.Loads.Add(new Load()
            {
                Amount = -nodalLoad, Node = model.NodesDictionary[7], DOF = DOFType.Z
            });
            model.Loads.Add(new Load()
            {
                Amount = -nodalLoad, Node = model.NodesDictionary[8], DOF = DOFType.Z
            });

            // Needed in order to make all the required data structures
            model.ConnectDataStructures();

            // Choose linear equation system solver
            SolverSkyline solver = new SolverSkyline(model);

            // Choose the provider of the problem -> here a structural problem
            ProblemStructural provider = new ProblemStructural(model, solver.SubdomainsDictionary);

            // Choose parent and child analyzers -> Parent: Static, Child: Linear
            Analyzers.LinearAnalyzer childAnalyzer  = new LinearAnalyzer(solver, solver.SubdomainsDictionary);
            StaticAnalyzer           parentAnalyzer = new StaticAnalyzer(provider, childAnalyzer, solver.SubdomainsDictionary);

            // Choose dof types X, Y, Z to log for node 5
            childAnalyzer.LogFactories[1] = new LinearAnalyzerLogFactory(new int[] {
                model.NodalDOFsDictionary[5][DOFType.X],
                model.NodalDOFsDictionary[5][DOFType.Y],
                model.NodalDOFsDictionary[5][DOFType.Z]
            });

            // Analyze the problem
            parentAnalyzer.BuildMatrices();
            parentAnalyzer.Initialize();
            parentAnalyzer.Solve();

            // Write results to console
            Console.WriteLine("Writing results for node 5");
            Console.WriteLine("Dof and Values for Displacement X, Y, Z");
            Console.WriteLine(childAnalyzer.Logs[1][0]);
        }