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 — Better I/O systems support for phase plots by murrayrm · Pull Request #1001 · python-control/python-control

Conversation

@murrayrm

@murrayrm murrayrm commented May 11, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This PR provides better I/O systems support for making phase plots:

  • Allow I/O systems with no inputs and/or no outputs to be specified. This is useful when generating phase plots, where you might just have a simple dynamical systems but still want to use the I/O system objects.
  • Improve the error messages in input_output_response when the number of states, inputs, or outputs are incompatible with the system size by telling you which one didn't match.
  • Generate warnings when simulations fail for individual initial conditions and drop individual trace (rather than terminating). This yields much nicer phase plane plots by allowing the system to generate lines when it can and ignoring the rest.
  • Added Jupyter notebook analyzing open and closed loop dynamics of an inverted pendulum, showing off some of the capabilities of the package.
  • Changed the way plot titles are created, using axes.set_title (centers title over axes) instead of fig.suptitle (centers over figure, which is good for multi-axes plots but otherwise looks funny). I'll propagate this same change to time plots and frequency plots in separate PRs.
  • Did some tweaking on arrow placement so that very short lines have zero or one arrows. Could use more work, but this is better than what we had.

As an example of the changes, here is the code to produce a phase portrait for the inverted pendulum example in FBS2e, Figure 5.4:

from math import pi
import control as ct
def invpend_update(t, x, u, params):
    m, l, b, g = params['m'], params['l'], params['b'], params['g']
    return [x[1], -b/m * x[1] + (g * l / m) * np.sin(x[0])]
invpend = ct.nlsys(
    invpend_update, states=2, inputs=0, name='invpend',
    params={'m': 1, 'l': 1, 'b': 0.2, 'g': 1})

ct.phase_plane_plot(invpend, [-2*pi - 1, 2*pi + 1, -2, 2], 10)

Before:
invpend_before

After:
invpend_after

The changes are not major, but if you look at the number and spacing of arrows along the streamlines, you'll see examples of the changes there (some streamlines have no arrows in "before" plot). Also note the change in location of the title.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
murrayrm added 3 commits May 11, 2024 10:06
@murrayrm
add better check for find_eqpt with mixed specifications
ff2fe8d
@murrayrm
fix nlsys conversion of float, array to dt=None
df2436f
@murrayrm
add support for nlsys w/out inputs or outputs
f6f88f8
@coveralls

coveralls commented May 11, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Coverage Status

coverage: 94.522% (+0.02%) from 94.503%
when pulling 951e171 on murrayrm:phaseplot_improvements-16Apr2024
into e4a03e8 on python-control:main.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

murrayrm added 9 commits June 4, 2024 22:15
@murrayrm
allow solve_ivp errors and improve arrow placement
d44a577
@murrayrm
add warning messages on trajectory errors (+ ability to suppress)
1b71fa0
@murrayrm
tweak arrow placement in _add_arrows_to_line2D
ab3b498
@murrayrm
add invpend example from Caltech CDS 110
44ccafb
@murrayrm
change phase_plane_plot to use axes.set_title instead of fig.suptitle
5d0450b
@murrayrm
fix bug in the way dir=-1 arrows are handled at endpoint
57e3e4e
@murrayrm
using hanging indent for import (isort -m2)
b34f72e
@murrayrm
revert unneeded change on find_eqpt checks for arg lengths
d6432ca
@murrayrm
final tweaks of arrow code
c72fa91
@slivingston
slivingston self-requested a review June 13, 2024 06:06
@slivingston slivingston self-assigned this Jun 13, 2024
slivingston
slivingston reviewed Jun 20, 2024
View reviewed changes
Comment thread examples/cds101_invpend-dynamics.ipynb Outdated

@slivingston slivingston Jun 20, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this file have a different name prefix than "cds101"? The commit message has "CDS 110", and the top of the file has

CDS 110/ChE 105, Winter 2024

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@slivingston

slivingston commented Jun 20, 2024

Copy link
Copy Markdown
Member

I agree that the plots are better. After a quick review, I did not find any errors, but I need 1 day more to review the changes carefully.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

slivingston
slivingston requested changes Jun 21, 2024
View reviewed changes

@slivingston slivingston left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments on the ipynb file

  • "insighs" -> "insights"

  • "which will will" -> "which we will"

  • "resuling dynamics" -> "resulting dynamics"

  • "reseting" -> "resetting"

  • Example 3.3 in the book refers to b (γ there) as "rotational friction," but here you write "viscous friction." The equations are consistent, and Example 3.2 (balance systems) refers to "viscous friction," so either choice works. Nonetheless I am calling it out for consistency with Example 3.3.

Other comments

  • While reviewing this, I noticed functions that return TimeResponseData (e.g., step_response) list some properties of it. Since those docstrings were written, more properties have been added (including 2 in this pull request), so users may not be aware of the new properties. After merging this, I am happy to add a note to relevant docstrings suggesting that users read the documentation of TimeResponseData for all properties.

  • Thanks for the many code quality improvements (sorting imports, deleting trailing space, ...)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@murrayrm
updates to address @slivingston review comments
951e171
@murrayrm

murrayrm commented Jun 26, 2024

Copy link
Copy Markdown
Member Author

Check failures are due to NumPy 2.0 and can be ignored (#1013 fixes this).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

slivingston
slivingston approved these changes Jun 26, 2024
View reviewed changes
@slivingston

slivingston commented Jun 26, 2024

Copy link
Copy Markdown
Member

@murrayrm thanks; I am reviewing #1013 now

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@murrayrm
murrayrm merged commit d92ae6a into python-control:main Jun 26, 2024
@murrayrm murrayrm added this to the 0.10.1 milestone Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@slivingston slivingston slivingston approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@slivingston slivingston

Labels

None yet

Projects

None yet

Milestone

0.10.1

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@murrayrm @coveralls @slivingston
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — 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.