This project has moved. For the latest updates, please go here.

Getting an exception I don't understand

Aug 11, 2014 at 9:24 PM
First let me say that I really appreciate all of the effort that has been put into this.

I have had some experience using FEM libraries (Engissol and Frame3DD) but I can't quite get a simple "hello world" example to work. I am trying to model a simple cantilevered beam (below is my latest simplified attempt but I have tried a few times).
Model model = new Model();
Node node1 = new Node(0, 0, 0) { Label = "node1" };
Node node2 = new Node(0, 0, 10) { Label = "node2" };

FrameElement2Node beam1 = new FrameElement2Node(node1, node2) { Label = "beam1" };

beam1.A = 0.145;    //cross sectional area m^2
beam1.E = 1.7e6;    //Elastic modulus

model.Nodes.Add(node1, node2);
model.Elements.Add(beam1);

node1.Constraints = Constraint.Fixed;
node2.Constraints = Constraint.Released;

Force force = new Force(100, 0, 0, 0, 0, 0);
node2.Loads.Add(new NodalLoad(force));//adds a load with LoadCase of DefaultLoadCase to node loads

model.Solve();

var r1 = node1.GetSupportReaction();
var r2 = node2.GetSupportReaction();
But no matter what I do it always throws an exception in SparseCholesky,cs line 295
if (d <= 0)
{
    throw new Exception("not pos def"); // TODO: ex
}
Any assistance would be appreciated in making a simple stacked cantilever would be great
Developer
Aug 12, 2014 at 12:09 PM
Edited Aug 12, 2014 at 12:11 PM
The exception means that the stiffness matrix assembled for this model is not positive definite, so Cholesky won't work. Actually, the matrix is 6x6 with only one non-zero value at position (2, 2).

I'm not familiar with structural analysis, but to me, your model makes sense, so I guess it's a matter of setting up correct default values for the beam. If you create a beam with StructureGenerator.GenerateSimpleBeam(2), you'll find that most parameters (A, E, G, J, Iy, Iz) are set to non-zero values.
Coordinator
Aug 12, 2014 at 1:18 PM
Hi,
As user wo80 said, you did not defined some parameters for your beam1 and while all DoFs of node2 is free, physically your model do not makes sense.
I've made some changes in your code and now works fine on my computer:
Model model = new Model();
Node node1 = new Node(0, 0, 0) {Label = "node1"};
Node node2 = new Node(0, 0, 10) {Label = "node2"};

FrameElement2Node beam1 = new FrameElement2Node(node1, node2) {Label = "beam1"};

beam1.A = 0.145; //cross sectional area m^2
beam1.E = 1.7e6; //Elastic modulus

//Added stuff
var no = 0.3;
beam1.G =beam1.E/(2*(1 + no));
beam1.J = beam1.Iz = beam1.Iy = 0.00174; //Second area moment m^4
//Added stuff

model.Nodes.Add(node1, node2);
model.Elements.Add(beam1);

node1.Constraints = Constraint.Fixed;
node2.Constraints = Constraint.Released;

Force force = new Force(100, 0, 0, 0, 0, 0);
node2.Loads.Add(new NodalLoad(force)); //adds a load with LoadCase of DefaultLoadCase to node loads

model.Solve();

var r1 = node1.GetSupportReaction();
var r2 = node2.GetSupportReaction();
If you do not want to apply the J and G parameters, then you should fix two DoFs of rotation about Z axis on both nodes in order to make the model solvable.

Regards
Marked as answer by epsi1on on 8/18/2014 at 10:32 AM