TransWikia.com

Proper way to produce StreamPlot

Mathematica Asked by RuD_wow on September 4, 2020

I have faced with problem of not completely correct phase trajectories of ODE, which was produced by StreamPlot.

Next following code ends up with this plot:

 f[x_, y_] = x/(-x - 2 y)
 StreamPlot[{1, f[x, y]}, {x, -10, 10}, {y, -10, 10}, Frame -> False, 
 Axes -> True, AspectRatio -> 1/GoldenRatio, StreamStyle -> "PinDart"]

Phase trajectoies

Unfortunately, streamlines are interrupting on line $y = -dfrac{x}{2}$, when they should go as they were. By this, I mean that there should be only clockwise directed streamlines.

Is there any straightforward way to deal with this issue?
Thank you!

2 Answers

Will this do the trick:

Clear[f]
f[x_, y_] := {1, x/(-x - 2 y)};
f[x_, y_] /; y > -x/2 := -{1, x/(-x - 2 y)};
StreamPlot[f[x, y], {x, -10, 10}, {y, -10, 10}, Frame -> False, 
 Axes -> True, AspectRatio -> 1/GoldenRatio, StreamStyle -> "PinDart"]

Answered by Algohi on September 4, 2020

Since we're not given an ODE by the OP, it's hard to comment on which phase portrait is correct. But taking the OP's desire for clockwise flow as given and working backwards, we might reach the following system (or a positive multiple of it): $${dx over dt} = x+2y, {dy over dt} = -x ,.tag{1}$$ In that case, the phase field is given by

Clear[f]
f[x_, y_] := {x + 2 y, -x};

StreamPlot[f[x, y], {x, -10, 10}, {y, -10, 10}, Frame -> False, 
 Axes -> True, AspectRatio -> 1/GoldenRatio, StreamStyle -> "PinDart"]

enter image description here

(If the ODE/system was ${d^2yover dt^2} + {dy over dt} + 2y=0$, with $x = dy/dt$, then the flow as plotted would be the same as above, because the "position" y and the "velocity" x are switched from the usual velocity versus position. If the ODE/system was $dy/dx = x/(-x-2y)$, then $dx/dt = 1 > 0$ and all trajectories move to the right; the original stream plot was correct. And if the ODE/system was a negative multiple of (1), then the phase flow is counterclockwise.)

Answered by Michael E2 on September 4, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP