-
Notifications
You must be signed in to change notification settings - Fork 14
/
step.py
319 lines (259 loc) · 8.43 KB
/
step.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
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
# Author(s): Andrew Liew (github.com/andrewliew), Tomas Mendez Echenagucia (github.com/tmsmendez)
__all__ = [
'Step',
'GeneralStep',
# 'HeatStep',
'ModalStep',
'HarmonicStep',
'BucklingStep',
'AcousticStep'
]
class Step(object):
"""Initialises base Step object.
Parameters
----------
name : str
Name of the Step object.
Attributes
----------
name : str
Name of the Step object.
"""
def __init__(self, name):
self.__name__ = 'StepObject'
self.name = name
self.attr_list = ['name']
def __str__(self):
print('\n')
print('compas_fea {0} object'.format(self.__name__))
print('-' * (len(self.__name__) + 10))
for attr in self.attr_list:
print('{0:<13} : {1}'.format(attr, getattr(self, attr)))
return ''
def __repr__(self):
return '{0}({1})'.format(self.__name__, self.name)
class GeneralStep(Step):
"""Initialises GeneralStep object for use in a static analysis.
Parameters
----------
name : str
Name of the GeneralStep.
increments : int
Number of step increments.
iterations : int
Number of step iterations.
tolerance : float
A tolerance for analysis solvers.
factor : float, dict
Proportionality factor(s) on the loads and displacements.
nlgeom : bool
Analyse non-linear geometry effects.
nlmat : bool
Analyse non-linear material effects.
displacements : list
Displacement object names.
loads : list
Load object names.
type : str
'static','static,riks'.
modify : bool
Modify the previously added loads.
"""
def __init__(self, name, increments=100, iterations=100, tolerance=0.01, factor=1.0, nlgeom=True, nlmat=True, displacements=None, loads=None, type='static', modify=True):
Step.__init__(self, name=name)
if not displacements:
displacements = []
if not loads:
loads = []
self.__name__ = 'GeneralStep'
self.name = name
self.increments = increments
self.iterations = iterations
self.tolerance = tolerance
self.factor = factor
self.nlgeom = nlgeom
self.nlmat = nlmat
self.displacements = displacements
self.loads = loads
self.modify = modify
self.type = type
self.attr_list.extend(['increments', 'iterations', 'factor', 'nlgeom', 'nlmat', 'displacements', 'loads',
'type', 'tolerance', 'modify'])
class HeatStep(Step):
"""Initialises HeatStep object for use in a thermal analysis.
Parameters
----------
name : str
Name of the HeatStep.
interaction : str
Name of the HeatTransfer interaction.
increments : int
Number of step increments.
temp0 : float
Initial temperature of all nodes.
dTmax : float
Maximum temperature increase per increment.
type : str
'heat transfer'.
duration : float
Duration of step.
"""
def __init__(self, name, interaction, increments=100, temp0=20, dTmax=1, type='heat transfer', duration=1):
Step.__init__(self, name=name)
self.__name__ = 'HeatStep'
self.name = name
self.interaction = interaction
self.increments = increments
self.temp0 = temp0
self.dTmax = dTmax
self.type = type
self.duration = duration
self.attr_list.extend(['interaction', 'increments', 'temp0', 'dTmax', 'type', 'duration'])
class ModalStep(Step):
"""Initialises ModalStep object for use in a modal analysis.
Parameters
----------
name : str
Name of the ModalStep.
modes : int
Number of modes to analyse.
increments : int
Number of increments.
displacements : list
Displacement object names.
type : str
'modal'.
"""
def __init__(self, name, modes=10, increments=100, displacements=None, type='modal'):
Step.__init__(self, name=name)
if not displacements:
displacements = []
self.__name__ = 'ModalStep'
self.name = name
self.modes = modes
self.increments = increments
self.displacements = displacements
self.type = type
self.attr_list.extend(['modes', 'increments', 'displacements', 'type'])
class HarmonicStep(Step):
"""Initialises HarmonicStep object for use in a harmonic analysis.
Parameters
----------
name : str
Name of the HarmonicStep.
freq_list : list
Sorted list of frequencies to analyse.
displacements : list
Displacement object names.
loads : list
Load object names.
factor : float
Proportionality factor on the loads and displacements.
damping : float
Constant harmonic damping ratio.
type : str
'harmonic'.
"""
def __init__(self, name, freq_list, displacements=None, loads=None, factor=1.0, damping=None, type='harmonic'):
Step.__init__(self, name=name)
if not displacements:
displacements = []
if not loads:
loads = []
self.__name__ = 'HarmonicStep'
self.name = name
self.freq_list = freq_list
self.displacements = displacements
self.loads = loads
self.factor = factor
self.damping = damping
self.type = type
self.attr_list.extend(['freq_list', 'displacements', 'loads', 'factor', 'damping', 'type'])
class BucklingStep(Step):
"""Initialises BucklingStep object for use in a buckling analysis.
Parameters
----------
name : str
Name of the BucklingStep.
modes : int
Number of modes to analyse.
increments : int
Number of increments.
factor : float, dict
Proportionality factor on the loads and displacements.
displacements : list
Displacement object names.
loads : list
Load object names.
type : str
'buckle'.
step : str
Step to copy loads and displacements from.
"""
def __init__(self, name, modes=5, increments=100, factor=1., displacements=None, loads=None, type='buckle',
step=None):
Step.__init__(self, name=name)
if not displacements:
displacements = []
if not loads:
loads = []
self.__name__ = 'BucklingStep'
self.name = name
self.modes = modes
self.increments = increments
self.factor = factor
self.displacements = displacements
self.loads = loads
self.type = type
self.step = step
self.attr_list.extend(['modes', 'increments', 'factor', 'displacements', 'loads', 'type', 'step'])
class AcousticStep(Step):
"""Initialises AcousticStep object for use in a acoustic analysis.
Parameters
----------
name : str
Name of the AcousticStep.
freq_range : list
Range of frequencies to analyse.
freq_step : int
Step size for frequency range.
displacements : list
Displacement object names.
loads : list
Load object names.
sources : list
List of source elements or element sets radiating sound.
samples : int
Number of samples for acoustic analysis.
factor : float
Proportionality factor on the loads and displacements.
damping : float
Constant harmonic damping ratio.
type : str
'acoustic'.
"""
def __init__(self, name, freq_range, freq_step, displacements=None, loads=None, sources=None, samples=5,
factor=1.0, damping=None, type='acoustic'):
Step.__init__(self, name=name)
if not displacements:
displacements = []
if not loads:
loads = []
if not sources:
sources = []
self.__name__ = 'AcousticStep'
self.name = name
self.freq_range = freq_range
self.freq_step = freq_step
self.displacements = displacements
self.sources = sources
self.samples = samples
self.loads = loads
self.factor = factor
self.damping = damping
self.type = type
self.attr_list.extend(['freq_range', 'freq_step', 'displacements', 'sources', 'samples', 'loads', 'factor',
'damping', 'type'])