BriefFiniteElementNet / BriefFiniteElement.Net

BriefFiniteElementDotNET (BFE.NET) is a library for linear-static Finite Element Method (FEM) analysis of solids and structures in .NET
https://www.bfe-framework.net
GNU Lesser General Public License v3.0
154 stars 58 forks source link

Vertical BarElements return NaN #96

Closed SerGlushko closed 3 years ago

SerGlushko commented 3 years ago

Describe the bug Greetings! First of all, thank you for your continued development and support of this fantastic library. I've been using BFE.NET version from autumn 2019 in my project and decided to migrate to the newest build. I have encountered an issue: any 2D frame or truss I create have NaN values of support reactions, internal forces and deformations for the vertical elements, e.g BarElement (0, 0, 0), (0, 0, 1). This issue might also effect FrameElement2Node elements.

To Reproduce This is the code We've used and caused wrong result/ runtime error

var m1 = new Model();

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

m1.Nodes.Add(new Node(0, 0, 6) { Label = "n2" });

m1.Nodes["n1"].Constraints = new Constraint(dx: DofConstraint.Fixed, dy: DofConstraint.Fixed, dz: DofConstraint.Fixed, rx: DofConstraint.Fixed, ry: DofConstraint.Fixed, rz: DofConstraint.Fixed);

m1.Nodes["n2"].Loads.Add(new NodalLoad(new Force(0, 0, -4000, 0, 0, 0)));

m1.Elements.Add(new BarElement(m1.Nodes["n1"], m1.Nodes["n2"]) { Label = "r1" });

(m1.Elements["r1"] as BarElement).Behavior = BarElementBehaviours.FullFrame;

(m1.Elements["r1"] as BarElement).Section = new BriefFiniteElementNet.Sections.UniformParametric1DSection(16.43 / 10000, 541.22 / 100000000, 44.92 / 100000000, 541.22 / 100000000 + 44.92 / 100000000);

(m1.Elements["r1"] as BarElement).Material = BriefFiniteElementNet.Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210 * Math.Pow(10, 9), 0.3);

m1.Solve();

var r11 = m1.Nodes[0].GetSupportReaction();

var r12 = m1.Nodes[1].GetSupportReaction();

Console.WriteLine("n0 reaction: {0}", r11);

Console.WriteLine("n1 reaction: {0}", r12);

Console.ReadKey();

image

image

Expected behavior The expected result for n0 is "F: 0, 0, 4000, M: 0, 0, 0"

Additional context image

I've tested multiple frame configurations and ones without strictly vertical elements had correct results.

epsi1on commented 3 years ago

I think there is problem with transformation calculations I'll check this week and fix the issue. Thanks

epsi1on commented 3 years ago

Hi This works fine now. this is the result of your code I did not changed the code. image

SerGlushko commented 3 years ago

Hello, I've downloaded the latest version of the library, results remain the same for me

image

epsi1on commented 3 years ago

Could you please also check with model.Solve_MPC() instead of model.Solve()? I've coppied your code into this file: https://github.com/BriefFiniteElementNet/BriefFiniteElement.Net/blob/7ab78543b48b2f50fd1942dba29f686033e5dd3e/BriefFiniteElementNet.Validation/GithubIssues/Issue96.cs#L10

If you set BriefFiniteElementNet.TestConsole.csproj as startup project, it will call

https://github.com/BriefFiniteElementNet/BriefFiniteElement.Net/blob/7ab78543b48b2f50fd1942dba29f686033e5dd3e/BriefFiniteElementNet.TestConsole/Program.cs#L39

Could you please check?

SerGlushko commented 3 years ago

I've tested Solve_MPC method, it returns NaN. Same for the project in the TestConsole image

Here's the matrix:

Click to expand 595673076.923077,0,84134615.3846154,0,0,0,-588942307.692308,252403846.153846,-33653846.1538462,0,0,0,6730769.23076923,-252403846.153846,50480769.2307692,0,0,0,-13461538.4615385,0,-100961538.461538,0,0,0;0,175000000,0,0,0,0,168269230.769231,-168269230.769231,33653846.1538462,0,0,0,-168269230.769231,6730769.23076923,-33653846.1538462,0,0,0,0,-13461538.4615385,0,0,0,0;84134615.3846154,0,191826923.076923,0,0,0,-50480769.2307693,50480769.2307693,-168269230.769231,0,0,0,33653846.1538462,-50480769.2307693,23557692.3076923,0,0,0,-67307692.3076923,0,-47115384.6153846,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;-588942307.692308,168269230.769231,-50480769.2307692,0,0,0,757211538.461539,-420673076.923077,0,0,0,0,-168269230.769231,252403846.153846,-50480769.2307692,0,0,0,0,0,100961538.461538,0,0,0;252403846.153846,-168269230.769231,50480769.2307692,0,0,0,-420673076.923077,757211538.461539,0,0,0,0,168269230.769231,-588942307.692308,50480769.2307692,0,0,0,0,0,-100961538.461538,0,0,0;-33653846.1538462,33653846.1538462,-168269230.769231,0,0,0,0,0,336538461.538462,0,0,0,-33653846.1538462,33653846.1538462,-168269230.769231,0,0,0,67307692.3076923,-67307692.3076923,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;6730769.23076923,-168269230.769231,33653846.1538462,0,0,0,-168269230.769231,168269230.769231,-33653846.1538462,0,0,0,175000000,0,0,0,0,0,-13461538.4615385,0,0,0,0,0;-252403846.153846,6730769.23076923,-50480769.2307692,0,0,0,252403846.153846,-588942307.692308,33653846.1538462,0,0,0,0,595673076.923077,-84134615.3846154,0,0,0,0,-13461538.4615385,100961538.461538,0,0,0;50480769.2307693,-33653846.1538462,23557692.3076923,0,0,0,-50480769.2307693,50480769.2307693,-168269230.769231,0,0,0,0,-84134615.3846154,191826923.076923,0,0,0,0,67307692.3076923,-47115384.6153846,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;-13461538.4615385,0,-67307692.3076923,0,0,0,0,0,67307692.3076923,0,0,0,-13461538.4615385,0,0,0,0,0,26923076.9230769,0,0,0,0,0;0,-13461538.4615385,0,0,0,0,0,0,-67307692.3076923,0,0,0,0,-13461538.4615385,67307692.3076923,0,0,0,0,26923076.9230769,0,0,0,0;-100961538.461539,0,-47115384.6153846,0,0,0,100961538.461539,-100961538.461539,0,0,0,0,0,100961538.461539,-47115384.6153846,0,0,0,0,0,94230769.2307693,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
epsi1on commented 3 years ago

There was problem with bar transformation which is fixed. Could you please do check again? Thanks

SerGlushko commented 3 years ago

The example works correctly now, but I've tried the latest version in my main project that uses some legacy code too. The issue is still there for FrameElement2Node elements

epsi1on commented 3 years ago

it should be fixed, could you please do check again?

SerGlushko commented 3 years ago

It works for FrameElement2Node now too. Thank you!