.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/howto_quickstart/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 or to run this example in your browser via Binder. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_howto_quickstart_plot_solid_mechanics.py: Stress analysis =============== The following example from the ogs benchmark collection is used for the stress analysis: .. GENERATED FROM PYTHON SOURCE LINES 14-23 .. code-block:: Python import ogstools as ot from ogstools import examples mesh = examples.load_mesh_mechanics_2D() fig = ot.plot.contourf(mesh, ot.variables.displacement) .. image-sg:: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_001.png :alt: plot solid mechanics :srcset: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 29-32 Tensor components ----------------- We can inspect the stress (or strain) tensor components by indexing. .. GENERATED FROM PYTHON SOURCE LINES 34-37 .. code-block:: Python fig = ot.plot.contourf(mesh, ot.variables.stress["xx"]) fig = ot.plot.contourf(mesh, ot.variables.stress["xy"]) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_002.png :alt: plot solid mechanics :srcset: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_002.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_003.png :alt: plot solid mechanics :srcset: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_003.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 38-44 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 46-50 .. code-block:: Python eigvecs = ot.variables.stress.eigenvectors fig = ot.plot.contourf(mesh, variable=ot.variables.stress.eigenvalues[0]) ot.plot.quiver(mesh, ax=fig.axes[0], variable=eigvecs[0], glyph_type="line") .. image-sg:: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_004.png :alt: plot solid mechanics :srcset: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 51-54 .. code-block:: Python fig = ot.plot.contourf(mesh, variable=ot.variables.stress.eigenvalues[1]) ot.plot.quiver(mesh, ax=fig.axes[0], variable=eigvecs[1], glyph_type="line") .. image-sg:: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_005.png :alt: plot solid mechanics :srcset: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_005.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 55-58 .. code-block:: Python fig = ot.plot.contourf(mesh, variable=ot.variables.stress.eigenvalues[2]) ot.plot.quiver(mesh, ax=fig.axes[0], variable=eigvecs[2], glyph_type="line") .. image-sg:: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_006.png :alt: plot solid mechanics :srcset: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_006.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 59-62 We can also plot the mean of the principal stress, i.e. the magnitude of the hydrostatic component of the stress tensor. see: :func:`ogstools.variables.tensor_math.mean` .. GENERATED FROM PYTHON SOURCE LINES 64-66 .. code-block:: Python fig = ot.plot.contourf(mesh, ot.variables.stress.tensor_mean) .. image-sg:: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_007.png :alt: plot solid mechanics :srcset: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_007.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 67-70 Von Mises stress ---------------- see: :func:`ogstools.variables.tensor_math.von_mises` .. GENERATED FROM PYTHON SOURCE LINES 72-74 .. code-block:: Python fig = ot.plot.contourf(mesh, ot.variables.stress.von_Mises) .. image-sg:: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_008.png :alt: plot solid mechanics :srcset: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_008.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 75-78 octahedral shear stress ----------------------- see: :func:`ogstools.variables.tensor_math.octahedral_shear` .. GENERATED FROM PYTHON SOURCE LINES 80-82 .. code-block:: Python fig = ot.plot.contourf(mesh, ot.variables.stress.octahedral_shear) .. image-sg:: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_009.png :alt: plot solid mechanics :srcset: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_009.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 83-88 Stresses in polar coordinates ============================= You can inspect stresses in a polar coordinate system by deriving a new Variable from the stress Variable. Specify the polar center and, if needed, the rotation axis (default is z-axis: [0, 0, 1]). .. GENERATED FROM PYTHON SOURCE LINES 90-95 .. code-block:: Python polar_stress = ot.variables.stress.to_polar(center=(150, -650, 0)) fig = ot.plot.contourf(mesh, polar_stress["rr"]) fig = ot.plot.contourf(mesh, polar_stress["tt"]) fig = ot.plot.contourf(mesh, polar_stress["pp"]) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_010.png :alt: plot solid mechanics :srcset: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_010.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_011.png :alt: plot solid mechanics :srcset: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_011.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_012.png :alt: plot solid mechanics :srcset: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_012.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 96-97 Here is a 3D example with a cylindrical hole at (0, 0, 0) in y direction: .. GENERATED FROM PYTHON SOURCE LINES 99-106 .. code-block:: Python mesh_3D = examples.load_mesh_mechanics_3D_sphere() polar_stress_3D = ot.variables.stress.to_polar() for comp in ["rr", "tt", "pp"]: pl = ot.plot.contourf(mesh_3D, polar_stress_3D[comp]) pl.view_xz() pl.show() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_013.png :alt: plot solid mechanics :srcset: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_013.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /builds/ogs/tools/ogstools/docs/auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_013.vtksz .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_014.png :alt: plot solid mechanics :srcset: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_014.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /builds/ogs/tools/ogstools/docs/auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_014.vtksz .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_015.png :alt: plot solid mechanics :srcset: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_015.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /builds/ogs/tools/ogstools/docs/auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_015.vtksz .. GENERATED FROM PYTHON SOURCE LINES 107-112 Integrity criteria ================== Evaluating models regarding their integrity is often dependent on the fluid pressure. If not already present, we have to calculate it manually, e.g. as a hypothetical water column proportional to the depth. .. GENERATED FROM PYTHON SOURCE LINES 114-117 .. code-block:: Python mesh["pressure"] = -1000 * 9.81 * mesh.points[:, 1] fig = ot.plot.contourf(mesh, ot.variables.pressure) .. image-sg:: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_016.png :alt: plot solid mechanics :srcset: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_016.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 118-121 Dilantancy criterion -------------------- see: :func:`ogstools.variables.mesh_dependent.dilatancy_critescu` .. GENERATED FROM PYTHON SOURCE LINES 123-126 .. code-block:: Python fig = ot.plot.contourf(mesh, ot.variables.dilatancy_critescu_tot) fig = ot.plot.contourf(mesh, ot.variables.dilatancy_critescu_eff) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_017.png :alt: plot solid mechanics :srcset: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_017.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_018.png :alt: plot solid mechanics :srcset: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_018.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 127-130 Fluid pressure criterion ------------------------ see: :func:`ogstools.variables.mesh_dependent.fluid_pressure_criterion` .. GENERATED FROM PYTHON SOURCE LINES 132-133 .. code-block:: Python fig = ot.plot.contourf(mesh, ot.variables.fluid_pressure_crit) .. image-sg:: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_019.png :alt: plot solid mechanics :srcset: /auto_examples/howto_quickstart/images/sphx_glr_plot_solid_mechanics_019.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 6.269 seconds) .. _sphx_glr_download_auto_examples_howto_quickstart_plot_solid_mechanics.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://binder.opengeosys.org/v2/gh/bilke/binder-ogs-requirements/6.5.7-0.8.0?urlpath=git-pull%3Frepo%3Dhttps%253A%252F%252Fgitlab.opengeosys.org%252Fogs%252Ftools%252Fogstools%26urlpath%3Dlab%252Ftree%252Fogstools/docs/examples/howto_quickstart/plot_solid_mechanics.py :alt: Launch binder :width: 150 px .. 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 ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_solid_mechanics.zip `