.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/basic/spherical_shell_compression.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_basic_spherical_shell_compression.py: Compression of a ping-pong ball ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Example that shows how to use plate (shell) elements with a pressure load in a geometrically nonlinear analysis. A ping-pong ball (diameter 40 mm, wall thickness 0.45 mm, celluloid-like material with :math:`E = 2` GPa) is squeezed by a pressure applied on its two poles. Each pole carries a resultant of about 175 N. The deflection is of the order of the wall thickness, which is where the geometric nonlinearity of a thin shell becomes significant, while the strains remain small (below 1 %). .. GENERATED FROM PYTHON SOURCE LINES 14-19 .. code-block:: Python import fedoo as fd import pyvista as pv import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 20-21 The problems parameters (units: mm, N, MPa) .. GENERATED FROM PYTHON SOURCE LINES 21-28 .. code-block:: Python E = 2e3 # MPa nu = 0.37 radius = 20 # mm thickness = 0.45 # mm pressure = 0.5 # MPa .. GENERATED FROM PYTHON SOURCE LINES 29-30 Create a simple sphere mesh using pyvista. .. GENERATED FROM PYTHON SOURCE LINES 30-33 .. code-block:: Python mesh = fd.Mesh.from_pyvista(pv.Sphere(radius=radius)) .. GENERATED FROM PYTHON SOURCE LINES 34-47 Define the material and an homogeneous shell section. The shell kinematics are corotational: large rotations are handled by the weak form, and the material only sees the small strains of the corotated frame. At such strains any hyperelastic law (Neo-Hookean, ...) reduces to its linearization, i.e. the isotropic linear elastic law with the same :math:`E` and :math:`\nu` used here. .. note:: Finite-strain hyperelastic laws (simcoon ``NEOHC``, ...) need the full deformation gradient and are not available with the plane-stress assumption of shell elements. Use a solid model for large-strain (e.g. rubber) shells. .. GENERATED FROM PYTHON SOURCE LINES 47-51 .. code-block:: Python material = fd.constitutivelaw.ElasticIsotrop(E, nu, name="Material") shell_section = fd.constitutivelaw.ShellHomogeneous("Material", thickness) .. GENERATED FROM PYTHON SOURCE LINES 52-55 Define the weakform and associated assembly for plate model. For plate elements, we first need to create a 3D modeling space. ``nlgeom=True`` activates the corotational geometric nonlinearities. .. GENERATED FROM PYTHON SOURCE LINES 55-60 .. code-block:: Python fd.ModelingSpace("3D") wf = fd.weakform.PlateEquilibrium(shell_section, nlgeom=True) solid_assembly = fd.Assembly.create(wf, mesh) .. GENERATED FROM PYTHON SOURCE LINES 61-69 Select mesh elements where we will apply the pressure. The mesh.find_elements method is used with an arbitrary expression. Here we select all elements whose z coordinates are less than 3mm from minimal or maximal z value (sphere extremities along the z axis). The loaded caps have a height :math:`h = 3` mm, hence a projected area :math:`\pi a^2 = \pi (2Rh - h^2) \approx 349\ \mathrm{mm}^2`, and a resultant force :math:`F = p \pi a^2 \approx 175` N on each pole. .. GENERATED FROM PYTHON SOURCE LINES 69-74 .. code-block:: Python boundaries = mesh.find_elements( f"Z>{mesh.bounding_box.zmax - 3} or Z<{mesh.bounding_box.zmin + 3}" ) .. GENERATED FROM PYTHON SOURCE LINES 75-79 Now we build the pressure load by extracting the loaded surface mesh. The pressure is then added to the problem as an external (Neumann) boundary condition with ``pb.bc.add``. With geometric nonlinearities, the pressure is a follower load (it stays normal to the deformed surface). .. GENERATED FROM PYTHON SOURCE LINES 79-85 .. code-block:: Python pressure_assembly = fd.constraint.Pressure( mesh.extract_elements(boundaries), pressure, ) .. GENERATED FROM PYTHON SOURCE LINES 86-104 Define a nonlinear analysis and solve the problem. Order of magnitude: in the loaded caps the shell is in a membrane state close to that of a sphere under external pressure, :math:`\sigma \approx pR/(2t) \approx 11` MPa, i.e. an equibiaxial membrane strain :math:`\sigma(1-\nu)/E \approx 0.35` %, with additional bending at the edge of the loaded zones. Both stay well below the yield stress of the material (about 35 MPa, see the elastoplastic version of this example in :ref:`sphx_glr_examples_shells_spherical_shell_compression_plastic.py`). .. note:: To improve numerical stability, a few displacement boundary conditions are added to remove rigid-body motions. These constraints do not affect the strain/stress solution because they only suppress the nullspace modes. Without them, the unconstrained problem is singular; some solvers may still return a usable strain/stress field, but the displacement field can contain arbitrary rigid-body motion. .. GENERATED FROM PYTHON SOURCE LINES 104-121 .. code-block:: Python assembly = solid_assembly pb = fd.problem.NonLinear(assembly, nlgeom=True) pb.bc.add(pressure_assembly) nodes = mesh.nodes node_a = int(np.argmin(nodes[:, 0])) node_b = int(np.argmax(nodes[:, 0])) node_c = int(np.argmax(nodes[:, 1])) pb.bc.add("Dirichlet", node_a, "Disp", 0) pb.bc.add("Dirichlet", node_b, ["DispY", "DispZ"], 0) pb.bc.add("Dirichlet", node_c, "DispZ", 0) pb.set_nr_criterion("Displacement", tol=5e-3, max_subiter=15) pb.nlsolve(dt=0.25, tmax=1, update_dt=True, print_info=1) .. rst-class:: sphx-glr-script-out .. code-block:: none Iter 1 - Time: 0.25000 - dt 0.25000 - NR iter: 3 - Err: 0.00006 Iter 2 - Time: 0.50000 - dt 0.31250 - NR iter: 3 - Err: 0.00013 Iter 3 - Time: 0.75000 - dt 0.31250 - NR iter: 3 - Err: 0.00025 Iter 4 - Time: 1.00000 - dt 0.31250 - NR iter: 3 - Err: 0.00048 .. GENERATED FROM PYTHON SOURCE LINES 122-127 Extract the results: position = 1 is set for the surface along the positive direction of the normal vector (0 is the mean plane). The strains and stresses components are defined in the element local coordinate system (mesh.get_element_local_frame()). .. GENERATED FROM PYTHON SOURCE LINES 127-133 .. code-block:: Python res = pb.get_results(solid_assembly, ["Disp", "Rot", "Stress", "Strain"], position=1) pl = pv.Plotter() res.plot("Stress", component="XX", data_type="Node", plotter=pl) pl.view_isometric() pl.show() .. image-sg:: /examples/basic/images/sphx_glr_spherical_shell_compression_001.png :alt: spherical shell compression :srcset: /examples/basic/images/sphx_glr_spherical_shell_compression_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.491 seconds) .. _sphx_glr_download_examples_basic_spherical_shell_compression.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: spherical_shell_compression.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: spherical_shell_compression.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: spherical_shell_compression.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_