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(new Force(0, 0, 0, 00, 10, 00), new IsoPoint(0.50), CoordinationSystem.Local);

            load3.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);
        }
        public static void TestBarStiffness()
        {
            var iy = 0.02;
            var iz = 0.02;
            var a  = 0.01;

            var j = iy + iz;

            var e = 210e9;
            var g = 70e9;
            //var rho = 13;

            var model = new Model();

            model.Nodes.Add(new Node(0, 0, 0));
            model.Nodes.Add(new Node(3, 5, 7));

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

            barElement.Behavior = BarElementBehaviours.FullFrame;
            barElement.Material = UniformIsotropicMaterial.CreateFromYoungShear(e, g);

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

            frameElement.ConsiderShearDeformation = false;

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

            var frK  = frameElement.GetGlobalStifnessMatrix();
            var barK = barElement.GetGlobalStifnessMatrix();

            var d = (frK - barK).Max(i => Math.Abs(i));
        }
Exemple #3
0
        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();
        }
        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);
        }
        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();
        }
        public static void Run()
        {
            var model = new Model();

            var l = 5;

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


            var axialLoad      = 1000;
            var horizontalLoad = 1000;

            var f = new Force(horizontalLoad, 0, axialLoad, 0, 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(n1, n2)
            {
                Material = mat, Section = sec, Behavior = BarElementBehaviours.FullFrame
            };

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

            n1.Constraints = Constraints.Fixed;

            n2.Loads.Add(new NodalLoad(f));


            model.Solve_MPC();

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

            var expectedDx = (horizontalLoad * l * l * l) / (3 * e * iy);
            var expectedRy = (horizontalLoad * l * l) / (2 * e * iy);
            var expectedDz = axialLoad * l / (e * a);

            var epsilon = 0.0;

            if (Math.Abs(d.DX - expectedDx) > epsilon)
            {
                throw new NotImplementedException();
            }
            if (Math.Abs(d.RY - expectedRy) > epsilon)
            {
                throw new NotImplementedException();
            }
            if (Math.Abs(d.DZ - expectedDz) > epsilon)
            {
                throw new NotImplementedException();
            }
        }