Repository navigation
Expand file tree
/
Copy pathTruss.py
More file actions
72 lines (57 loc) · 1.44 KB
/
Copy pathTruss.py
File metadata and controls
72 lines (57 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from StructPy import structural_classes as sc
from StructPy import cross_sections as xs
from StructPy import materials as ma
import numpy as np
import logging
class TrussNode(sc.Node):
DoFNames = ['x', 'y']
fixities = { # x, y
'free' : (1.0, 1.0),
'pin' : (0.0, 0.0),
'roller' : (1.0, 0.0),
'yroller': (0.0, 1.0),
}
@property
def deformation_dict(self):
return {
'x': self.deformation[0],
'y': self.deformation[1]
}
class TrussMember(sc.Member):
"""
Define Truss Member class. Only allows axial loading.
"""
nDoFPerNode = 2
@property
def k(self):
"""Local member stiffness matrix"""
a = (self.cross.A * self.material.E)/self.length
return a * np.array([
[1, -1],
[-1, 1]
])
@property
def T(self):
"""Local to global transformation matrix"""
l = self.unVec[0]
m = self.unVec[1]
return np.array([
[l, m, 0, 0],
[0, 0, l, m]
])
@property
def axial(self):
l = self.unVec[0]
m = self.unVec[1]
A = self.cross.A
E = self.material.E
L = self.length
deformation = self.SN.deformation + self.EN.deformation
return (A*E)/L * np.array([l, m, -l, -m]) @ np.array(deformation).T
class Truss(sc.Structure, sc.Planar):
"""This class builds on the structure class adding truss methods"""
#Number of degrees of freedom for this structure type in the global coordinate system
whatDoF = ['x', 'y']
nDoFPerNode = len(whatDoF)
MemberType = TrussMember
NodeType = TrussNode