Beispiel #1
0
        public static void ValidateOneSpanUniformLoad()
        {
            var model = new Model();

            var ndes = new Node[] {
                new Node(0, 0, 0),
                new Node(1, 0, 0),
                //new Node(2, 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 sec = new Sections.UniformParametric1DSection(a, iy, iz, j);
            var mat = UniformIsotropicMaterial.CreateFromYoungPoisson(e, 0.25);

            BarElement e1;

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

            e1.StartReleaseCondition =
                //e1.EndReleaseCondition =
                Constraints.MovementFixed;

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

            var eqload = e1.GetGlobalEquivalentNodalLoads(ld);


            model.Nodes.Add(ndes);

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

            //for (var i = 0; i < model.Elements.Count; i++)
            //    (model.Elements[i] as BarElement).Loads.Add();

            //ndes[1].Loads.Add(new NodalLoad(new Force(0, 1, 0, 0, 0, 0)));



            model.Solve_MPC();

            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();
        }
        public static void Test1()
        {
            var model = new Model();

            Node n1, n2;

            model.Nodes.Add(n1 = new Node(0, 0, 0)
            {
                Constraints = Constraints.Fixed
            });
            model.Nodes.Add(n2 = new Node(1, 0, 0)
            {
                Constraints = Constraints.Fixed
            });

            var elm = new BarElement(n1, n2);

            elm.Section  = new BriefFiniteElementNet.Sections.UniformParametric1DSection(a: 0.01, iy: 0.01, iz: 0.01, j: 0.01);
            elm.Material = BriefFiniteElementNet.Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.3);

            var load = new Loads.UniformLoad();

            load.Case = LoadCase.DefaultLoadCase;
            load.CoordinationSystem = CoordinationSystem.Global;
            load.Direction          = Vector.K;
            load.Magnitude          = 10;

            elm.Loads.Add(load);
            model.Elements.Add(elm);

            model.Solve_MPC();

            var f1 = elm.GetInternalForceAt(0);
            var f2 = elm.GetExactInternalForceAt(0);
        }
Beispiel #3
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");
            }
        }
Beispiel #4
0
        public static ValidationResult TestFixedEndMoment_uniformLoad()
        {
            var buff = new ValidationResult();

            buff.Title = "Test #1 for UniformLoad on BarElement";
            buff.Span.Add("p").Text("endforce from uniformload should be statically in equiblirium with uniform load");


            var elm = new BarElement(new Node(0, 0, 0), new Node(8.66, 0, 5));

            elm.Behavior = BarElementBehaviours.FullFrame;

            var ld = new Loads.UniformLoad();

            ld.Magnitude          = 1;//*Math.Sqrt(2);
            ld.Direction          = Vector.K;
            ld.CoordinationSystem = CoordinationSystem.Global;
            elm.Loads.Add(ld);

            var loads = elm.GetGlobalEquivalentNodalLoads(ld);

            {//test 1 : static balance
                var l = (elm.Nodes[1].Location - elm.Nodes[0].Location);

                var totEndForces = new Force();

                for (int i = 0; i < loads.Length; i++)
                {
                    totEndForces += loads[i].Move(elm.Nodes[i].Location, elm.Nodes[0].Location);
                }

                var d = l / 2;

                var gDir = ld.Direction;

                if (ld.CoordinationSystem == CoordinationSystem.Local)
                {
                    gDir = elm.GetTransformationManager().TransformLocalToGlobal(ld.Direction);
                }

                var cos = (1 / (d.Length * gDir.Length)) * Vector.Dot(d, gDir);

                var f_mid = gDir * ld.Magnitude * (l.Length);//uniform load as concentrated load at middle
                var m     = Vector.Cross(d, f_mid);

                var expectedForce = new Force(f_mid, m);
                var zero          = totEndForces - expectedForce;

                buff.ValidationFailed = !zero.Forces.Length.FEquals(0, epsilon) || !zero.Moments.Length.FEquals(0, epsilon);
            }


            return(buff);
        }
        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);
        }
        public static void SimplySupportedBeamUDL()
        {
            var model = new BriefFiniteElementNet.Model();

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

            Node n1, n2;

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

            var elm1 = new BarElement(n1, n2);

            model.Elements.Add(elm1);

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

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

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

            elm1.Loads.Add(u1);

            model.Solve_MPC();

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

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

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

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

            var delta = elm1.GetInternalDisplacementAt(0);
        }
Beispiel #7
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)
                {
                }
            }
        }
        public void LoadInternalForce_uniformload_eulerbernoullybeam_dirY()
        {
            //internal force of 2 node beam beam with uniform load and both ends fixed

            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(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 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");
            }
        }
Beispiel #9
0
        public static ValidationResult Test_Trapezoid_1()
        {
            var buff = new ValidationResult();

            buff.Title = "Test #2 for Trapezoid Load on BarElement";

            buff.Span = new HtmlTag("span");

            buff.Span.Add("p").Text("endforces from Trapezoidal load with 0 offset and same start and end should be same as uniform load");

            var elm = new BarElement(new Node(0, 0, 0), new Node(1, 0, 0));

            elm.Behavior = BarElementBehaviours.BeamZ;

            var direction = Vector.K + Vector.I + Vector.J;
            var ld_u      = new Loads.UniformLoad();

            ld_u.Magnitude          = 1;//*Math.Sqrt(2);
            ld_u.Direction          = direction;
            ld_u.CoordinationSystem = CoordinationSystem.Global;

            var ld_t = new Loads.PartialNonUniformLoad();

            //ld_t.EndLocation = ld_t.StartLocation = new double[] { 0 };
            //ld_t.StartMagnitude = ld_t.EndMagnitude = new double[] { 1 };
            ld_t.Direction          = direction;
            ld_t.CoordinationSystem = CoordinationSystem.Global;

            var loads  = elm.GetGlobalEquivalentNodalLoads(ld_u);
            var loads2 = elm.GetGlobalEquivalentNodalLoads(ld_t);

            var epsilon = 1e-9;

            {//test 1 : equality betweeb above
                var resid = new Force[loads.Length];

                for (var i = 0; i < loads.Length; i++)
                {
                    var f = resid[i] = loads[i] - loads2[i];

                    buff.ValidationFailed = Math.Abs(f.Forces.Length) > epsilon || Math.Abs(f.Moments.Length) > epsilon;
                }
            }


            return(buff);
        }
Beispiel #10
0
        public void LoadEquivalentNodalLoads_uniformload_eulerbernoullybeam_dirZ()
        {
            //internal force of 2 node beam beam with uniform load and both ends fixed

            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.J, w, 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 m1 = -w * L * L / 12;
            var m2 = w * L * L / 12;

            var v1 = -w * L / 2;
            var v2 = -w * L / 2;



            Assert.IsTrue(Math.Abs(loads[0].Fy - v1) < 1e-5, "invalid value");
            Assert.IsTrue(Math.Abs(loads[0].Mz - m1) < 1e-5, "invalid value");

            Assert.IsTrue(Math.Abs(loads[1].Fy - v2) < 1e-5, "invalid value");
            Assert.IsTrue(Math.Abs(loads[1].Mz - m2) < 1e-5, "invalid value");
        }
Beispiel #11
0
        public void Run3()
        {
            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(4, 0, 3)
            {
                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 loadMagnitude = -1e3;
            var loadDirection = Vector.K;

            var l1 = new Loads.UniformLoad();

            var elementDir = el1.Nodes[1].Location - el1.Nodes[0].Location;//or n0 - n1, does not matter

            var absCosTeta = Vector.Cross(elementDir.GetUnit(), loadDirection.GetUnit()).Length;


            l1.Direction          = loadDirection;
            l1.CoordinationSystem = CoordinationSystem.Global;
            l1.Magnitude          = loadMagnitude * absCosTeta; //magnitude should multiple by reduction coefficient absCosTeta


            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());
        }
Beispiel #12
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");
            }
        }
Beispiel #13
0
        public static void Run()
        {
            var model = new Model();

            model.Nodes.Add(new Node(0, 0, 0)
            {
                Label = "n0"
            });
            model.Nodes.Add(new Node(4, 0, 0)
            {
                Label = "n1"
            });

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

            model.Nodes["n0"].Constraints     =
                model.Nodes["n1"].Constraints =
                    Constraints.Fixed;

            var sec = new Sections.UniformGeometric1DSection(SectionGenerator.GetISetion(0.24, 0.67, 0.01, 0.006));
            var mat = Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.3);

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

            (model.Elements["e0"] as BarElement).Section = sec;

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

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

            model.Solve_MPC();

            var n1Force = model.Nodes["n1"].GetSupportReaction();

            Console.WriteLine("support reaction of n1: {0}", n1Force);
            var elm = model.Elements[0] as BarElement;

            var frc = elm.GetExactInternalForceAt(1 - 1e-9);
        }
Beispiel #14
0
        public void LoadEquivalentNodalLoads_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];

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

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

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

            var f1 = -w * L / 2;
            var f2 = -w * L / 2;



            Assert.IsTrue(Math.Abs(loads[0].Fx - f1) < 1e-5, "invalid value");

            Assert.IsTrue(Math.Abs(loads[1].Fx - f2) < 1e-5, "invalid value");
        }
Beispiel #15
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());
        }
        public static void Run()
        {
            var delta = 2;

            var n1 = new Node(0 * delta, 0, 0)
            {
                Constraints = Constraints.Fixed
            };
            var n2 = new Node(1 * delta, 0, 0);
            var n3 = new Node(2 * delta, 0, 0); // { Constraints = Constraints.FixedDZ  };
            var n4 = new Node(3 * delta, 0, 0); // { Constraints = Constraints.FixedDZ  };
            var n5 = new Node(4 * delta, 0, 0)
            {
                Constraints = Constraints.Fixed
            };

            var e1 = new BarElement(n1, n2);
            var e2 = new BarElement(n2, n3);
            var e3 = new BarElement(n3, n4);// { StartReleaseCondition = Constraint.MovementFixed };
            var e4 = new BarElement(n4, n5);

            var sec = new Sections.UniformGeometric1DSection(SectionGenerator.GetRectangularSection(0.05, 0.05));
            var mat = Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.3);

            e1.Section  = e2.Section = e3.Section = e4.Section = sec;
            e1.Material = e2.Material = e3.Material = e4.Material = mat;

            var model = new Model();

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

            e1.Loads.Add(load);
            e2.Loads.Add(load);
            e3.Loads.Add(load);
            e4.Loads.Add(load);

            var elms = new[] { e1, e2, e3, e4 };

            //n1.Loads.Add(new NodalLoad(new Force(0, 0, 100, 0, 0, 0)));
            //n2.Loads.Add(new NodalLoad(new Force(0, 0, 100, 0, 0, 0)));
            //n3.Loads.Add(new NodalLoad(new Force(0, 0, 100, 0, 0, 0)));
            //n4.Loads.Add(new NodalLoad(new Force(0, 0, 100, 0, 0, 0)));
            //n5.Loads.Add(new NodalLoad(new Force(0, 0, 100, 0, 0, 0)));

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

            model.Solve_MPC();

            var rnd = new Random();

            var fnc = new Func <double, double>(x =>
            {
                try
                {
                    var i = x / (delta);

                    var ii = (int)i;

                    var elm = elms[ii];


                    var x_i = (i - ii) * delta;

                    //x_i = delta - x_i;

                    x_i += rnd.NextDouble() * 1e-3;

                    if (x_i < 0)
                    {
                        x_i = 0;
                    }

                    if (x_i > delta)
                    {
                        x_i = delta;
                    }

                    var xi = elm.LocalCoordsToIsoCoords(x_i)[0];

                    var f = elm.GetExactInternalForceAt(xi);

                    return(f.Fz);
                }
                catch
                {
                    return(0);
                }
            });


            Controls.FunctionVisualizer.VisualizeInNewWindow(fnc, 1E-6, 4 * delta - 1E-6, 537);
        }
Beispiel #17
0
        public void Run()
        {
            var model = new Model();

            model.Nodes.Add(new Node(0, 0, 0)
            {
                Label = "n0"
            });
            model.Nodes.Add(new Node(0, 2, 0)
            {
                Label = "n1"
            });
            model.Nodes.Add(new Node(4, 2, 0)
            {
                Label = "n2"
            });
            model.Nodes.Add(new Node(4, 0, 0)
            {
                Label = "n3"
            });

            model.Nodes.Add(new Node(0, 0, 1)
            {
                Label = "n4"
            });
            model.Nodes.Add(new Node(0, 2, 1)
            {
                Label = "n5"
            });
            model.Nodes.Add(new Node(4, 2, 1)
            {
                Label = "n6"
            });
            model.Nodes.Add(new Node(4, 0, 1)
            {
                Label = "n7"
            });


            var a  = 0.1 * 0.1;                    //area, assume sections are 10cm*10cm rectangular
            var iy = 0.1 * 0.1 * 0.1 * 0.1 / 12.0; //Iy
            var iz = 0.1 * 0.1 * 0.1 * 0.1 / 12.0; //Iz
            var j  = 0.1 * 0.1 * 0.1 * 0.1 / 12.0; //Polar
            var e  = 20e9;                         //young modulus, 20 [GPa]
            var nu = 0.2;                          //poissons ratio

            var sec = new Sections.UniformParametric1DSection(a, iy, iz, j);
            var mat = Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(e, nu);

            model.Elements.Add(new BarElement(model.Nodes["n0"], model.Nodes["n4"])
            {
                Label = "e0", Section = sec, Material = mat
            });
            model.Elements.Add(new BarElement(model.Nodes["n1"], model.Nodes["n5"])
            {
                Label = "e1", Section = sec, Material = mat
            });
            model.Elements.Add(new BarElement(model.Nodes["n2"], model.Nodes["n6"])
            {
                Label = "e2", Section = sec, Material = mat
            });
            model.Elements.Add(new BarElement(model.Nodes["n3"], model.Nodes["n7"])
            {
                Label = "e3", Section = sec, Material = mat
            });

            model.Elements.Add(new BarElement(model.Nodes["n4"], model.Nodes["n5"])
            {
                Label = "e4", Section = sec, Material = mat
            });
            model.Elements.Add(new BarElement(model.Nodes["n5"], model.Nodes["n6"])
            {
                Label = "e5", Section = sec, Material = mat
            });
            model.Elements.Add(new BarElement(model.Nodes["n6"], model.Nodes["n7"])
            {
                Label = "e6", Section = sec, Material = mat
            });
            model.Elements.Add(new BarElement(model.Nodes["n7"], model.Nodes["n4"])
            {
                Label = "e7", Section = sec, Material = mat
            });



            model.Nodes["n0"].Constraints             =
                model.Nodes["n1"].Constraints         =
                    model.Nodes["n2"].Constraints     =
                        model.Nodes["n3"].Constraints =
                            Constraints.Fixed;

            var d_case  = new LoadCase("d1", LoadType.Dead);
            var l_case  = new LoadCase("l1", LoadType.Dead);
            var qx_case = new LoadCase("qx", LoadType.Dead);
            var qy_case = new LoadCase("qy", LoadType.Dead);

            var d1 = new Loads.UniformLoad(d_case, -1 * Vector.K, 2e3, CoordinationSystem.Global);
            var l1 = new Loads.UniformLoad(l_case, -1 * Vector.K, 1e3, CoordinationSystem.Global);



            model.Elements["e4"].Loads.Add(d1);
            model.Elements["e5"].Loads.Add(d1);
            model.Elements["e6"].Loads.Add(d1);
            model.Elements["e7"].Loads.Add(d1);

            model.Elements["e4"].Loads.Add(l1);
            model.Elements["e5"].Loads.Add(l1);
            model.Elements["e6"].Loads.Add(l1);
            model.Elements["e7"].Loads.Add(l1);

            var qx_f = new Force(5000 * Vector.I, Vector.Zero);
            var qy_f = new Force(10000 * Vector.J, Vector.Zero);

            model.Nodes["n4"].Loads.Add(new NodalLoad(qx_f, qx_case));
            model.Nodes["n4"].Loads.Add(new NodalLoad(qy_f, qy_case));

            model.Solve_MPC();



            var combination1 = new LoadCombination();// for D + 0.8 L

            combination1[d_case] = 1.0;
            combination1[l_case] = 0.8;

            var n3Force = model.Nodes["N3"].GetSupportReaction(combination1);

            Console.WriteLine("support reaction of n3: " + n3Force);

            var e1 = (model.Elements["e1"] as BarElement);

            var e1Force = (model.Elements["e1"] as BarElement).GetInternalForceAt(0);

            Console.WriteLine("internal force of e1 at middle : ", e1Force);
        }
Beispiel #18
0
        public void Run()
        {
            var model = new Model();

            //adding nodes
            model.Nodes.Add(new Node(-10, 0, 0)
            {
                Label = "n0"
            });
            model.Nodes.Add(new Node(-10, 0, 6)
            {
                Label = "n1"
            });
            model.Nodes.Add(new Node(0, 0, 8)
            {
                Label = "n2"
            });
            model.Nodes.Add(new Node(10, 0, 6)
            {
                Label = "n3"
            });
            model.Nodes.Add(new Node(10, 0, 0)
            {
                Label = "n4"
            });

            //adding elements
            model.Elements.Add(new BarElement(model.Nodes["n0"], model.Nodes["n1"])
            {
                Label = "e0"
            });
            model.Elements.Add(new BarElement(model.Nodes["n1"], model.Nodes["n2"])
            {
                Label = "e1"
            });
            model.Elements.Add(new BarElement(model.Nodes["n2"], model.Nodes["n3"])
            {
                Label = "e2"
            });
            model.Elements.Add(new BarElement(model.Nodes["n3"], model.Nodes["n4"])
            {
                Label = "e3"
            });

            //assign constraint to nodes
            model.Nodes["n0"].Constraints     =
                model.Nodes["n4"].Constraints =
                    Constraints.Fixed;

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

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

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

            //creating loads
            var u1 = new Loads.UniformLoad(LoadCase.DefaultLoadCase, new Vector(0, 0, 1), -6000, CoordinationSystem.Global);
            var u2 = new Loads.UniformLoad(LoadCase.DefaultLoadCase, new Vector(0, 0, 1), -5000, CoordinationSystem.Local);

            //assign loads
            model.Elements["e1"].Loads.Add(u1);
            model.Elements["e2"].Loads.Add(u2);

            //solve model
            model.Solve_MPC();

            //retrieve solve result
            var n0reaction = model.Nodes["N0"].GetSupportReaction();
            var n4reaction = model.Nodes["N4"].GetSupportReaction();

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

            var d1 = model.Nodes["N1"].GetNodalDisplacement();

            Console.WriteLine("Displacement of n1: {0}", d1);


            Controls.BarInternalForceVisualizer.VisualizeInNewWindow((model.Elements["e1"] as BarElement));

            //Controls.ModelInternalForceVisualizer.VisualizeInNewWindow(model);
        }
Beispiel #19
0
        public void Run()
        {
            var model = new Model();

            model.Nodes.Add(new Node(-10, 0, 0)
            {
                Label = "n0"
            });
            model.Nodes.Add(new Node(-10, 0, 6)
            {
                Label = "n1"
            });
            model.Nodes.Add(new Node(0, 0, 8)
            {
                Label = "n2"
            });
            model.Nodes.Add(new Node(10, 0, 6)
            {
                Label = "n3"
            });
            model.Nodes.Add(new Node(10, 0, 0)
            {
                Label = "n4"
            });

            model.Elements.Add(new BarElement(model.Nodes["n0"], model.Nodes["n1"])
            {
                Label = "e0"
            });
            model.Elements.Add(new BarElement(model.Nodes["n1"], model.Nodes["n2"])
            {
                Label = "e1"
            });
            model.Elements.Add(new BarElement(model.Nodes["n2"], model.Nodes["n3"])
            {
                Label = "e2"
            });
            model.Elements.Add(new BarElement(model.Nodes["n3"], model.Nodes["n4"])
            {
                Label = "e3"
            });


            model.Nodes["n0"].Constraints     =
                model.Nodes["n4"].Constraints =
                    Constraints.Fixed;

            var secAA = new Sections.UniformGeometric1DSection(SectionGenerator.GetISetion(0.24, 0.67, 0.01, 0.006));
            var secBB = new Sections.UniformGeometric1DSection(SectionGenerator.GetISetion(0.24, 0.52, 0.01, 0.006));
            var mat   = Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.3);

            (model.Elements["e0"] as BarElement).Material = mat;
            (model.Elements["e1"] as BarElement).Material = mat;
            (model.Elements["e2"] as BarElement).Material = mat;
            (model.Elements["e3"] as BarElement).Material = mat;

            (model.Elements["e0"] as BarElement).Section = secAA;
            (model.Elements["e1"] as BarElement).Section = secBB;
            (model.Elements["e2"] as BarElement).Section = secBB;
            (model.Elements["e3"] as BarElement).Section = secAA;


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

            model.Elements["e1"].Loads.Add(u1);
            model.Elements["e2"].Loads.Add(u2);

            model.Solve_MPC();

            var n3Force = model.Nodes["N3"].GetSupportReaction();

            Console.WriteLine("support reaction of n3: {0}", n3Force);

            {
                var x = 1.0;

                var iso = (model.Elements["e3"] as BarElement).LocalCoordsToIsoCoords(x);

                var e4Force = (model.Elements["e3"] as BarElement).GetInternalForceAt(iso[0]);
                Console.WriteLine("internal force at x={0} is {1}", x, e4Force);
            }
        }
Beispiel #20
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");
            }
        }
        private static void testMultySpan()
        {
            var model = StructureGenerator.Generate3DBarElementGrid(4, 1, 1);

            var bar1 = model.Elements[0] as BarElement;
            var bar2 = model.Elements[1] as BarElement;
            var bar3 = model.Elements[2] as BarElement;

            model.Nodes[0].Constraints = Constraints.MovementFixed & Constraints.FixedRY;
            model.Nodes[1].Constraints = Constraints.MovementFixed; // & Constraints.FixedRY;
            model.Nodes[2].Constraints = Constraints.MovementFixed; // MovementFixed & Constraints.FixedRY;
            model.Nodes[3].Constraints = Constraints.MovementFixed & Constraints.FixedRY;


            var l = (model.Nodes.Last().Location - model.Nodes[0].Location).Length;


            //bar.StartReleaseCondition = Constraints.MovementFixed & Constraints.FixedRX;
            //bar.EndReleaseCondition = Constraints.MovementFixed & Constraints.FixedRX;

            //var ld = new Loads.UniformLoad() { Direction = Vector.K, Magnitude = -100 };

            var ld = new Loads.ConcentratedLoad()
            {
                Force = new Force(0, 0, -1, 0, 0, 0), CoordinationSystem = CoordinationSystem.Global, ForceIsoLocation = new IsoPoint(0.0)
            };
            var ld2 = new Loads.UniformLoad()
            {
                Direction = -Vector.K, Magnitude = 1, CoordinationSystem = CoordinationSystem.Global,
            };

            bar1.Material = bar2.Material = bar3.Material;
            bar1.Section  = bar2.Section = bar3.Section;


            bar1.Loads.Add(ld2);
            //bar2.Loads.Add(ld2);
            bar3.Loads.Add(ld2);



            model.Solve_MPC();

            var r0 = model.Nodes[0].GetSupportReaction();


            var st  = model.Nodes[0].Location;
            var mid = model.Nodes[1].Location;
            var en  = model.Nodes[2].Location;


            var ss = model.Nodes.Select(ii => ii.GetSupportReaction()).ToArray();

            var pts = new List <Tuple <double, double> >();

            foreach (var elm in model.Elements)
            {
                var b = elm as BarElement;

                if (b == null)
                {
                    continue;
                }

                for (var ii = -1.0; ii <= 1; ii += 0.001)
                {
                    var global = b.IsoCoordsToGlobalCoords(ii);

                    try
                    {
                        var f1 = b.GetExactInternalForceAt(ii);
                        var f2 = b.GetInternalForceAt(ii);

                        var f = f2 - f1;

                        pts.Add(Tuple.Create(global.Y, -f1.My));
                    }
                    catch { }
                }
            }


            pts.Sort((i, j) => i.Item1.CompareTo(j.Item1));


            FunctionVisualizer.VisualizeInNewWindow((x =>
            {
                var tt = pts.LastOrDefault(j => j.Item1 <= x);

                if (tt != null)
                {
                    return(tt.Item2);
                }

                return(0);
            }), 0, l, 1000);

            throw new NotImplementedException();
        }
        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();
        }