Exemple #1
0
        public static void ValidateSingleInclinedFrame()
        {
            var model = new Model();
            var ndes  = new Node[] { new Node(0, 0, 0), new Node(2, 3, 5) };

            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 sec = new Sections.UniformParametric1DSection(a, iy, iz, j);
            var mat = UniformIsotropicMaterial.CreateFromYoungPoisson(1, 0.25);

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

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

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

            ndes[0].Constraints = Constraints.Fixed;

            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);
        }
Exemple #2
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();
        }
        static void TestTet()
        {
            //new Validation.Case_03.Validator().Validate();

            var tet =
                new TetrahedronElement();

            //new Tetrahedral();

            tet.Nodes[0] = new Node(-1, -1, 0);
            tet.Nodes[1] = new Node(1, -1, 0);
            tet.Nodes[2] = new Node(1, 1, 0);
            tet.Nodes[3] = new Node(0, 0, 5);

            tet.Material = UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.3);
            //tet.E = 1000;tet.Nu = 0.3;

            var stf = tet.GetGlobalStifnessMatrix();

            var ctrl = new MatrixVisualizerControl();

            ctrl.VisualizeMatrix(stf);

            new Window()
            {
                Content = ctrl, Title = "epsi1on Matrix Visualizer!", Width = 24 * 50, Height = 24 * 50
            }
            .ShowDialog();
        }
        public static void Run()
        {
            var model = new Model();
            var n1    = new Node(0, 0, 0)
            {
                Label = "n1", Constraints = Constraints.Fixed
            };
            var n2 = new Node(10, 0, 0)
            {
                Label = "n2", Constraints = Constraints.RotationFixed & Constraints.FixedDX & Constraints.FixedDY
            };

            var beam = new BarElement(n1, n2)
            {
                Label = "Beam", Behavior = BarElementBehaviour.BeamYEulerBernoulli
            };

            //beam.Section = new UniformGeometric1DSection(SectionGenerator.GetISetion(0.24, 0.67, 0.01, 0.006));
            beam.Section = new UniformParametric1DSection()
            {
                A = 1e-4, Iy = 1e-6, Iz = 1e-6, J = 1e-6
            };
            beam.Material = UniformIsotropicMaterial.CreateFromYoungPoisson(1e10, 0.2);

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

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

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

            model.Solve_MPC();
        }
        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);
        }
        public static void Run1()
        {
            var l     = 10;
            var model = new Model();

            model.Nodes.Add(new Node(0, 0, 0)
            {
                Label = "n0"
            });
            model.Nodes.Add(new Node(l, 0, 0)
            {
                Label = "n1"
            });
            //Fixed nodes
            model.Nodes["n0"].Constraints = Constraints.Fixed;
            model.Nodes["n1"].Constraints = Constraints.Fixed;

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

            //Pinned bar releases

            bar.StartReleaseCondition = Constraints.MovementFixed;

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

            model.Elements.Add(bar);

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

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

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

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

            model.Solve_MPC();

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

            Console.WriteLine("support reaction of n0: {0}, n1: {1}", n0Force, n1Force);

            var elm = model.Elements[0] as BarElement;

            BarInternalForceVisualizer.VisualizeInNewWindow(elm);
        }
Exemple #7
0
        public static void testInternalForce_Console()
        {
            var model = new Model();
            var ndes  = new Node[] { new Node(0, 0, 0), new Node(3, 0, 0) };

            var h = UnitConverter.In2M(4);
            var w = UnitConverter.In2M(4);

            var e = UnitConverter.Psi2Pas(20e4);

            var a  = h * w;
            var iy = h * h * h * w / 12;
            var iz = w * w * w * h / 12;
            var j  = iy + iz;

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

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

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

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

            ndes[0].Constraints = Constraints.Fixed;

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

            model.Solve_MPC();

            var tr = elm.GetTransformationManager();

            var d1 = tr.TransformLocalToGlobal(elm.GetInternalDisplacementAt(1 - 1e-10, LoadCase.DefaultLoadCase));
            var d2 = ndes[1].GetNodalDisplacement(LoadCase.DefaultLoadCase);


            var frc = elm.GetInternalForceAt(-1, LoadCase.DefaultLoadCase);

            var gfrc = elm.GetTransformationManager().TransformLocalToGlobal(frc);

            var f0 = ndes[0].GetSupportReaction();
        }
        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);
        }
Exemple #9
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());
        }
Exemple #10
0
        public static void ValidateConsoleUniformLoad()
        {
            var model = new Model();

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

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

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

            model.Nodes.Add(ndes);

            ndes[0].Constraints = Constraints.Fixed;

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

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

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

            var old = n1.Constraints;

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

            var elm = new BarElement(n1, n2);

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

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

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

            model.Nodes.Add(n1);

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

            model.Solve_MPC();

            var d = n1.GetNodalDisplacement();
        }
Exemple #12
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());
        }
Exemple #13
0
        public static Model Generate3DTetrahedralElementGrid(int m, int n, int l)
        {
            var buf = new Model();

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

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

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

                        nde.Constraints = Constraints.RotationFixed;

                        nodes[j, i, k] = nde;
                    }
                }
            }


            var elm = new Func <Node, Node, Node, Node, TetrahedronElement>((n1, n2, n3, n4) =>
            {
                var buff = new TetrahedronElement();

                buff.Nodes[0] = n1;
                buff.Nodes[1] = n2;
                buff.Nodes[2] = n3;
                buff.Nodes[3] = n4;

                buff.Material = UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.3);

                buff.FixNodeOrder();
                return(buff);
            });

            var elms = new List <Element>();

            for (int i = 0; i < m - 1; i++)
            {
                for (int j = 0; j < n - 1; j++)
                {
                    for (int k = 0; k < l - 1; k++)
                    {
                        var ns = new Node[] {
                            nodes[i, j, k],
                            nodes[i + 1, j, k],
                            nodes[i + 1, j + 1, k],
                            nodes[i, j + 1, k],

                            nodes[i, j, k + 1],
                            nodes[i + 1, j, k + 1],
                            nodes[i + 1, j + 1, k + 1],
                            nodes[i, j + 1, k + 1],
                        };


                        elms.Add(elm(ns[0], ns[1], ns[3], ns[4]));
                        elms.Add(elm(ns[2], ns[1], ns[3], ns[6]));

                        elms.Add(elm(ns[1], ns[3], ns[4], ns[6]));

                        elms.Add(elm(ns[4], ns[5], ns[6], ns[1]));
                        elms.Add(elm(ns[4], ns[6], ns[7], ns[3]));
                    }
                }
            }

            buf.Elements.Add(elms.ToArray());

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


            return(buf);
        }
        /// <summary>
        /// Method that reads an Abaqus input file and returns a BFE model with the same nodes and elements
        /// </summary>
        /// <param name="path">Path to an input file</param>
        /// <returns>A BFE model</returns>
        public static Model AbaqusInputToBFE(string pathToInputFile)
        {
            var buf = new Model();

            //splitting char
            char delimiter = ',';
            Node node;
            TetrahedronElement element;

            //list for the node- and elementsets
            List <NodeSet>    nodeSets    = new List <NodeSet>();
            List <ElementSet> elementSets = new List <ElementSet>();

            using (StreamReader sr = File.OpenText(pathToInputFile))
            {
                string[] split;
                selectedInputVariable selectedVar = selectedInputVariable.Nodes;
                string input = sr.ReadLine();
                while (input != null)
                {
                    split = input.Split(delimiter);
                    if (split[0].Contains('*'))
                    {
                        switch (split[0])
                        {
                        case "*Node":
                            selectedVar = selectedInputVariable.Nodes;
                            break;

                        case "*Element":
                            selectedVar = selectedInputVariable.Elements;
                            break;

                        case "*Nset":
                            selectedVar = selectedInputVariable.NodeSet;
                            nodeSets.Add(new NodeSet()
                            {
                                Name = split[1].Replace("nset=", "")
                            });
                            break;

                        case "*Elset":
                            selectedVar = selectedInputVariable.ElementSet;
                            elementSets.Add(new ElementSet()
                            {
                                Name = split[1].Replace("elset=", "")
                            });
                            break;

                        case "*Cload":
                            selectedVar = selectedInputVariable.CLoad;
                            break;

                        case "*Boundary":
                            selectedVar = selectedInputVariable.BC;
                            break;

                        default:
                            selectedVar = selectedInputVariable.Other;
                            break;
                        }
                    }
                    else
                    {
                        switch (selectedVar)
                        {
                        case selectedInputVariable.Nodes:
                        {
                            node = ReadNode(input, delimiter);
                            if (node != null)
                            {
                                //tetrahedron element - > fix rotation
                                node.Constraints = Constraints.RotationFixed;
                                buf.Nodes.Add(node);
                            }
                            break;
                        }

                        case selectedInputVariable.Elements:
                        {
                            element = ReadTetraElement(input, delimiter, buf.Nodes);
                            if (element != null)
                            {
                                element.Material = UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.25);
                                element.FixNodeOrder();
                                buf.Elements.Add(element);
                            }
                            break;
                        }

                        case selectedInputVariable.NodeSet:
                        {
                            for (int i = 0; i < split.Count(); i++)
                            {
                                nodeSets[nodeSets.Count - 1].Nodes.Add(Convert.ToInt32(split[i]));
                            }
                            break;
                        }

                        case selectedInputVariable.ElementSet:
                        {
                            for (int i = 0; i < split.Count(); i++)
                            {
                                elementSets[elementSets.Count - 1].Elements.Add(Convert.ToInt32(split[i]));
                            }
                            break;
                        }

                        case selectedInputVariable.CLoad:
                        {
                            NodeSet set = nodeSets.Where(x => x.Name.Replace(" ", "") == split[0].Replace(" ", "")).FirstOrDefault();
                            if (set != null)
                            {
                                //determine the magnitude of the load
                                var load = new BriefFiniteElementNet.NodalLoad();
                                var frc  = new Force();
                                if (Convert.ToInt32(split[1]) == 1)
                                {
                                    frc.Fx     = Convert.ToDouble(split[2]);
                                    load.Force = frc;
                                }
                                else if (Convert.ToInt32(split[1]) == 2)
                                {
                                    frc.Fy     = Convert.ToDouble(split[2]);
                                    load.Force = frc;
                                }
                                else if (Convert.ToInt32(split[1]) == 3)
                                {
                                    frc.Fz     = Convert.ToDouble(split[2]);
                                    load.Force = frc;
                                }
                                //add the load to the nodes
                                foreach (var nodeLabel in set.Nodes)
                                {
                                    buf.Nodes[nodeLabel - 1].Loads.Add(load);
                                }
                            }
                            break;
                        }

                        case selectedInputVariable.BC:
                        {
                            NodeSet set = nodeSets.Where(x => x.Name.Replace(" ", "") == split[0].Replace(" ", "")).FirstOrDefault();
                            if (set != null)
                            {
                                //add the load to the nodes
                                foreach (var nodeLabel in set.Nodes)
                                {
                                    buf.Nodes[nodeLabel - 1].Constraints = Constraints.Fixed;
                                }
                            }
                            break;
                        }

                        default:
                            break;
                        }
                    }
                    input = sr.ReadLine();
                }
            }
            return(buf);
        }