.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/fluid_engineering/hydrostatics/plot_01_archimedes_buoyancy.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_fluid_engineering_hydrostatics_plot_01_archimedes_buoyancy.py: Archimedes's principle (c. 250 BC) ================================== In *On Floating Bodies* (c. 250 BC) Archimedes proved that a body immersed in a fluid is pushed up by the weight of the fluid it displaces, :math:`F_B = \rho g V` (:func:`~engineeringkit.fluid_engineering.buoyancy_force`). Galileo's reconstruction of the story of King Hiero's crown uses that principle: hang the crown and an equal mass of pure gold from a balance and lower both into water. A crown alloyed with silver is bulkier, is pushed up harder, and rises. This example weighs the crown in water, reads its silver content back from the apparent weight, and floats an iceberg. .. GENERATED FROM PYTHON SOURCE LINES 16-21 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from engineeringkit.fluid_engineering import G, buoyancy_force .. GENERATED FROM PYTHON SOURCE LINES 22-28 Weighing a crown in water ------------------------- A 1 kg crown is a mixture of gold (19 300 kg/m³) and silver (10 490 kg/m³). Its volume, and so its buoyancy, grows with the silver fraction by mass :math:`x`. .. GENERATED FROM PYTHON SOURCE LINES 28-48 .. code-block:: Python RHO_GOLD, RHO_SILVER, RHO_WATER, MASS = 19300.0, 10490.0, 998.0, 1.0 def crown_volume(x): return MASS * ((1 - x) / RHO_GOLD + x / RHO_SILVER) x = np.linspace(0, 1, 101) apparent = MASS * G - buoyancy_force(RHO_WATER, crown_volume(x)) gold_bar = MASS * G - buoyancy_force(RHO_WATER, crown_volume(0.0)) print(f"pure gold in water weighs {gold_bar:.4f} N; a 30% silver crown {apparent[30]:.4f} N") fig, ax = plt.subplots(figsize=(6, 4)) ax.plot(100 * x, apparent, label="crown") ax.axhline(gold_bar, color="k", ls="--", label="equal mass of gold") ax.set(xlabel="silver content [% by mass]", ylabel="apparent weight in water [N]", title="Hiero's crown") ax.legend() fig.tight_layout() .. image-sg:: /api/gallery/fluid_engineering/hydrostatics/images/sphx_glr_plot_01_archimedes_buoyancy_001.png :alt: Hiero's crown :srcset: /api/gallery/fluid_engineering/hydrostatics/images/sphx_glr_plot_01_archimedes_buoyancy_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none pure gold in water weighs 9.2995 N; a 30% silver crown 9.1718 N .. GENERATED FROM PYTHON SOURCE LINES 49-54 Reading the alloy back ---------------------- The apparent weight is linear in :math:`x`, so one weighing in air and one in water fix the silver fraction. .. GENERATED FROM PYTHON SOURCE LINES 54-60 .. code-block:: Python measured = apparent[30] volume = (MASS * G - measured) / (RHO_WATER * G) x_back = (volume / MASS - 1 / RHO_GOLD) / (1 / RHO_SILVER - 1 / RHO_GOLD) print(f"silver fraction from the weighing: {x_back:.3f}") .. rst-class:: sphx-glr-script-out .. code-block:: none silver fraction from the weighing: 0.300 .. GENERATED FROM PYTHON SOURCE LINES 61-66 A floating iceberg ------------------ A floating body displaces its own weight, so the submerged fraction is the density ratio: about 89% for ice (917 kg/m³) in sea water (1025 kg/m³). .. GENERATED FROM PYTHON SOURCE LINES 66-75 .. code-block:: Python rho_ice, rho_sea, V_ice = 917.0, 1025.0, 1.0e6 submerged = rho_ice * V_ice / rho_sea print(f"submerged fraction of an iceberg: {submerged / V_ice:.3f}") assert np.all(np.diff(apparent) < 0) and np.isclose(x_back, 0.30) assert np.isclose(buoyancy_force(rho_sea, submerged), rho_ice * V_ice * G) plt.show() .. rst-class:: sphx-glr-script-out .. code-block:: none submerged fraction of an iceberg: 0.895 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.027 seconds) .. _sphx_glr_download_api_gallery_fluid_engineering_hydrostatics_plot_01_archimedes_buoyancy.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/fluid_engineering/hydrostatics/plot_01_archimedes_buoyancy.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_archimedes_buoyancy.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_archimedes_buoyancy.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_archimedes_buoyancy.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_