Esempio n. 1
0
        //[TestMethod]
        public void LoadInternalForce_trapezoidload_eulerbernoullybeam_dirY()
        {
            //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.(LoadCase.DefaultLoadCase, -Vector.K, w, CoordinationSystem.Global);
                new Loads.PartialNonUniformLoad();


            u1.CoordinationSystem = CoordinationSystem.Global;
            u1.Direction          = -Vector.K;

            // u1.StartLocation = new double[] { };
            // u1.EndLocation = new double[] { };

            //u1.StartMagnitude

            var hlpr = new ElementHelpers.EulerBernoulliBeamHelper(ElementHelpers.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 = 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) });

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

                var d = testFrc.FirstOrDefault(i => i.Item1 == DoF.Ry).Item2 + exactFrc.My;

                Assert.IsTrue(d < 1e-5, "invalid value");
            }
        }
Esempio n. 2
0
        public void LoadInternalForce_uniformload_eulerbernoullybeam_endrelease()
        {
            //load internal force of beam with hinged ends should match the end releases
            //if hinged then moment should be zero and so on
            //added for issue#48


            var w = 2.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.UniformLoad(LoadCase.DefaultLoadCase, -Vector.K, w, CoordinationSystem.Global);

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

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

            elm.NodalReleaseConditions[0] = Constraints.MovementFixed;
            elm.NodalReleaseConditions[1] = Constraints.MovementFixed & Constraints.FixedRX;

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

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

                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 d = testFrc - exactFrc;

                var dm = d.My;
                var df = d.Fz;

                Assert.IsTrue(dm.FEquals(0, 1e-5), "invalid value");
                Assert.IsTrue(df.FEquals(0, 1e-5), "invalid value");
            }
        }
        public static void Run()
        {
            var model = new Model();

            var l = 5.0;

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

            var elm = new BarElement();

            elm.Material = Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.25);
            elm.Section  = new Sections.UniformGeometric1DSection(SectionGenerator.GetRectangularSection(0.05, 0.05));

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

            // elm.EndReleaseCondition = Constraints.RotationFixed;

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

            //var load2 = new Loads.ConcentratedLoad();// LoadCase.DefaultLoadCase, Vector.K, -100, CoordinationSystem.Global);
            //l/oad2.Force = new Force(0, 100, 100, 0, 0, 0);
            //load2.ForceIsoLocation = new IsoPoint(0.5, 0, 0);

            elm.Loads.Add(load);

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

            model.Solve_MPC();

            var fnc = new Func <double, double>(x =>
            {
                try
                {
                    var xi  = elm.LocalCoordsToIsoCoords(x);
                    var frc = elm.GetExactInternalForceAt(xi[0]);
                    return(frc.Fz);
                }
                catch
                {
                    return(0);
                }
            });

            Controls.FunctionVisualizer.VisualizeInNewWindow(fnc, 1E-6, l - 1E-6, 500);
        }
Esempio n. 4
0
        public static void TestFixedInternalForce2()
        {
            //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);

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

            hlpr.GetLoadInternalForceAt(elm, u1, new double[] { -0.5774 });

            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) });

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

                var d = testFrc.FirstOrDefault(i => i.Item1 == DoF.Rz).Item2 + exactFrc.Mz;

                if (Math.Abs(d) > 1e-5)
                {
                }
            }
        }
Esempio n. 5
0
        public void LoadInternalForce_uniformload_truss()
        {
            //internal force of 2 node beam beam with uniform load and both ends fixed

            var w = 2.0;

            var nodes = new Node[2];

            var l = 4;

            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.I, w, CoordinationSystem.Global);

            var hlpr = new ElementHelpers.TrussHelper(elm);


            for (var x = 0.0 + 1e-6; x <= l - 1e-6; x += 0.1)
            {
                var local = x;
                var iso   = elm.LocalCoordsToIsoCoords(x);

                var test = hlpr.GetLoadInternalForceAt(elm, u1, iso).FirstOrDefault(i => i.Item1 == DoF.Dx).Item2;


                var exact = (w * l - x * l) / 2.0;

                Assert.IsTrue(test.FEquals(exact, 1e-5), "invalid value");
            }
        }
Esempio n. 6
0
        public void LoadEquivalentNodalLoads_ConcentratedLod_eulerbernoullybeam_dirY_My_End()
        {
            var l = 4.0;
            var w = 2.0;
            var a = l;

            var nodes = new Node[2];

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

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

            var f = new Force(0, 0, 0, 0, w, 0);

            var loc = new IsoPoint(elm.LocalCoordsToIsoCoords(a)[0]);

            var u1 = new Loads.ConcentratedLoad(f, loc, CoordinationSystem.Global);

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

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

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


            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");
        }
Esempio n. 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");
            }
        }
        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
            }
        }
        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");
        }
        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");
            }
        }
        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");
            }
        }
        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");
            }
        }
        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");
            }
        }
        public void eulerbernoullybeam_dirZ()
        {
            var w = 2.0;
            var a = 4;

            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 L = (elm.Nodes[1].Location - elm.Nodes[0].Location).Length;

            var b = L - a;

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

            for (var i = 0.0; i <= 1; i += 0.01)
            {
                var x = i * L;

                var iso = elm.LocalCoordsToIsoCoords(x);

                var n = hlpr.GetNMatrixAt(elm, iso);

                var n1 = n[0, 0];
                var m1 = n[0, 1];
                var n2 = n[0, 2];
                var m2 = n[0, 3];

                var n1p = n[1, 0];
                var m1p = n[1, 1];
                var n2p = n[1, 2];
                var m2p = n[1, 3];


                var xi = iso[0];

                var n1e = 0.25 * (2 - 3 * xi + xi * xi * xi);
                var m1e = 0.125 * L * (1 - xi - xi * xi + xi * xi * xi);
                var n2e = 0.25 * (2 + 3 * xi - xi * xi * xi);
                var m2e = 0.125 * L * (-1 - xi + xi * xi + xi * xi * xi);

                var epsilon = 1e-5;

                Assert.IsTrue(Math.Abs(n1 - n1e) < epsilon, "invalid value");
                Assert.IsTrue(Math.Abs(n2 - n2e) < epsilon, "invalid value");
                Assert.IsTrue(Math.Abs(m1 - m1e) < epsilon, "invalid value");
                Assert.IsTrue(Math.Abs(m2 - m2e) < epsilon, "invalid value");
            }
        }