.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/Hyperelasticity/Hyperelas2.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_examples_Hyperelasticity_Hyperelas2.py: Hyperelas2 ========== A hyper elastic cube in compression. .. GENERATED FROM PYTHON SOURCE LINES 12-72 .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/Hyperelasticity/images/sphx_glr_Hyperelas2_001.png :alt: Hyperelas2 :srcset: /examples/Hyperelasticity/images/sphx_glr_Hyperelas2_001.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/docs/checkouts/readthedocs.org/user_builds/easyfea/checkouts/v1.7.4/docs/examples/Hyperelasticity/images/sphx_glr_Hyperelas2_001.vtksz .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/Hyperelasticity/images/sphx_glr_Hyperelas2_002.png :alt: Hyperelas2 :srcset: /examples/Hyperelasticity/images/sphx_glr_Hyperelas2_002.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/docs/checkouts/readthedocs.org/user_builds/easyfea/checkouts/v1.7.4/docs/examples/Hyperelasticity/images/sphx_glr_Hyperelas2_002.vtksz .. rst-class:: sphx-glr-script-out .. code-block:: none ===== hyperelastic problem at iteration 0 ===== At Newton iteration 1 norm is 3.873448821042e-01 At Newton iteration 2 norm is 9.538664605952e-03 At Newton iteration 3 norm is 8.884193859163e-04 At Newton iteration 4 norm is 5.678328312556e-05 At Newton iteration 5 norm is 4.665333617495e-07 | .. code-block:: Python :lineno-start: 13 import numpy as np from EasyFEA import Display, ElemType, Models, Simulations, PyVista from EasyFEA.Geoms import Domain if __name__ == "__main__": Display.Clear() # ---------------------------------------------- # Configuration # ---------------------------------------------- dim = 3 # geom L = 1 h = 1 # ---------------------------------------------- # Mesh # ---------------------------------------------- meshSize = h / 10 contour = Domain((0, 0), (L, h), h / 10) if dim == 2: mesh = contour.Mesh_2D([], ElemType.QUAD8, isOrganised=True) else: mesh = contour.Mesh_Extrude( [], [0, 0, h], [h / meshSize], ElemType.HEXA8, isOrganised=True ) nodesX0 = mesh.Nodes_Conditions(lambda x, y, z: x == 0) nodesXL = mesh.Nodes_Conditions(lambda x, y, z: x == L) # ---------------------------------------------- # Simulation # ---------------------------------------------- isot = Models.Elastic.Isotropic(dim, E=1, v=0.3) lmbda = isot.get_lambda() mu = isot.get_mu() mat = Models.HyperElastic.SaintVenantKirchhoff(dim, lmbda, mu, thickness=h) simu = Simulations.HyperElastic(mesh, mat) uc = -0.3 simu.add_dirichlet(nodesX0, [0] * dim, simu.Get_unknowns()) values = np.zeros_like(simu.Get_unknowns(), dtype=float) values[0] = uc simu.add_dirichlet(nodesXL, values, simu.Get_unknowns()) simu.Solve() # ---------------------------------------------- # Results # ---------------------------------------------- PyVista.Plot_BoundaryConditions(simu).show() PyVista.Plot(simu, "ux", 1, plotMesh=True).show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.267 seconds) .. _sphx_glr_download_examples_Hyperelasticity_Hyperelas2.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Hyperelas2.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: Hyperelas2.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: Hyperelas2.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_