.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/howto_meshplotlib/plot_solid_mechanics.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_howto_meshplotlib_plot_solid_mechanics.py: Stress analysis =============== .. sectionauthor:: Florian Zill (Helmholtz Centre for Environmental Research GmbH - UFZ) The following example from the ogs benchmark collection is used for the stress analysis: .. GENERATED FROM PYTHON SOURCE LINES 16-31 .. code-block:: Python import ogstools as ot from ogstools import examples from ogstools.meshplotlib import plot, setup from ogstools.meshplotlib.plot_features import plot_streamlines from ogstools.propertylib import mesh_dependent, properties setup.reset() setup.length.output_unit = "km" mesh = examples.load_mesh_mechanics_2D() mesh_property = ot.properties.displacement fig = plot(mesh, mesh_property) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_001.png :alt: plot solid mechanics :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 37-40 Tensor components ----------------- We can inspect the stress (or strain) tensor components by indexing. .. GENERATED FROM PYTHON SOURCE LINES 42-45 .. code-block:: Python fig = plot(mesh, properties.stress["xx"]) fig = plot(mesh, properties.stress["xy"]) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_002.png :alt: plot solid mechanics :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_002.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_003.png :alt: plot solid mechanics :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_003.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 46-52 Principal stresses ------------------ Let's plot the the principal stress components and also overlay the direction of the corresponding eigenvector in the plot. Note: the eigenvalues are sorted by increasing order, i.e. eigenvalue[0] is the most negative / largest compressive principal stress. .. GENERATED FROM PYTHON SOURCE LINES 54-60 .. code-block:: Python eigvecs = properties.stress.eigenvectors fig = plot(mesh, mesh_property=properties.stress.eigenvalues[0]) plot_streamlines( ax=fig.axes[0], mesh=mesh, mesh_property=eigvecs[0], plot_type="lines" ) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_004.png :alt: plot solid mechanics :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 61-66 .. code-block:: Python fig = plot(mesh, mesh_property=properties.stress.eigenvalues[1]) plot_streamlines( ax=fig.axes[0], mesh=mesh, mesh_property=eigvecs[1], plot_type="lines" ) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_005.png :alt: plot solid mechanics :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_005.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 67-72 .. code-block:: Python fig = plot(mesh, mesh_property=properties.stress.eigenvalues[2]) plot_streamlines( ax=fig.axes[0], mesh=mesh, mesh_property=eigvecs[2], plot_type="lines" ) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_006.png :alt: plot solid mechanics :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_006.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 73-76 We can also plot the mean of the principal stress, i.e. the magnitude of the hydrostatic component of the stress tensor. see: :py:func:`ogstools.propertylib.tensor_math.mean` .. GENERATED FROM PYTHON SOURCE LINES 78-80 .. code-block:: Python fig = plot(mesh, properties.stress.mean) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_007.png :alt: plot solid mechanics :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_007.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 81-84 Von Mises stress ---------------- see: :py:func:`ogstools.propertylib.tensor_math.von_mises` .. GENERATED FROM PYTHON SOURCE LINES 86-88 .. code-block:: Python fig = plot(mesh, properties.stress.von_Mises) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_008.png :alt: plot solid mechanics :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_008.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 89-92 octahedral shear stress ----------------------- see: :py:func:`ogstools.propertylib.tensor_math.octahedral_shear` .. GENERATED FROM PYTHON SOURCE LINES 94-96 .. code-block:: Python fig = plot(mesh, properties.stress.octahedral_shear) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_009.png :alt: plot solid mechanics :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_009.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 97-103 Integrity criteria ================== Evaluating models regarding their integrity is often dependent on the geometry, e.g. for a hypothetical water column proportional to the depth. Presets which fall under this category make use of :py:mod:`ogstools.propertylib.mesh_dependent`. .. GENERATED FROM PYTHON SOURCE LINES 105-108 The hypothetical water column used in the integrity criteria would initially use existing "pressure" data in the mesh, otherwise it is automatically calculated as the following: .. GENERATED FROM PYTHON SOURCE LINES 110-113 .. code-block:: Python mesh["pressure"] = mesh_dependent.p_fluid(mesh) fig = plot(mesh, properties.pressure) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_010.png :alt: plot solid mechanics :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_010.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /builds/ogs/tools/ogstools/.venv-devcontainer/lib/python3.9/site-packages/pyvista/core/dataset.py:1975: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray. scalars = np.asanyarray(scalars) .. GENERATED FROM PYTHON SOURCE LINES 114-117 But since this assumes that the top of the model is equal to the ground surface, the resulting pressure is underestimated. In this case we have to correct the depth manually. Then the pressure is calculated correctly: .. GENERATED FROM PYTHON SOURCE LINES 119-124 .. code-block:: Python mesh["depth"] = mesh_dependent.depth(mesh, use_coords=True) fig = plot(mesh, "depth") mesh["pressure"] = mesh_dependent.p_fluid(mesh) fig = plot(mesh, properties.pressure) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_011.png :alt: plot solid mechanics :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_011.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_012.png :alt: plot solid mechanics :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_012.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 125-128 Dilantancy criterion -------------------- see: :py:func:`ogstools.propertylib.mesh_dependent.dilatancy_critescu` .. GENERATED FROM PYTHON SOURCE LINES 130-133 .. code-block:: Python fig = plot(mesh, properties.dilatancy_critescu_tot) fig = plot(mesh, properties.dilatancy_critescu_eff) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_013.png :alt: plot solid mechanics :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_013.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_014.png :alt: plot solid mechanics :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_014.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 134-137 Fluid pressure criterion ------------------------ see: :py:func:`ogstools.propertylib.mesh_dependent.fluid_pressure_criterion` .. GENERATED FROM PYTHON SOURCE LINES 139-140 .. code-block:: Python fig = plot(mesh, properties.fluid_pressure_crit) .. image-sg:: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_015.png :alt: plot solid mechanics :srcset: /auto_examples/howto_meshplotlib/images/sphx_glr_plot_solid_mechanics_015.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 6.357 seconds) .. _sphx_glr_download_auto_examples_howto_meshplotlib_plot_solid_mechanics.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_solid_mechanics.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_solid_mechanics.py `