Hi I am trying to visualize the phase space of SIS model, but here is what I obtained. The problem is the trajectories should on the line of S+I=1, but somehow they did not, in the plot.
begin
using CairoMakie
let
β=0.8
μ=0.1
PP_SIS(S,I) = Point(-β*S*I+μ*I,β*S*I-μ*I)
fig = Figure(resolution = (1400, 800), fontsize = 20)
ax1 = fig[1, 1] = Axis(fig, xlabel = "S", ylabel = "I", title = "phase portrait of SIS model", aspect = 1, backgroundcolor = :black)
streamplot!(ax1, PP_SIS, 0.01..0.99, 0.01..0.99, colormap = Reverse(:plasma),
gridsize= (20,20), arrow_size = 20)
fig
end
end
Thus, im wondering how to specify the admissible region (S+I=1) of SIS model when plotting its phase portrait, using streamplot? Hope anyone could help. Thank you!
What do you mean precisely with that? Physically, the model conserves S+I=1, so yes, actually evolving the model with initial conditions that satisfy S+I = 1 would keep it on this manifold. But that’s not what streamplot does. it just plots the vector field.
You can’t use streamplot for what you want. I propose to use a quiver plot. Calculate the rate of change in all points that satisfy S+I=1 and just plot a quiver of arrows on these points.
What do you mean precisely with that? Physically, the model conserves S+I=1, so yes, actually evolving the model with initial conditions that satisfy S+I = 1 would keep it on this manifold. But that’s not what streamplot does. it just plots the vector field.
I think the trajectories supposed to strictly on the line of S+I=1, and the phase portrait of SIS model is like this:
Also, I am not sure whether the following understanding is correct:
Plotting the vector field: plot the vector on each point, its direction is obtained according to the differential equations (\frac{dS}{dt},\frac{dI}{dt},\frac{dR}{dt}). So, we can use streamplot.
Plotting the phase space
plot trajectories starting from every possible initial
state (initial condition). And, your suggestion is quiver plot?
As I said, the stream plot does not make what you want. The plot you paste in your latest comment can’t be done with the streamplot given intervals. Obviously, if you do streamplot(f, interval1, interval2), it will evaluate arrows over all points in the given box, not just those that lie on the line S+I=1.
So, just create a vector of points points = [Point2f0(x, 1-x) for x in 0:0.1:1], then calculate their velocities v = [f(x) for x in points] and then do a quiver(points, v).