.. 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 circular 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(\boldsymbol{C}) = \frac{\mu}{2} \text{tr}(\boldsymbol{C}) - \mu \ln(J) + \frac{\lambda}{2} \ln(J)^2 .. GENERATED FROM PYTHON SOURCE LINES 42-68 .. code-block:: Python import contique import numpy as np import felupe as fem mesh = fem.Rectangle(b=(1, 25), n=(2, 4)).add_midpoints_edges().add_midpoints_faces() region = fem.RegionBiQuadraticQuad(mesh) field = fem.FieldsMixed(region, n=1, axisymmetric=True) boundaries = fem.dof.symmetry(field[0], axes=(0, 1)) boundaries["fix-y"] = fem.Boundary(field[0], fy=mesh.y.max(), mode="or", skip=(0, 1)) dof0, dof1 = fem.dof.partition(field, boundaries) umat = fem.NeoHookeCompressible(mu=1, lmbda=50) solid = fem.SolidBody(umat, field) region_for_pressure = fem.RegionBiQuadraticQuadBoundary( 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 70-72 The next step involves the problem definition for contique. For details have a look at its `README `_. .. GENERATED FROM PYTHON SOURCE LINES 72-102 .. 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.""" field[0].values.ravel()[dof1] = x pressure.update(lpf) K = fem.tools.jac(items=[solid, pressure], x=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 103-106 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 106-123 .. code-block:: Python Res = contique.solve( fun=fun, jac=[dfundx, dfundl], x0=field[0][dof1], lpf0=0, control0=(0, 1), dxmax=1.0, dlpfmax=0.0075, maxsteps=17, rebalance=True, tol=1e-3, decrease=1.2, increase=0.4, high=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+ => 12+ | 5.8e-07 ( 4#) | => re-Cycle | | 2 | 12+ => 12+ | 5.7e-07 ( 4#) | | | 2,1 | 12+ => 0+ | 5.7e-07 ( 4#) | => re-Cycle | | 2 | 0+ => 0+ | 5.8e-07 ( 4#) | | | 3,1 | 0+ => 0+ | 9.2e-07 ( 4#) | | | 4,1 | 0+ => 0+ | 2.3e-05 ( 4#) | | | 5,1 | 0+ => 0+ | 5.1e-04 ( 4#) | | | 6,1 | 0+ => 0+ | 4.7e-07 ( 5#) | | | 7,1 | 0+ => 0+ | 1.8e-07 ( 5#) | | | 8,1 | 0+ => 0+ | 8.5e-07 ( 5#) | | | 9,1 | 0+ => 0+ | 1.5e-06 ( 5#) | | | 10,1 | 0+ => 36+ | 2.0e-05 ( 5#) | => re-Cycle | | 2 | 36+ => 36+ | 9.1e-05 ( 5#) | | | 11,1 | 36+ => 0+ | 1.9e-07 ( 5#) | => re-Cycle | | 2 | 0+ => 0+ | 2.5e-06 ( 7#) | | | 12,1 | 0+ => 0+ | 5.5e-04 ( 5#) | | | 13,1 | 0+ => 0+ | 3.6e-04 ( 4#) | | | 14,1 | 0+ => 0+ | 5.8e-04 ( 4#) | | | 15,1 | 0+ => 0+ | 4.3e-04 ( 4#) | | | 16,1 | 0+ => 0+ | 3.4e-09 ( 5#) | | | 17,1 | 0+ => 0+ | 5.5e-04 ( 4#) | | .. GENERATED FROM PYTHON SOURCE LINES 124-126 The unstable pressure-controlled equilibrium path is plotted as pressure-displacement curve. .. GENERATED FROM PYTHON SOURCE LINES 126-132 .. 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 133-134 The deformed configuration of the revolved solid body is plotted. .. GENERATED FROM PYTHON SOURCE LINES 134-137 .. code-block:: Python solid.revolve(n=10, phi=90).plot( "Principal Values of Cauchy Stress", project=fem.topoints, nonlinear_subdivision=3 ).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/stable/docs/examples/images/sphx_glr_ex04_balloon_002.vtksz .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/felupe/envs/stable/lib/python3.12/site-packages/felupe/view/_scene.py:251: PyVistaFutureWarning: The default value of `algorithm` for the filter `UnstructuredGrid.extract_surface` will change in the future. It currently defaults to `'dataset_surface'`, but will change to `None`. Explicitly set the `algorithm` keyword to silence this warning. surface = surface.extract_surface( /home/docs/checkouts/readthedocs.org/user_builds/felupe/envs/stable/lib/python3.12/site-packages/felupe/view/_scene.py:290: PyVistaFutureWarning: The default value of `algorithm` for the filter `UnstructuredGrid.extract_surface` will change in the future. It currently defaults to `'dataset_surface'`, but will change to `None`. Explicitly set the `algorithm` keyword to silence this warning. .extract_surface(nonlinear_subdivision=nonlinear_subdivision) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.790 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 ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: ex04_balloon.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_