コード例 #1
0
    void Start()
    {
        //現在表示中のシーンを判断し、タブバーに反映させる
        BarElement currentSceneElement = GetCurrentSceneElement();

        if (currentSceneElement != null)
        {
            ClearAllToggleCheck();
            currentSceneElement.toggle.isOn    = true;
            currentSceneElement.iconText.color = isOnColor;
        }
        //バー要素を押したときに実行されるイベントを登録する
        SetBarElementsEvent();
        //設定項目のお知らせアイコンを制御する
        ControllNoticeIconOnSetting();
        //デバイスとのペアリングが切れた際にアイコンの表示を更新できるように設定する
        DeviceStateManager.Instance.OnDevicePareringDisConnectEvent += ControllNoticeIconOnSetting;
        //ファームウェアの更新が必要になった場合にアイコンの表示を更新できるように設定する
        DeviceStateManager.Instance.OnFarmwareUpdateNecessaryEvent += ControllNoticeIconOnSetting;
        //ファームウェアの更新が必要なくなった場合にアイコンの表示を更新できるように設定する
        DeviceStateManager.Instance.OnFarmwareUpdateNonNecessaryEvent += ControllNoticeIconOnSetting;
    }
        public void LoadEquivalentNodalLoads_ConcentratedLod_eulerbernoullybeam_dirZ_Fy_End()
        {
            var w = 2.0;

            var l = 4.0;
            var a = l;


            var nodes = new Node[2];

            nodes[0] = (new Node(0, 0, 0)
            {
                Label = "n0"
            });
            nodes[1] = (new Node(4, 0, 0)
            {
                Label = "n1"
            });

            var elm = new BarElement(nodes[0], nodes[1])
            {
                Label = "e0"
            };

            var u1 = new Loads.ConcentratedLoad(new Force(0, -w, 0, 0, 0, 0), new IsoPoint(elm.LocalCoordsToIsoCoords(a)[0]), CoordinationSystem.Global);

            var hlpr = new ElementHelpers.EulerBernoulliBeamHelper(ElementHelpers.BeamDirection.Z, elm);

            var loads = hlpr.GetLocalEquivalentNodalLoads(elm, u1);

            var d0 = Force.Zero;
            var d1 = loads[1] - u1.Force;

            Assert.IsTrue(Math.Abs(d0.Forces.Length) < 1e-5, "invalid value");
            Assert.IsTrue(Math.Abs(d0.Moments.Length) < 1e-5, "invalid value");

            Assert.IsTrue(Math.Abs(d1.Forces.Length) < 1e-5, "invalid value");
            Assert.IsTrue(Math.Abs(d1.Moments.Length) < 1e-5, "invalid value");
        }
コード例 #3
0
        public void barelement_endrelease()
        {
            //internal force of 2 node beam beam with uniform load and both ends fixed

            var e = 210e9;

            var I = 0.01;

            var eI = e * I;
            var l  = 2.0;

            var n1 = new Node(0, 0, 0);
            var n2 = new Node(l, 0, 0);

            var e1 = new BarElement(2);

            e1.Nodes[0] = n1;
            e1.Nodes[1] = n2;

            //e1.NodalReleaseConditions[0] = Constraints.Fixed;
            //e1.NodalReleaseConditions[1] = Constraints.MovementFixed;

            e1.Material = new UniformIsotropicMaterial(e, 0.3);
            e1.Section  = new UniformParametric1DSection(0, I, I, 0);

            var hlpr = new EulerBernoulliBeamHelper(BeamDirection.Y, e1);

            var s1 = hlpr.CalcLocalStiffnessMatrix(e1);

            //var d1 = 1.0/s1[3, 3];

            var theoricalK  = 12 * eI / (l * l * l);
            var calculatedK = s1[0, 0];

            var ratio = theoricalK / calculatedK;

            Assert.IsTrue(ratio.FEquals(1, 1e-5));
        }
        public void LoadEquivalentNodalLoads_ConcentratedLod_eulerbernoullybeam_dirY_Fz_Start()
        {
            //concentrated load applies on location xi=-1, then equivalent nodal loads at start node should be same as concentrated load
            var w = 2.0;
            var a = 0;

            var nodes = new Node[2];

            nodes[0] = (new Node(0, 0, 0)
            {
                Label = "n0"
            });
            nodes[1] = (new Node(4, 0, 0)
            {
                Label = "n1"
            });

            var elm = new BarElement(nodes[0], nodes[1])
            {
                Label = "e0"
            };

            var u1 = new Loads.ConcentratedLoad(new Force(0, 0, -w, 0, 0, 0), new IsoPoint(elm.LocalCoordsToIsoCoords(a)[0]), CoordinationSystem.Global);

            var hlpr = new ElementHelpers.EulerBernoulliBeamHelper(ElementHelpers.BeamDirection.Y, elm);

            var loads = hlpr.GetLocalEquivalentNodalLoads(elm, u1);

            var d0 = loads[0] - u1.Force;
            var d1 = Force.Zero;

            Assert.IsTrue(Math.Abs(d0.Forces.Length) < 1e-5, "invalid value");
            Assert.IsTrue(Math.Abs(d0.Moments.Length) < 1e-5, "invalid value");

            Assert.IsTrue(Math.Abs(d1.Forces.Length) < 1e-5, "invalid value");
            Assert.IsTrue(Math.Abs(d1.Moments.Length) < 1e-5, "invalid value");
        }
コード例 #5
0
        static public void test0()
        {
            var model = new Model();

            var n1 = new Node()
            {
                Constraints = Constraints.Fixed
            };
            var n2 = new Node(5, 0, 0)
            {
                Constraints = Constraints.Fixed
            };

            var old = n1.Constraints;

            old.DY         = DofConstraint.Released;
            n1.Constraints = old;

            var elm = new BarElement(n1, n2);

            var sec = SectionGenerator.GetRectangularSection(0.1, 0.1);

            elm.Section  = new UniformGeometric1DSection(sec);
            elm.Material = UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.3);

            n1.Settlements.Add(new Settlement(new Displacement(0, 0, 0.01)));

            model.Nodes.Add(n1);

            model.Nodes.Add(n2);
            model.Elements.Add(elm);

            model.Solve_MPC();

            var d = n1.GetNodalDisplacement();
        }
コード例 #6
0
        public void Run2()
        {
            var m1 = new Model();

            var el1 = new BarElement();

            el1.Nodes[0] = new Node(0, 0, 0)
            {
                Constraints = Constraints.MovementFixed & Constraints.FixedRX, Label = "n0"
            };
            el1.Nodes[1] = new Node(3, 0, 4)
            {
                Constraints = Constraints.MovementFixed, Label = "n1"
            };

            el1.Section  = new Sections.UniformGeometric1DSection(SectionGenerator.GetISetion(0.24, 0.67, 0.01, 0.006));
            el1.Material = UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.3);


            var l1 = new Loads.UniformLoad();

            l1.Direction          = Vector.K;
            l1.CoordinationSystem = CoordinationSystem.Local;
            l1.Magnitude          = 1e3;


            el1.Loads.Add(l1);

            m1.Elements.Add(el1);
            m1.Nodes.Add(el1.Nodes);

            m1.Solve_MPC();

            Console.WriteLine("n0 reaction: {0}", m1.Nodes[0].GetSupportReaction());
            Console.WriteLine("n1 reaction: {0}", m1.Nodes[0].GetSupportReaction());
        }
コード例 #7
0
        public void LoadInternalForce_uniformload_eulerbernoullybeam_dirZ()
        {
            //internal force of 2 node beam beam with uniform load and both ends fixed

            var w = 2.0;

            //var model = new Model();

            var nodes = new Node[2];

            nodes[0] = (new Node(0, 0, 0)
            {
                Label = "n0"
            });
            nodes[1] = (new Node(4, 0, 0)
            {
                Label = "n1"
            });

            var elm = new BarElement(nodes[0], nodes[1])
            {
                Label = "e0"
            };


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

            var hlpr = new ElementHelpers.EulerBernoulliBeamHelper(ElementHelpers.BeamDirection.Z, elm);

            var length = (elm.Nodes[1].Location - elm.Nodes[0].Location).Length;


            foreach (var x in CalcUtil.Divide(length, 10))
            {
                var xi = elm.LocalCoordsToIsoCoords(x);

                var mi = w / 12 * (6 * length * x - 6 * x * x - length * length);
                var vi = -w * (length / 2 - x);

                var testFrc = hlpr.GetLoadInternalForceAt(elm, u1, new double[] { xi[0] * (1 - 1e-9) }).ToForce();

                var exactFrc = new Force(fx: 0, fy: vi, fz: 0, mx: 0, my: 0, mz: mi);

                var dm = Math.Abs(testFrc.Mz) - Math.Abs(exactFrc.Mz);
                var df = Math.Abs(testFrc.Fy) - Math.Abs(exactFrc.Fy);


                Assert.IsTrue(Math.Abs(dm) < 1e-5, "invalid value");
                Assert.IsTrue(Math.Abs(df) < 1e-5, "invalid value");
            }

            {
                var end1 = hlpr.GetLocalEquivalentNodalLoads(elm, u1);

                var f0 = hlpr.GetLoadInternalForceAt(elm, u1, new double[] { -1 + 1e-9 }).ToForce();;

                var sum = end1[0] - f0;

                Assert.IsTrue(Math.Abs(sum.Forces.Length) < 1e-5, "invalid value");
                Assert.IsTrue(Math.Abs(sum.Moments.Length) < 1e-5, "invalid value");
            }
        }
コード例 #8
0
        private static void Example1()
        {
            Console.WriteLine("Example 1: Simple 3D truss with four members");


            // Initiating Model, Nodes and Members
            var model = new Model();

            var n1 = new Node(1, 1, 0);

            n1.Label = "n1";//Set a unique label for node
            var n2 = new Node(-1, 1, 0)
            {
                Label = "n2"
            };                                         //using object initializer for assigning Label
            var n3 = new Node(1, -1, 0)
            {
                Label = "n3"
            };
            var n4 = new Node(-1, -1, 0)
            {
                Label = "n4"
            };
            var n5 = new Node(0, 0, 1)
            {
                Label = "n5"
            };

            var e1 = new BarElement(n1, n5)
            {
                Label = "e1", Behavior = BarElementBehaviours.Truss
            };
            var e2 = new BarElement(n2, n5)
            {
                Label = "e2", Behavior = BarElementBehaviours.Truss
            };
            var e3 = new BarElement(n3, n5)
            {
                Label = "e3", Behavior = BarElementBehaviours.Truss
            };
            var e4 = new BarElement(n4, n5)
            {
                Label = "e4", Behavior = BarElementBehaviours.Truss
            };

            //Note: labels for all members should be unique, else you will receive InvalidLabelException when adding it to model

            e1.Section = new Sections.UniformParametric1DSection()
            {
                A = 9e-4
            };
            e2.Section = new Sections.UniformParametric1DSection()
            {
                A = 9e-4
            };
            e3.Section = new Sections.UniformParametric1DSection()
            {
                A = 9e-4
            };
            e4.Section = new Sections.UniformParametric1DSection()
            {
                A = 9e-4
            };

            e1.Material = Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.3);
            e2.Material = Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.3);
            e3.Material = Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.3);
            e4.Material = Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.3);


            model.Nodes.Add(n1, n2, n3, n4, n5);
            model.Elements.Add(e1, e2, e3, e4);

            //Applying restrains


            n1.Constraints = n2.Constraints = n3.Constraints = n4.Constraints = Constraints.Fixed;
            n5.Constraints = Constraints.RotationFixed;


            //Applying load
            var force = new Force(0, 0, -1000, 0, 0, 0);

            n5.Loads.Add(new NodalLoad(force));//adds a load with LoadCase of DefaultLoadCase to node loads

            //Adds a NodalLoad with Default LoadCase

            model.Solve();

            var r1 = n1.GetSupportReaction();
            var r2 = n2.GetSupportReaction();
            var r3 = n3.GetSupportReaction();
            var r4 = n4.GetSupportReaction();

            var rt = r1 + r2 + r3 + r4;//shows the Fz=1000 and Fx=Fy=Mx=My=Mz=0.0

            Console.WriteLine("Total reactions SUM :" + rt.ToString());
        }
コード例 #9
0
        public static Model Generate3DBarElementGrid(int m, int n, int l)
        {
            var buf = new Model();

            var dx = 1.0;
            var dy = 1.0;
            var dz = 1.0;

            var nodes = new Node[m, n, l];

            for (int k = 0; k < l; k++)
            {
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < m; j++)
                    {
                        var pos = new Point(i * dx, j * dy, k * dz);
                        var nde = new Node()
                        {
                            Location = pos
                        };
                        buf.Nodes.Add(nde);
                        nodes[j, i, k] = nde;
                    }
                }
            }

            for (int k = 0; k < l - 1; k++)
            {
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < m; j++)
                    {
                        var elm = new BarElement();
                        elm.StartNode = nodes[j, i, k];
                        elm.EndNode   = nodes[j, i, k + 1];
                        buf.Elements.Add(elm);
                    }
                }
            }


            for (int i = 0; i < n - 1; i++)
            {
                for (int k = 0; k < l; k++)
                {
                    for (int j = 0; j < m; j++)
                    {
                        var elm = new BarElement();
                        elm.StartNode = nodes[j, i, k];
                        elm.EndNode   = nodes[j, i + 1, k];
                        buf.Elements.Add(elm);
                    }
                }
            }

            for (int j = 0; j < m - 1; j++)
            {
                for (int k = 0; k < l; k++)
                {
                    for (int i = 0; i < n; i++)

                    {
                        var elm = new BarElement();
                        elm.StartNode = nodes[j, i, k];
                        elm.EndNode   = nodes[j + 1, i, k];
                        buf.Elements.Add(elm);
                    }
                }
            }

            foreach (var elm in buf.Elements)
            {
                var framElm = elm as BarElement;


                if (framElm == null)
                {
                    continue;
                }

                framElm.Behavior = BarElementBehaviours.FullFrame;


                var h = RandomStuff.GetRandomNumber(0.01, 0.1);
                var w = RandomStuff.GetRandomNumber(0.01, 0.1);

                var a  = h * w;
                var iy = h * h * h * w / 12;
                var iz = w * w * w * h / 12;
                var j  = iy + iz;
                var e  = RandomStuff.GetRandomNumber(100e9, 200e9);
                var nu = RandomStuff.GetRandomNumber(0.2, 0.3);

                var sec = (Sections.UniformParametric1DSection)(framElm.Section = new Sections.UniformParametric1DSection());
                var mat = framElm.Material = Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(e, nu);

                sec.A  = a;
                sec.Iy = iy;
                sec.Iz = iz;
                sec.J  = j;
            }


            for (int i = 0; i < n * m; i++)
            {
                buf.Nodes[i].Constraints = Constraint.Fixed;
            }


            return(buf);
        }
コード例 #10
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)
        }
コード例 #11
0
        public static void Run1()
        {
            ///https://user-images.githubusercontent.com/10573467/111787314-781d7d00-88c7-11eb-869d-d8d7d40db005.png

            var model = new Model();

            //adding nodes
            model.Nodes.Add(new Node(0, 0, 0)
            {
                Label = "n0"
            });
            model.Nodes.Add(new Node(5, 0, 5)
            {
                Label = "n1"
            });

            //adding elements

            BarElement elm;

            model.Elements.Add(elm = new BarElement(model.Nodes["n0"], model.Nodes["n1"])
            {
                Label = "e0"
            });

            //assign constraint to nodes
            model.Nodes["n0"].Constraints = Constraints.MovementFixed;
            model.Nodes["n1"].Constraints = Constraints.MovementFixed;

            //define sections and material
            var secAA = new Sections.UniformGeometric1DSection(SectionGenerator.GetISetion(0.24, 0.67, 0.01, 0.006));
            var mat   = Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.3);

            //assign materials
            (model.Elements["e0"] as BarElement).Material = mat;

            //assign sections
            (model.Elements["e0"] as BarElement).Section = secAA;

            //creating loads
            var u1 = new Loads.PartialNonUniformLoad()
            {
                Direction = Vector.K, CoordinationSystem = CoordinationSystem.Local
            };

            u1.SeverityFunction = Mathh.SingleVariablePolynomial.FromPoints(-1, -6, 1, -4);
            u1.StartLocation    = new IsoPoint(-1);   //set locations of trapezoidal load
            u1.EndLocation      = new IsoPoint(1);    //set locations of trapezoidal load

            //assign loads
            model.Elements["e0"].Loads.Add(u1);

            var cse = new LoadCase("T1", LoadType.Other);

            Util.AreaLoad2ConcentratedLoads(elm, u1, cse);

            //solve model
            model.Solve_MPC(LoadCase.DefaultLoadCase, cse);

            //retrieve solve result
            var n0reaction  = model.Nodes["n0"].GetSupportReaction();
            var n0reaction2 = model.Nodes["n0"].GetSupportReaction(cse);

            var n1reaction  = model.Nodes["n1"].GetSupportReaction();
            var n1reaction2 = model.Nodes["n1"].GetSupportReaction(cse);

            Console.WriteLine("Support reaction of n0: {0}", n0reaction);
            Console.WriteLine("Support reaction of n1: {0}", n1reaction);

            var x       = 1.0;                                                             //need to find internal force at x = 1.0 m
            var iso     = (model.Elements["e0"] as BarElement).LocalCoordsToIsoCoords(x);  //find the location of 1m in iso coordination system
            var e4Force = (model.Elements["e0"] as BarElement).GetInternalForceAt(iso[0]); //find internal force

            Console.WriteLine("internal force at x={0} is {1}", x, e4Force);


            var r1 = new Force(fx: -13.33333333, fy: 0, fz: 13.333333333, mx: 0, my: 0, mz: 0);
            var r2 = new Force(fx: -11.666666666, fy: 0, fz: 11.66666666, mx: 0, my: 0, mz: 0);

            var d1 = n0reaction - r1;
            var d2 = n1reaction - r2;

            var epsilon = 1e-3;


            Debug.Assert(d1.Forces.Length < epsilon && d1.Moments.Length < epsilon);
            Debug.Assert(d2.Forces.Length < epsilon && d2.Moments.Length < epsilon);
        }
コード例 #12
0
        public void LoadInternalForce_concentratedLLoad_eulerbernoullybeam_dirY_My()
        {
            //internal force of 2 node beam beam with uniform load and both ends fixed

            var w             = 2.0;
            var forceLocation = 0.5; //[m]
            var L             = 4;   //[m]

            //var model = new Model();

            var nodes = new Node[2];

            nodes[0] = (new Node(0, 0, 0)
            {
                Label = "n0"
            });
            nodes[1] = (new Node(4, 0, 0)
            {
                Label = "n1"
            });

            var elm = new BarElement(nodes[0], nodes[1])
            {
                Label = "e0"
            };

            var u1 = new Loads.ConcentratedLoad();

            u1.Case  = LoadCase.DefaultLoadCase;
            u1.Force = new Force(0, 0, 0, 0, w, 0);
            u1.CoordinationSystem = CoordinationSystem.Global;

            u1.ForceIsoLocation = new IsoPoint(elm.LocalCoordsToIsoCoords(forceLocation)[0]);

            var hlpr = new EulerBernoulliBeamHelper(BeamDirection.Y);

            var length = (elm.Nodes[1].Location - elm.Nodes[0].Location).Length;


            foreach (var x in CalcUtil.Divide(length, 10))
            {
                var xi = elm.LocalCoordsToIsoCoords(x);

                var mi = 0.0;
                var vi = 0.0;

                {
                    //https://www.amesweb.info/Beam/Fixed-Fixed-Beam-Bending-Moment.aspx

                    var a = forceLocation;
                    var b = L - a;

                    var ma = -w / (L * L) * (L * L - 4 * a * L + 3 * a * a);

                    var mb = -w / (L * L) * (3 * a * a - 2 * a * L);

                    //var m = (y1 - y0) / (x1 - x0);



                    var ra = -6 * w * a / (L * L * L) * (L - a); //R1
                    var rb = -ra;                                //R2

                    mi = ma + ra * x + ((x > forceLocation) ? w : 0.0);

                    vi = ra;
                }


                var ends = hlpr.GetLocalEquivalentNodalLoads(elm, u1);

                var testFrc = hlpr.GetLoadInternalForceAt(elm, u1, new double[] { xi[0] * (1 - 1e-9) });

                var exactFrc = new Force(fx: 0, fy: 0, fz: vi, mx: 0, my: -mi, mz: 0);

                var dm = testFrc.FirstOrDefault(i => i.Item1 == DoF.Ry).Item2 - exactFrc.My;
                var df = testFrc.FirstOrDefault(i => i.Item1 == DoF.Dz).Item2 + exactFrc.Fz;


                Assert.IsTrue(Math.Abs(dm) < 1e-5, "invalid value");
                Assert.IsTrue(Math.Abs(df) < 1e-5, "invalid value");
            }
        }
コード例 #13
0
        public ValidationResult Validate()
        {
            var model = new Model();

            var ndes = new Node[] {
                new Node(0, 0, 0),
                new Node(1, 0, 0),
                new Node(2, 0, 0),
                new Node(3, 0, 0),
            };

            /**/
            var h = 0.1;
            var w = 0.05;

            var a  = h * w;
            var iy = h * h * h * w / 12;
            var iz = w * w * w * h / 12;
            var j  = iy + iz;
            var e  = 210e9;
            var nu = 0.3;

            var g = e / (2 * 1 + nu);
            /**/

            var sec = new Sections.UniformParametric1DSection(a, iy, iz, j);
            var mat = UniformIsotropicMaterial.CreateFromYoungShear(e, g);

            //bar-element -> rigid linkg -> bar element
            {
                var barElm = new BarElement(ndes[0], ndes[1])
                {
                    Material = mat, Section = sec, Behavior = BarElementBehaviours.FullFrame
                };
                model.Elements.Add(barElm);
            }
            {
                var rigidElm = new RigidElement_MPC();
                rigidElm.Nodes = new NodeList()
                {
                    ndes[1], ndes[2]
                };
                rigidElm.UseForAllLoads = true;
                model.MpcElements.Add(rigidElm);
            }
            {
                var barElm = new BarElement(ndes[2], ndes[3])
                {
                    Material = mat, Section = sec, Behavior = BarElementBehaviours.FullFrame
                };
                model.Elements.Add(barElm);
            }
            model.Nodes.Add(ndes);

            ndes[0].Constraints = Constraints.Fixed;

            ndes[3].Loads.Add(new NodalLoad(new Force(1000, 2000, 5000, 1000, 2000, 2000)));
            //ndes[1].Loads.Add(new NodalLoad(new Force(Vector.J * 2, Vector.Zero)));

            model.Solve_MPC();

            var span = new HtmlTag("span");

            span.Add("p").Text("Validation of rigid element");
            span.Add("paragraph").Text("The rigid element connects different nodes through non-deformable elements. ");
            span.Add("h3").Text("Model Definition");

            span.Add("paragraph").Text(string.Format(CultureInfo.CurrentCulture, "A linear beam of 3 meters long, with 4 nodes, 2 bar elements and 1 rigid element in-between.")).AddClosedTag("br");

            span.Add("paragraph").Text("The first node is fixed in the 3D space.").AddClosedTag("br");
            span.Add("paragraph").Text("The last node is loaded with a random load; both forces and moments.").AddClosedTag("br");
            span.Add("paragraph").Text("The rigid element should transfer all rotational DOF from the second node to the thrid. The displacements  along the beam will be trasnfered ass well, although the the displacements in the perpendicular direct will scale.").AddClosedTag("br");

            span.Add("h3").Text("Validation Result");
            span.Add("h4").Text("Nodal Displacements");
            span.Add("paragraph").Text(string.Format("Validation output for nodal displacements:"));


            var n1   = model.Nodes[1].GetNodalDisplacement();
            var n2   = model.Nodes[2].GetNodalDisplacement();
            var diff = n1 - n2;

            //linear beam with loads -> rigid elements introduces rigid body -> Y and Z (translations perpendicular to the beam) are non zero and scaled. Set to zero to avoid confusion with result.
            diff.DY = diff.DZ = 0.0;

            //span.Add("p").AddClass("bg-info").Text(string.Format("-Max ABSOLUTE Error: {0:e3}", diff));//htmltags cannot encode the delta and teta chars so will use vector length
            span.Add("p").AddClass("bg-info")
            .Text(string.Format("-Max ABSOLUTE Error: Displacement:{0:e3} , Rotation:{1:e3}",
                                diff.Displacements.Length, diff.Rotations.Length));

            var buf = new ValidationResult();

            buf.Span  = span;
            buf.Title = "Rigid element Validation";

            return(buf);
        }
コード例 #14
0
        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);
        }
        public void LoadEquivalentNodalLoads_ConcentratedLod_eulerbernoullybeam_dirZ_Fy()
        {
            //internal force of 2 node beam beam with uniform load and both ends fixed


            //     ^y                       w
            //     |                        ||
            //     |                        \/
            //      ====================================== --> x
            //    /
            //   /z

            var w = 2.0;
            var a = 2;

            var nodes = new Node[2];

            nodes[0] = (new Node(0, 0, 0)
            {
                Label = "n0"
            });
            nodes[1] = (new Node(4, 0, 0)
            {
                Label = "n1"
            });

            var elm = new BarElement(nodes[0], nodes[1])
            {
                Label = "e0"
            };

            var u1 = new Loads.ConcentratedLoad(new Force(0, -w, 0, 0, 0, 0), new IsoPoint(elm.LocalCoordsToIsoCoords(a)[0]), CoordinationSystem.Global);

            var hlpr = new ElementHelpers.EulerBernoulliBeamHelper(ElementHelpers.BeamDirection.Z, elm);

            var loads = hlpr.GetLocalEquivalentNodalLoads(elm, u1);

            var L = (elm.Nodes[1].Location - elm.Nodes[0].Location).Length;

            var b = L - a;


            var ma = w * a * b * b / (L * L);
            var mb = w * a * a * b / (L * L);

            var ra = w * (3 * a + b) * b * b / (L * L * L); //1f
            var rb = w * (a + 3 * b) * a * a / (L * L * L); //1g

            var expectedF0 = new Force(0, -ra, 0, 0, 0, -ma);
            var expectedF1 = new Force(0, -rb, 0, 0, 0, mb);

            /*
             * var m1 = -w * L * L / 12;
             * var m2 = w * L * L / 12;
             *
             * var v1 = -w * L / 2;
             * var v2 = -w * L / 2;
             */

            var d0 = loads[0] - expectedF0;
            var d1 = loads[1] - expectedF1;

            Assert.IsTrue(Math.Abs(d0.Forces.Length) < 1e-5, "invalid value");
            Assert.IsTrue(Math.Abs(d0.Moments.Length) < 1e-5, "invalid value");

            Assert.IsTrue(Math.Abs(d1.Forces.Length) < 1e-5, "invalid value");
            Assert.IsTrue(Math.Abs(d1.Moments.Length) < 1e-5, "invalid value");
        }
        public void LoadEquivalentNodalLoads_ConcentratedLod_eulerbernoullybeam_dirZ_Mz()
        {
            //internal force of 2 node beam beam with uniform load and both ends fixed
            //https://www.amesweb.info/Beam/Fixed-Fixed-Beam-Bending-Moment.aspx

            //                               ^
            //     ^m                     m0 ^
            //     |  /z                     |
            //     | /                       |
            //      ====================================== --> x
            //

            var w = 2.0;
            var a = 1.234560;

            var nodes = new Node[2];

            nodes[0] = (new Node(0, 0, 0)
            {
                Label = "n0"
            });
            nodes[1] = (new Node(4, 0, 0)
            {
                Label = "n1"
            });

            var elm = new BarElement(nodes[0], nodes[1])
            {
                Label = "e0"
            };

            var u1 = new Loads.ConcentratedLoad(new Force(0, 0, 0, 0, 0, w), new IsoPoint(elm.LocalCoordsToIsoCoords(a)[0]), CoordinationSystem.Global);

            var hlpr = new ElementHelpers.EulerBernoulliBeamHelper(ElementHelpers.BeamDirection.Z, elm);

            var loads = hlpr.GetLocalEquivalentNodalLoads(elm, u1);

            var L = (elm.Nodes[1].Location - elm.Nodes[0].Location).Length;

            var b = L - a;

            var ma = -w / (L * L) * (L * L - 4 * a * L + 3 * a * a);
            var mb = w / (L * L) * (3 * a * a - 2 * a * L);

            var ra = 6 * w * a / (L * L * L) * (L - a);  //R1
            var rb = -6 * w * a / (L * L * L) * (L - a); //R1


            var expectedR1 = new Force(0, ra, 0, 0, 0, ma);  //expected reaction 1
            var expectedR2 = new Force(0, rb, 0, 0, 0, -mb); //expected reaction 2



            /*
             * var m1 = -w * L * L / 12;
             * var m2 = w * L * L / 12;
             *
             * var v1 = -w * L / 2;
             * var v2 = -w * L / 2;
             */

            var d0 = loads[0] + expectedR1;
            var d1 = loads[1] + expectedR2;

            Assert.IsTrue(Math.Abs(d0.Forces.Length) < 1e-5, "invalid value");
            Assert.IsTrue(Math.Abs(d0.Moments.Length) < 1e-5, "invalid value");

            Assert.IsTrue(Math.Abs(d1.Forces.Length) < 1e-5, "invalid value");
            Assert.IsTrue(Math.Abs(d1.Moments.Length) < 1e-5, "invalid value");
        }
        public void LoadInternalForce_concentratedLLoad_Shaft_Mx()
        {
            //internal force of 2 node truss with concentrated load and both ends fixed

            var w             = 2.0;
            var forceLocation = 0.5; //[m]
            var L             = 4;   //[m]

            //var model = new Model();

            var nodes = new Node[2];

            nodes[0] = (new Node(0, 0, 0)
            {
                Label = "n0"
            });
            nodes[1] = (new Node(4, 0, 0)
            {
                Label = "n1"
            });

            var elm = new BarElement(nodes[0], nodes[1])
            {
                Label = "e0"
            };

            var u1 = new Loads.ConcentratedLoad();

            u1.Case  = LoadCase.DefaultLoadCase;
            u1.Force = new Force(0, 0, 0, w, 0, 0);
            u1.CoordinationSystem = CoordinationSystem.Global;

            u1.ForceIsoLocation = new IsoPoint(elm.LocalCoordsToIsoCoords(forceLocation)[0]);

            var hlpr = new ShaftHelper(elm);

            var length = (elm.Nodes[1].Location - elm.Nodes[0].Location).Length;


            foreach (var x in CalcUtil.Divide(length, 10))
            {
                var xi = elm.LocalCoordsToIsoCoords(x);

                var mi = 0.0;
                var vi = 0.0;

                {
                    var a = forceLocation;
                    var b = L - a;

                    var ra = (1 - (a / L)) * w;

                    var rb = (1 - (b / L)) * w;

                    mi = ra + ((x > forceLocation) ? -w : 0.0);
                }


                var ends = hlpr.GetLocalEquivalentNodalLoads(elm, u1);

                var testFrc = hlpr.GetLoadInternalForceAt(elm, u1, new double[] { xi[0] * (1 - 1e-9) }).ToForce();

                var exactFrc = new Force(fx: 0, fy: 0, fz: vi, mx: -mi, my: 0, mz: 0);

                var df = Math.Abs(testFrc.Mx) - Math.Abs(exactFrc.Mx);


                Assert.IsTrue(Math.Abs(df) < 1e-5, "invalid value");
            }

            {
                var end1 = hlpr.GetLocalEquivalentNodalLoads(elm, u1);

                var f0 = hlpr.GetLoadInternalForceAt(elm, u1, new double[] { -1 + 1e-9 }).ToForce();;

                var sum = end1[0] + f0;

                Assert.IsTrue(Math.Abs(sum.Forces.Length) < 1e-5, "invalid value");
                Assert.IsTrue(Math.Abs(sum.Moments.Length) < 1e-5, "invalid value");
            }
        }
コード例 #18
0
        public static Model CreateModel(Matrix <double> coords, Matrix <double> occupancy, int xSize, int ySize, int zSize)
        {
            // Initiating Model, Nodes and Members
            var model = new Model();

            var nodes       = new Dictionary <int, Node>();
            var nodeIndices = new List <int>();

            //if occupied add node to model
            for (int i = 0; i < coords.RowCount; i++)
            {
                if (occupancy[i, 0] == 1.0)
                {
                    nodes[i] = new Node(coords[i, 0], coords[i, 1], coords[i, 2]);
                    nodeIndices.Add(i);
                }
            }

            //for node in nodes, connect to neighbours

            int groundLevel = 0;         // nodeIndices.Select(i => i / (xSize * ySize)).Min();
            int topLevel    = zSize - 1; // nodeIndices.Select(i => i / (xSize * ySize)).Max();
            //int topNode = nodeIndices.Max();
            var b = nodeIndices.Where(value => (value / (xSize * ySize) == 5)).Count();

            int topNode;

            try
            {
                topNode = nodeIndices.Where(value => (value / (xSize * ySize) == topLevel)).Max(); //this line fails if can't find something on top row.
            }
            catch
            {
                return(null);
            }

            int fixedCount = 0;

            var sec = new BriefFiniteElementNet.Sections.UniformParametric1DSection(a: 0.1, iy: 0.1, iz: 0.1);
            var mat = BriefFiniteElementNet.Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.3);

            var elements = new ConcurrentBag <Element>();

            Parallel.For(0, nodeIndices.Count, i =>
            {
                var index = nodeIndices[i];

                int x = (index % (xSize * ySize)) % xSize;
                int y = (index % (xSize * ySize)) / xSize; //integer division
                int z = index / (xSize * ySize);           //integer division

                var xNeigh = index + 1;
                var yNeigh = index + xSize;
                var zNeigh = index + xSize * ySize;

                //lock nodes on the ground floor
                if (z == groundLevel)
                {
                    nodes[index].Constraints = Constraint.Fixed;
                    fixedCount++;
                }

                if (x < xSize - 1 & nodeIndices.Contains(xNeigh))
                {
                    var xBar = new BarElement(nodes[index], nodes[xNeigh])
                    {
                        Label = index.ToString() + ":" + xNeigh.ToString()
                    };
                    xBar.Material = mat;
                    xBar.Section  = sec;
                    elements.Add(xBar);
                }

                if (y < ySize - 1 & nodeIndices.Contains(yNeigh))
                {
                    var yBar = new BarElement(nodes[index], nodes[yNeigh])
                    {
                        Label = index.ToString() + ":" + yNeigh.ToString()
                    };
                    yBar.Material = mat;
                    yBar.Section  = sec;
                    elements.Add(yBar);
                }

                if (z < zSize - 1 & nodeIndices.Contains(zNeigh))
                {
                    var zBar = new BarElement(nodes[index], nodes[zNeigh])
                    {
                        Label = index.ToString() + ":" + zNeigh.ToString()
                    };
                    zBar.Material = mat;
                    zBar.Section  = sec;
                    elements.Add(zBar);
                }
            });


            model.Nodes.AddRange(nodes.Values);
            model.Elements.Add(elements.ToArray());

            //Applying load
            var force = new Force(0, -5000, -0, 0, 0, 0);

            nodes[topNode].Loads.Add(new NodalLoad(force));//adds a load with LoadCase of DefaultLoadCase to node loads

            model.Solve();

            return(model);
        }
コード例 #19
0
        public void LoadInternalForce_concentratedLLoad_truss_Fx()
        {
            //internal force of 2 node truss with concentrated load and both ends fixed

            var w             = 2.0;
            var forceLocation = 0.5; //[m]
            var L             = 4;   //[m]

            //var model = new Model();

            var nodes = new Node[2];

            nodes[0] = (new Node(0, 0, 0)
            {
                Label = "n0"
            });
            nodes[1] = (new Node(4, 0, 0)
            {
                Label = "n1"
            });

            var elm = new BarElement(nodes[0], nodes[1])
            {
                Label = "e0"
            };

            var u1 = new Loads.ConcentratedLoad();

            u1.Case  = LoadCase.DefaultLoadCase;
            u1.Force = new Force(w, 0, 0, 0, 0, 0);
            u1.CoordinationSystem = CoordinationSystem.Global;

            u1.ForceIsoLocation = new IsoPoint(elm.LocalCoordsToIsoCoords(forceLocation)[0]);

            var hlpr = new TrussHelper();

            var length = (elm.Nodes[1].Location - elm.Nodes[0].Location).Length;


            foreach (var x in CalcUtil.Divide(length, 10))
            {
                var xi = elm.LocalCoordsToIsoCoords(x);

                var mi = 0.0;
                var vi = 0.0;

                {
                    //https://www.amesweb.info/Beam/Fixed-Fixed-Beam-Bending-Moment.aspx

                    var a = forceLocation;
                    var b = L - a;

                    var ra = (1 - (a / L)) * w;

                    var rb = (1 - (b / L)) * w;

                    mi = ra + ((x > forceLocation) ? -w : 0.0);
                }


                var ends = hlpr.GetLocalEquivalentNodalLoads(elm, u1);

                var testFrc = hlpr.GetLoadInternalForceAt(elm, u1, new double[] { xi[0] * (1 - 1e-9) });

                var exactFrc = new Force(fx: -mi, fy: 0, fz: vi, mx: 0, my: 0, mz: 0);

                var df = testFrc.FirstOrDefault(i => i.Item1 == DoF.Dx).Item2 + exactFrc.Fx;


                Assert.IsTrue(Math.Abs(df) < 1e-5, "invalid value");
            }
        }
コード例 #20
0
ファイル: BarElementTester.cs プロジェクト: vulf3d/BFE.Net
        public static void TestEndreleaseInternalForce()
        {
            /**/
            var m1 = new Model();



            var I = (0.1 * 0.1 * 0.1 * 0.1) / 12;
            var A = (0.1 * 0.1 * 0.1);
            var E = 210e9;

            var sec = new Sections.UniformParametric1DSection(A, I, I, I);
            var mat = new Materials.UniformIsotropicMaterial(E, 0.3);
            var p   = 1e3;

            /**/
            //var p0 = new Point(0, 0, 0);
            //var p1 = new Point(3, 4, 5);

            var l = 4.0;

            {//model 1
                var el1 = new BarElement(3);

                el1.Nodes[0] = new Node(0, 0, 0)
                {
                    Constraints = Constraints.Fixed & Constraints.FixedRX, Label = "n0"
                };;
                el1.Nodes[1] = new Node(l, 0, 0)
                {
                    Label = "n1"
                };
                el1.Nodes[2] = new Node(2 * l, 0, 0)
                {
                    Constraints = Constraints.Released, Label = "n2"
                };

                el1.Section  = sec;
                el1.Material = mat;

                m1.Nodes.Add(el1.Nodes);
                m1.Elements.Add(el1);
                m1.Nodes[1].Loads.Add(new NodalLoad(new Force(0, 0, p, 0, 0, 0)));

                var ep = 1e-10;

                m1.Solve_MPC();

                var frc = el1.GetInternalForceAt(1 - ep);

                var fnc = new Func <double, double>(i => el1.GetInternalDisplacementAt(i).DZ);

                Controls.FunctionVisualizer.VisualizeInNewWindow(fnc, -1 + ep, 1 - ep);

                var s2 = m1.Nodes["n2"].GetSupportReaction();
                var s0 = m1.Nodes["n0"].GetSupportReaction();

                var k = (el1 as BarElement).GetLocalStifnessMatrix();
            }



            //m1.Solve_MPC();
            // m2.Solve_MPC();

            // var d1 = m1.Nodes.Last().GetNodalDisplacement();
            // var d2 = m2.Nodes.Last().GetNodalDisplacement();
        }
コード例 #21
0
        public static void ValidateConsoleUniformLoad()
        {
            var model = new Model();

            var ndes = new Node[] {
                new Node(0, 0, 0),
                new Node(3, 0, 0)
            };

            /**/
            var h = 0.1;
            var w = 0.05;

            var a  = h * w;
            var iy = h * h * h * w / 12;
            var iz = w * w * w * h / 12;
            var j  = iy + iz;
            var e  = 210e9;
            var nu = 0.3;

            var g = e / (2 * 1 + nu);
            /**/

            var sec = new Sections.UniformParametric1DSection(a, iy, iz, j);
            var mat = UniformIsotropicMaterial.CreateFromYoungShear(e, g);

            BarElement        belm;
            FrameElement2Node frmelm;

            belm = new BarElement(ndes[0], ndes[1])
            {
                Material = mat, Section = sec, Behavior = BarElementBehaviours.FullFrame
            };
            frmelm = new FrameElement2Node(ndes[0], ndes[1])
            {
                Iz = sec.Iz, Iy = sec.Iy, A = sec.A, J = sec.J, E = e, G = g
            };

            var bk   = belm.GetGlobalStifnessMatrix();
            var fk   = frmelm.GetGlobalStifnessMatrix();
            var diff = bk - fk;

            model.Elements.Add(belm);

            model.Nodes.Add(ndes);

            ndes[0].Constraints = Constraints.Fixed;

            //ndes[1].Constraints =
            //    Constraints.FixedDX & Constraints.FixedRX
            //& Constraints.FixedDY & Constraints.FixedRZ//find beam.z dofs

            ;
            var ul = new Loads.UniformLoad(LoadCase.DefaultLoadCase, Vector.K, 1000, CoordinationSystem.Global);

            (model.Elements[0] as BarElement).Loads.Add(ul);


            var eqv = (model.Elements[0] as BarElement).GetGlobalEquivalentNodalLoads(ul);

            //ndes[1].Loads.Add(new NodalLoad(new Force(Vector.K, Vector.Zero)));
            //ndes[1].Loads.Add(new NodalLoad(new Force(Vector.J*2, Vector.Zero)));

            model.Solve_MPC();


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

            var t = (model.Elements[0] as BarElement).GetInternalForceAt(-1);


            var res = OpenseesValidator.OpenseesValidate(model, LoadCase.DefaultLoadCase, false);

            var disp = res[0];

            var idx = disp.Columns["Absolute Error"].Ordinal;

            var max = disp.Rows.Cast <DataRow>().Select(i => (double)i[idx]).Max();
        }
コード例 #22
0
ファイル: BarElementTester.cs プロジェクト: vulf3d/BFE.Net
        public static void TestEndrelease()
        {
            var m1 = new Model();
            var m2 = new Model();

            var l = 4.0;

            var I = (0.1 * 0.1 * 0.1 * 0.1) / 12;
            var A = (0.1 * 0.1 * 0.1);
            var E = 210e9;

            var sec = new Sections.UniformParametric1DSection(A, I, I, I);
            var mat = new Materials.UniformIsotropicMaterial(E, 0.3);
            var p   = 1e3;


            //var p0 = new Point(0, 0, 0);
            //var p1 = new Point(3, 4, 5);


            {//model 1
                var el1 = new BarElement(2);
                var el2 = new BarElement(2);

                el1.Nodes[0] = new Node(0, 0, 0)
                {
                    Constraints = Constraints.Fixed, Label = "n0"
                };;
                el2.Nodes[0] = el1.Nodes[1] = new Node(l / 2, 0, 0)
                {
                    Label = "n1"
                };
                el2.Nodes[1] = new Node(l, 0, 0)
                {
                    Label = "n2"
                };

                el1.Section  = el2.Section = sec;
                el1.Material = el2.Material = mat;

                m1.Nodes.Add(el1.Nodes);
                m1.Nodes.Add(el2.Nodes[1]);

                m1.Elements.Add(el1, el2);

                m1.Nodes["n1"].Loads.Add(new NodalLoad(new Force(0, 0, p, 0, 0, 0)));

                var k = (el1 as BarElement).GetLocalStifnessMatrix();
            }

            {//model 2
                var el2 = new BarElement(3);

                el2.Nodes[0] = new Node(0, 0, 0)
                {
                    Constraints = Constraints.Fixed, Label = "n0"
                };
                el2.Nodes[1] = new Node(l / 2, 0, 0)
                {
                    Label = "n1"
                };
                el2.Nodes[2] = new Node(l, 0, 0)
                {
                    Constraints = Constraints.Fixed, Label = "n2"
                };

                el2.NodalReleaseConditions[2] = Constraints.Released;

                el2.Section  = sec;
                el2.Material = mat;

                m2.Nodes.Add(el2.Nodes);
                m2.Elements.Add(el2);

                m2.Nodes["n1"].Loads.Add(new NodalLoad(new Force(0, 0, p, 0, 0, 0)));

                var k = (el2 as BarElement).GetLocalStifnessMatrix();
            }

            m1.Solve_MPC();
            m2.Solve_MPC();

            var d1 = m1.Nodes["n1"].GetNodalDisplacement();
            var d2 = m2.Nodes["n1"].GetNodalDisplacement();
        }
        public void LoadInternalForce_concentratedLLoad_eulerbernoullybeam_dirZ_fy()
        {
            //internal force of 2 node beam beam with uniform load and both ends fixed

            var w             = 2.0;
            var forceLocation = 0.5; //[m]
            var L             = 4;   //[m]

            //var model = new Model();

            var nodes = new Node[2];

            nodes[0] = (new Node(0, 0, 0)
            {
                Label = "n0"
            });
            nodes[1] = (new Node(4, 0, 0)
            {
                Label = "n1"
            });

            var elm = new BarElement(nodes[0], nodes[1])
            {
                Label = "e0"
            };

            var u1 = new Loads.ConcentratedLoad();

            u1.Case  = LoadCase.DefaultLoadCase;
            u1.Force = new Force(0, -w, 0, 0, 0, 0);
            u1.CoordinationSystem = CoordinationSystem.Global;

            u1.ForceIsoLocation = new IsoPoint(elm.LocalCoordsToIsoCoords(forceLocation)[0]);

            var hlpr = new EulerBernoulliBeamHelper(BeamDirection.Z, elm);

            var length = (elm.Nodes[1].Location - elm.Nodes[0].Location).Length;


            foreach (var x in CalcUtil.Divide(length, 10))
            {
                var xi = elm.LocalCoordsToIsoCoords(x);


                //https://www.engineeringtoolbox.com/beams-fixed-both-ends-support-loads-deflection-d_809.html

                var mi = 0.0;
                var vi = 0.0;

                {
                    var a = forceLocation;
                    var b = L - a;

                    var ma = -w * a * b * b / (L * L);
                    var mb = -w * a * a * b / (L * L);
                    var mf = 2 * w * a * a * b * b / (L * L * L);

                    double x0, x1, y0, y1;

                    if (x < forceLocation)
                    {
                        x0 = 0;
                        x1 = forceLocation;

                        y0 = ma;
                        y1 = mf;
                    }
                    else
                    {
                        x0 = forceLocation;
                        x1 = L;

                        y0 = mf;
                        y1 = mb;
                    }


                    var m = (y1 - y0) / (x1 - x0);

                    mi = m * (x - x0) + y0;

                    var ra = w * (3 * a + b) * b * b / (L * L * L); //1f
                    var rb = w * (a + 3 * b) * a * a / (L * L * L); //1g

                    if (x < forceLocation)
                    {
                        vi = ra;
                    }
                    else
                    {
                        vi = -rb;
                    }
                }


                var ends = hlpr.GetLocalEquivalentNodalLoads(elm, u1);

                var testFrc = hlpr.GetLoadInternalForceAt(elm, u1, new double[] { xi[0] * (1 - 1e-9) }).ToForce();

                var exactFrc = new Force(fx: 0, fy: vi, fz: 0, mx: 0, my: 0, mz: +mi);

                var dm = Math.Abs(testFrc.Mz) - Math.Abs(exactFrc.Mz);
                var df = Math.Abs(testFrc.Fy) - Math.Abs(exactFrc.Fy);


                Assert.IsTrue(Math.Abs(dm) < 1e-5, "invalid value");
                Assert.IsTrue(Math.Abs(df) < 1e-5, "invalid value");
            }

            {
                var end1 = hlpr.GetLocalEquivalentNodalLoads(elm, u1);

                var f0 = hlpr.GetLoadInternalForceAt(elm, u1, new double[] { -1 + 1e-9 }).ToForce();;

                var sum = end1[0] + f0;

                Assert.IsTrue(Math.Abs(sum.Forces.Length) < 1e-5, "invalid value");
                Assert.IsTrue(Math.Abs(sum.Moments.Length) < 1e-5, "invalid value");
            }
        }
コード例 #24
0
        public static void Run1()
        {
            double h = 5;

            Node n1 = new Node(0, 0, 0);
            Node n2 = new Node(h, 0, 0);

            n1.Constraints = Constraints.Fixed;

            var section  = new UniformGeometric1DSection(SectionGenerator.GetRectangularSection(1, 0.5));
            var material = UniformIsotropicMaterial.CreateFromYoungShear(205e9, 81e9);

            BarElement e = new BarElement(n1, n2)
            {
                Section  = section,
                Material = material
            };

            e.Behavior = BarElementBehaviours.FullFrame;

            var lc1 = new LoadCase("C1", LoadType.Dead);
            var lc2 = new LoadCase("C2", LoadType.Live);
            var lc3 = new LoadCase("C3", LoadType.Live);

            var load = new UniformLoad()
            {
                Direction          = Vector.FromXYZ(0, 0, -1),
                CoordinationSystem = CoordinationSystem.Global,
                Magnitude          = 1,
                Case = lc1
            };
            var load2 = new UniformLoad()
            {
                Direction          = Vector.FromXYZ(1, 0, 0),
                CoordinationSystem = CoordinationSystem.Global,
                Magnitude          = 10,
                Case = lc2
            };

            var load3 = new ConcentratedLoad()
            {
                Force              = new Force(10, 10, 10, 10, 0, 0),
                ForceIsoLocation   = new IsoPoint(0.50),
                CoordinationSystem = CoordinationSystem.Local,
                Case = lc3
            };


            e.Loads.Add(load);
            e.Loads.Add(load2);
            e.Loads.Add(load3);

            Model model = new Model();

            model.Nodes.Add(n1);
            model.Nodes.Add(n2);
            model.Elements.Add(e);
            model.Solve_MPC();

            BarInternalForceVisualizer.VisualizeInNewWindow(e);
        }
コード例 #25
0
        private static void TestBar()
        {
            var iy = 0.03;
            var iz = 0.02;
            var a  = 0.01;
            var j  = iy + iz;

            var e   = 7;
            var g   = 11;
            var rho = 13;

            var model = new Model();

            model.Nodes.Add(new Node(0, 0, 0));
            model.Nodes.Add(new Node(1, 0, 0));

            var barElement = new BarElement(model.Nodes[0], model.Nodes[1]);

            barElement.Behavior = BarElementBehaviours.FullFrame;

            var frameElement = new FrameElement2Node(model.Nodes[0], model.Nodes[1])
            {
                Iy          = iy,
                Iz          = iz,
                A           = a,
                J           = j,
                E           = e,
                G           = g,
                MassDensity = rho
            };


            //barElement.Material = new UniformBarMaterial(e, g, rho);
            barElement.Section = new UniformParametric1DSection()
            {
                Iy = iy, Iz = iz, A = a
            };

            frameElement.MassFormulationType = MassFormulation.Consistent;

            //barElement.EndConnection = BarElementEndConnection.TotallyHinged;
            //barElement.StartConnection = BarElementEndConnection.TotallyHinged;

            frameElement.HingedAtStart = true;
            //frameElement.HingedAtEnd = true;


            var frameM = frameElement.GetLocalStiffnessMatrix();
            //MathUtil.FillLowerTriangleFromUpperTriangle(frameM);

            var barM = barElement.GetLocalStifnessMatrix();

            var t = 1;                      //- 1e-10;

            var d    = (frameM - t * barM); //
            var dMax = d.CoreArray.Max(i => Math.Abs(i));

            model.Nodes[0].Constraints = Constraint.Fixed;

            model.Solve();
        }
        public void LoadInternalForce_concentratedLLoad_eulerbernoullybeam_dirY_My()
        {
            //internal force of 2 node beam beam with uniform load and both ends fixed

            var w             = 2.0;
            var forceLocation = 2.123; //[m]
            var L             = 4;     //[m]

            //var model = new Model();

            var nodes = new Node[2];

            nodes[0] = (new Node(0, 0, 0)
            {
                Label = "n0"
            });
            nodes[1] = (new Node(4, 0, 0)
            {
                Label = "n1"
            });

            var elm = new BarElement(nodes[0], nodes[1])
            {
                Label = "e0"
            };

            var u1 = new Loads.ConcentratedLoad();

            u1.Case  = LoadCase.DefaultLoadCase;
            u1.Force = new Force(0, 0, 0, 0, w, 0);
            u1.CoordinationSystem = CoordinationSystem.Global;

            u1.ForceIsoLocation = new IsoPoint(elm.LocalCoordsToIsoCoords(forceLocation)[0]);

            var hlpr = new EulerBernoulliBeamHelper(BeamDirection.Y, elm);

            var length = (elm.Nodes[1].Location - elm.Nodes[0].Location).Length;


            //foreach (var x in CalcUtil.Divide(length, 10))
            {
                var x = 2.4;

                var xi = elm.LocalCoordsToIsoCoords(x);

                var mi = 0.0;
                var vi = 0.0;

                {
                    //https://www.amesweb.info/Beam/Fixed-Fixed-Beam-Bending-Moment.aspx

                    var a = forceLocation;
                    var b = L - a;

                    var ma = w / (L * L) * (L * L - 4 * a * L + 3 * a * a);
                    var mb = w / (L * L) * (3 * a * a - 2 * a * L);

                    var ra = -6 * w * a / (L * L * L) * (L - a); //R1
                    var rb = 6 * w * a / (L * L * L) * (L - a);  //R1


                    mi = ma + ra * x - ((x > forceLocation) ? w : 0.0);

                    vi = ra;
                }


                var ends = hlpr.GetLocalEquivalentNodalLoads(elm, u1);

                var testFrc = hlpr.GetLoadInternalForceAt(elm, u1, new double[] { xi[0] * (1 - 1e-9) }).ToForce();

                var exactFrc = new Force(fx: 0, fy: 0, fz: vi, mx: 0, my: -mi, mz: 0);


                var dm = Math.Abs(testFrc.My) - Math.Abs(exactFrc.My); //regarding value
                var df = Math.Abs(testFrc.Fz) - Math.Abs(exactFrc.Fz); //regarding value


                Assert.IsTrue(Math.Abs(dm) < 1e-5, "invalid value");
                Assert.IsTrue(Math.Abs(df) < 1e-5, "invalid value");
            }

            {
                var end1 = hlpr.GetLocalEquivalentNodalLoads(elm, u1);

                var f0 = hlpr.GetLoadInternalForceAt(elm, u1, new double[] { -1 + 1e-9 }).ToForce();;

                var sum = end1[0] + f0;

                Assert.IsTrue(Math.Abs(sum.Forces.Length) < 1e-5, "invalid value");  //regarding sign
                Assert.IsTrue(Math.Abs(sum.Moments.Length) < 1e-5, "invalid value"); //regarding sign
            }
        }
コード例 #27
0
ファイル: BarElementTester.cs プロジェクト: vulf3d/BFE.Net
        public static void Test3NodeBeam()
        {
            var m1 = new Model();
            var m2 = new Model();

            var l = 2.0;

            var I = 1; //(0.1 * 0.1 * 0.1 * 0.1) / 12;
            var A = 1; //(0.1 * 0.1 * 0.1);
            var E = 1; //210e9;

            var sec = new Sections.UniformParametric1DSection(A, I, I, I);
            var mat = new Materials.UniformIsotropicMaterial(E, 0.3);
            var p   = 1e3;


            //var p0 = new Point(0, 0, 0);
            //var p1 = new Point(3, 4, 5);


            {//model 1
                var el1 = new BarElement(3);

                //el1.Behavior= BarElementBehaviour.BeamZEulerBernoulli;
                el1.Nodes[0] = new Node(0, 0, 0)
                {
                    Constraints = Constraints.Fixed
                };;
                el1.Nodes[1] = new Node(l / 2, 0, 0)
                {
                    Constraints = Constraints.Released
                };
                el1.Nodes[2] = new Node(l, 0, 0)
                {
                    Constraints = Constraints.Released
                };

                el1.Section  = sec;
                el1.Material = mat;

                m1.Nodes.Add(el1.Nodes);
                m1.Elements.Add(el1);
                m1.Nodes.Last().Loads.Add(new NodalLoad(new Force(0, 0, p, 0, 0, 0)));

                var k = (el1 as BarElement).GetLocalStifnessMatrix();
            }


            {//model 2
                var el1 = new BarElement(3);

                //el1.Behavior= BarElementBehaviour.BeamZEulerBernoulli;
                el1.Nodes[0] = new Node(0, 0, 0)
                {
                    Constraints = Constraints.Fixed
                };;
                el1.Nodes[1] = new Node(l / 2, 0, 0)
                {
                    Constraints = Constraints.Released
                };
                el1.Nodes[2] = new Node(l, 0, 0)
                {
                    Constraints = Constraints.Released
                };

                el1.Section  = sec;
                el1.Material = mat;

                m1.Nodes.Add(el1.Nodes);
                m1.Elements.Add(el1);
                m1.Nodes.Last().Loads.Add(new NodalLoad(new Force(0, 0, p, 0, 0, 0)));

                var k = (el1 as BarElement).GetLocalStifnessMatrix();
            }


            m1.Solve_MPC();

            var d1 = m1.Nodes.First().GetSupportReaction();
            //var d2 = m2.Nodes.Last().GetNodalDisplacement();
        }
コード例 #28
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();
        }
コード例 #29
0
ファイル: BarElementTester.cs プロジェクト: vulf3d/BFE.Net
        public static void ValidateEndRelease()
        {
            var model = new Model();

            var ndes = new Node[] {
                new Node(0, 0, 0),
                new Node(3, 0, 0),
                new Node(6, 0, 0),
            };

            /**/
            var h = 0.1;
            var w = 0.05;

            var a  = h * w;
            var iy = h * h * h * w / 12;
            var iz = w * w * w * h / 12;
            var j  = iy + iz;
            var e  = 210e9;
            var nu = 0.3;

            var g = e / (2 * 1 + nu);
            /**/

            var sec = new Sections.UniformParametric1DSection(a, iy, iz, j);
            var mat = UniformIsotropicMaterial.CreateFromYoungShear(e, g);

            {
                var belm = new BarElement(ndes[0], ndes[1])
                {
                    Material = mat, Section = sec, Behavior = BarElementBehaviours.FullFrame
                };

                belm.StartReleaseCondition =
                    Constraints.FixedDX & Constraints.FixedDY & Constraints.FixedDZ &
                    Constraints.FixedRX;

                model.Elements.Add(belm);
            }
            {
                var belm = new BarElement(ndes[1], ndes[2])
                {
                    Material = mat, Section = sec, Behavior = BarElementBehaviours.FullFrame
                };

                belm.EndReleaseCondition =
                    Constraints.FixedDX & Constraints.FixedDY & Constraints.FixedDZ &
                    Constraints.FixedRX;

                model.Elements.Add(belm);
            }


            model.Nodes.Add(ndes);

            ndes[0].Constraints = ndes[2].Constraints = Constraints.Fixed;

            //ndes[1].Constraints =
            //    Constraints.FixedDX & Constraints.FixedRX
            //& Constraints.FixedDY & Constraints.FixedRZ//find beam.z dofs

            ;
            //(model.Elements[0] as BarElement).Loads.Add(new Loads.UniformLoad(LoadCase.DefaultLoadCase, Vector.K, 1000, CoordinationSystem.Local));

            ndes[1].Loads.Add(new NodalLoad(new Force(Vector.K, Vector.Zero)));
            //ndes[1].Loads.Add(new NodalLoad(new Force(Vector.J * 2, Vector.Zero)));

            model.Solve_MPC();


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


            var t = (model.Elements[0] as BarElement).GetInternalForceAt(1);


            var res = OpenseesValidator.OpenseesValidate(model, LoadCase.DefaultLoadCase, false);

            var disp = res[0];

            var idx = disp.Columns["Absolute Error"].Ordinal;

            var max = disp.Rows.Cast <DataRow>().Select(i => (double)i[idx]).Max();
        }
コード例 #30
0
        public static Model Generate3DBarElementGrid(int m, int n, int l)
        {
            var buf = new Model();

            var dx = 1.0;
            var dy = 1.0;
            var dz = 1.0;

            var nodes = new Node[m, n, l];

            for (int k = 0; k < l; k++)
            {
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < m; j++)
                    {
                        var pos = new Point(i * dx, j * dy, k * dz);
                        var nde = new Node()
                        {
                            Location = pos
                        };
                        buf.Nodes.Add(nde);
                        nodes[j, i, k] = nde;
                    }
                }
            }

            for (int k = 0; k < l - 1; k++)
            {
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < m; j++)
                    {
                        var elm = new BarElement();
                        elm.StartNode = nodes[j, i, k];
                        elm.EndNode   = nodes[j, i, k + 1];
                        buf.Elements.Add(elm);
                    }
                }
            }


            for (int i = 0; i < n - 1; i++)
            {
                for (int k = 0; k < l; k++)
                {
                    for (int j = 0; j < m; j++)
                    {
                        var elm = new BarElement();
                        elm.StartNode = nodes[j, i, k];
                        elm.EndNode   = nodes[j, i + 1, k];
                        buf.Elements.Add(elm);
                    }
                }
            }

            for (int j = 0; j < m - 1; j++)
            {
                for (int k = 0; k < l; k++)
                {
                    for (int i = 0; i < n; i++)

                    {
                        var elm = new BarElement();
                        elm.StartNode = nodes[j, i, k];
                        elm.EndNode   = nodes[j + 1, i, k];
                        buf.Elements.Add(elm);
                    }
                }
            }

            foreach (var elm in buf.Elements)
            {
                var framElm = elm as BarElement;


                if (framElm == null)
                {
                    continue;
                }

                framElm.Behavior = BarElementBehaviours.FullFrame;

                var sec = (Sections.UniformParametric1DSection)(framElm.Section = new Sections.UniformParametric1DSection());
                var mat = framElm.Material = Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.2);

                sec.A  = 7.64 * 1e-4;                // 0.01;
                sec.Iy = sec.Iz = sec.J = 80 * 1e-8; // 0.1 * 0.1 * 0.1 * 0.1 / 12.0;
            }


            for (int i = 0; i < n * m; i++)
            {
                buf.Nodes[i].Constraints = Constraint.Fixed;
            }


            return(buf);
        }