Skip to main content

lib_jsl_electromagnetics/antenna_models/
half_wave_dipole.rs

1//! Thin-wire dipoles of finite length, and the half-wave dipole.
2//!
3//! See the book entry [Antenna models](https://jwkunz.github.io/lib_jsl/book/em-arrays/antennas.html).
4
5use super::{Antenna, Excitation};
6use crate::conventions::{C64, Medium, TimeConvention};
7use lib_jsl_core::constants::em::C0;
8use std::f64::consts::{PI, TAU};
9
10/// A centre-fed thin wire of total length `L` along `z` with the standard sinusoidal current
11/// `I(z) = I_m sin(k (L/2 - |z|))`. Far field per unit *maximum* current `I_m`
12/// (Balanis §4.6), in the `e^{+jωt}` convention:
13///
14/// `E_θ = j η I_m / (2π) · [cos(kL/2 cos θ) - cos(kL/2)] / sin θ`.
15///
16/// Radiation resistance is referred to the current maximum.
17#[derive(Debug, Clone, Copy, PartialEq)]
18pub struct Dipole {
19    pub length: f64,
20}
21
22impl Dipole {
23    pub fn new(length: f64) -> Self {
24        Dipole { length }
25    }
26}
27
28impl Antenna for Dipole {
29    fn far_field(&self, theta: f64, _phi: f64, frequency: f64, convention: TimeConvention) -> [C64; 2] {
30        // ANCHOR: dipole_far_field
31        let half_kl = 0.5 * TAU * frequency / C0 * self.length;
32        let s = theta.sin();
33        let eta = Medium::VACUUM.impedance(TimeConvention::PlusJ).re;
34        let shape = if s.abs() < 1e-12 { 0.0 } else { ((half_kl * theta.cos()).cos() - half_kl.cos()) / s };
35        [convention.unit() * (eta / TAU * shape), C64::new(0.0, 0.0)]
36        // ANCHOR_END: dipole_far_field
37    }
38
39    fn excitation(&self) -> Excitation {
40        Excitation::Current
41    }
42
43    fn power_grid(&self, frequency: f64) -> (usize, usize) {
44        // Longer dipoles have more lobes; keep several nodes per lobe.
45        let electrical = self.length * frequency / C0;
46        ((48.0 + 24.0 * electrical).ceil() as usize, 8)
47    }
48
49    fn peak_directivity(&self, frequency: f64) -> f64 {
50        // The pattern is rotationally symmetric: search θ only, finely.
51        let p = self.radiated_power(frequency);
52        let best = (0..=20_000).map(|i| self.radiation_intensity(PI * i as f64 / 20_000.0, 0.0, frequency)).fold(0.0, f64::max);
53        4.0 * PI * best / p
54    }
55}
56
57/// A dipole cut to half a wavelength at `design_frequency` (`L = λ₀/2`). At the design frequency
58/// it has directivity ≈ 1.64 (2.15 dBi) and radiation resistance ≈ 73.1 Ω; at other frequencies
59/// it behaves as the corresponding finite [`Dipole`].
60#[derive(Debug, Clone, Copy, PartialEq)]
61pub struct HalfWaveDipole {
62    pub design_frequency: f64,
63}
64
65impl HalfWaveDipole {
66    pub fn new(design_frequency: f64) -> Self {
67        HalfWaveDipole { design_frequency }
68    }
69
70    /// The physical length `λ₀ / 2`.
71    pub fn length(&self) -> f64 {
72        0.5 * C0 / self.design_frequency
73    }
74
75    fn dipole(&self) -> Dipole {
76        Dipole::new(self.length())
77    }
78}
79
80impl Antenna for HalfWaveDipole {
81    fn far_field(&self, theta: f64, phi: f64, frequency: f64, convention: TimeConvention) -> [C64; 2] {
82        self.dipole().far_field(theta, phi, frequency, convention)
83    }
84
85    fn excitation(&self) -> Excitation {
86        Excitation::Current
87    }
88
89    fn power_grid(&self, frequency: f64) -> (usize, usize) {
90        self.dipole().power_grid(frequency)
91    }
92
93    fn peak_directivity(&self, frequency: f64) -> f64 {
94        self.dipole().peak_directivity(frequency)
95    }
96}
97
98#[cfg(test)]
99mod tests {
100    use super::*;
101
102    #[test]
103    fn half_wave_dipole_textbook_values() {
104        let f = 1e9;
105        let d = HalfWaveDipole::new(f);
106        assert!((d.length() - 0.149_896_229).abs() < 1e-9);
107        let r = d.radiation_resistance(f).unwrap();
108        assert!((r - 73.08).abs() < 0.02, "{r}"); // 30 Cin(2π) = 73.08 Ω
109        let dmax = d.peak_directivity(f);
110        assert!((dmax - 1.6409).abs() < 1e-3, "{dmax}");
111        assert!((10.0 * dmax.log10() - 2.15).abs() < 0.01);
112        assert!(d.far_field(0.0, 0.0, f, TimeConvention::PlusJ)[0].norm() < 1e-12); // nulls on axis
113        // The two conventions give conjugate phasors.
114        let (a, b) = (d.far_field(1.0, 0.0, f, TimeConvention::PlusJ)[0], d.far_field(1.0, 0.0, f, TimeConvention::MinusI)[0]);
115        assert!((a - b.conj()).norm() < 1e-12);
116    }
117
118    #[test]
119    fn short_dipoles_approach_the_hertzian_limit_and_long_ones_sharpen() {
120        let f = 3e8;
121        let short = Dipole::new(0.01);
122        assert!((short.peak_directivity(f) - 1.5).abs() < 1e-3);
123        // A full-wave dipole is more directive (≈ 2.41) with R ≈ 199 Ω at its current maximum.
124        let full = Dipole::new(1.0);
125        assert!((full.peak_directivity(f) - 2.41).abs() < 0.01, "{}", full.peak_directivity(f));
126        assert!((full.radiation_resistance(f).unwrap() - 199.1).abs() < 0.5, "{}", full.radiation_resistance(f).unwrap());
127    }
128}