Closed Martin15135215 closed 10 months ago
I forgot to add a support:
Now, the code is working without error.
import numpy as np
import calfem.core as cfc
# Topology matrix Edof
Edof = np.array([
[1,2,3,4,5,6], # Element 1
[1,2,3,7,8,9], # Element 2
[1,2,3,10,11,12], # Element 3
])
K = np.matrix(np.zeros((12,12)))
f = np.matrix(np.zeros((12,1)))
# Area and E-Modulus
E = 1000000.0 # E-Modulus kN/m²
A = 0.001 # Area m²
ep = [E,A]
#Element coordinates
ex1 = np.array([0., 0.]) # Element 1
ex2 = np.array([0., -4.]) # Element 2
ex3 = np.array([0., -4.]) # Element 3
ey1 = np.array([0., 0.]) # Element 1
ey2 = np.array([0., 0.]) # Element 2
ey3 = np.array([0., 0.]) # Element 3
ez1 = np.array([3., 0.]) # Element 1
ez2 = np.array([3., 3.]) # Element 2
ez3 = np.array([3., 6.]) # Element 3
# Element stiffness matrices
Ke1 = cfc.bar3e(ex1,ey1,ez1,ep)
Ke2 = cfc.bar3e(ex2,ey2,ez2,ep)
Ke3 = cfc.bar3e(ex3,ey3,ez3,ep)
# Assemble Ke into K
cfc.assem(Edof[0,:],K,Ke1)
cfc.assem(Edof[1,:],K,Ke2)
cfc.assem(Edof[2,:],K,Ke3)
# prescribed displacements in bc
bc = np.array([2, # has also a support
4,5,6,7,8,9,10,11,12])
f[1] = 100 # kN
f[2] = -100 # kN
a, r = cfc.solveq(K,f,bc)
This is my example truss:
This is the code:
When I run this, I get this error message:
My example truss is 2-dimensional, but I wanted to test bar3e whether it also works in 3 dimensions, and accordingly set all coordinates to zero on one axis.