-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibrary.py
More file actions
464 lines (390 loc) · 13.3 KB
/
library.py
File metadata and controls
464 lines (390 loc) · 13.3 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
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
# ===----------------------------------------------------------------------===//
#
# OpenSees - Open System for Earthquake Engineering Simulation
# Structural Artificial Intelligence Laboratory
# gallery.stairlab.io
#
# ===----------------------------------------------------------------------===//
"""
References
==========
Koohestani, K., and A. Kaveh.
“Efficient Buckling and Free Vibration Analysis of Cyclically Repeated Space Truss Structures.”
Finite Elements in Analysis and Design 46, no. 10 (October 2010): 943–48.
https://doi.org/10.1016/j.finel.2010.06.009.
"""
from math import pi, sin, cos, sqrt
import opensees.openseespy as ops
import xara
def create_dome(design: str, *args, **kwds):
return _DOMES[design](*args, **kwds)
def truss10(L, D):
E = 3000.0
A = 1.0
model = xara.Model(ndm=2, ndf=2)
model.uniaxialMaterial('Elastic', 1, E)
model.section("Truss", 1, area=A, material=1)
model.node(1, (2*L, D))
model.node(2, (2*L, 0))
model.node(3, ( L, D))
model.node(4, ( L, 0))
model.node(5, ( 0, D))
model.node(6, ( 0, 0))
model.fix(5, (1, 1))
model.fix(6, (1, 1))
model.element("Truss", 1, (5, 3), section=1)
model.element("Truss", 2, (3, 1), section=1)
model.element("Truss", 3, (6, 4), section=1)
model.element("Truss", 4, (4, 2), section=1)
# Vertical bracing
model.element("Truss", 5, (3, 4), section=1)
model.element("Truss", 6, (1, 2), section=1)
# Diagonal bracing
model.element("Truss", 7, (5, 4), section=1)
model.element("Truss", 8, (6, 3), section=1)
model.element("Truss", 9, (3, 2), section=1)
model.element("Truss", 10, (4, 1), section=1)
return model
def truss25(B, H, D, W):
"""
Wang, D., Cheng, F. & Jawad, F.K.J.
Layout optimization of truss structures by an improved Prairie Dog algorithm integrated with a monitored convergence curve.
Struct Multidisc Optim 67, 99 (2024).
https://doi.org/10.1007/s00158-024-03805-y
"""
E = 3000.0
A = 1.0
model = xara.Model(ndm=3, ndf=3)
model.uniaxialMaterial('Elastic', 1, E)
model.section("Truss", 1, area=A, material=1)
# Level 2
model.node( 1, (-D/2, 0.0, 2*H))
model.node( 2, ( D/2, 0.0, 2*H))
# Level 1
model.node( 3, (-D/2, W/2, H))
model.node( 4, ( D/2, W/2, H))
model.node( 5, ( D/2, -W/2, H))
model.node( 6, (-D/2, -W/2, H))
# Ground
model.node( 7, (-B/2, B/2, 0.0))
model.node( 8, ( B/2, B/2, 0.0))
model.node( 9, ( B/2, -B/2, 0.0))
model.node(10, (-B/2, -B/2, 0.0))
for node in 7, 8, 9, 10:
model.fix(node, (1, 1, 1))
# Top chord
model.element("Truss", 1, ( 1, 2), section=1)
# Level 2 Bracing
model.element("Truss", 2, ( 1, 4), section=1)
model.element("Truss", 3, ( 2, 3), section=1)
model.element("Truss", 4, ( 1, 5), section=1)
model.element("Truss", 5, ( 2, 6), section=1)
# Level 2 Legs
model.element("Truss", 6, ( 2, 4), section=1)
model.element("Truss", 7, ( 2, 5), section=1)
model.element("Truss", 8, ( 1, 3), section=1)
model.element("Truss", 9, ( 1, 6), section=1)
# Level 1 Chords
model.element("Truss", 10, ( 3, 6), section=1)
model.element("Truss", 11, ( 4, 5), section=1)
model.element("Truss", 12, ( 3, 4), section=1)
model.element("Truss", 13, ( 5, 6), section=1)
# Level 1 Bracing
model.element("Truss", 14, ( 3, 10), section=1)
model.element("Truss", 15, ( 7, 6), section=1)
model.element("Truss", 16, ( 4, 9), section=1)
model.element("Truss", 17, ( 5, 8), section=1)
model.element("Truss", 18, ( 4, 7), section=1)
model.element("Truss", 19, ( 3, 8), section=1)
model.element("Truss", 20, ( 5, 10), section=1)
model.element("Truss", 21, ( 6, 9), section=1)
# Level 1 Legs
model.element("Truss", 22, ( 6, 10), section=1)
model.element("Truss", 23, ( 3, 7), section=1)
model.element("Truss", 24, ( 5, 9), section=1)
model.element("Truss", 25, ( 4, 8), section=1)
return model
def dome52():
"""
References
==========
Degertekin, S.O., G. Yalcin Bayar, and L. Lamberti.
“Parameter Free Jaya Algorithm for Truss Sizing-Layout Optimization under Natural Frequency Constraints.”
Computers & Structures 245 (March 2021): 106461. https://doi.org/10.1016/j.compstruc.2020.106461.
"""
pass
def dome120():
"""
Create a segment of the 120-bar dome. Use with revolve() to generate
a full structural model as follows:
nodes, elems = revolve(*dome120())
References
==========
Lieu, Qui X., Dieu T. T. Do, and Jaehong Lee.
“An Adaptive Hybrid Evolutionary Firefly Algorithm for Shape and Size Optimization of Truss Structures with Frequency Constraints.”
Computers & Structures 195 (January 15, 2018): 99–112. https://doi.org/10.1016/j.compstruc.2017.06.016.
Kaveh, A., and M. Ilchi Ghazaan.
“Optimal Design of Dome Truss Structures with Dynamic Frequency Constraints.”
Structural and Multidisciplinary Optimization 53, no. 3 (March 1, 2016): 605–21. https://doi.org/10.1007/s00158-015-1357-2.
"""
# Number of repeated segments
s = 12
# Number of nodes per segment
n = 4
scale = 1/100
r1 = 273.26*scale
r2 = 492.12*scale
r = 625.59*scale
h = 275.59*scale
h1 = 196.85*scale
h2 = 118.11*scale
c2 = cos(pi/s)
s2 = sin(pi/s)
nodes = {
0: ( 0 , 0.0 , h ),
1: ( r1, 0.0 , h1),
2: ( r2, 0.0 , h2),
3: ( r , 0.0 , 0 ),
4: (r2*c2, r2*s2, h2),
}
elems = [
(0, 1),
(1, 2),
(2, 3),
(3, 4),
(2, 4),
(1, 4),
(1+n, 4),
(1+n, 1),
(3+n, 4),
(2+n, 4),
(1+n, 4)
]
return nodes, elems, {3}, s, {0}
def dome600():
"""
Create a segment of the 600-bar dome. Use with revolve() to generate
a full structural model as follows:
nodes, elems = revolve(*dome600())
References
==========
Kaveh, Ali, Kiarash Biabani Hamedani, and Bamdad Biabani Hamedani.
“Optimal Design of Large-Scale Dome Truss Structures with Multiple Frequency Constraints Using Success-History Based Adaptive Differential Evolution Algorithm.”
Periodica Polytechnica Civil Engineering, September 28, 2022. https://doi.org/10.3311/PPci.21147.
"""
# Number of repeated segments
s = 24
# Number of nodes per segment
n = 9
nodes = {
1: ( 1.0, 0.0, 7.0) ,
2: ( 1.0, 0.0, 7.5) ,
3: ( 3.0, 0.0, 7.25) ,
4: ( 5.0, 0.0, 6.75) ,
5: ( 7.0, 0.0, 6.0) ,
6: ( 9.0, 0.0, 5.0) ,
7: (11.0, 0.0, 3.5) ,
8: (13.0, 0.0, 1.5) ,
9: (14.0, 0.0, 0.0)
}
elems = [
(1, 2),
(1, 3),
(1, 1+n),
(1, 2+n),
(2, 3),
(2, 2+n),
(3, 2+n),
(3, 3+n),
(3, 4),
(4, 3+n),
(4, 4+n),
(4, 5),
(5, 4+n),
(5, 5+n),
(5, 6),
(6, 5+n),
(6, 6+n),
(6, 7),
(7, 6+n),
(7, 7+n),
(7, 8),
(8, 7+n),
(8, 8+n),
(8, 9),
(9, 8+n)
]
return nodes, elems, {9}, s, {}
def dome1180():
"""
Create a segment of the 1180-bar dome. Use with revolve() to generate
a full structural model as follows:
nodes, elems = revolve(*dome1180())
Kaveh, Ali, Kiarash Biabani Hamedani, and Bamdad Biabani Hamedani. “Optimal Design of Large-Scale Dome Truss Structures with Multiple Frequency Constraints Using Success-History Based Adaptive Differential Evolution Algorithm.” Periodica Polytechnica Civil Engineering, September 28, 2022. https://doi.org/10.3311/PPci.21147.
Kaveh, Ali, and M. Ilchi Ghazaan. “Optimal Design of Dome Truss Structures with Dynamic Frequency Constraints.” Structural and Multidisciplinary Optimization 53, no. 3 (March 1, 2016): 605–21. https://doi.org/10.1007/s00158-015-1357-2.
"""
s = 20
n = 20
nodes = {
1: ( 3.1181, 0.0 , 14.6723),
2: ( 6.1013, 0.0 , 13.7031),
3: ( 8.8166, 0.0 , 12.1354),
4: (11.1476, 0.0 , 10.0365),
5: (12.9904, 0.0 , 7.5000),
6: (14.2657, 0.0 , 4.6358),
7: (14.9179, 0.0 , 1.5676),
8: (14.9179, 0.0 , -1.5677),
9: (14.2656, 0.0 , -4.6359),
10: (12.9903, 0.0 , -7.5001),
11: ( 4.5788, 0.7252, 14.2657),
12: ( 7.4077, 1.1733, 12.9904),
13: ( 9.9130, 1.5701, 11.1476),
14: (11.9860, 1.8984, 8.8165),
15: (13.5344, 2.1436, 6.1013),
16: (14.4917, 2.2953, 3.1180),
17: (14.8153, 2.3465, 0.0),
18: (14.4917, 2.2953, -3.1181),
19: (13.5343, 2.1436, -6.1014),
20: ( 3.1181, 0.0 , 13.7031)
}
elems = [
(i, i+1) for i in range(1, 10)
] + [
(i, i+n) for i in range(1, 10)
] + [
(i, i+9) for i in range(2, 10)
] + [
(i, i+10) for i in range(2, 10)
] + [
(i+n, i+9) for i in range(2, 10)
] + [
(i+n, i+10) for i in range(2, 10)
]
return nodes, elems, {None}, s, {}
def dome1410():
"""
Create a segment of the 1410-bar dome. Use with revolve() to generate
a full structural model as follows:
nodes, elems = revolve(*dome1410())
Koohestani, K., and A. Kaveh.
“Efficient Buckling and Free Vibration Analysis of Cyclically Repeated Space Truss Structures.”
Finite Elements in Analysis and Design 46, no. 10 (October 2010): 943–48.
https://doi.org/10.1016/j.finel.2010.06.009.
"""
s = 30
n = 13
nodes = {
1: ( 1.0,0.0,4.0),
2: ( 3.0,0.0,3.75),
3: ( 5.0,0.0,3.25),
4: ( 7.0,0.0,2.75),
5: ( 9.0,0.0,2.0),
6: (11.0,0.0,1.25),
7: (13.0,0.0,0.0),
8: ( 1.989,0.209, 3.0),
9: ( 3.978,0.418,2.75),
10: ( 5.967,0.627,2.25),
11: ( 7.956,0.836,1.75),
12: ( 9.945,1.0453,1.0),
13: (11.934,1.2543,-0.5)
}
elems = [
( 1, 2),
( 2, 3),
( 3, 4),
( 4, 5),
( 5, 6),
( 6, 7),
( 8, 9),
( 9, 10),
(10, 11),
(11, 12),
(12, 13),
( 8+n, 8),
( 9+n, 9),
(10+n, 10),
(11+n, 11),
(12+n, 12),
(13+n, 13),
( 7, 13),
( 7+n, 13)
]
for i in range(2, 7):
elems.extend([(i , i+6),
(i , i+7),
(i+n, i+6),
(i+n, i+7)])
return nodes, elems, {None}, s, {}
_DOMES = {
"600": dome600,
"120": dome120,
"1410": dome1410,
"1180": dome1180
}
def revolve(ref_nodes, ref_elems, fixed, count, key_nodes=None, scale=1, shift=None):
"""
Create nodes and connectivity of a structure that is generated by revolving a
reference assembly idenfied by ref_nodes and ref_elems.
wr
"""
nodes = {}
elems = []
if key_nodes is None:
key_nodes = set()
nn = len(ref_nodes) - len(key_nodes)
for i in range(count):
angle = 2*pi*i/count
cs = cos(angle)
sn = sin(angle)
if 0 in ref_nodes:
node = ref_nodes[0]
nodes[0] = (cs*node[0] - sn*node[1],
sn*node[0] + cs*node[1],
node[2])
# Create nodes
for j,node in ref_nodes.items():
if j : # not in key_nodes:
nodes[j+i*nn] = (cs*node[0] - sn*node[1],
sn*node[0] + cs*node[1],
node[2])
for elem in ref_elems:
elems.append(tuple(
node if node in key_nodes else (node-1+i*nn)%(count*nn)+1 for node in elem
))
return nodes, elems
def create_truss(nodes, elems, area=1.0, modulus=3000, density=1.0):
"""
Create a truss model in OpenSees
"""
# Create a model in 3 dimensions with 3 degrees of freedom
model = ops.Model(ndm=3, ndf=3)
# Define a linear-elastic material
model.uniaxialMaterial('Elastic', 1, modulus)#, density=density)
# Add nodes to the model
for tag, node in nodes.items():
model.node(tag, node)
# Add elements to the model
for tag, nodes in enumerate(elems):
model.element("Truss", tag, nodes, area, 1)
return model
def create_builder(prototype):
if prototype == "dome120":
nodes, elems = revolve(*dome120())
elif prototype == "dome600":
nodes, elems = revolve(*dome600())
elif prototype == "dome1410":
nodes, elems = revolve(*dome1410())
elif prototype == "dome1180":
nodes, elems = revolve(*dome1180())
def build_truss(area, modulus):
return create_truss(nodes, elems, area, modulus)
return build_truss
if __name__ == "__main__":
import veux
nodes, elems = revolve(*dome120())
model = create_truss(nodes, elems)
artist = veux.create_artist(model, vertical=3)
artist.draw_outlines()
artist.draw_nodes()
# Show the rendering
veux.serve(artist)