-
Notifications
You must be signed in to change notification settings - Fork 14
/
section.py
499 lines (370 loc) · 11.1 KB
/
section.py
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from math import pi
# Author(s): Andrew Liew (github.com/andrewliew)
__all__ = [
'Section',
'AngleSection',
'BoxSection',
'CircularSection',
'GeneralSection',
'ISection',
'PipeSection',
'RectangularSection',
'ShellSection',
'MembraneSection',
'SolidSection',
'TrapezoidalSection',
'TrussSection',
'StrutSection',
'TieSection',
'SpringSection',
'MassSection'
]
class Section(object):
"""Initialises base Section object.
Parameters
----------
name : str
Section object name.
Attributes
----------
name : str
Section object name.
geometry : dict
Geometry of the Section.
"""
def __init__(self, name):
self.__name__ = 'Section'
self.name = name
self.geometry = {}
def __str__(self):
print('\n')
print('compas_fea {0} object'.format(self.__name__))
print('-' * (len(self.__name__) + 18))
print('name : {0}'.format(self.name))
for i, j in self.geometry.items():
print('{0:<5} : {1}'.format(i, j))
return ''
def __repr__(self):
return '{0}({1})'.format(self.__name__, self.name)
# ==============================================================================
# 1D
# ==============================================================================
class AngleSection(Section):
"""Uniform thickness angle cross-section for beam elements.
Parameters
----------
name : str
Section name.
b : float
Width.
h : float
Height.
t : float
Thickness.
Notes
-----
- Ixy not yet calculated.
"""
def __init__(self, name, b, h, t):
Section.__init__(self, name=name)
p = 2. * (b + h - t)
xc = (b**2 + h * t - t**2) / p
yc = (h**2 + b * t - t**2) / p
A = t * (b + h - t)
Ixx = (1. / 3) * (b * h**3 - (b - t) * (h - t)**3) - A * (h - yc)**2
Iyy = (1. / 3) * (h * b**3 - (h - t) * (b - t)**3) - A * (b - xc)**2
J = (1. / 3) * (h + b - t) * t**3
self.__name__ = 'AngleSection'
self.name = name
self.geometry = {'b': b, 'h': h, 't': t, 'A': A, 'J': J, 'Ixx': Ixx, 'Iyy': Iyy, 'Ixy': None}
class BoxSection(Section):
"""Hollow rectangular box cross-section for beam elements.
Parameters
----------
name : str
Section name.
b : float
Width.
h : float
Height.
tw : float
Web thickness.
tf : float
Flange thickness.
"""
def __init__(self, name, b, h, tw, tf):
Section.__init__(self, name=name)
A = b * h - (b - 2 * tw) * (h - 2 * tf)
Ap = (h - tf) * (b - tw)
Ixx = (b * h**3) / 12. - ((b - 2 * tw) * (h - 2 * tf)**3) / 12.
Iyy = (h * b**3) / 12. - ((h - 2 * tf) * (b - 2 * tw)**3) / 12.
p = 2 * ((h - tf) / tw + (b - tw) / tf)
J = 4 * (Ap**2) / p
self.__name__ = 'BoxSection'
self.name = name
self.geometry = {'b': b, 'h': h, 'tw': tw, 'tf': tf, 'A': A, 'J': J, 'Ixx': Ixx, 'Iyy': Iyy, 'Ixy': 0}
class CircularSection(Section):
"""Solid circular cross-section for beam elements.
Parameters
----------
name : str
Section name.
r : float
Radius.
"""
def __init__(self, name, r):
Section.__init__(self, name=name)
D = 2 * r
A = 0.25 * pi * D**2
Ixx = Iyy = (pi * D**4) / 64.
J = (pi * D**4) / 32
self.__name__ = 'CircularSection'
self.name = name
self.geometry = {'r': r, 'D': D, 'A': A, 'Ixx': Ixx, 'Iyy': Iyy, 'Ixy': 0, 'J': J}
class GeneralSection(Section):
"""General cross-section for beam elements.
Parameters
----------
name : str
Section name.
A : float
Area.
Ixx : float
Second moment of area about axis x-x.
Ixy : float
Cross moment of area.
Iyy : float
Second moment of area about axis y-y.
J : float
Torsional rigidity.
g0 : float
Sectorial moment.
gw : float
Warping constant.
"""
def __init__(self, name, A, Ixx, Ixy, Iyy, J, g0, gw):
Section.__init__(self, name=name)
self.__name__ = 'GeneralSection'
self.name = name
self.geometry = {'A': A, 'Ixx': Ixx, 'Ixy': Ixy, 'Iyy': Iyy, 'J': J, 'g0': g0, 'gw': gw}
class ISection(Section):
"""Equal flanged I-section for beam elements.
Parameters
----------
name : str
Section name.
b : float
Width.
h : float
Height.
tw : float
Web thickness.
tf : float
Flange thickness.
"""
def __init__(self, name, b, h, tw, tf):
Section.__init__(self, name=name)
A = 2 * b * tf + (h - 2 * tf) * tw
Ixx = (tw * (h - 2 * tf)**3) / 12. + 2 * ((tf**3) * b / 12. + b * tf * (h / 2. - tf / 2.)**2)
Iyy = ((h - 2 * tf) * tw**3) / 12. + 2 * ((b**3) * tf / 12.)
J = (1. / 3) * (2 * b * tf**3 + (h - tf) * tw**3)
self.__name__ = 'ISection'
self.name = name
self.geometry = {'b': b, 'h': h, 'tw': tw, 'tf': tf, 'c': h/2., 'A': A, 'J': J, 'Ixx': Ixx, 'Iyy': Iyy, 'Ixy': 0}
class PipeSection(Section):
"""Hollow circular cross-section for beam elements.
Parameters
----------
name : str
Section name.
r : float
Outer radius.
t : float
Wall thickness.
"""
def __init__(self, name, r, t):
Section.__init__(self, name=name)
D = 2 * r
A = 0.25 * pi * (D**2 - (D - 2 * t)**2)
Ixx = Iyy = 0.25 * pi * (r**4 - (r - t)**4)
J = (2. / 3) * pi * (r + 0.5 * t) * t**3
self.__name__ = 'PipeSection'
self.name = name
self.geometry = {'r': r, 't': t, 'D': D, 'A': A, 'J': J, 'Ixx': Ixx, 'Iyy': Iyy, 'Ixy': 0}
class RectangularSection(Section):
"""Solid rectangular cross-section for beam elements.
Parameters
----------
name : str
Section name.
b : float
Width.
h : float
Height.
"""
def __init__(self, name, b, h):
Section.__init__(self, name=name)
A = b * h
Ixx = (1 / 12.) * b * h**3
Iyy = (1 / 12.) * h * b**3
l1 = max([b, h])
l2 = min([b, h])
# Avy = 0.833 * A
# Avx = 0.833 * A
J = (l1 * l2**3) * (0.33333 - 0.21 * (l2 / l1) * (1 - (l2**4) / (12 * l1**4)))
self.__name__ = 'RectangularSection'
self.name = name
self.geometry = {'b': b, 'h': h, 'A': A, 'J': J, 'Ixx': Ixx, 'Iyy': Iyy, 'Ixy': 0}
class TrapezoidalSection(Section):
"""Solid trapezoidal cross-section for beam elements.
Parameters
----------
name : str
Section name.
b1 : float
Width at bottom.
b2 : float
Width at top.
h : float
Height.
Notes
-----
- J not yet calculated.
"""
def __init__(self, name, b1, b2, h):
Section.__init__(self, name=name)
c = (h * (2 * b2 + b1)) / (3. * (b1 + b2))
A = 0.5 * (b1 + b2) * h
Ixx = (1 / 12.) * (3 * b2 + b1) * h**3
Iyy = (1 / 48.) * h * (b1 + b2) * (b2**2 + 7 * b1**2)
self.__name__ = 'TrapezoidalSection'
self.name = name
self.geometry = {'b1': b1, 'b2': b2, 'h': h, 'A': A, 'c': c, 'Ixx': Ixx, 'Iyy': Iyy, 'Ixy': 0, 'J': None}
class TrussSection(Section):
"""For use with truss elements.
Parameters
----------
name : str
Section name.
A : float
Area.
"""
def __init__(self, name, A):
Section.__init__(self, name=name)
self.__name__ = 'TrussSection'
self.name = name
self.geometry = {'A': A, 'Ixx': 0, 'Iyy': 0, 'Ixy': 0, 'J': 0}
class StrutSection(TrussSection):
"""For use with strut elements.
Parameters
----------
name : str
Section name.
A : float
Area.
"""
def __init__(self, name, A):
TrussSection.__init__(self, name=name, A=A)
self.__name__ = 'StrutSection'
class TieSection(TrussSection):
"""For use with tie elements.
Parameters
----------
name : str
Section name.
A : float
Area.
"""
def __init__(self, name, A):
TrussSection.__init__(self, name=name, A=A)
self.__name__ = 'TieSection'
class SpringSection(Section):
"""For use with spring elements.
Parameters
----------
name : str
Section name.
forces : dict
Forces data for non-linear springs.
displacements : dict
Displacements data for non-linear springs.
stiffness : dict
Elastic stiffness for linear springs.
Notes
-----
- Force and displacement data should range from negative to positive values.
- Requires either a stiffness dict for linear springs, or forces and displacement lists for non-linear springs.
- Directions are 'axial', 'lateral', 'rotation'.
"""
def __init__(self, name, forces={}, displacements={}, stiffness={}):
Section.__init__(self, name=name)
self.__name__ = 'SpringSection'
self.name = name
self.geometry = None
self.forces = forces
self.displacements = displacements
self.stiffness = stiffness
# ==============================================================================
# 2D
# ==============================================================================
class ShellSection(Section):
"""Section for shell elements.
Parameters
----------
name : str
Section name.
t : float
Thickness.
"""
def __init__(self, name, t):
Section.__init__(self, name=name)
self.__name__ = 'ShellSection'
self.name = name
self.geometry = {'t': t}
class MembraneSection(Section):
"""Section for membrane elements.
Parameters
----------
name : str
Section name.
t : float
Thickness.
"""
def __init__(self, name, t):
Section.__init__(self, name=name)
self.__name__ = 'MembraneSection'
self.name = name
self.geometry = {'t': t}
# ==============================================================================
# 3D
# ==============================================================================
class SolidSection(Section):
"""Section for solid elements.
Parameters
----------
name : str
Section name.
"""
def __init__(self, name):
Section.__init__(self, name=name)
self.__name__ = 'SolidSection'
self.name = name
self.geometry = None
# ==============================================================================
# 0D
# ==============================================================================
class MassSection(Section):
"""Section for mass elements.
Parameters
----------
name : str
Section name.
"""
def __init__(self, name):
Section.__init__(self, name=name)
self.__name__ = 'MassSection'
self.name = name
self.geometry = None