BriefFiniteElementNet / BriefFiniteElement.Net

BriefFiniteElementDotNET (BFE.NET) is a library for linear-static Finite Element Method (FEM) analysis of solids and structures in .NET
GNU Lesser General Public License v3.0
154 stars 57 forks source link

Facing problem getting started #66

Closed zahmed80 closed 4 years ago

zahmed80 commented 4 years ago

Below is the code that i am trying, and here is a screenshot of error :

Please Help

`using System; using BriefFiniteElementNet; using BriefFiniteElementNet.Elements;

namespace ConsoleApp1 { class Program { static void Main(string[] args) { var model = new BriefFiniteElementNet.Model(); var n1 = new Node(); var n2 = new Node(); var bar = new BarElement(n1, n2); model.Nodes.Add(n1 = new Node(x: 0.0, y: 0.0, z: 0.0) { Constraints = Constraints.Fixed, Label = "n0" }); model.Nodes.Add(n2 = new Node(x: 1.0, y: 0.0, z: 0.0) { Constraints = Constraints.Released, Label = "n1" }); model.Elements.Add(bar); bar.Section = new BriefFiniteElementNet.Sections.UniformParametric1DSection(a: 0.01, iy: 8.3e-6, iz: 8.3e-6, j: 16.6e-6);//section's second area moments Iy and Iz = 8.310^-6, area = 0.01 bar.Material = BriefFiniteElementNet.Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.3);//Elastic mudule is 210e9 and poisson ratio is 0.3 var load = new BriefFiniteElementNet.NodalLoad(); var frc = new Force(); frc.Fz = 1000;// 1kN force in Z direction load.Force = frc; n2.Loads.Add(load); model.Solve_MPC();//or model.Solve(); var d2 = n2.GetNodalDisplacement(); Console.WriteLine("Nodal displacement in Z direction is {0} meters (thus {1} mm)", d2.DZ, d2.DZ 1000);//print the Dz of n2 into console Console.WriteLine("Nodal rotation in Y direction is {0} radians (thus {1} degrees)", d2.RY, d2.RY * 180.0 / Math.PI);//print the Rz of n2 into console

    }
}

} `

image

epsi1on commented 4 years ago

Hi, Can you please check this out:

https://github.com/BriefFiniteElementNet/BriefFiniteElement.Net/wiki/How-to-fix-NotPosDef-error

Let me know if it didn't solve your problem,

Thanks

epsi1on commented 4 years ago

The problem is that you created the bar element with n1 and n2, then you did re assigned new Node reference to n1 and n2. this would work:

    var model = new BriefFiniteElementNet.Model();
    var n1 = new Node(x: 0.0, y: 0.0, z: 0.0) { Constraints = Constraints.Fixed, Label = "n0" };
    var n2 = new Node(x: 1.0, y: 0.0, z: 0.0) { Constraints = Constraints.Released, Label = "n1" }
    var bar = new BarElement(n1, n2);
    model.Nodes.Add(n1 );
    model.Nodes.Add(n2 );
   //rest is same as your code