JWock82 / Pynite

A 3D structural engineering finite element library for Python.
MIT License
460 stars 93 forks source link

What is "matrix is singular" error? #160

Closed omar-alzeer closed 1 year ago

omar-alzeer commented 1 year ago

I am a Civil engineering student(3rd year) , and i am programming a simple program to calc internal forces using PyNite in 2D.

I am facing this error in some problems and i don't know how to solve it, altgough the the beam is constrained, it is just a fixed support beam, but when i change the length of beam sometime get this error.

and can i solve problems without adding the members properities?, because at university we solve problems without detrmine the material props, i used some programs that gives output correctly without add logic props (so the props in code below it is bad) ?

# Example of a simply supported beam with a point load.
# Units used for the model in this example are inches and kips

# Import `FEModel3D` from `PyNite`
from PyNite import FEModel3D

# Import 'Visualization' for rendering the model
# from PyNite import Visualization

# Create a new finite element model
simple_beam = FEModel3D()

# Add nodes (meter)
simple_beam.add_node('N1', 0, 0, 0)
simple_beam.add_node('N2', 3, 0, 0) 

# Define a material
E = 10000      # Modulus of elasticity (kN/m^2)
G = 11200      # Shear modulus of elasticity (kN/^2)
nu = 0.3        # Poisson's ratio
rho = 2.836e-4 
simple_beam.add_material('Steel', E, G, nu, rho)

# Add a beam with the following properties:
simple_beam.add_member('M1', 'N1', 'N2', 'Steel', 10, 15, 25, 2)

# Provide simple supports
simple_beam.def_support('N1', True, True, False, True, True, True)  # Constrained for torsion at 'N1'
simple_beam.def_support('N2', False, False, False, True, True, False) # Not constrained for torsion at 'N2'

# Add a downward point load of 5 kips at the midspan of the beam
simple_beam.add_member_dist_load('M1', 'Fy', -1,-1,0,1)

# Add load combinations
# simple_beam.add_load_combo('1.4D', {'D':1})
#simple_beam.add_load_combo('1.2D+1.6L', {'D':1.2, 'L':1.6})

# Analyze the beam and perform a statics check
simple_beam.analyze(check_stability=True,log=True,check_statics=True,sparse=False)

# Print the shear, moment, and deflection diagrams
simple_beam.Members['M1'].plot_shear('Fy')
simple_beam.Members['M1'].plot_moment('Mz')
simple_beam.Members['M1'].plot_deflection('dy')

# Print reactions at each end of the beam
print('Left Support Reaction:', simple_beam.Nodes['N1'].RxnFY, 'kN')
print('Right Support Reacton:', simple_beam.Nodes['N2'].RxnFY, 'kN')

# Print the max/min shears and moments in the beam
print('Maximum Shear:', simple_beam.Members['M1'].max_shear('Fy'), 'kN')
print('Minimum Shear:', simple_beam.Members['M1'].min_shear('Fy'), 'kN')
print('Maximum Moment:', simple_beam.Members['M1'].max_moment('Mz'), 'kN.m')
print('Minimum Moment:', simple_beam.Members['M1'].min_moment('Mz'), 'kN.m')

# Print the max/min deflections in the beam
print('Maximum Deflection:', simple_beam.Members['M1'].max_deflection('dy'), 'm')
print('Minimum Deflection:', simple_beam.Members['M1'].min_deflection('dy'), 'm') 
JWock82 commented 1 year ago

A singular stiffness matrix means the structure is unstable. In your case, the model has no support in the Z direction. Read the link below for more clarification.

Pynite Documentation: Stability

JWock82 commented 1 year ago

Also - FEA always requires beam stiffness properties. For textbook problems with no properties, you can simply make them up. Your deflections will be the only thing affected, but textbook problems like that don't deal with deflection.

omar-alzeer commented 1 year ago

Thank you so much, it is working :)

But it is stable (at university we call it above stable) , the indeterminate degree was 1 (7 - 6) and after adding 2 supports in Z direction it would be become 3 (9 - 6), i know that i can solve it, because i am solving 2D problem in 3D probem but why i should add that three support?

I am sorry for my question, it seems that i should learn more about 3D analysis and FEM

JWock82 commented 1 year ago

The model is 3D, so it needs to be stable in 3D, even though your problem is only dealing with loads in 2D.