.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/verification/example_verify_cantilever_eb.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_gallery_verification_example_verify_cantilever_eb.py: Cantilever tip deflection — Euler-Bernoulli closed form ======================================================= Slender clamped cantilever under a transverse tip load has tip deflection .. math:: \delta = \frac{P L^{3}}{3 E I}, \qquad I = \frac{w h^{3}}{12}. Reference: Timoshenko, S. P. *Strength of Materials, Part I*, 3rd ed., Van Nostrand, 1955, §5.4. This gallery example drives a multi-refinement :class:`~femorph_solver.validation.ConvergenceStudy` and renders the deformed shape at the finest mesh. .. GENERATED FROM PYTHON SOURCE LINES 19-28 .. code-block:: Python from __future__ import annotations import numpy as np import pyvista as pv from femorph_solver.validation import ConvergenceStudy from femorph_solver.validation.problems import CantileverEulerBernoulli .. GENERATED FROM PYTHON SOURCE LINES 29-35 Problem + convergence ladder ---------------------------- Three in-plane refinements (slenderness L/h = 20); three transverse layers keeps the shear-strain field resolved at the HEX8 EAS formulation used under the hood. .. GENERATED FROM PYTHON SOURCE LINES 35-47 .. code-block:: Python problem = CantileverEulerBernoulli() study = ConvergenceStudy( problem=problem, refinements=[ {"nx": 20, "ny": 3, "nz": 3}, {"nx": 40, "ny": 3, "nz": 3}, {"nx": 80, "ny": 3, "nz": 3}, ], ) records = study.run() .. GENERATED FROM PYTHON SOURCE LINES 48-49 Print the comparison table .. GENERATED FROM PYTHON SOURCE LINES 49-67 .. code-block:: Python rec = records[0] pub = rec.results[0].published print(f"{problem.name}: {problem.description}") print(f"\n source : {pub.source}") print(f" formula: {pub.formula}") print(f" published: {pub.value:.6e} {pub.unit}\n") print(f" {'mesh':<20s} {'n_dof':>8s} {'computed':>14s} {'rel err':>10s} pass") for r in rec.results: mesh_str = " ".join(f"{k}={v}" for k, v in r.mesh_params.items()) pass_str = "✓" if r.passed else "✗" print( f" {mesh_str:<20s} {r.n_dof:>8d} {r.computed:+14.6e} " f"{r.rel_error * 100:+9.2f}% {pass_str}" ) if rec.convergence_rate is not None: print(f"\n fitted rate: |err| ∝ n_dof^(-{rec.convergence_rate:.2f})") .. rst-class:: sphx-glr-script-out .. code-block:: none cantilever_eb: Slender clamped cantilever under transverse tip load — Euler-Bernoulli closed-form (Timoshenko 1955 §5.4). source : Timoshenko 1955 §5.4 formula: delta = P L^3 / (3 E I) published: 3.200000e-03 m mesh n_dof computed rel err pass nx=20 ny=3 nz=3 1008 +3.168413e-03 -0.99% ✓ nx=40 ny=3 nz=3 1968 +3.184714e-03 -0.48% ✓ nx=80 ny=3 nz=3 3888 +3.191451e-03 -0.27% ✓ fitted rate: |err| ∝ n_dof^(-0.85) .. GENERATED FROM PYTHON SOURCE LINES 68-70 Render the deformed shape at the finest mesh -------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 70-86 .. code-block:: Python m = problem.build_model(nx=80, ny=3, nz=3) res = m.solve() u = np.asarray(res.displacement).reshape(-1, 3) warped = m.grid.copy() warped.points = m.grid.points + 1.0 * u warped["|u|"] = np.linalg.norm(u, axis=1) plotter = pv.Plotter(off_screen=True) plotter.add_mesh(m.grid, style="wireframe", color="#888888", opacity=0.3) plotter.add_mesh(warped, scalars="|u|", cmap="viridis", show_edges=False) plotter.view_isometric() plotter.camera.zoom(1.1) plotter.show() .. image-sg:: /gallery/verification/images/sphx_glr_example_verify_cantilever_eb_001.png :alt: example verify cantilever eb :srcset: /gallery/verification/images/sphx_glr_example_verify_cantilever_eb_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 87-89 Acceptance ---------- .. GENERATED FROM PYTHON SOURCE LINES 89-95 .. code-block:: Python finest = rec.results[-1] assert finest.passed, ( f"finest-mesh tip_deflection failed: {finest.rel_error:.2%} " f"above tolerance {finest.published.tolerance:.0%}" ) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.747 seconds) .. _sphx_glr_download_gallery_verification_example_verify_cantilever_eb.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_verify_cantilever_eb.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_verify_cantilever_eb.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: example_verify_cantilever_eb.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_