Hotspot calculation demo¶
This notebook detects and classifies hotspots of the von Mises stress in a connected FEM mesh. Each element/node entry of the mesh receives a number of the hotspot it is member of. “0” means the element/node is not part of any hotspots. “1” means that the element/node is part of the hotspot with the highes peak, “2” the same for the second highest peak and so forth.
See module documentation further details.
[1]:
import numpy as np
import pylife
import pandas as pd
import scipy.stats as stats
import pylife.stress.equistress
import pylife.strength.meanstress
import pylife.mesh.hotspot
import pylife.vmap
import pyvista as pv
pv.set_plot_theme('document')
pv.set_jupyter_backend('ipygany')
[2]:
vm_mesh = pylife.vmap.VMAPImport("plate_with_hole.vmap")
pyLife_mesh = (vm_mesh.make_mesh('1', 'STATE-2')
.join_coordinates()
.join_variable('STRESS_CAUCHY')
.join_variable('DISPLACEMENT')
.to_frame())
Equivalent stress calculation¶
[3]:
pyLife_mesh['mises'] = pyLife_mesh.equistress.mises()
Hot spot Calculation¶
[4]:
threshold = .9 # factor of the maximum local value
pyLife_mesh['hotspot'] = pyLife_mesh.hotspot.calc("mises", threshold)
display(pyLife_mesh[['x', 'y', 'z', 'mises', 'hotspot']])
x | y | z | mises | hotspot | ||
---|---|---|---|---|---|---|
element_id | node_id | |||||
1 | 1734 | 14.897208 | 5.269875 | 0.0 | 33.996987 | 0 |
1582 | 14.555333 | 5.355806 | 0.0 | 33.399850 | 0 | |
1596 | 14.630658 | 4.908741 | 0.0 | 54.777007 | 0 | |
4923 | 14.726271 | 5.312840 | 0.0 | 33.446991 | 0 | |
4924 | 14.592996 | 5.132274 | 0.0 | 44.070962 | 0 | |
... | ... | ... | ... | ... | ... | ... |
4770 | 3812 | -13.189782 | -5.691876 | 0.0 | 43.577209 | 0 |
12418 | -13.560289 | -5.278386 | 0.0 | 39.903508 | 0 | |
14446 | -13.673285 | -5.569107 | 0.0 | 40.478974 | 0 | |
14614 | -13.389065 | -5.709927 | 0.0 | 42.140169 | 0 | |
14534 | -13.276068 | -5.419206 | 0.0 | 41.143837 | 0 |
37884 rows × 5 columns
[5]:
print("%d hotspots found over the threshold" % pyLife_mesh['hotspot'].max())
3 hotspots found over the threshold
[6]:
# plotting using pyvista
pyLife_nodes = pyLife_mesh[['x', 'y', 'z', 'hotspot']].groupby('node_id').mean()
mesh = pv.PolyData(pyLife_nodes[['x', 'y', 'z']].values)
mesh.point_arrays["hotspot"] = pyLife_nodes["hotspot"].values
mesh.plot(scalars="hotspot",log_scale = False, off_screen=True)
First hotspot¶
[7]:
display(pyLife_mesh[pyLife_mesh['hotspot'] == 1])
x | y | z | S11 | S22 | S33 | S12 | S13 | S23 | dx | dy | dz | mises | hotspot | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
element_id | node_id | ||||||||||||||
456 | 5 | 0.0 | 6.3 | 0.0 | 300.899658 | 30.574533 | 0.0 | -7.081042 | 0.0 | 0.0 | 1.365477e-35 | -0.005435 | 0.0 | 287.099222 | 1 |
[ ]: