Skip to content

Phase shift in bode plot #467

Closed
Closed

Description

@SebastienDeriaz

Given the transfer function
G = 1/s^3
We should see a constant negative phase of -270°, which is confirmed in matlab

image

However, both control.bode and control.matlab.bode give 90° instead of -270°. Although technically the same value, it does get confusing.

import control
import control.matlab
s = control.tf('s')

G = 1/s**3

control.bode(G);

image

control.matlab.bode(G);

image

What i've tried so far

Is it possible to get the "absolute" phase of the transfer function ? If not, i would suggest that control.matlab.bode be corrected as to reflect the behavior of matlab's bode

Thanks for your help !

Activity

  1. SebastienDeriaz commented on Nov 10, 2020

    @SebastienDeriaz
    Author

    My (limited) understanding of the function is that bode uses freqresp which uses evalfr and then numpy.angle. Since evalfr returns a complex number it isn't directly possible to get the "absolute" angle so the issue i'm reporting seems to require a dedicated code to determine a "reference phase" of some sort.
    My excuses for my current level of python (or gitHub) doesn't lead me much further than that

  2. bnavigator commented on Nov 10, 2020

    @bnavigator
    Contributor

    Thanks, for bringing this up.

    Related issue: #388

    My excuses for my current level of python (or gitHub) doesn't lead me much further than that

    You are nevertheless very welcome to practice your Python and GitHub skills by trying to fix the issue and submitting a pull request 🧑‍🎓

  3. ilayn commented on Nov 10, 2020

    @ilayn

    The phase correction is only possible when you have the pole-zero structure and the behavior w->0, so you have to compute the initial phase to get the right amount of shift which is typically done with a decision of adding a minus sign attached to the atan2 computation.

    When you supply a custom frequency grid then it is trickier to snap to the correct phase since then you have to evaluate more stuff to get to that grid from the pole-zero structure (if there is any, say FRD objects don't have it).

  4. added this to the 0.9.x milestone on Dec 26, 2020
  5. self-assigned this
    on Dec 29, 2020
  6. bnavigator commented on Jan 3, 2021

    @bnavigator
    Contributor

    Resolved in #494. If you think this is not solved, please reopen.

  7. Juan-Gg commented on Aug 9, 2023

    @Juan-Gg

    It seems to work with poles, but it does not with zeros.

    For a single zero a constant phase of 90º would be expected, it gives -270º instead.

    from matplotlib import pyplot as plt 
    from control.matlab import *  # MATLAB-like functions
    
    %matplotlib widget
    s = tf('s')
    G = (s)
    plt.figure()
    bode(G, wrap_phase = False)
    plt.show()
    

    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions