[SciPy-User] how to create a phase portrait for a nonlinear diff. eqn.

Ryan Krauss ryanlists at gmail.com
Wed Jan 5 01:10:55 EST 2011


It's good to know I am not completely crazy....

But then practically what do you do to get nicely looking embedded arrows:
 ------>-------->-------
It feels like I am reinventing the wheel here a bit.  It seems like I
would have to define a dy and dx for my arrow head and project them
along and perpendicular to the tangent.

On Tue, Jan 4, 2011 at 9:31 PM, Rob Clewley <rob.clewley at gmail.com> wrote:
> On Tue, Jan 4, 2011 at 9:07 PM, Ryan Krauss <ryanlists at gmail.com> wrote:
>> I am teaching a nonlinear controls course this coming semester.  I
>> plan to have the students write code to generate phase portraits as a
>> project.  It is fairly easy to randomly (or intelligently?) create
>> initial condition seeds and run integrate.odeint.  What isn't obvious
>> to me is how to put arrows on phase portrait lines to indicate the
>> direction of the evolution over time.  For example, the attached code
>> creates a phase portrait for a fairly simple system.  The graph is
>> shown in the attached png.  But this equilibrium point is either
>> stable or unstable depending on whether the curve spirals in or out
>> over time.  How do I write code to automatically determine the
>> direction of increasing time and indicate it by arrow heads on the
>> graph?
>>
>> I know x, xdot, and time as vectors for each point on the graph.  I
>> guess I could numerically determine (d xdot)/dx for each point, but is
>> that the best route to go?  And that leads to issues as dx gets
>> small....
>
> Typically, in publications only a small number of arrows per curve is
> used. You should have no "dx" problems provided you keep sufficiently
> far from the equilibrium in the plane (e.g., using a radius distance
> threshold).
>
> If I understand your problem correctly, I'd pick no more than three
> points sufficiently far from the equilibrium on the curve (maybe
> approx equidistant in arc length), and then simply look at the next
> point forward in time in the phaseplane. That already gives you a
> linearized forward direction of a tangent line for your arrow and a
> basepoint. If your time step is reasonably good then I'd expect this
> to look presentable, at least for the purposes of a class project!
>
> -Rob
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>



More information about the SciPy-User mailing list