.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/structural_engineering/members/plot_01_hooke_axial.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 or to run this example in your browser via JupyterLite. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_structural_engineering_members_plot_01_hooke_axial.py: Hooke's law: ut tensio, sic vis (1678) ====================================== In 1676 Robert Hooke published an anagram, *ceiiinosssttuu*, and in 1678 its solution, *ut tensio, sic vis*: "as the extension, so the force". Springs, wires and wooden rods all stretched in proportion to the weight hung on them. Written for a bar of length :math:`L`, area :math:`A` and modulus :math:`E` (Young's, 1807), the extension is :math:`\delta = PL/(AE)` (:func:`~engineeringkit.structural_engineering.axial_deformation`) and the stored energy is the triangle under the load-extension line, :math:`U = P\delta/2 = P^2L/(2AE)` (:func:`~engineeringkit.structural_engineering.strain_energy_axial`). The example repeats Hooke's experiment on a steel wire and checks both. .. GENERATED FROM PYTHON SOURCE LINES 18-24 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from scipy.integrate import simpson from engineeringkit.structural_engineering import axial_deformation, strain_energy_axial .. GENERATED FROM PYTHON SOURCE LINES 25-27 Weights on a wire ----------------- .. GENERATED FROM PYTHON SOURCE LINES 27-38 .. code-block:: Python L, d, E = 2.0, 1e-3, 200e9 # a 2 m steel wire, 1 mm diameter A = np.pi * d**2 / 4 loads = 9.81 * np.arange(0, 11) * 2.0 # 0 to 20 kg in 2 kg steps [N] stretch = axial_deformation(loads, L, A, E) for P, dl in list(zip(loads, stretch))[::5]: print(f"load {P:6.1f} N: extension {1e3 * dl:.3f} mm") stiffness = np.polyfit(stretch, loads, 1)[0] print(f"measured stiffness {stiffness / 1e3:.1f} kN/m = AE/L = {A * E / L / 1e3:.1f} kN/m") assert np.isclose(stiffness, A * E / L) .. rst-class:: sphx-glr-script-out .. code-block:: none load 0.0 N: extension 0.000 mm load 98.1 N: extension 1.249 mm load 196.2 N: extension 2.498 mm measured stiffness 78.5 kN/m = AE/L = 78.5 kN/m .. GENERATED FROM PYTHON SOURCE LINES 39-41 Energy is the area under the line --------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 41-56 .. code-block:: Python P_max = loads[-1] area = simpson(loads, x=stretch) U = strain_energy_axial(P_max, L, A, E) print(f"area under the load-extension line {1e3 * area:.3f} mJ, P^2 L/(2AE) = {1e3 * U:.3f} mJ") assert np.isclose(area, U) and np.isclose(U, P_max * stretch[-1] / 2) fig, ax = plt.subplots(figsize=(6, 3.5)) ax.plot(1e3 * stretch, loads, "o-") ax.fill_between(1e3 * stretch, loads, alpha=0.2, label=f"U = {1e3 * U:.1f} mJ") ax.set(xlabel="extension [mm]", ylabel="load [N]", title="Ut tensio, sic vis") ax.legend() fig.tight_layout() plt.show() .. image-sg:: /api/gallery/structural_engineering/members/images/sphx_glr_plot_01_hooke_axial_001.png :alt: Ut tensio, sic vis :srcset: /api/gallery/structural_engineering/members/images/sphx_glr_plot_01_hooke_axial_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none area under the load-extension line 245.063 mJ, P^2 L/(2AE) = 245.063 mJ .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.029 seconds) .. _sphx_glr_download_api_gallery_structural_engineering_members_plot_01_hooke_axial.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../../../lite/lab/index.html?path=api/gallery/structural_engineering/members/plot_01_hooke_axial.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_hooke_axial.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_hooke_axial.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_hooke_axial.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_