.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/01-simple/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_01-simple_spherical_shell_compression.py: Compression of a ping pong ball ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Example that show how to use plate elements with a pressure load. .. GENERATED FROM PYTHON SOURCE LINES 7-12 .. code-block:: Python import fedoo as fd import pyvista as pv import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 13-14 The problems parameters .. GENERATED FROM PYTHON SOURCE LINES 14-21 .. code-block:: Python E = 2e3 # MPa nu = 0.37 radius = 20 # mm thickness = 0.45 # mm pressure = 10 # MPa .. GENERATED FROM PYTHON SOURCE LINES 22-23 Create a simple sphere mesh using pyvista. .. GENERATED FROM PYTHON SOURCE LINES 23-26 .. code-block:: Python mesh = fd.Mesh.from_pyvista(pv.Sphere(radius=radius)) .. GENERATED FROM PYTHON SOURCE LINES 27-28 Define a linear isotropic material and an homogeneous shell section .. GENERATED FROM PYTHON SOURCE LINES 28-32 .. code-block:: Python material = fd.constitutivelaw.ElasticIsotrop(E, nu, name="Material") shell_section = fd.constitutivelaw.ShellHomogeneous("Material", thickness) .. GENERATED FROM PYTHON SOURCE LINES 33-35 Define the weakform and associated assembly for plate model For plate elements, we first need to create a 3D modeling space .. GENERATED FROM PYTHON SOURCE LINES 35-40 .. code-block:: Python fd.ModelingSpace("3D") wf = fd.weakform.PlateEquilibrium(shell_section) solid_assembly = fd.Assembly.create(wf, mesh) .. GENERATED FROM PYTHON SOURCE LINES 41-45 Select mesh elements where we will apply the pressure. The mesh.find_elements method is used with an arbitrary exression. Here we select all elements whose z coordinates are less that 3mm from minimal or maximal z value (sphere extremity along the z axis. .. GENERATED FROM PYTHON SOURCE LINES 45-50 .. 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 51-54 Now we build the pressure load by extracting the loaded surface mesh. For nonlinear analyses, the pressure is added as an external Neumann boundary condition so that the residual normalization sees the applied load. .. GENERATED FROM PYTHON SOURCE LINES 54-60 .. code-block:: Python pressure_assembly = fd.constraint.Pressure( mesh.extract_elements(boundaries), pressure, ) .. GENERATED FROM PYTHON SOURCE LINES 61-71 Define a nonlinear analysis and solve the problem. .. 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 71-87 .. code-block:: Python assembly = solid_assembly pb = fd.problem.Linear(assembly) 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.solve() .. GENERATED FROM PYTHON SOURCE LINES 88-93 Extract the results: position = 1 is set for the surface along the positif 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 93-99 .. 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/01-simple/images/sphx_glr_spherical_shell_compression_001.png :alt: spherical shell compression :srcset: /examples/01-simple/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 0.295 seconds) .. _sphx_glr_download_examples_01-simple_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 `_