1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
//! The SNR-loss budget of an OFDM receiver (Speth, Fechtel, Fock & Meyr 1999).
//!
//! In tracking mode every residual imperfection of the inner receiver, a noisy channel
//! estimate, a timing offset, a carrier frequency offset, fading within a symbol, is
//! a rotation of the subcarriers plus an additive noise of power $\sigma^{2}$ (relative to
//! the power of a subcarrier, $E|a_{k}|^{2} = E|H_{k}|^{2} = 1$), and its cost is the
//! loss of SNR it causes, their eq. (14),
//!
//! $$
//! \Delta\gamma = \frac{\gamma_{\mathrm{ideal}}}{\gamma_{\mathrm{real}}}, \qquad
//! \sigma_{\mathrm{res}}^{2} = \sigma_{\varepsilon}^{2} + \sigma_{\Omega}^{2} +
//! \sigma_{\mathrm{fad}}^{2} < \frac{1}{\gamma}\left(1 - \frac{1}{\Delta\gamma_{\max}}\right)
//! $$
//!
//! (eqs. (50)–(51), $\gamma$ the SNR per subcarrier): the noises add, and a loss
//! $\Delta\gamma_{\max}$ allows the total [`noise_budget`]. The noises of the
//! imperfections:
//!
//! - a channel estimate of gain $G$ (its error is the noise divided by $G$, eq. (19)):
//! $\Delta\gamma = 1 + 1/G$, eq. (20), [`estimator_loss_db`] and [`estimator_gain`];
//! - a timing offset of $n_{\varepsilon}$ samples beyond the part of the guard interval
//! that the echoes leave free, eqs. (30)–(31), [`timing_noise_power`];
//! - a carrier frequency offset $\Delta f T_{u}$ (in subcarrier spacings), eq. (42),
//! [`cfo_noise_power`], $\frac{\pi^{2}}{3}(\Delta f T_{u})^{2}$, and the largest one
//! for a loss, eq. (43), [`max_cfo`];
//! - fading of maximum Doppler $f_{D}$ within a symbol (Jakes), eq. (47),
//! [`doppler_noise_power`], $\frac{\pi^{2}}{6}(f_{D} T_{u})^{2}$, and the largest
//! Doppler for a loss, [`max_doppler`] (the curves of their Fig. 7).
//!
//! The approximations are those of the paper: one imperfection at a time, small errors
//! (the attenuation of the wanted subcarrier neglected), every interference Gaussian;
//! [`super::sync::ici_power`] gives the exact interference of a frequency offset.
//!
//! # Examples
//! ```
//! use comnum_waveform::ofdm::budget::{estimator_gain, estimator_loss_db, max_doppler};
//! // Sec. IV-A: an estimator of gain 10 costs 0.41 dB; 0.1 dB needs a gain of 43
//! assert!((estimator_loss_db(10.0) - 0.414).abs() < 1e-3);
//! assert!((estimator_gain(0.1) - 42.9).abs() < 0.05);
//! // Fig. 7: at 20 dB of SNR, 1 dB of loss tolerates f_D T_u = 0.035
//! assert!((max_doppler(100.0, 1.0) - 0.0354).abs() < 1e-4);
//! ```
//!
//! # References
//!
//! 1. M. Speth, S. A. Fechtel, G. Fock and H. Meyr, "Optimum receiver design for wireless
//! broad-band systems using OFDM — Part I," *IEEE Trans. Commun.*, 47(11),
//! 1668–1677, 1999.
use ;
use PI;
/// The SNR loss (dB) of a receiver that equalises with a channel estimate of gain $G$,
/// $10 \log_{10}(1 + 1/G)$ (eq. (20)).
/// The gain $G = 1/(\Delta\gamma - 1)$ a channel estimator needs for a loss of `loss_db`
/// (dB): the inverse of [`estimator_loss_db`] (their Fig. 2).
/// The largest total power $\sigma_{\mathrm{res}}^{2}$ of the residual noises (relative to
/// the power of a subcarrier) for a loss of `loss_db` (dB) at the SNR `snr_lin` (linear,
/// per subcarrier): $(1 - 1/\Delta\gamma_{\max})/\gamma$ (eqs. (32), (51)).
/// The power of the intersymbol and intercarrier interference of a timing offset
/// (eqs. (30)–(31)): over the taps `(delay, power)` of the channel (delays in samples,
/// powers of unit sum), $\sum_{i} p_{i}\,(2\Delta_{i}/N - (\Delta_{i}/N)^{2})$, with
/// $\Delta_{i}$ the samples of the FFT window of $N$ = `n_fft` points that fall outside
/// the symbol of tap $i$ for a window `offset` samples late (positive) or early
/// (negative) of the end of the guard interval of `guard` samples:
/// $\Delta_{i} = n_{\varepsilon} - \tau_{i}$ if $n_{\varepsilon} > \tau_{i}$,
/// $\tau_{i} - N_{g} - n_{\varepsilon}$ if $n_{\varepsilon} < \tau_{i} - N_{g}$, 0
/// otherwise (the second condition is printed $0 < n_{\varepsilon}T < -(T_{g} -
/// \tau_{i})$ in the paper, which cannot hold for an echo inside the guard interval).
///
/// # Errors
/// [`comnum_core::Error::Config`] for an empty FFT, a negative delay or power.
/// The power of the intercarrier interference of a small carrier frequency offset
/// `eps` (in subcarrier spacings), $\frac{\pi^{2}}{3}\varepsilon^{2}$ (eq. (42)): the
/// second-order term of [`super::sync::ici_power`] when every subcarrier is active.
/// The power of the intercarrier interference of fading within a symbol, for a Jakes
/// spectrum of maximum Doppler `fd_tu` (normalised to the subcarrier spacing,
/// $f_{D} T_{u}$), $\frac{\pi^{2}}{6}(f_{D} T_{u})^{2}$ (eq. (47); taps of unit total
/// power).
/// The largest carrier frequency offset (in subcarrier spacings) for a loss of
/// `loss_db` (dB) at the SNR `snr_lin` (linear, per subcarrier), eq. (43):
/// [`cfo_noise_power`] equal to the [`noise_budget`].
/// The largest maximum Doppler $f_{D} T_{u}$ (normalised to the subcarrier spacing) for a
/// loss of `loss_db` (dB) at the SNR `snr_lin` (linear, per subcarrier): the bound of
/// Fig. 7 of Speth et al., [`doppler_noise_power`] equal to the [`noise_budget`]
/// ([`max_cfo`] times $\sqrt{2}$).