Exemplo n.º 1
0
        private static void TestTrussShapeFunction()
        {
            var bar = new BarElement(3);

            bar.Nodes[0] = new Node(0, 0, 0);
            bar.Nodes[1] = new Node(1, 0, 0);
            bar.Nodes[2] = new Node(2, 0, 0);

            bar.Material = UniformIsotropicMaterial.CreateFromYoungPoisson(3, 0.3);
            bar.Section  = new Sections.UniformParametric1DSection(4);

            var hlp = new TrussHelper(bar);

            var pl = hlp.GetN_i(bar, 0);

            hlp.GetJMatrixAt(bar, 0);
            var stf = hlp.CalcLocalStiffnessMatrix(bar);
        }
        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(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;

                {
                    //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");
            }

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