.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/ex04_balloon.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_ex04_balloon.py: Inflation of a hyperelastic balloon ----------------------------------- .. topic:: Numeric continuation of a hyperelastic balloon under inner pressure. * use FElupe with contique * plot pressure-displacement curve * view the deformed balloon .. admonition:: This example requires external packages. :class: hint .. code-block:: pip install contique With the help of `contique `_ it is possible to apply a numerical parameter continuation algorithm on any system of equilibrium equations. This advanced tutorial demonstrates the usage of FElupe in conjunction with `contique `_. The unstable inflation of a rectangular hyperelastic balloon demonstrates this powerful approach. The deformed model and the pressure - displacement curve is plotted. .. image:: ../../examples/ex04_balloon_sketch.png :width: 400px First, setup a problem in FElupe as usual (mesh, region, field, boundaries, umat, solid and a pressure boundary). For the material definition we use the :class:`Neo-Hooke ` built-in hyperelastic material formulation, see Eq. :eq:`neo-hookean-strain-energy`. .. math:: :label: neo-hookean-strain-energy \psi = \frac{\mu}{2} \left( \text{tr}(\boldsymbol{C}) - \ln(\det(\boldsymbol{C})) \right) .. GENERATED FROM PYTHON SOURCE LINES 42-64 .. code-block:: Python import contique import numpy as np import felupe as fem mesh = fem.Rectangle(b=(1, 25), n=(2, 6)) region = fem.RegionQuad(mesh) field = fem.FieldContainer([fem.FieldAxisymmetric(region, dim=2)]) bounds = {"fix-y": fem.Boundary(field[0], fy=mesh.y.max(), mode="or", skip=(0, 1))} dof0, dof1 = fem.dof.partition(field, bounds) umat = fem.NeoHookeCompressible(mu=1) solid = fem.SolidBodyNearlyIncompressible(umat, field, bulk=5000) region_for_pressure = fem.RegionQuadBoundary(mesh, mask=(mesh.x == 0), ensure_3d=True) field_for_pressure = fem.FieldContainer( [fem.FieldAxisymmetric(region_for_pressure, dim=2)] ) pressure = fem.SolidBodyPressure(field_for_pressure) .. GENERATED FROM PYTHON SOURCE LINES 66-68 The next step involves the problem definition for contique. For details have a look at its `README `_. .. GENERATED FROM PYTHON SOURCE LINES 68-95 .. code-block:: Python def fun(x, lpf, *args): "The system vector of equilibrium equations." field[0].values.ravel()[dof1] = x pressure.update(lpf) return fem.tools.fun([solid, pressure], field)[dof1] def dfundx(x, lpf, *args): """The jacobian of the system vector of equilibrium equations w.r.t. the primary unknowns.""" K = fem.tools.jac([solid, pressure], field) return fem.solve.partition(field, K, dof1, dof0)[2] def dfundl(x, lpf, *args): """The jacobian of the system vector of equilibrium equations w.r.t. the load proportionality factor.""" pressure.update(1) return fem.tools.fun([pressure], field)[dof1] .. GENERATED FROM PYTHON SOURCE LINES 96-99 Next we have to init the problem and specify the initial values of unknowns (the undeformed configuration). After each completed step of the numeric continuation the results are saved. .. GENERATED FROM PYTHON SOURCE LINES 99-111 .. code-block:: Python Res = contique.solve( fun=fun, jac=[dfundx, dfundl], x0=field[0][dof1], lpf0=0, control0=(0, 1), maxsteps=150, rebalance=True, tol=1e-2, ) X = np.array([res.x for res in Res]) .. rst-class:: sphx-glr-script-out .. code-block:: none |Step,C.| Control Component | Norm (Iter.#) | Message | |-------|-------------------|---------------|-------------| | 1,1 | 0+ => 0+ | 1.1e-06 ( 3#) | | | 2,1 | 0+ => 0+ | 8.4e-07 ( 3#) | | | 3,1 | 0+ => 0+ | 6.4e-07 ( 3#) | | | 4,1 | 0+ => 0+ | 3.4e-06 ( 3#) | | | 5,1 | 0+ => 0+ | 1.4e-05 ( 3#) | | | 6,1 | 0+ => 0+ | 4.9e-05 ( 3#) | | | 7,1 | 0+ => 0+ | 3.2e-04 ( 3#) | | | 8,1 | 0+ => 0+ | 2.1e-03 ( 3#) | | | 9,1 | 0+ => 0+ | 7.8e-03 ( 3#) | | | 10,1 | 0+ => 0+ | 4.9e-08 ( 6#) | | | 11,1 | 0+ => 0+ | 6.4e-06 ( 6#) | | | 12,1 | 0+ => 0+ | 2.3e-04 ( 7#) | | | 13,1 | 0+ => 0+ | 7.8e-03 ( 7#) | | /home/docs/checkouts/readthedocs.org/user_builds/felupe/envs/latest/lib/python3.12/site-packages/felupe/constitution/hyperelasticity/core/_neo_hooke_compressible.py:176: RuntimeWarning: invalid value encountered in log lnJ = np.log(J, out=J) /home/docs/checkouts/readthedocs.org/user_builds/felupe/envs/latest/lib/python3.12/site-packages/felupe/constitution/hyperelasticity/core/_neo_hooke_compressible.py:216: RuntimeWarning: invalid value encountered in log lnJ = np.log(J, out=J) | 14,1 | 0+ => 22- | 1.1e+12 ( 8#) |Failed | | 15,1 | 0+ => 20+ | 6.0e+05 ( 8#) |Failed | | 16,1 | 0+ => 0+ | 1.9e-08 ( 6#) | | | 17,1 | 0+ => 0+ | 4.3e-05 ( 3#) | | | 18,1 | 0+ => 0+ | 6.6e-05 ( 3#) | | | 19,1 | 0+ => 0+ | 2.6e-04 ( 3#) | | | 20,1 | 0+ => 0+ | 9.6e-04 ( 3#) | | | 21,1 | 0+ => 0+ | 5.0e-03 ( 3#) | | | 22,1 | 0+ => 0+ | 1.1e-04 ( 6#) | | | 23,1 | 0+ => 0+ | 1.8e+02 ( 8#) |Failed | | 24,1 | 0+ => 0+ | 8.5e-03 ( 4#) | | | 25,1 | 0+ => 0+ | 2.4e-03 ( 3#) | | | 26,1 | 0+ => 0+ | 2.8e-03 ( 3#) | | | 27,1 | 0+ => 0+ | 6.0e-03 ( 3#) | | | 28,1 | 0+ => 0+ | 1.7e-05 ( 6#) | | | 29,1 | 0+ => 8- | 1.5e+03 ( 8#) |Failed | | 30,1 | 0+ => 0+ | 4.8e-07 ( 6#) | | | 31,1 | 0+ => 0+ | 4.4e-03 ( 3#) | | | 32,1 | 0+ => 0+ | 4.8e-03 ( 3#) | | | 33,1 | 0+ => 0+ | 9.1e-03 ( 3#) | | | 34,1 | 0+ => 0+ | 3.9e-04 ( 7#) | | | 35,1 | 0+ => 12- | 1.5e+06 ( 8#) |Failed | | 36,1 | 0+ => 8+ | 1.3e+03 ( 8#) |Failed | | 37,1 | 0+ => 0+ | 1.7e-07 ( 6#) | | | 38,1 | 0+ => 0+ | 5.4e-04 ( 3#) | | | 39,1 | 0+ => 0+ | 5.6e-04 ( 3#) | | | 40,1 | 0+ => 0+ | 1.5e-03 ( 3#) | | | 41,1 | 0+ => 0+ | 3.9e-03 ( 3#) | | | 42,1 | 0+ => 0+ | 9.3e-03 ( 3#) | | | 43,1 | 0+ => 0+ | 5.0e-05 ( 6#) | | | 44,1 | 0+ => 0+ | 9.0e-08 ( 6#) | | | 45,1 | 0+ => 22+ | 7.3e+06 ( 8#) |Failed | | 46,1 | 0+ => 3+ | 4.5e+04 ( 8#) |Failed | | 47,1 | 0+ => 8+ | 2.4e+02 ( 8#) |Failed | | 48,1 | 0+ => 0+ | 7.3e-05 ( 3#) | | | 49,1 | 0+ => 0+ | 2.8e-05 ( 3#) | | | 50,1 | 0+ => 0+ | 2.8e-05 ( 3#) | | | 51,1 | 0+ => 0+ | 1.1e-04 ( 3#) | | | 52,1 | 0+ => 0+ | 4.1e-04 ( 3#) | | | 53,1 | 0+ => 0+ | 1.3e-03 ( 3#) | | | 54,1 | 0+ => 0+ | 3.6e-03 ( 3#) | | | 55,1 | 0+ => 0+ | 9.2e-03 ( 3#) | | | 56,1 | 0+ => 0+ | 2.3e-09 ( 6#) | | | 57,1 | 0+ => 0+ | 7.7e-09 ( 6#) | | | 58,1 | 0+ => 0+ | 3.0e-09 ( 6#) | | | 59,1 | 0+ => 0+ | 3.9e+02 ( 8#) |Failed | | 60,1 | 0+ => 0+ | 2.3e-05 ( 6#) | | | 61,1 | 0+ => 0+ | 4.1e-03 ( 4#) | | | 62,1 | 0+ => 0+ | 4.2e-03 ( 4#) | | | 63,1 | 0+ => 0+ | 1.7e-09 ( 6#) | | | 64,1 | 0+ => 0+ | 1.1e-08 ( 6#) | | | 65,1 | 0+ => 0+ | 3.6e-06 ( 6#) | | | 66,1 | 0+ => 0+ | 1.8e-08 ( 6#) | | | 67,1 | 0+ => 6+ | 1.5e+03 ( 8#) |Failed | | 68,1 | 0+ => 0+ | 6.6e-03 ( 5#) | | | 69,1 | 0+ => 0+ | 4.1e-03 ( 4#) | | | 70,1 | 0+ => 0+ | 3.9e-03 ( 4#) | | | 71,1 | 0+ => 0+ | 5.6e-03 ( 5#) | | | 72,1 | 0+ => 0+ | 8.8e-07 ( 6#) | | | 73,1 | 0+ => 0+ | 3.3e-06 ( 6#) | | | 74,1 | 0+ => 0+ | 3.2e-05 ( 6#) | | | 75,1 | 0+ => 0+ | 8.5e-04 ( 6#) | | | 76,1 | 0+ => 0+ | 1.4e-01 ( 8#) |Failed | | 77,1 | 0+ => 0+ | 7.0e-03 ( 4#) | | | 78,1 | 0+ => 0+ | 6.4e-03 ( 4#) | | | 79,1 | 0+ => 0+ | 6.6e-03 ( 4#) | | | 80,1 | 0+ => 8+ | 1.6e+03 ( 8#) |Failed | | 81,1 | 0+ => 0+ | 2.9e-07 ( 6#) | | | 82,1 | 0+ => 0+ | 1.8e-04 ( 4#) | | | 83,1 | 0+ => 0+ | 1.9e-04 ( 4#) | | | 84,1 | 0+ => 0+ | 1.0e-03 ( 4#) | | | 85,1 | 0+ => 0+ | 7.5e-03 ( 4#) | | | 86,1 | 0+ => 2+ | 3.1e+02 ( 8#) |Failed | | 87,1 | 0+ => 2- | 2.5e+04 ( 8#) |Failed | | 88,1 | 0+ => 0+ | 2.5e-05 ( 3#) | | | 89,1 | 0+ => 0+ | 1.1e-04 ( 3#) | | | 90,1 | 0+ => 0+ | 1.1e-04 ( 3#) | | | 91,1 | 0+ => 0+ | 5.2e-04 ( 3#) | | | 92,1 | 0+ => 0+ | 3.1e-03 ( 3#) | | | 93,1 | 0+ => 0+ | 5.1e-04 ( 4#) | | | 94,1 | 0+ => 0+ | 1.0e-03 ( 4#) | | | 95,1 | 0+ => 22- | 2.8e+10 ( 8#) |Failed | | 96,1 | 0+ => 0+ | 5.6e-02 ( 8#) |Failed | | 97,1 | 0+ => 0+ | 3.5e-05 ( 3#) | | | 98,1 | 0+ => 0+ | 3.4e-05 ( 3#) | | | 99,1 | 0+ => 0+ | 3.2e-05 ( 3#) | | | 100,1 | 0+ => 0+ | 1.6e-04 ( 3#) | | | 101,1 | 0+ => 0+ | 9.4e-04 ( 3#) | | | 102,1 | 0+ => 0+ | 7.9e-03 ( 3#) | | | 103,1 | 0+ => 0+ | 4.3e-04 ( 4#) | | | 104,1 | 0+ => 0+ | 3.5e-05 ( 7#) | | | 105,1 | 0+ => 0+ | 2.3e-05 ( 6#) | | | 106,1 | 0+ => 14+ | 1.9e+04 ( 8#) |Failed | | 107,1 | 0+ => 0+ | 2.1e-08 ( 6#) | | | 108,1 | 0+ => 0+ | 4.8e-03 ( 3#) | | | 109,1 | 0+ => 0+ | 4.5e-03 ( 3#) | | | 110,1 | 0+ => 0+ | 4.0e-03 ( 4#) | | | 111,1 | 0+ => 0+ | 6.1e-02 ( 8#) |Failed | | 112,1 | 0+ => 0+ | 6.6e-04 ( 3#) | | | 113,1 | 0+ => 0+ | 6.3e-04 ( 3#) | | | 114,1 | 0+ => 0+ | 6.1e-04 ( 3#) | | | 115,1 | 0+ => 0+ | 7.9e-03 ( 3#) | | | 116,1 | 0+ => 0+ | 9.9e-06 ( 6#) | | | 117,1 | 0+ => 0+ | 1.1e-03 ( 8#) | | | 118,1 | 0+ => 0+ | 2.7e-03 ( 7#) | | | 119,1 | 0+ => 0+ | 1.7e-07 ( 6#) | | | 120,1 | 0+ => 0+ | 7.7e-08 ( 6#) | | | 121,1 | 0+ => 0+ | 2.6e+01 ( 8#) |Failed | | 122,1 | 0+ => 0+ | 6.7e-03 ( 3#) | | | 123,1 | 0+ => 0+ | 6.5e-03 ( 3#) | | | 124,1 | 0+ => 0+ | 6.6e-03 ( 3#) | | | 125,1 | 0+ => 0+ | 1.8e-04 ( 6#) | | | 126,1 | 0+ => 0+ | 5.9e-06 ( 6#) | | | 127,1 | 0+ => 0+ | 2.5e-08 ( 6#) | | | 128,1 | 0+ => 0+ | 1.5e+01 ( 8#) |Failed | | 129,1 | 0+ => 0+ | 5.1e-03 ( 3#) | | | 130,1 | 0+ => 0+ | 5.2e-03 ( 3#) | | | 131,1 | 0+ => 0+ | 5.3e-03 ( 3#) | | | 132,1 | 0+ => 0+ | 1.0e-03 ( 4#) | | | 133,1 | 0+ => 0+ | 1.1e-07 ( 6#) | | | 134,1 | 0+ => 0+ | 9.7e-07 ( 6#) | | | 135,1 | 0+ => 0+ | 2.3e-07 ( 6#) | | | 136,1 | 0+ => 0+ | 5.4e+01 ( 8#) |Failed | | 137,1 | 0+ => 0+ | 8.4e-01 ( 8#) |Failed | | 138,1 | 0+ => 0+ | 1.2e-04 ( 3#) | | | 139,1 | 0+ => 0+ | 1.2e-04 ( 3#) | | | 140,1 | 0+ => 0+ | 1.2e-04 ( 3#) | | | 141,1 | 0+ => 0+ | 7.7e-04 ( 3#) | | | 142,1 | 0+ => 0+ | 6.1e-03 ( 3#) | | | 143,1 | 0+ => 0+ | 6.4e-03 ( 4#) | | | 144,1 | 0+ => 0+ | 3.4e-07 ( 6#) | | | 145,1 | 0+ => 0+ | 1.4e-03 ( 7#) | | | 146,1 | 0+ => 0+ | 9.2e-04 ( 6#) | | | 147,1 | 0+ => 0+ | 1.0e-04 ( 6#) | | | 148,1 | 0+ => 5+ | 9.0e+03 ( 8#) |Failed | | 149,1 | 0+ => 9+ | 9.2e+05 ( 8#) |Failed | | 150,1 | 0+ => 0+ | 4.4e-03 ( 3#) | | .. GENERATED FROM PYTHON SOURCE LINES 112-114 The unstable pressure-controlled equilibrium path is plotted as pressure-displacement curve. .. GENERATED FROM PYTHON SOURCE LINES 114-120 .. code-block:: Python import matplotlib.pyplot as plt plt.plot(X[:, 0], X[:, -1], "x-", lw=3) plt.xlabel(r"Max. Displacement $u_1(X_1=X_2=0)$ $\longrightarrow$") plt.ylabel(r"Load-Proportionality-Factor $\lambda$ $\longrightarrow$") .. image-sg:: /examples/images/sphx_glr_ex04_balloon_001.png :alt: ex04 balloon :srcset: /examples/images/sphx_glr_ex04_balloon_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 121-122 The 3d-deformed configuration of the solid body is plotted. .. GENERATED FROM PYTHON SOURCE LINES 122-129 .. code-block:: Python mesh_3d = mesh.revolve(phi=90, n=6) region_3d = fem.RegionHexahedron(mesh_3d) values = mesh.copy(points=field[0].values).revolve(phi=90, n=6).points u_3d = fem.Field(region_3d, values=values, dim=3) field_3d = fem.FieldContainer([u_3d]) solid_3d = fem.SolidBodyNearlyIncompressible(umat, field_3d, bulk=5000) solid_3d.plot("Principal Values of Cauchy Stress", project=fem.topoints).show() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/images/sphx_glr_ex04_balloon_002.png :alt: ex04 balloon :srcset: /examples/images/sphx_glr_ex04_balloon_002.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/docs/checkouts/readthedocs.org/user_builds/felupe/checkouts/latest/docs/examples/images/sphx_glr_ex04_balloon_002.vtksz .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 11.744 seconds) .. _sphx_glr_download_examples_ex04_balloon.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ex04_balloon.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ex04_balloon.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_