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.meshsignal
import pylife.mesh.hotspot
import pylife.vmap
import pyvista as pv
pv.set_plot_theme('document')
pv.set_jupyter_backend('panel')
[2]:
vm_mesh = pylife.vmap.VMAPImport("plate_with_hole.vmap")
mesh = (vm_mesh.make_mesh('1', 'STATE-2')
.join_coordinates()
.join_variable('STRESS_CAUCHY')
.join_variable('DISPLACEMENT')
.to_frame())
Equivalent stress calculation¶
[3]:
mesh['mises'] = mesh.equistress.mises()
Hot spot Calculation¶
[4]:
threshold = .9 # factor of the maximum local value
mesh['hotspot'] = mesh.hotspot.calc("mises", threshold)
display(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" % mesh['hotspot'].max())
3 hotspots found over the threshold
[6]:
grid = pv.UnstructuredGrid(*mesh.mesh.vtk_data())
plotter = pv.Plotter(window_size=[1920, 1080])
plotter.add_mesh(grid, scalars=mesh.groupby('element_id')['hotspot'].first().to_numpy(),
show_edges=True, cmap='prism_r')
plotter.add_scalar_bar()
plotter.show()
First hotspot¶
[7]:
first_hotspot = mesh[mesh['hotspot'] == 1]
display(first_hotspot)
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 |
[8]:
second_hotspot = mesh[mesh['hotspot'] == 2]
display(second_hotspot)
x | y | z | S11 | S22 | S33 | S12 | S13 | S23 | dx | dy | dz | mises | hotspot | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
element_id | node_id | ||||||||||||||
2852 | 9 | 0.0 | -6.3 | 0.0 | 284.085327 | 30.704277 | 0.0 | 3.546472 | 0.0 | 0.0 | 1.400164e-35 | 0.005436 | 0.0 | 270.115389 | 2 |
[ ]:
[ ]: