.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/geophysics/plot_05_cavendish_weighs_the_earth.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_geophysics_plot_05_cavendish_weighs_the_earth.py: Cavendish weighs the Earth (1798) ================================= Henry Cavendish hung a 1.8 m rod carrying two small lead balls from a fine wire and brought two 158 kg balls close to them. The rod twisted by about a milliradian, and timing its slow free swing calibrated the wire. Together these give the gravitational constant, and with surface gravity the mean density of the Earth: Cavendish found 5.48 times that of water, about twice the density of surface rock, so the interior must be much denser. .. GENERATED FROM PYTHON SOURCE LINES 12-42 .. image-sg:: /api/gallery/geophysics/images/sphx_glr_plot_05_cavendish_weighs_the_earth_001.png :alt: Torsion balance, Weighing the Earth :srcset: /api/gallery/geophysics/images/sphx_glr_plot_05_cavendish_weighs_the_earth_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from earthsciencekit.constants import EARTH_RADIUS, G from earthsciencekit.geophysics import earth_mean_density, torsion_balance_gravitational_constant arm, separation, large, period = 1.86, 0.225, 158.0, 420.0 deflection = 1.0e-3 measured = torsion_balance_gravitational_constant(arm, separation, deflection, large, period) density = earth_mean_density(9.81, EARTH_RADIUS, measured) assert np.isclose(measured, G, rtol=0.01) assert 5400 < density < 5600 and density / 2700 > 2 twist = np.linspace(0.5e-3, 1.5e-3, 50) fig, (left, right) = plt.subplots(1, 2, figsize=(10, 4)) left.plot(twist * 1e3, torsion_balance_gravitational_constant(arm, separation, twist, large, period)) left.axhline(G, color="0.5", ls="--", label="CODATA G") left.plot(deflection * 1e3, measured, "o") left.set(xlabel="rod deflection [mrad]", ylabel="G [m^3/(kg s^2)]", title="Torsion balance") left.legend() constants = np.linspace(5e-11, 9e-11, 50) right.plot(constants, earth_mean_density(9.81, EARTH_RADIUS, constants)) right.axhline(2700, color="0.5", ls=":", label="granite") right.plot(measured, density, "o", label=f"{density:.0f} kg/m^3") right.set(xlabel="G [m^3/(kg s^2)]", ylabel="mean density [kg/m^3]", title="Weighing the Earth") right.legend() fig.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.209 seconds) .. _sphx_glr_download_api_gallery_geophysics_plot_05_cavendish_weighs_the_earth.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/geophysics/plot_05_cavendish_weighs_the_earth.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_05_cavendish_weighs_the_earth.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_05_cavendish_weighs_the_earth.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_05_cavendish_weighs_the_earth.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_