-
Notifications
You must be signed in to change notification settings - Fork 438
problematic step() output: unstable instead of sinusoidal #384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The system is ill-conditioned since the closed loop system has a pure imaginary pole => small numerical errors can generate problems. The main problem in the
There is still a problem here to be fixed, which is the computation of the default time for the simulation in cases where there is a pure imaginary pole. Currently this computation is coming from |
Thanks. Missed the e15 part. As you have mentioned, a problematic default sampling rate gave me the following aliased output even for the simple damped oscillator, G = s/[(s + 0.01)^2 + 1] (this's similar to the 'goto example' mentioned by ilayn in #287, but a bit simpler.) a = -0.01
G1 = tf([1,0],[1,-2*a, 1+a**2])
y,t = step(G1)
ytrue_func = lambda t : np.exp(a*t)*np.sin(t)
t_true = linspace(0,700,2000)
ytrue = ytrue_func(t_true) Somehow all cases like this seem to be using a fixed 100 time steps, instead of using more to avoid aliasing. The code at https://github.com/ilayn/harold/blob/master/harold/_time_domain.py#L280-L454 mentioned in #287 works very well for this case with a good dt of 0.25 and ~1800 steps. |
Thanks for pointing out the Harold code, @prashant2. I'm going to spend some time trying to fix up this problem as part of PR #383. |
This is what I get from the current master of Gp = harold.Transfer(6,[1,6,11,6])
Gc = 10
Gor = Gp*Gc/(1 + Gp*Gc) # should have used feedback() command here anyways
harold.step_response_plot(Gor) and for the other example a = -0.01
G1 = harold.Transfer([1,0],[1,-2*a, 1+a**2])
step_response_plot(G1)
If this corona WFH thing lets me do some open source work, I'll try to release 1.0.2 soon. Please let me know if you encounter some nonsensical results. Richard it would be great if you can look into the repeated pole sensitivity issue. The rest you can copy/paste at will if the code is useful (I can delicense it if needed no attribution etc. required). |
I am trying to plot step response of a 3rd order process Gp, controlled with a P controller.
Gp = 6/[(s+1)(s+2)(s+3)]
I am using v0.8.3
Gor has 3 poles at (-6, sqrt(11) j, - sqrt(11) j ) and the expected behavior is sinusoidal oscillations after the initial transients have died down (ie t > ~ 2/3)

But what I get is an unstable system:
Octave gives the correct result (ymin 0.113, ymax 1.705 after transients):

The text was updated successfully, but these errors were encountered: