public static void SimplySupportedBeamUDL()
        {
            var model = new BriefFiniteElementNet.Model();

            var pin = new Constraint(
                dx: DofConstraint.Fixed, dy: DofConstraint.Fixed, dz: DofConstraint.Fixed,
                rx: DofConstraint.Fixed, ry: DofConstraint.Released, rz: DofConstraint.Released);

            Node n1, n2;

            model.Nodes.Add(n1 = new Node(x: 0.0, y: 0.0, z: 0.0)
            {
                Constraints = pin
            });
            model.Nodes.Add(n2 = new Node(x: 10.0, y: 0.0, z: 0.0)
            {
                Constraints = pin
            });

            var elm1 = new BarElement(n1, n2);

            model.Elements.Add(elm1);

            double       height   = 0.200;
            double       width    = 0.050;
            double       E        = 7900;
            var          section  = new UniformGeometric1DSection(SectionGenerator.GetRectangularSection(height, width));
            BaseMaterial material = UniformIsotropicMaterial.CreateFromYoungPoisson(E, 1);

            elm1.Section  = section;
            elm1.Material = material;

            var u1 = new Loads.UniformLoad(LoadCase.DefaultLoadCase, new Vector(0, 1, 1), -1, CoordinationSystem.Global);

            elm1.Loads.Add(u1);

            model.Solve_MPC();

            double x;
            Force  reaction1 = n1.GetSupportReaction();

            x = reaction1.Fz;                                             //15000 = 3*10000/2 -> correct
            x = reaction1.My;                                             // 0 -> correct

            Force f1_internal = elm1.GetExactInternalForceAt(-1 + 1e-10); //-1 is start

            x = f1_internal.Fz;
            x = f1_internal.My;

            var delta = elm1.GetInternalDisplacementAt(0);
        }
        static void TestIssue22()
        {
            var model = new BriefFiniteElementNet.Model();

            var n1 = new Node(-1, 0, 0)
            {
                Label = "n1", Constraints = BriefFiniteElementNet.Constraints.MovementFixed & BriefFiniteElementNet.Constraints.FixedRX
            };

            var n2 = new Node(1, 0, 0)
            {
                Label = "n2", Constraints = BriefFiniteElementNet.Constraints.MovementFixed
            };

            var loadPositionX = 0.5;

            var e1 = new BarElement(n1, n2)
            {
                Label = "e1"
            };

            e1.Section  = new BriefFiniteElementNet.Sections.UniformGeometric1DSection(SectionGenerator.GetRectangularSection(0.1d, 0.2d));
            e1.Material = BriefFiniteElementNet.Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.3);
            model.Nodes.Add(n1, n2);
            model.Elements.Add(e1);

            var force       = new Force(0, 1, 1, 0, 0, 0);
            var elementLoad = new BriefFiniteElementNet.Loads.ConcentratedLoad
            {
                CoordinationSystem = CoordinationSystem.Global,
                Force            = force,
                ForceIsoLocation = new IsoPoint(loadPositionX)
            };

            e1.Loads.Add(elementLoad);
            model.Solve();

            var eqv = e1.GetGlobalEquivalentNodalLoads(elementLoad);

            var data =
                e1.GetExactInternalForceAt(-0.99999999999);
            //e1.GetInternalForceAt(-0.99999999999);


            var func = new Func <double, double>(xi => e1.GetExactInternalForceAt(xi).My);



            FunctionVisualizer.VisualizeInNewWindow(func, -1 + 1e-10, 1 - 1e-10, 100);
        }
        public static void SingleSpanBeamWithOverhang()
        {
            var model = new BriefFiniteElementNet.Model();

            var pin = new Constraint(dx: DofConstraint.Fixed, dy: DofConstraint.Fixed, dz: DofConstraint.Fixed, rx: DofConstraint.Fixed, ry: DofConstraint.Fixed, rz: DofConstraint.Released);

            Node n1, n2;

            model.Nodes.Add(n1 = new Node(x: 0.0, y: 0.0, z: 0.0)
            {
                Constraints = pin
            });
            model.Nodes.Add(n2 = new Node(x: 10.0, y: 0.0, z: 0.0)
            {
                Constraints = pin
            });

            var elm1 = new BarElement(n1, n2);

            model.Elements.Add(elm1);

            elm1.Section  = new BriefFiniteElementNet.Sections.UniformParametric1DSection(a: 0.01, iy: 8.3e-6, iz: 8.3e-6, j: 16.6e-6); //section's second area moments Iy and Iz = 8.3*10^-6, area = 0.01
            elm1.Material = BriefFiniteElementNet.Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.3);                //Elastic mudule is 210e9 and poisson ratio is 0.3

            var frc = new Force();

            frc.Fz = 1000;// 1kN force in Z direction

            var elementLoad = new BriefFiniteElementNet.Loads.ConcentratedLoad();

            elementLoad.CoordinationSystem = CoordinationSystem.Local;
            elementLoad.Force            = frc;
            elementLoad.ForceIsoLocation = new IsoPoint(0);

            //frc, 5, CoordinationSystem.Local);
            elm1.Loads.Add(elementLoad); //is this possible?

            model.Solve_MPC();           //crashes here


            var val = elm1.GetExactInternalForceAt(-0.25);

            var d2 = n2.GetNodalDisplacement();
        }
        static public void test1()
        {
            // Two span beam of 20m overall length with elements of 1m length

            List <Node>       nodeList    = new List <Node>();
            List <BarElement> elementList = new List <BarElement>();

            var model = new BriefFiniteElementNet.Model();

            for (double n = 0; n <= 20; n = n + 1)
            {
                nodeList.Add(new Node(x: n, y: 0.0, z: 0.0)
                {
                    Label = "N" + n
                });
            }

            nodeList[0].Constraints  = Constraints.MovementFixed & Constraints.FixedRX;
            nodeList[10].Constraints = Constraints.FixedDZ & Constraints.FixedDY;                 // z = vertical
            nodeList[nodeList.Count - 1].Constraints = Constraints.FixedDZ & Constraints.FixedDY; // z = vertical

            model.Nodes.AddRange(nodeList);

            model.Nodes[10].Settlements.Add(new Settlement(LoadCase.DefaultLoadCase, new Displacement(0, 0, -0.0000000000010, 0, 0, 0)));             // This does not seem to be working correctly based on the reported displacement at Node 10

            var load1 = new BriefFiniteElementNet.Loads.UniformLoad(LoadCase.DefaultLoadCase, new Vector(0, 0, 1), -6000, CoordinationSystem.Global); // Load in N/m

            var a     = 0.1;                                                                                                                          // m²
            var iy    = 0.008333;                                                                                                                     // m4
            var iz    = 8.333e-5;                                                                                                                     // m4
            var j     = 0.1 * 0.1 * 0.1 * 1 / 12.0;                                                                                                   // m4
            var e     = 205e9;                                                                                                                        // N/m²
            var nu    = 0.3;                                                                                                                          // Poisson's ratio
            var secAA = new BriefFiniteElementNet.Sections.UniformParametric1DSection(a, iy, iz, j);

            var mat = BriefFiniteElementNet.Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(e, nu);

            for (int m = 0; m <= 19; m++)
            {
                BarElement el = new BarElement(nodeList[m], nodeList[m + 1]);
                el.Section  = secAA;
                el.Material = mat;
                el.Loads.Add(load1);
                elementList.Add(el);
            }

            model.Elements.Add(elementList.ToArray());

            model.Solve_MPC();//or model.Solve();

            model.Trace.Listeners.Add(new ConsoleTraceListener());

            PosdefChecker.CheckModel_mpc(model, LoadCase.DefaultLoadCase);


            var nde  = nodeList[10];
            var disp = nde.GetNodalDisplacement();

            Console.WriteLine("Node 10 displacement in Z direction is {0:0.000} m", disp.DZ);
            Console.WriteLine("Node 10 rotation in YY direction is {0:0.000} rads\n", disp.RY);

            foreach (BarElement elem in elementList)
            {
                Force f1 = elem.GetExactInternalForceAt(-0.999999);  // -1 = start, 0 = mid, 1 = end, exact solver takes UDL on member into account, doesn't then accept -1 or 1
                Console.WriteLine("Element BMyy is {0:0.000} kNm", f1.My / 1000);
            }


            var str = new MemoryStream();

            Model.Save(str, model);

            str.Position = 0;
            var m2 = Model.Load(str);

            Console.WriteLine("Element BMyy is {0:0.000} kNm", elementList[19].GetExactInternalForceAt(0.999999).My / 1000);
        }
Beispiel #5
0
        static public void Run3()
        {
            // 2 x 20m spans with elements of 1m length
            // Test of running model with 4 loadcases - 2 with vertical loads and 2 with settlements
            // It can be seen that results for loadCase3 are only correct if it uses the DefaultLoadCase

            List <Node>       nodeList    = new List <Node>();
            List <BarElement> elementList = new List <BarElement>();

            var model = new BriefFiniteElementNet.Model();

            for (double n = 0; n <= 40; n = n + 1)
            {
                nodeList.Add(new Node(x: n, y: 0.0, z: 0.0)
                {
                    Label = "N" + n
                });
            }

            nodeList[0].Constraints  = Constraints.MovementFixed & Constraints.FixedRX;           // Constraints.FixedDX & Constraints.FixedDY & Constraints.FixedDZ & Constraints.FixedRY & Constraints.FixedRZ;
            nodeList[20].Constraints = Constraints.FixedDZ & Constraints.FixedDY;                 // z = vertical
            nodeList[nodeList.Count - 1].Constraints = Constraints.FixedDZ & Constraints.FixedDY; // z = vertical

            model.Nodes.AddRange(nodeList);

            model.Trace.Listeners.Add(new ConsoleTraceListener());

            List <LoadCase> loadCases = new List <LoadCase>();

            LoadCase loadCase1 = new LoadCase("L1", LoadType.Dead);
            LoadCase loadCase2 = new LoadCase("L2", LoadType.Dead);
            LoadCase loadCase3 = new LoadCase("L3", LoadType.Other);  // using LoadCase.DefaultLoadCase gives correct loadCase3 results
            LoadCase loadCase4 = new LoadCase("L4", LoadType.Other);

            loadCases.Add(loadCase1);
            loadCases.Add(loadCase2);
            loadCases.Add(loadCase3);
            loadCases.Add(loadCase4);

            var load1 = new BriefFiniteElementNet.Loads.UniformLoad(loadCase1, new Vector(0, 0, 1), -6000, CoordinationSystem.Global); // Load in N/m
            var load2 = new BriefFiniteElementNet.Loads.UniformLoad(loadCase2, new Vector(0, 0, 1), -6000, CoordinationSystem.Global); // Load in N/m

            var a     = 0.1;                                                                                                           // m²
            var iy    = 0.008333;                                                                                                      // m4
            var iz    = 8.333e-5;                                                                                                      // m4
            var j     = 0.1 * 0.1 * 0.1 * 1 / 12.0;                                                                                    // m4
            var e     = 205e9;                                                                                                         // N/m²
            var nu    = 0.3;                                                                                                           // Poisson's ratio
            var secAA = new BriefFiniteElementNet.Sections.UniformParametric1DSection(a, iy, iz, j);

            var mat = BriefFiniteElementNet.Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(e, nu);

            for (int m = 0; m < 40; m++)
            {
                BarElement el = new BarElement(nodeList[m], nodeList[m + 1]);
                el.Section  = secAA;
                el.Material = mat;
                el.Loads.Add(load1);
                el.Loads.Add(load2);
                elementList.Add(el);
            }

            model.Elements.Add(elementList.ToArray());

            model.Nodes[20].Settlements.Add(new Settlement(loadCase3, new Displacement(0, 0, -0.010, 0, 0, 0)));  // -10mm settlement
            model.Nodes[20].Settlements.Add(new Settlement(loadCase4, new Displacement(0, 0, -0.010, 0, 0, 0)));  // +10mm settlement

            foreach (LoadCase loadCase in loadCases)
            {
                model.Solve_MPC(loadCase);
            }

            //model.Solve_MPC(loadCase1,loadCase2,loadCase3,loadCase4);

            BarElement elem = (BarElement)model.Elements[9];

            for (int load = 0; load < loadCases.Count; load++)
            {
                //BarElement elem = (BarElement)model.Elements[9];
                // For settlement loadcases GetExactInternalForce does not return the correct results

                Force f = (load < 2) ?
                          elem.GetExactInternalForceAt(+0.999999, loadCases[load]) :
                          elem.GetInternalForceAt(+0.999999, loadCases[load]);

                Console.WriteLine("Element 10 BMyy is {0:0.000} kNm at end", f.My / 1000);
            }

            var d = model.Nodes[20].GetNodalDisplacement(loadCase3);


            var c1 = elem.GetInternalForceAt(+0.999999, loadCase3);
            var c2 = elem.GetInternalForceAt(+0.999999, loadCase4);

            // Results: Element 10 BMyy is -149.500 kNm at end (correct)
            //          Element 10 BMyy is -149.500 kNm at end (correct)
            //          Element 10 BMyy is 0.000 kNm at end (incorrect, should be -64.060)
            //          Element 10 BMyy is 64.060 kNm at end (correct)
        }
Beispiel #6
0
        public static void Run()
        {
            // Two span beam of 20m overall length with elements of 1m length
            // Vertical 'springs' are used at supports

            List <Node>       nodeList    = new List <Node>();
            List <BarElement> elementList = new List <BarElement>();
            LoadCase          loadCase1   = new LoadCase("test", LoadType.Other);// LoadCase.DefaultLoadCase;  // new LoadCase("L1", LoadType.Dead);

            var model = new BriefFiniteElementNet.Model();

            for (double n = 0; n <= 20; n = n + 1)
            {
                nodeList.Add(new Node(x: n, y: 0.0, z: 0.0)
                {
                    Label = "N" + n
                });
            }

            nodeList.Add(new Node(x: 0, y: 0.0, z: -2.0)
            {
                Label = "N21"
            });
            nodeList.Add(new Node(x: 10, y: 0.0, z: -2.0)
            {
                Label = "N22"
            });
            nodeList.Add(new Node(x: 20, y: 0.0, z: -2.0)
            {
                Label = "N23"
            });

            //var load1 = new BriefFiniteElementNet.Loads.UniformLoad(loadCase1, new Vector(0, 0, 1), 0, CoordinationSystem.Global);  // Load in N/m (UDL = 0 N/m)

            var a  = 0.1;                           // m²
            var iy = 0.008333
            ;                                       // m4
            var iz    = 8.333e-5;                   // m4
            var j     = 0.1 * 0.1 * 0.1 * 1 / 12.0; // m4
            var e     = 205e9;                      // N/m²
            var nu    = 0.3;                        // Poisson's ratio
            var secAA = new BriefFiniteElementNet.Sections.UniformParametric1DSection(a, iy, iz, j);

            var mat = BriefFiniteElementNet.Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(e, nu);

            for (int m = 0; m <= 19; m++)
            {
                BarElement el = new BarElement(nodeList[m], nodeList[m + 1]);
                el.Section  = secAA;
                el.Material = mat;
                //el.Loads.Add(load1);
                elementList.Add(el);
            }


            BarElement el2 = new BarElement(nodeList[0], nodeList[21]); el2.Section = secAA; el2.Material = mat; elementList.Add(el2);
            BarElement el3 = new BarElement(nodeList[10], nodeList[22]); el3.Section = secAA; el3.Material = mat; elementList.Add(el3);
            BarElement el4 = new BarElement(nodeList[20], nodeList[23]); el4.Section = secAA; el4.Material = mat; elementList.Add(el4);

            nodeList[21].Constraints = Constraints.MovementFixed & Constraints.FixedRX;                       // Constraints.FixedDX & Constraints.FixedDY & Constraints.FixedDZ & Constraints.FixedRY & Constraints.FixedRZ;
            nodeList[22].Constraints = Constraints.FixedDZ & Constraints.FixedDY & Constraints.FixedRX;       // z = vertical
            nodeList[23].Constraints = Constraints.FixedDZ & Constraints.FixedDY & Constraints.FixedRX;       // z = vertical

            nodeList[22].Settlements.Add(new Settlement(loadCase1, new Displacement(0, 0, -0.010, 0, 0, 0))); // -10mm settlement

            model.Elements.Add(elementList.ToArray());
            model.Nodes.AddRange(nodeList);

            model.Solve_MPC(loadCase1);//or model.Solve();


            var disp = nodeList[10].GetNodalDisplacement(loadCase1);

            Console.WriteLine("Node 10 displacement in Z direction is {0:0.000} m", disp.DZ);
            Console.WriteLine("Node 10 rotation in YY direction is {0:0.000} rads\n", disp.RY);

            foreach (BarElement elem in elementList)
            {
                Force f1 = elem.GetExactInternalForceAt(-0.999999, loadCase1);  // -1 = start, 0 = mid, 1 = end, exact solver takes UDL on member into account, doesn't then accept -1 or 1
                Console.WriteLine("Element BMyy is {0:0.000} kNm at start,    SFz is {1:0.000} kN at start", f1.My / 1000, f1.Fz / 1000);
                Force f2 = elem.GetExactInternalForceAt(0.999999, loadCase1);
                Console.WriteLine("Element BMyy is {0:0.000} kNm at end,    SFz is {1:0.000} kN at start", f2.My / 1000, f2.Fz / 1000);
            }

            Console.WriteLine("Node 21 vertical reaction {0:0.000} kN", model.Nodes[21].GetSupportReaction(loadCase1).Fz / 1000);  // gives      51.171 kN  CORRECT
            Console.WriteLine("Node 22 vertical reaction {0:0.000} kN", model.Nodes[22].GetSupportReaction(loadCase1).Fz / 1000);  // gives  102397.658 kN  INCORRECT   (EXPECT -102.342 kN)
            Console.WriteLine("Node 23 vertical reaction {0:0.000} kN", model.Nodes[23].GetSupportReaction(loadCase1).Fz / 1000);  // gives      51.171 kN  CORRECT


            Console.ReadKey();
        }
        public static void Test3()
        {
            var model = new BriefFiniteElementNet.Model();

            var p  = new Point[20];
            var ns = new Node[20];


            p[0]  = new Point(x: 0, y: 1, z: 0);
            p[1]  = new Point(x: 0, y: 0, z: 0);
            p[2]  = new Point(x: 0.20, y: 0, z: 0);
            p[3]  = new Point(x: 0.20, y: 0, z: 0.20);
            p[4]  = new Point(x: 0.20, y: 1, z: 0);
            p[5]  = new Point(x: 0.20, y: 1, z: 0.20);
            p[6]  = new Point(x: 0, y: 1, z: 0.20);
            p[7]  = new Point(x: 0, y: 0, z: 0.20);
            p[8]  = new Point(x: 0, y: 0.50, z: 0);
            p[9]  = new Point(x: 0.20, y: 0.50, z: 0);
            p[10] = new Point(x: 0, y: 0.50, z: 0.20);
            p[11] = new Point(x: 0.20, y: 0.50, z: 0.20);
            p[12] = new Point(x: 0.20, y: 0.25, z: 0.20);
            p[13] = new Point(x: 0, y: 0.25, z: 0.20);
            p[14] = new Point(x: 0, y: 0.25, z: 0);
            p[15] = new Point(x: 0.20, y: 0.25, z: 0);
            p[16] = new Point(x: 0.20, y: 0.75, z: 0.20);
            p[17] = new Point(x: 0.20, y: 0.75, z: 0);
            p[18] = new Point(x: 0, y: 0.75, z: 0);
            p[19] = new Point(x: 0, y: 0.75, z: 0.20);

            for (var i = 0; i < 20; i++)
            {
                model.Nodes.Add(ns[i] = new Node(p[i]));
                ns[i].Label           = "n" + i.ToString(CultureInfo.CurrentCulture);
                ns[i].Constraints     = Constraints.RotationFixed;
            }



            var mesh = new int[24][];

            mesh[0]  = new int[] { 0, 4, 16, 17 };
            mesh[1]  = new int[] { 8, 15, 12, 14 };
            mesh[2]  = new int[] { 8, 16, 17, 18 };
            mesh[3]  = new int[] { 10, 8, 11, 12 };
            mesh[4]  = new int[] { 5, 19, 0, 16 };
            mesh[5]  = new int[] { 1, 15, 14, 12 };
            mesh[6]  = new int[] { 8, 10, 11, 16 };
            mesh[7]  = new int[] { 3, 13, 1, 7 };
            mesh[8]  = new int[] { 3, 13, 12, 1 };
            mesh[9]  = new int[] { 8, 12, 13, 14 };
            mesh[10] = new int[] { 1, 15, 12, 2 };
            mesh[11] = new int[] { 9, 8, 11, 16 };
            mesh[12] = new int[] { 10, 8, 12, 13 };
            mesh[13] = new int[] { 5, 0, 4, 16 };
            mesh[14] = new int[] { 5, 19, 6, 0 };
            mesh[15] = new int[] { 8, 19, 16, 18 };
            mesh[16] = new int[] { 8, 19, 10, 16 };
            mesh[17] = new int[] { 0, 19, 18, 16 };
            mesh[18] = new int[] { 1, 3, 2, 12 };
            mesh[19] = new int[] { 8, 15, 9, 12 };
            mesh[20] = new int[] { 13, 12, 1, 14 };
            mesh[21] = new int[] { 8, 9, 11, 12 };
            mesh[22] = new int[] { 9, 8, 16, 17 };
            mesh[23] = new int[] { 16, 0, 17, 18 };

            foreach (var elm in mesh)
            {
                var felm = new Tetrahedral();

                felm.Nodes[0] = ns[elm[0]];
                felm.Nodes[1] = ns[elm[1]];
                felm.Nodes[2] = ns[elm[2]];
                felm.Nodes[3] = ns[elm[3]];

                felm.E  = 210e9;
                felm.Nu = 0.33;
                model.Elements.Add(felm);
            }


            var relm = new BriefFiniteElementNet.MpcElements.RigidElement_MPC();

            relm.Nodes = new NodeList()
            {
                ns[0], ns[4], ns[5], ns[6]
            };
            relm.UseForAllLoads = true;
            //model.MpcElements.Add(relm);

            ns[1].Constraints = ns[2].Constraints = ns[3].Constraints = ns[7].Constraints = Constraints.Fixed;



            var load = new BriefFiniteElementNet.NodalLoad();
            var frc  = new Force();

            frc.Fz     = 1000;// 1kN force in Z direction
            load.Force = frc;

            ns[5].Loads.Add(load);
            ns[6].Loads.Add(load);

            model.Solve_MPC();

            var d5 = ns[5].GetNodalDisplacement();
            var d6 = ns[6].GetNodalDisplacement();

            Console.WriteLine("Nodal displacement in Z direction is {0} meters (thus {1} mm)", d5.DZ, d5.DZ * 1000);
            Console.WriteLine("Nodal displacement in Z direction is {0} meters (thus {1} mm)", d6.DZ, d6.DZ * 1000);

            var tetra  = model.Elements[0] as Tetrahedral;
            var stress = tetra.GetInternalForce(LoadCombination.DefaultLoadCombination);
        }