diff --git a/demos/hotspot_plate.ipynb b/demos/hotspot_beam.ipynb similarity index 90% rename from demos/hotspot_plate.ipynb rename to demos/hotspot_beam.ipynb index c731e70a..ca106cae 100644 --- a/demos/hotspot_plate.ipynb +++ b/demos/hotspot_beam.ipynb @@ -44,8 +44,8 @@ "metadata": {}, "outputs": [], "source": [ - "vm_mesh = pylife.vmap.VMAPImport(\"plate_with_hole.vmap\")\n", - "mesh = (vm_mesh.make_mesh('1', 'STATE-2')\n", + "vm_mesh = pylife.vmap.VMAPImport(\"two_notched_beam.vmap\")\n", + "mesh = (vm_mesh.make_mesh('beam', 'STATE-1')\n", " .join_coordinates()\n", " .join_variable('STRESS_CAUCHY')\n", " .join_variable('DISPLACEMENT')\n", @@ -81,7 +81,7 @@ "metadata": {}, "outputs": [], "source": [ - "threshold = .9 # factor of the maximum local value\n", + "threshold = .3 # factor of the maximum local value\n", "mesh['hotspot'] = mesh.hotspot.calc(\"mises\", threshold)\n", "display(mesh[['x', 'y', 'z', 'mises', 'hotspot']])" ] @@ -103,8 +103,7 @@ "source": [ "grid = pv.UnstructuredGrid(*mesh.mesh.vtk_data())\n", "plotter = pv.Plotter(window_size=[1920, 1080])\n", - "plotter.add_mesh(grid, scalars=mesh.groupby('element_id')['hotspot'].first().to_numpy(),\n", - " show_edges=True, cmap='prism_r')\n", + "plotter.add_mesh(grid, scalars=mesh.groupby('element_id')['hotspot'].first().to_numpy(), show_edges=True)\n", "plotter.add_scalar_bar()\n", "plotter.show()" ] @@ -113,7 +112,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### First hotspot" + "### Hotspots" ] }, { @@ -141,7 +140,10 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "third_hotspot = mesh[mesh['hotspot'] == 3]\n", + "display(third_hotspot)" + ] }, { "cell_type": "code", @@ -166,7 +168,8 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.9" } }, "nbformat": 4, diff --git a/demos/index.ipynb b/demos/index.ipynb index 07e6d630..1bb37d4d 100644 --- a/demos/index.ipynb +++ b/demos/index.ipynb @@ -55,7 +55,7 @@ "\n", "In a connected FEM mesh, hotspots of a scalar value like damage sum, or von Mises stress can be detected and classified.\n", "\n", - "[Hotspot detection](hotspot_plate.ipynb)\n", + "[Hotspot detection](hotspot_beam.ipynb)\n", "\n", "\n", "### Gradients in a mesh\n", diff --git a/demos/two_notched_beam.vmap b/demos/two_notched_beam.vmap new file mode 100644 index 00000000..d90535f9 Binary files /dev/null and b/demos/two_notched_beam.vmap differ diff --git a/docs/demos/hotspot_beam.nblink b/docs/demos/hotspot_beam.nblink new file mode 100644 index 00000000..9eba4ea9 --- /dev/null +++ b/docs/demos/hotspot_beam.nblink @@ -0,0 +1,4 @@ +{ + "path": "../../demos/hotspot_beam.ipynb", + "extra-media": ["../../demos/two_notched_beam.vmap"] +} diff --git a/docs/demos/hotspot_plate.nblink b/docs/demos/hotspot_plate.nblink deleted file mode 100644 index a6382ff7..00000000 --- a/docs/demos/hotspot_plate.nblink +++ /dev/null @@ -1,4 +0,0 @@ -{ - "path": "../../demos/hotspot_plate.ipynb", - "extra-media": ["../../demos/plate_with_hole.vmap"] -} diff --git a/tests/demos/test_demo_notebooks.py b/tests/demos/test_demo_notebooks.py index 89d0a5a4..cc332aaa 100644 --- a/tests/demos/test_demo_notebooks.py +++ b/tests/demos/test_demo_notebooks.py @@ -38,27 +38,27 @@ def change_workingdir_dir(monkeypatch): monkeypatch.chdir('demos') -@testbook('demos/hotspot_plate.ipynb') -def test_hotspot_plate(tb): +@testbook('demos/hotspot_beam.ipynb') +def test_hotspot_beam(tb): with tb.patch('pyvista.Plotter'): tb.execute() tb.inject( """ first_hotspot = mesh[mesh['hotspot'] == 1] - pd.testing.assert_index_equal( - first_hotspot.index, - pd.MultiIndex.from_tuples([(456, 5), (456, 6433)], names=['element_id', 'node_id']) - ) + assert len(first_hotspot) == 1296 """ ) tb.inject( """ second_hotspot = mesh[mesh['hotspot'] == 2] - pd.testing.assert_index_equal( - second_hotspot.index, - pd.MultiIndex.from_tuples([(2852, 9)], names=['element_id', 'node_id']) - ) + assert len(second_hotspot) == 1504 + """ + ) + tb.inject( + """ + third_hotspot = mesh[mesh['hotspot'] == 3] + assert len(third_hotspot) == 160 """ )