Repository navigation
Commit 3b3c005
committed
Fix discrete-time frequency handling in describing_function_response
For a discrete-time system, describing_function_response found limit
cycles with about the right amplitude but reported the wrong frequency:
it took the oscillation frequency as the imaginary part of the Nyquist
contour, which for a discrete system lies on the unit circle
exp(1j*w*dt), so it reported about sin(w*dt) - the same number whatever
dt is. The refinement cost function and the returned positions also
evaluated H at z = 1j*w rather than on the unit circle, and refinement
typically failed with "not able to refine result; returning estimate".
For example, H(z) = 0.5/(z^2 - 0.5z) with dt = 1 crosses the negative
real axis at w = 1.3181, but the reported frequency was 0.9703, and
dt = 0.5 gave the same 0.9703 instead of 2.6362.
When H.isdtime(strict=True) - matching the timebase semantics used by
nyquist_response - take the frequencies as np.angle(contour) / dt and
evaluate H at exp(1j*w*dt) in the refinement cost function and for the
returned positions. The strict check keeps dt=None (unspecified
timebase) on the continuous-time path; dt=True (discrete, unspecified
sample time) reports rad/sample.
Adds regression tests: a known unit-circle crossing for dt = 1 and
dt = 0.5, plus dt=None continuous-equivalence and dt=True coverage.
The discrete tests fail at baseline; continuous-time behavior is
unchanged.
Fixes #12691 parent bfe9380 commit 3b3c005
2 files changed
Lines changed: 63 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
349 | | - | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
350 | 362 | | |
351 | 363 | | |
352 | 364 | | |
| |||
375 | 387 | | |
376 | 388 | | |
377 | 389 | | |
378 | | - | |
| 390 | + | |
379 | 391 | | |
380 | 392 | | |
381 | 393 | | |
| |||
386 | 398 | | |
387 | 399 | | |
388 | 400 | | |
389 | | - | |
| 401 | + | |
390 | 402 | | |
391 | 403 | | |
392 | 404 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
175 | 223 | | |
176 | 224 | | |
177 | 225 | | |
| |||
0 commit comments