.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/communications/propagation/plot_02_friis_transmission.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_communications_propagation_plot_02_friis_transmission.py: The Friis transmission formula ============================== Harald Friis (1946) wrote the received power between two antennas in free space as :math:`P_r = P_t G_t G_r (\lambda/4\pi d)^2` (:func:`~engineeringkit.communications.friis_received_power`). The :math:`1/d^2` factor is pure geometry: power spreads over a sphere of area :math:`4\pi d^2`. The :math:`\lambda^2` factor comes from an antenna's effective aperture, :math:`A_e = G\lambda^2/4\pi`. This example checks both interpretations and the 6 dB-per-doubling slope of :func:`~engineeringkit.communications.free_space_path_loss_db`. .. GENERATED FROM PYTHON SOURCE LINES 16-21 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from engineeringkit.communications import free_space_path_loss_db, friis_received_power, wavelength .. GENERATED FROM PYTHON SOURCE LINES 22-24 Spherical spreading times effective aperture -------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 24-35 .. code-block:: Python Pt, Gt, Gr, f = 10.0, 30.0, 20.0, 5.8e9 d = np.logspace(2, 5, 100) flux = Pt * Gt / (4 * np.pi * d**2) aperture = Gr * float(wavelength(f)) ** 2 / (4 * np.pi) assert np.allclose(friis_received_power(Pt, Gt, Gr, d, f), flux * aperture) slope = np.polyfit(np.log2(d), free_space_path_loss_db(d, f), 1)[0] print(f"path loss grows by {slope:.2f} dB per doubling of distance") print(f"received power at 10 km: {float(friis_received_power(Pt, Gt, Gr, 1e4, f)) * 1e9:.2f} nW") .. rst-class:: sphx-glr-script-out .. code-block:: none path loss grows by 6.02 dB per doubling of distance received power at 10 km: 1.02 nW .. GENERATED FROM PYTHON SOURCE LINES 36-38 Higher frequency, same antennas: more loss ------------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 38-49 .. code-block:: Python fig, axes = plt.subplots(1, 2, figsize=(9, 3.6)) axes[0].loglog(d / 1e3, friis_received_power(Pt, Gt, Gr, d, f)) axes[0].set(xlabel="distance [km]", ylabel="received power [W]", title="Inverse-square spreading") for freq in [900e6, 2.4e9, 28e9]: axes[1].semilogx(d / 1e3, free_space_path_loss_db(d, freq), label=f"{freq / 1e9:g} GHz") axes[1].set(xlabel="distance [km]", ylabel="free-space path loss [dB]") axes[1].legend() fig.tight_layout() plt.show() .. image-sg:: /api/gallery/communications/propagation/images/sphx_glr_plot_02_friis_transmission_001.png :alt: Inverse-square spreading :srcset: /api/gallery/communications/propagation/images/sphx_glr_plot_02_friis_transmission_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.448 seconds) .. _sphx_glr_download_api_gallery_communications_propagation_plot_02_friis_transmission.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/communications/propagation/plot_02_friis_transmission.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_02_friis_transmission.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_friis_transmission.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_friis_transmission.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_