engforge 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. engforge/__init__.py +26 -0
  2. engforge/_testing_components.py +864 -0
  3. engforge/analysis.py +257 -0
  4. engforge/attr_dynamics.py +222 -0
  5. engforge/attr_plotting.py +811 -0
  6. engforge/attr_signals.py +116 -0
  7. engforge/attr_slots.py +211 -0
  8. engforge/attr_solver.py +443 -0
  9. engforge/attributes.py +326 -0
  10. engforge/common.py +76 -0
  11. engforge/component_collections.py +276 -0
  12. engforge/components.py +55 -0
  13. engforge/configuration.py +673 -0
  14. engforge/dataframe.py +185 -0
  15. engforge/datastores/__init__.py +116 -0
  16. engforge/datastores/data.py +519 -0
  17. engforge/datastores/gdocs.py +2650 -0
  18. engforge/datastores/reporting.py +935 -0
  19. engforge/datastores/secrets.py +549 -0
  20. engforge/dynamics.py +662 -0
  21. engforge/eng/__init__.py +0 -0
  22. engforge/eng/costs.py +1459 -0
  23. engforge/eng/fluid_material.py +279 -0
  24. engforge/eng/geometry.py +1060 -0
  25. engforge/eng/pipes.py +1211 -0
  26. engforge/eng/prediction.py +366 -0
  27. engforge/eng/solid_materials.py +445 -0
  28. engforge/eng/structure.py +2228 -0
  29. engforge/eng/structure_beams.py +821 -0
  30. engforge/eng/thermodynamics.py +271 -0
  31. engforge/engforge_attributes.py +380 -0
  32. engforge/env_var.py +214 -0
  33. engforge/locations.py +18 -0
  34. engforge/logging.py +290 -0
  35. engforge/patterns.py +449 -0
  36. engforge/problem_context.py +2251 -0
  37. engforge/properties.py +501 -0
  38. engforge/reporting.py +595 -0
  39. engforge/solveable.py +964 -0
  40. engforge/solver.py +316 -0
  41. engforge/solver_utils.py +726 -0
  42. engforge/system.py +143 -0
  43. engforge/system_reference.py +299 -0
  44. engforge/tabulation.py +288 -0
  45. engforge/test/__init__.py +2 -0
  46. engforge/test/_pre_test_structures.py +221 -0
  47. engforge/test/report_testing.py +158 -0
  48. engforge/test/test_airfilter.py +91 -0
  49. engforge/test/test_analysis.py +3 -0
  50. engforge/test/test_comp_iter.py +196 -0
  51. engforge/test/test_composition.py +139 -0
  52. engforge/test/test_costs.py +338 -0
  53. engforge/test/test_dynamics.py +109 -0
  54. engforge/test/test_dynamics_spaces.py +39 -0
  55. engforge/test/test_four_bar.py +97 -0
  56. engforge/test/test_modules.py +72 -0
  57. engforge/test/test_performance.py +93 -0
  58. engforge/test/test_pipes.py +49 -0
  59. engforge/test/test_problem.py +411 -0
  60. engforge/test/test_problem_deepscoping.py +68 -0
  61. engforge/test/test_slider_crank.py +51 -0
  62. engforge/test/test_solver.py +343 -0
  63. engforge/test/test_tabulation.py +233 -0
  64. engforge/typing.py +92 -0
  65. engforge-0.3.0.dist-info/METADATA +392 -0
  66. engforge-0.3.0.dist-info/RECORD +69 -0
  67. engforge-0.3.0.dist-info/WHEEL +5 -0
  68. engforge-0.3.0.dist-info/licenses/LICENSE +7 -0
  69. engforge-0.3.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,445 @@
1
+ from engforge.configuration import Configuration, forge
2
+ from engforge.properties import *
3
+ from engforge.common import *
4
+ import matplotlib
5
+ import random
6
+ import attr
7
+ import numpy
8
+ import inspect
9
+ import sys
10
+ import uuid
11
+ import json, hashlib
12
+
13
+ # One Material To Merge Them All
14
+ from Pynite import Material as PyniteMat
15
+ from sectionproperties.pre.pre import Material as SecMat
16
+
17
+ SectionMaterial = SecMat.mro()[0]
18
+
19
+ ALL_MATERIALS = []
20
+ METALS = []
21
+ PLASTICS = []
22
+ CERAMICS = []
23
+
24
+
25
+ CMAP = matplotlib.cm.get_cmap("viridis")
26
+
27
+
28
+ def random_color():
29
+ return CMAP(random.randint(0, 255))
30
+
31
+
32
+ def ih(val):
33
+ """ignore hash"""
34
+ return ""
35
+
36
+
37
+ @forge(hash=False)
38
+ class SolidMaterial(SectionMaterial, PyniteMat.Material, Configuration):
39
+ """A class to hold physical properties of solid structural materials and act as both a section property material and a pynite material"""
40
+
41
+ __metaclass__ = SecMat
42
+
43
+ name: str = attr.ib(default="solid material")
44
+ color: tuple = attr.ib(factory=random_color, hash=False, eq=ih)
45
+
46
+ # Structural Properties
47
+ density: float = attr.ib(default=1.0)
48
+ elastic_modulus: float = attr.ib(default=1e8) # Pa
49
+ in_shear_modulus: float = attr.ib(default=None)
50
+ yield_strength: float = attr.ib(default=1e6) # Pa
51
+ tensile_strength_ultimate: float = attr.ib(default=2e6) # Pa
52
+ hardness: float = attr.ib(default=10) # rockwell
53
+ izod: float = attr.ib(default=100)
54
+ poissons_ratio: float = attr.ib(default=0.30)
55
+
56
+ # Thermal Properties
57
+ melting_point: float = attr.ib(default=1000 + 273) # K
58
+ maxium_service_temp: float = attr.ib(default=500 + 273) # K
59
+ thermal_conductivity: float = attr.ib(default=10) # W/mK
60
+ specific_heat: float = attr.ib(default=1000) # J/kgK
61
+ thermal_expansion: float = attr.ib(default=10e-6) # m/mK
62
+
63
+ # Electrical Properties
64
+ electrical_resistitivity: float = attr.ib(default=1e-8) # ohm-m
65
+
66
+ # Economic Properties
67
+ cost_per_kg: float = attr.ib(default=1.0) # dollar per kg
68
+
69
+ # Saftey Properties
70
+ factor_of_saftey: float = attr.ib(default=1.5)
71
+
72
+ _unique_id: str = None
73
+
74
+ @classmethod
75
+ def pre_compile(cls):
76
+ cls.color = random_color()
77
+
78
+ @property
79
+ def E(self) -> float:
80
+ return self.elastic_modulus
81
+
82
+ @property
83
+ def G(self) -> float:
84
+ return self.shear_modulus
85
+
86
+ @property
87
+ def nu(self) -> float:
88
+ return self.poissons_ratio
89
+
90
+ @property
91
+ def rho(self) -> float:
92
+ return self.density
93
+
94
+ @property
95
+ def shear_modulus(self) -> float:
96
+ """Shear Modulus"""
97
+ if self.in_shear_modulus:
98
+ return self.in_shear_modulus
99
+ # hello defaults
100
+ return self.E / (2.0 * (1 + self.poissons_ratio))
101
+
102
+ @property
103
+ def yield_stress(self) -> float:
104
+ return self.yield_strength
105
+
106
+ @property
107
+ def ultimate_stress(self) -> float:
108
+ return self.tensile_strength_ultimate
109
+
110
+ @inst_vectorize
111
+ def von_mises_stress_max(self, normal_stress, shear_stress):
112
+ a = normal_stress / 2.0
113
+ b = numpy.sqrt(a**2.0 + shear_stress**2.0)
114
+ v1 = a - b
115
+ v2 = a + b
116
+ vout = v1 if abs(v1) > abs(v2) else v2
117
+ return vout
118
+
119
+ @property
120
+ def allowable_stress(self) -> float:
121
+ return self.yield_stress / self.factor_of_saftey
122
+
123
+ @property
124
+ def unique_id(self):
125
+ if self._unique_id is None:
126
+ uid = str(uuid.uuid4())
127
+ self._unique_id = f"{self.name}_{uid}"
128
+ return self._unique_id
129
+
130
+ def __hash__(self):
131
+ """a stable hash that ignores name, color and unique id, ie only the material properties are the same if two hashes are the equal"""
132
+ # print('hashing...')
133
+ ignore = ["color", "_unique_id", "name"]
134
+ ict = {k: v for k, v in self.input_as_dict.items() if k not in ignore}
135
+ d = hashlib.sha1(json.dumps(ict, sort_keys=True).encode())
136
+ return int(d.hexdigest(), 16)
137
+
138
+
139
+ @forge(hash=False)
140
+ class SS_316(SolidMaterial):
141
+ name: str = attr.ib(default="stainless steel 316")
142
+
143
+ # Structural Properties
144
+ density: float = attr.ib(default=8000.0) # kg/m3
145
+ elastic_modulus: float = attr.ib(default=193e9) # Pa
146
+ yield_strength: float = attr.ib(default=240e6) # Pa
147
+ tensile_strength_ultimate: float = attr.ib(default=550e6) # Pa
148
+ poissons_ratio: float = attr.ib(default=0.30)
149
+
150
+ # Thermal Properties
151
+ melting_point: float = attr.ib(default=1370 + 273) # K
152
+ maxium_service_temp: float = attr.ib(default=870 + 273) # K
153
+ thermal_conductivity: float = attr.ib(default=16.3) # W/mK
154
+ specific_heat: float = attr.ib(default=500) # J/kgK
155
+ thermal_expansion: float = attr.ib(default=16e-6) # m/mK
156
+
157
+ # Electrical Properties
158
+ electrical_resistitivity: float = attr.ib(default=7.4e-7) # ohm-m
159
+
160
+ # Economic Properties
161
+ cost_per_kg: float = attr.ib(default=3.26) # dollar per kg
162
+
163
+
164
+ @forge(hash=False)
165
+ class ANSI_4130(SolidMaterial):
166
+ name: str = attr.ib(default="steel 4130")
167
+
168
+ # Structural Properties
169
+ density: float = attr.ib(default=7872.0) # kg/m3
170
+ elastic_modulus: float = attr.ib(default=205e9) # Pa
171
+ yield_strength: float = attr.ib(default=460e6) # Pa
172
+ tensile_strength_ultimate: float = attr.ib(default=560e6) # Pa
173
+ poissons_ratio: float = attr.ib(default=0.28)
174
+
175
+ # Thermal Properties
176
+ melting_point: float = attr.ib(default=1432 + 273) # K
177
+ maxium_service_temp: float = attr.ib(default=870 + 273) # K
178
+ thermal_conductivity: float = attr.ib(default=42.7) # W/mK
179
+ specific_heat: float = attr.ib(default=477) # J/kgK
180
+ thermal_expansion: float = attr.ib(default=11.2e-6) # m/mK
181
+
182
+ # Electrical Properties
183
+ electrical_resistitivity: float = attr.ib(default=2.23e-7) # ohm-m
184
+
185
+ # Economic Properties
186
+ cost_per_kg: float = attr.ib(default=2.92) # dollar per kg
187
+
188
+
189
+ @forge(hash=False)
190
+ class ANSI_4340(SolidMaterial):
191
+ name: str = attr.ib(default="steel 4340")
192
+
193
+ # Structural Properties
194
+ density: float = attr.ib(default=7872.0) # kg/m3
195
+ elastic_modulus: float = attr.ib(default=192e9) # Pa
196
+ yield_strength: float = attr.ib(default=470e6) # Pa
197
+ tensile_strength_ultimate: float = attr.ib(default=745e6) # Pa
198
+ poissons_ratio: float = attr.ib(default=0.28)
199
+
200
+ # Thermal Properties
201
+ melting_point: float = attr.ib(default=1427 + 273) # K
202
+ maxium_service_temp: float = attr.ib(default=830 + 273) # K
203
+ thermal_conductivity: float = attr.ib(default=44.5) # W/mK
204
+ specific_heat: float = attr.ib(default=475) # J/kgK
205
+ thermal_expansion: float = attr.ib(default=13.7e-6) # m/mK
206
+
207
+ # Electrical Properties
208
+ electrical_resistitivity: float = attr.ib(default=2.48e-7) # ohm-m
209
+
210
+ # Economic Properties
211
+ cost_per_kg: float = attr.ib(default=2.23) # dollar per kg
212
+
213
+
214
+ @forge(hash=False)
215
+ class Aluminum(SolidMaterial):
216
+ name: str = attr.ib(default="aluminum generic")
217
+
218
+ # Structural Properties
219
+ density: float = attr.ib(default=2680.0) # kg/m3
220
+ elastic_modulus: float = attr.ib(default=70.3e9) # Pa
221
+ yield_strength: float = attr.ib(default=240e6) # Pa
222
+ tensile_strength_ultimate: float = attr.ib(default=290e6) # Pa
223
+ poissons_ratio: float = attr.ib(default=0.33)
224
+
225
+ # Thermal Properties
226
+ melting_point: float = attr.ib(default=607 + 273) # K
227
+ maxium_service_temp: float = attr.ib(default=343 + 273) # K
228
+ thermal_conductivity: float = attr.ib(default=138) # W/mK
229
+ specific_heat: float = attr.ib(default=880) # J/kgK
230
+ thermal_expansion: float = attr.ib(default=22.1e-6) # m/mK
231
+
232
+ # Electrical Properties
233
+ electrical_resistitivity: float = attr.ib(default=4.99e-7) # ohm-m
234
+
235
+ # Economic Properties
236
+ cost_per_kg: float = attr.ib(default=1.90) # dollar per kg
237
+
238
+
239
+ @forge(hash=False)
240
+ class CarbonFiber(SolidMaterial):
241
+ name: str = attr.ib(default="carbon fiber")
242
+
243
+ # Structural Properties
244
+ density: float = attr.ib(default=1600.0) # kg/m3
245
+ elastic_modulus: float = attr.ib(default=140e9) # Pa
246
+ yield_strength: float = attr.ib(default=686e6) # Pa
247
+ tensile_strength_ultimate: float = attr.ib(default=919e6) # Pa
248
+ poissons_ratio: float = attr.ib(default=0.33)
249
+
250
+ # Thermal Properties
251
+ melting_point: float = attr.ib(default=300 + 273) # K
252
+ maxium_service_temp: float = attr.ib(default=150 + 273) # K
253
+ thermal_conductivity: float = attr.ib(default=250) # W/mK
254
+ specific_heat: float = attr.ib(default=1100) # J/kgK
255
+ thermal_expansion: float = attr.ib(default=14.1e-6) # m/mK
256
+
257
+ # Electrical Properties
258
+ electrical_resistitivity: float = attr.ib(default=10000) # ohm-m
259
+
260
+ # Economic Properties
261
+ cost_per_kg: float = attr.ib(default=1.90) # dollar per kg
262
+
263
+
264
+ @forge(hash=False)
265
+ class Concrete(SolidMaterial):
266
+ name: str = attr.ib(default="concrete")
267
+
268
+ # Structural Properties
269
+ density: float = attr.ib(default=2000.0) # kg/m3
270
+ elastic_modulus: float = attr.ib(default=2.92e9) # Pa
271
+ yield_strength: float = attr.ib(default=57.9e6) # Pa
272
+ tensile_strength_ultimate: float = attr.ib(default=0.910e6) # Pa
273
+ poissons_ratio: float = attr.ib(default=0.26)
274
+
275
+ # Thermal Properties
276
+ melting_point: float = attr.ib(default=3000 + 273) # K
277
+ maxium_service_temp: float = attr.ib(default=3000 + 273) # K
278
+ thermal_conductivity: float = attr.ib(default=0.5) # W/mK
279
+ specific_heat: float = attr.ib(default=736) # J/kgK
280
+ thermal_expansion: float = attr.ib(default=16.41e-6) # m/mK
281
+
282
+ # Electrical Properties
283
+ electrical_resistitivity: float = attr.ib(default=1e6) # ohm-m
284
+
285
+ # Economic Properties
286
+ cost_per_kg: float = attr.ib(default=95.44 / 1000.0) # dollar per kg
287
+
288
+
289
+ @forge(hash=False)
290
+ class DrySoil(SolidMaterial):
291
+ name: str = attr.ib(default="dry soil")
292
+
293
+ # Structural Properties
294
+ density: float = attr.ib(default=1600.0) # kg/m3
295
+ elastic_modulus: float = attr.ib(default=70.3e9) # Pa
296
+ yield_strength: float = attr.ib(default=0.0) # Pa
297
+ tensile_strength_ultimate: float = attr.ib(default=0.0) # Pa
298
+ poissons_ratio: float = attr.ib(default=0.33)
299
+
300
+ # Thermal Properties
301
+ melting_point: float = attr.ib(default=1550 + 273) # K
302
+ maxium_service_temp: float = attr.ib(default=1450 + 273) # K
303
+ thermal_conductivity: float = attr.ib(default=0.25) # W/mK
304
+ specific_heat: float = attr.ib(default=800) # J/kgK
305
+ thermal_expansion: float = attr.ib(default=16.41e-6) # m/mK
306
+
307
+ # Electrical Properties
308
+ electrical_resistitivity: float = attr.ib(default=1e6) # ohm-m
309
+
310
+ # Economic Properties
311
+ cost_per_kg: float = attr.ib(default=44.78 / 1000.0) # dollar per kg
312
+
313
+
314
+ @forge(hash=False)
315
+ class WetSoil(SolidMaterial):
316
+ name: str = attr.ib(default="wet soil")
317
+
318
+ # Structural Properties
319
+ density: float = attr.ib(default=2080.0) # kg/m3
320
+ elastic_modulus: float = attr.ib(default=70.3e9) # Pa
321
+ yield_strength: float = attr.ib(default=0.0) # Pa
322
+ tensile_strength_ultimate: float = attr.ib(default=0.0) # Pa
323
+ poissons_ratio: float = attr.ib(default=0.33)
324
+
325
+ # Thermal Properties
326
+ melting_point: float = attr.ib(default=1550 + 273) # K
327
+ maxium_service_temp: float = attr.ib(default=1450 + 273) # K
328
+ thermal_conductivity: float = attr.ib(default=2.75) # W/mK
329
+ specific_heat: float = attr.ib(default=1632) # J/kgK
330
+ thermal_expansion: float = attr.ib(default=16.41e-6) # m/mK
331
+
332
+ # Electrical Properties
333
+ electrical_resistitivity: float = attr.ib(default=940.0) # ohm-m
334
+
335
+ # Economic Properties
336
+ cost_per_kg: float = attr.ib(default=34.44 / 1000.0) # dollar per kg
337
+
338
+
339
+ @forge(hash=False)
340
+ class Rock(SolidMaterial):
341
+ name: str = attr.ib(default="wet soil")
342
+
343
+ # Structural Properties
344
+ density: float = attr.ib(default=2600.0) # kg/m3
345
+ elastic_modulus: float = attr.ib(default=67e9) # Pa
346
+ yield_strength: float = attr.ib(default=13e6) # Pa
347
+ tensile_strength_ultimate: float = attr.ib(default=13e6) # Pa
348
+ poissons_ratio: float = attr.ib(default=0.26)
349
+
350
+ # Thermal Properties
351
+ melting_point: float = attr.ib(default=3000) # K
352
+ maxium_service_temp: float = attr.ib(default=3000) # K
353
+ thermal_conductivity: float = attr.ib(default=1.0) # W/mK
354
+ specific_heat: float = attr.ib(default=2000) # J/kgK
355
+ thermal_expansion: float = attr.ib(default=16.41e-6) # m/mK
356
+
357
+ # Electrical Properties
358
+ electrical_resistitivity: float = attr.ib(default=1e6) # ohm-m
359
+
360
+ # Economic Properties
361
+ cost_per_kg: float = attr.ib(default=50.44 / 1000.0) # dollar per kg
362
+
363
+
364
+ @forge(hash=False)
365
+ class Rubber(SolidMaterial):
366
+ name: str = attr.ib(default="rubber")
367
+
368
+ # Structural Properties
369
+ density: float = attr.ib(default=1100.0) # kg/m3
370
+ elastic_modulus: float = attr.ib(default=0.1e9) # Pa
371
+ yield_strength: float = attr.ib(default=0.248e6) # Pa
372
+ tensile_strength_ultimate: float = attr.ib(default=0.5e6) # Pa
373
+ poissons_ratio: float = attr.ib(default=0.33)
374
+
375
+ # Thermal Properties
376
+ melting_point: float = attr.ib(default=600 + 273) # K
377
+ maxium_service_temp: float = attr.ib(default=300 + 273) # K
378
+ thermal_conductivity: float = attr.ib(default=0.108) # W/mK
379
+ specific_heat: float = attr.ib(default=2005) # J/kgK
380
+ thermal_expansion: float = attr.ib(default=100e-6) # m/mK
381
+
382
+ # Electrical Properties
383
+ electrical_resistitivity: float = attr.ib(default=1e13) # ohm-m
384
+
385
+ # Economic Properties
386
+ cost_per_kg: float = attr.ib(default=40.0 / 1000.0) # dollar per kg
387
+
388
+
389
+ # @attr.s
390
+ # class AL_6063(SolidMaterial):
391
+ # name:str = attr.ib(default='aluminum 6063')
392
+
393
+ # #Structural Properties
394
+ # density:float = attr.ib(default=2700.0) #kg/m3
395
+ # elastic_modulus:float = attr.ib(default=192E9) #Pa
396
+ # tensile_strength_yield = attr.ib(default=470E6) #Pa
397
+ # tensile_strength_ultimate:float = attr.ib(default=745E6) #Pa
398
+ # poissons_ratio:float = attr.ib(default=0.28)
399
+
400
+ # #Thermal Properties
401
+ # melting_point:float = attr.ib(default=1427+273) #K
402
+ # maxium_service_temp:float = attr.ib(default=830+273) #K
403
+ # thermal_conductivity:float = attr.ib(default=44.5) #W/mK
404
+ # specific_heat:float = attr.ib(default=475) #J/kgK
405
+ # thermal_expansion:float = attr.ib(default = 13.7E-6) #m/mK
406
+
407
+ # #Electrical Properties
408
+ # electrical_resistitivity:float = attr.ib(default=2.48E-7) #ohm-m
409
+
410
+ # #Economic Properties
411
+ # cost_per_kg:float = attr.ib(default=1.90) #dollar per kg
412
+
413
+
414
+ # @attr.s
415
+ # class AL_7075(SolidMaterial):
416
+ # name:str = attr.ib(default='aluminum 7075')
417
+
418
+ # #Structural Properties
419
+ # density:float = attr.ib(default=2700.0) #kg/m3
420
+ # elastic_modulus:float = attr.ib(default=192E9) #Pa
421
+ # tensile_strength_yield = attr.ib(default=470E6) #Pa
422
+ # tensile_strength_ultimate:float = attr.ib(default=745E6) #Pa
423
+ # poissons_ratio:float = attr.ib(default=0.28)
424
+
425
+ # #Thermal Properties
426
+ # melting_point:float = attr.ib(default=1427+273) #K
427
+ # maxium_service_temp:float = attr.ib(default=830+273) #K
428
+ # thermal_conductivity:float = attr.ib(default=44.5) #W/mK
429
+ # specific_heat:float = attr.ib(default=475) #J/kgK
430
+ # thermal_expansion:float = attr.ib(default = 13.7E-6) #m/mK
431
+
432
+ # #Electrical Properties
433
+ # electrical_resistitivity:float = attr.ib(default=2.48E-7) #ohm-m
434
+
435
+ # #Economic Properties
436
+ # cost_per_kg:float = attr.ib(default=1.90) #dollar per kg
437
+
438
+
439
+ ALL_MATERIALS = [
440
+ mat
441
+ for name, mat in inspect.getmembers(sys.modules[__name__])
442
+ if inspect.isclass(mat)
443
+ and issubclass(mat, SolidMaterial)
444
+ and mat is not SolidMaterial
445
+ ]