# How to make a phase portrait for two ODE system?

This is the code I currently have of the two ODE's:

L = 2000;
w = 27000;
alpha = 0.25
sigma = 3/4;
m = 12/50;
T = 1000;
sol = NDSolve[{
H'[t] == L*(H[t] + F[t])/(w + H[t] + F[t]) - H[t]*(alpha - sigma*(F[t]/(H[t] + F[t]))),
F'[t] == H[t]*(alpha - sigma*(F[t]/(H[t] + F[t]))) - m*F[t],
{H[0], F[0]} == {200, 300}},
{H, F}, {t, 0, T}, MaxSteps -> Infinity];


I have been able to plot the ODE with the following code:

Plot[{Evaluate[H[t] /. sol], Evaluate[F[t] /. sol]}, {t, 0, T},
PlotRange -> {0, 10000}, Frame -> True,
FrameLabel -> {Style["Time", 16], Style["Population fractions", 14]},
PlotStyle -> {Blue, Red}, PlotLegends -> SwatchLegend[{"H", "F"}],
ImageSize -> 500]


I would like to create a phase portrait and have a plot where one parameter changes a couple times. I haven't been able to find a solution.

• Can you be more specific in describing in what you want to see in your phase plot and what parameter will vary over what range? – m_goldberg May 5 at 18:33
• Possible duplicate: mathematica.stackexchange.com/questions/190420/… – Michael E2 May 5 at 20:05
• Hi, First of thanks alot for responding. My goal is to visualize the ODE system going to a steady state. I was able to achieve this on matlab using a phase plot, but I'm unable to recreate this in wolfram math which is required by the lecturer. I am trying to recreate the Figure 3 from the following paper: link – Luca May 6 at 13:19

Stream plot takes in systems of ode $$\{x'(t),y'(t)\}$$ where $$x'(t)=v_x(x(t),y(t))$$ and $$y'(t)=v_y(x(t),y(t))$$.

Stream plot then has the form StreamPlot[{vx,vy},{x,-x1,x2},{y,-y1,y2}].

In your system, you have $$H'(t)$$ and $$F'(t)$$. These are like $$y'(t)$$ and $$x'(t)$$.

So if we replace x by H and y by F and get rid of all the explicit time dependency in the code, since these are implicit, then

ClearAll[F, H]
L = 2000;
w = 27000;
alpha = 0.25
sigma = 3/4;
m = 12/50;
T = 1000;
vx = H*(alpha - sigma*(F/(H + F))) - m*F;
vy = L*(H + F)/(w + H + F) - H*(alpha - sigma*(F/(H + F)));


Now

StreamPlot[{vx, vy}, {F,0, 350}, {H, 0, 450},
StreamPoints -> {{{{200, 300}, Red}, Automatic}}]


The red line is trajectory (orbit) that passes through the specific point $$(200,300)$$ which is your initial conditions. Other trajectories can be added as well.

In the above, $$F$$ is one state variable and $$H$$ is the other state variable and the above plot shows the relation between these two state variables.

Manipulate[
Module[{L, vx, vy, H, F},
L = 2000;
T = 1000;
vx = L*(H + F)/(w + H + F) - H*(alpha - sigma*(F/(H + F)));
vy = H*(alpha - sigma*(F/(H + F))) - m*F;

StreamPlot[{vx, vy}, {F, 0, fmax}, {H, 0, hmax}]
],

{{w, 27000, "w"}, 1, 100000, 1, Appearance -> "Labeled"},
{{alpha, 0.25, "alpha"}, 0.01, 1, 0.01, Appearance -> "Labeled"},
{{sigma, 0.75, "sigma"}, 0.01, 10, 0.01, Appearance -> "Labeled"},
{{m, 0.4, "m"}, 0.01, 10, 0.01, Appearance -> "Labeled"},
{{fmax, 200, "F range"}, 1, 15000, 1, Appearance -> "Labeled"},
{{hmax, 200, "H range)"}, 0, 15000, 1, Appearance -> "Labeled"},
TrackedSymbols :> {w, alpha, sigma, m, fmax, hmax},
ContinuousAction -> False
]


Update

To answer comment that phase plot do not seem to match paper:

the paper seems to had the state variables in reverse order than what I had. So I changed them now.

The scale was also different. So made the values to go from zero on-wards only.

And now you can get close to what they show. Just need to play a little more with it by changing the sliders.

Diagram in paper reproduced

Here is current version after updating.

• Hi, First of thanks alot for responding. My goal is to visualize the ODE system going to a steady state. I was able to achieve this on matlab using a phase plot, but I'm unable to recreate this in wolfram math which is required by the lecturer. I am trying to recreate the Figure 3 from the following paper: link – Luca May 6 at 11:16
• @Luca the paper seems to had the states variables in different order than what I had. So I changed them now. The scale was also different. So made the values to go from zero onwards only. And now you can get close to what they show. Just need to play a little more with it. – Nasser May 6 at 20:16