GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Allow the initial phase of a bode plot to be specified · Issue #388 · python-control/python-control

Allow the initial phase of a bode plot to be specified #388

New issue
Copy link
New issue
Copy link
Closed
Closed
Allow the initial phase of a bode plot to be specified#388
Copy link
Labels
enhancement
Milestone
0.9.1

Description

@Nick-Hemenway
Nick-Hemenway
opened on Apr 3, 2020
Issue body actions

The output of the bode_plot function is bounded to between -180 degrees and 180 degrees and doesn't account for conditions when the phase should leave these ranges. For example a phase angle of -270 degrees will be represented as 90 degrees on the bode plot. To illustrate this, I've got a simple example below:

import control as ct

m = 2
k = 100_000
Wci = 2*np.pi*500

G1 = ct.TransferFunction([1],[m, 0, -k])
G2 = ct.TransferFunction([1], [1/Wci, 1])
G3 = G1*G2

ct.bode_plot([G1, G2, G3], dB = True, Hz = True)

image

-G1 (blue curve) contains two poles and a DC gain and has a phase angle of -180 degrees.

-G2 (orange curve) is a simple pole with no DC gain and thus has a phase that starts at 0 degrees and goes to -90 degrees

-G3 (green curve) is the product of the two transfer functions which on the bode plot corresponds to adding of the curves. We should see the green curve start at a phase of -180 degrees and go to -270 degrees but it does not do this because of the way that the phase angle is computed.

Activity

  1. murrayrm commented on Apr 3, 2020

    @murrayrm
    murrayrm
    on Apr 3, 2020
    Member
    More actions

    Bode plots can represent phase outside of -180 to 180. For example, if you change your example to have a positive spring constant with some damping, it gives you a more natural plot:

    import numpy as np
    import control as ct
    
    m = 2
    k = 100_000
    d = 100
    Wci = 2*np.pi*500
    
    G1 = ct.TransferFunction([1],[m, d, k])
    G2 = ct.TransferFunction([1], [1/Wci, 1])
    G3 = G1*G2
    
    ct.bode_plot([G1, G2, G3], dB = True, Hz = True)
    

    updated_bode

    Coming back to your example, the bode_plot function has to make some guesses about what the initial phase is. This is what is causing the problem in your plots. We can probably make things more "natural" here (volunteers to do this are welcome -:). It might also be nice to add a way to set the initial phase of the plot and/or separate the generation of the frequency response from plotting in a better way (see issue #65).

    The "fix" I can suggest is to store the return values from bode_plot and then plot by hand (sorry -:).

    Reacted by Ben Greiner
  2. murrayrm
    changed the title [-]Bode Plot Phase Bounded to Between -180 and 180 Degrees[/-] [+]Allow the initial phase of a bode plot to be specified[/+] on Jul 11, 2020
  3. murrayrm
    added
    enhancement
    on Jul 11, 2020
  4. murrayrm
    added this to the 0.9.x milestone on Dec 26, 2020
  5. murrayrm commented on Jan 4, 2021

    @murrayrm
    murrayrm
    on Jan 4, 2021
    Member
    More actions

    This has been fixed in PR #494 (currently pending).

  6. murrayrm
    added
    PR pending
    on Jan 4, 2021
  7. bnavigator commented on Jan 4, 2021

    @bnavigator
    bnavigator
    on Jan 4, 2021
    Contributor
    More actions

    It has already been merged 2 days ago.

  8. bnavigator
    closed this as completedon Jan 4, 2021
  9. bnavigator
    removed
    PR pending
    on Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      • 0.9.1

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.