Plot Phase Planes ODEs Mathematica

In summary, you can plot multiple null clines simultaneously in Mathematica by assigning a Plot command to a variable.
  • #1
Dustinsfl
2,281
5
How can I plot the different phase planes for a system of ODEs in Mathematica?
 
Last edited:
Physics news on Phys.org
  • #2
$$
\displaystyle\begin{array}{lcl}
\displaystyle \frac{du_1}{d\tau} & \displaystyle = & \displaystyle u_1\left(1 - u_1 - a_{12}u_2\right)\\
\frac{du_1}{d\tau} & \displaystyle = & \displaystyle\rho u_1\left(1 - a_{21}u_1\right)
\end{array}
$$

Where $\rho,a_{12},a_{21}$ are constants.
 
Last edited:
  • #3
I am pretty sure this works:

Show[StreamPlot[{(1 - x - 2 y), (1 - 2 x)}, {x, 0, 2}, {y, 0, 2},
Axes -> True]]

How can I plot the null clines simultaneously?

For the above phase plane, I used the case $a_{12},a_{21}>1$
 
  • #4
dwsmith said:
I am pretty sure this works:

Show[StreamPlot[{(1 - x - 2 y), (1 - 2 x)}, {x, 0, 2}, {y, 0, 2},
Axes -> True]]

How can I plot the null clines simultaneously?

For the above phase plane, I used the case $a_{12},a_{21}>1$

Any time you want to plot multiple plots simultaneously, you can assign a Plot command to a variable like this:

PlotOne = Plot[x^2,{x,-2,2}]
PlotTwo = Plot[Sin[x],{x,-Pi,Pi}]

Then you show them simultaneously by doing

Show[PlotOne, PlotTwo]

So, if you can plot everything you need separately, this is a way to combine it all.
 
  • #5
Ackbach said:
Any time you want to plot multiple plots simultaneously, you can assign a Plot command to a variable like this:

PlotOne = Plot[x^2,{x,-2,2}]
PlotTwo = Plot[Sin[x],{x,-Pi,Pi}]

Then you show them simultaneously by doing

Show[PlotOne, PlotTwo]

So, if you can plot everything you need separately, this is a way to combine it all.

Plotting the nullclines for these plots don't work the same since I have y and x terms. Do you know how to overcome that?
 
  • #6
dwsmith said:
Plotting the nullclines for these plots don't work the same since I have y and x terms. Do you know how to overcome that?

It doesn't matter how you generate a plot, you can still assign it to a variable like PlotOne, PlotTwo. You could say

PlotThree = ImplicitPlot[...]

or

PlotFour = ContourGraphics[...]

etc.

Let's back up a bit and ask this question: is your problem the problem of showing multiple plots simultaneously, or is the problem plotting one thing in the first place?
 
  • #7
Ackbach said:
It doesn't matter how you generate a plot, you can still assign it to a variable like PlotOne, PlotTwo. You could say

PlotThree = ImplicitPlot[...]

or

PlotFour = ContourGraphics[...]

etc.

Let's back up a bit and ask this question: is your problem the problem of showing multiple plots simultaneously, or is the problem plotting one thing in the first place?

plotting the null cline for

$
\frac{du_1}{d\tau}
$
 
  • #8
Ah. So, is your system in Post # 2 correct? I'm a bit confused, since the subscripts appear to be the same everywhere. Should it be, rather,

\begin{align*}
\frac{du_1}{d\tau} & = u_1\left(1 - u_1 - a_{12}u_2\right)\\
\frac{du_2}{d\tau} & = \rho u_1\left(1 - a_{21}u_1\right)?
\end{align*}
 
  • #9
Ackbach said:
Ah. So, is your system in Post # 2 correct? I'm a bit confused, since the subscripts appear to be the same everywhere. Should it be, rather,

\begin{align*}
\frac{du_1}{d\tau} & = u_1\left(1 - u_1 - a_{12}u_2\right)\\
\frac{du_2}{d\tau} & = \rho u_1\left(1 - a_{21}u_1\right)?
\end{align*}

the second one should be rho u_2
 
  • #10
dwsmith said:
the second one should be rho u_2

And what are $\rho, a_{21}$, and $a_{12}$?
 
  • #11
Ackbach said:
And what are $\rho, a_{21}$, and $a_{12}$?

a_{12} and a_{21} have 4 cases. Both greater than 1, less than 1, and then one less and greater. Rho positive.
 
  • #12
Well, ok, but you're going to have to have actual values in order to plot anything in Mathematica. Perhaps, if you're allowed to pick values, you could show me what commands you've used so far. The way I see it, you've got the two axes, and two other straight lines.
 
Last edited:
  • #13
Ackbach said:
Well, ok, but you're going to have to have actual values in order to plot anything in Mathematica. Perhaps, if you're allowed to pick values, you could show me what commands you've used so far. The way I see it, you've got the two axes, and two other straight lines.

For all my cases, I just used 2 and 1/2
 
Last edited by a moderator:
  • #14
dwsmith said:
For all my cases, I just used 2 and 1/2

So, using those values, what commands have you used so far?
 
  • #15
Ackbach said:
So, using those values, what commands have you used so far?
Here are my phase planes and one null cline since I can't get mathematica to graph a vertical line

View attachment 25https://www.physicsforums.com/attachments/26
 
  • #16
Try this sort of thing:

Code:
PlotOne = StreamPlot[{x(1-x-2y),y(1-2x)},{x,0,2},{y,0,2}];
PlotTwo = Plot[{(1-x)/2,{x,0,2}];
<< Graphics`ImplicitPlot`
PlotThree = ImplicitPlot[x==1,{x,0,2},{y,0,2}];
Show[PlotOne,PlotTwo,PlotThree]

My PlotThree line probably does not have the right equation in there. You might need x == 0, or whatever. Does this solve your problem?
 
  • #17
Ackbach said:
Try this sort of thing:

Code:
PlotOne = StreamPlot[{x(1-x-2y),y(1-2x)},{x,0,2},{y,0,2}];
PlotTwo = Plot[{(1-x)/2,{x,0,2}];
<< Graphics`ImplicitPlot`
PlotThree = ImplicitPlot[x==1,{x,0,2},{y,0,2}];
Show[PlotOne,PlotTwo,PlotThree]

My PlotThree line probably does not have the right equation in there. You might need x == 0, or whatever. Does this solve your problem?

Was the phase plan and null clines correct for that system of DEs?

That worked too thanks.
 
  • #18
dwsmith said:
Was the phase plan and null clines correct for that system of DEs?

That worked too thanks.

The first two lines of code in Post # 16 were taken directly from your first .jpg. To be honest, the version of Mathematica I have doesn't support the StreamPlot command, so I don't know much about it. One thing that puzzles me is what are the axes on these plots corresponding to? That is, what variables in your system of DE's are being plotted against which variables?

Your system is
\begin{align*}
\frac{du_{1}}{d\tau}&=u_{1}(1-u_{1}-a_{12}u_{2})\\
\frac{du_{2}}{d\tau}&=\rho u_{2}(1-a_{21}u_{1}).
\end{align*}

Null clines are by definition regions in the $u_{1}-u_{2}$ plane where the derivatives of the system are zero simultaneously. That is, we must have
\begin{align*}
0&=u_{1}(1-u_{1}-a_{12}u_{2})\\
0&=\rho u_{2}(1-a_{21}u_{1}).
\end{align*}
The $\rho$ disappears. The logic goes like this:

(Either $u_{1}=0$ OR $1-u_{1}-a_{12}u_{2}=0$) AND (Either $u_{2}=0$ OR $1-a_{21}u_{1}=0$).

There are four possibilities:

1. $u_{1}=0$ and $u_{2}=0$
2. $u_{1}=0$ and $1-a_{21}u_{1}=0$ (this one seems unlikely)
3. $1-u_{1}-a_{12}u_{2}=0$ and $u_{2}=0$
4. $1-u_{1}-a_{12}u_{2}=0$ and $1-a_{21}u_{1}=0$.

Each of these possibilities describe a single point in the $u_{1}-u_{2}$ plane. So, if the goal of your problem is to plot the null clines, then I'd say you need to plot the three points described by 1, 3, and 4.
 
  • #19
I let x = u_1 and y = u_2.

I just set rho to 1 since Mathematica won't graph with an unknown parameter.
 
Last edited:
  • #20
Have you been able to plot the three points described in Post # 18? Those ARE the null clines. If you're supposed to plot the null clines simultaneously with the stream plot, then you need to figure out how to plot individual points clearly (marked with an "x" or something).
 
  • #21
Ackbach said:
Have you been able to plot the three points described in Post # 18? Those ARE the null clines. If you're supposed to plot the null clines simultaneously with the stream plot, then you need to figure out how to plot individual points clearly (marked with an "x" or something).
Those lines are plotted already plotted. You sent the syntax to include them all prior.
 
  • #22
dwsmith said:
Those lines are plotted already plotted. You sent the syntax to include them all prior.

Ah, but the null clines for your system are three POINTS, not lines. Now, if you think it's clearer to just plot lines so that people can see the intersection, I suppose that'd be one way to present your solution. However, not all of the line represented by $1-a_{21}u_{1}=0$ is a null cline. Only one point on that line is a null cline.
 

FAQ: Plot Phase Planes ODEs Mathematica

What is a Plot Phase Plane?

A Plot Phase Plane is a graphical representation of solutions to a system of Ordinary Differential Equations (ODEs). It shows the trajectories of the solutions in a two-dimensional plane.

What is Mathematica?

Mathematica is a computational software program used for mathematical and scientific calculations. It allows users to perform complex calculations, graphing, and programming. It is commonly used by scientists and mathematicians for data analysis and modeling.

How do I create a Plot Phase Plane in Mathematica?

To create a Plot Phase Plane in Mathematica, you will need to define the ODEs and their initial conditions, then use the command "StreamPlot" to plot the direction field. Finally, use the command "ParametricPlot" to plot the solutions. For more detailed instructions, refer to the Mathematica documentation or online tutorials.

What information can be obtained from a Plot Phase Plane?

A Plot Phase Plane can provide information about the behavior of a system of ODEs. It can show the stability of equilibrium points, the direction and shape of trajectories, and the presence of limit cycles or other interesting behaviors.

What are some common applications of Plot Phase Planes in scientific research?

Plot Phase Planes are commonly used in fields such as physics, biology, and engineering to model and analyze complex systems. They can be used to study physical phenomena such as chemical reactions, population dynamics, and electrical circuits. They are also useful for predicting and understanding the behavior of systems in the real world.

Similar threads

Replies
9
Views
737
Replies
2
Views
612
Replies
1
Views
2K
Replies
1
Views
453
Replies
3
Views
2K
Replies
5
Views
2K
Replies
1
Views
1K
Replies
4
Views
1K
Back
Top