2

I know this question has been asked multiple times before, but I still have problems with the implementation.

enter image description here

These equations are refered to as the lokta-volterra equations, and are used as a simple bio-model between two species (hares and foxes for an example). The equations and images of the slope field diagram is taken from this document, see pages 4-7 for a complete background.

For those who can not see the equations they are du1/dt = u1*(1-u1-a12*u2) and du2/dt = u2*(1-u2-a21*u1). I want to draw the phase portrait, (vector diagram). For a few values different values of a12 and a21. The result should be as follows

enter image description here

However my code messes things up badly.

\documentclass[border=10pt]{standalone}
\usepackage{pst-plot,pst-ode}
\begin{document}

\psset{unit=3}
\begin{pspicture}(-0.2,-0.2)(2.1,2.1)
\psaxes[ticksize=0 4pt,axesstyle=frame,tickstyle=inner,subticks=20,
        Ox=0,Oy=0](0,0)(2,2)
\psset{arrows=->,algebraic}
\psVectorfield[linecolor=blue!60](0.1,0.1)(1.9,1.9){ x*(-0.75*y-x+1)*(2*y*(-0.75*x-y+1))^(-1) }
%y0_a=-0.5
\pstODEsolve[algebraicOutputFormat]{y0_a}{t | x[0]}{1}{0}{100}{-0.5}{t*(-0.75*x[0]-t+1)*(x[0]*(-0.75*t-x[0]+1))^(-1)}

\psset{arrows=-,linewidth=1pt}%
\listplot[linecolor=red  ]{y0_a}
\listplot[linecolor=green]{y0_b}
\listplot[linecolor=blue ]{y0_c}
\end{pspicture}

\end{document}

Which renders into

enter image description here

As you can see the arrows have some massive disstortion. Can the problem be solved using something different thant pstricks? I am most comfortable with tikz and pgfplots, however after testing a few solutions from Differential Equation direction plot with pgfplots the pstricks was the only one who was able to render the curves.

If I remove the first u1 from the first equation and the first u_2 so that I avoid dividing by zero. I still get artifacts (however it is slightly better).

enter image description here

N3buchadnezzar
  • 11,348
  • 7
  • 55
  • 114

1 Answers1

2

it is not possible to draw it in one turn. For some values you have a divsion by very small numbers. You have to choose different intervals. For example:

\documentclass[border=10pt]{standalone}
\usepackage{pst-plot,pst-ode}
\begin{document}

\psset{unit=3}
\begin{pspicture}(-0.2,-0.2)(2.1,2.1)
    \psaxes[ticksize=0 4pt,axesstyle=frame,tickstyle=inner,subticks=20,
    Ox=0,Oy=0](0,0)(2,2)
\psset{arrows=->,algebraic}
\pstVerb{
    /alpha12 0.75 def
    /alpha21 0.75 def
    /rho 2 def
}
\psVectorfield[linecolor=blue!60](0.1,0.1)(0.6,0.6)%
  {x*(1-x-alpha12*y)/(rho*y*(1-y-alpha21*x))}
\psVectorfield[linecolor=blue!60](0.5,0.7)(1.9,1.9)%
  {x*(1-x-alpha12*y)/(rho*y*(1-y-alpha21*x))}
\psVectorfield[linecolor=blue!60](0.1,0.7)(0.3,1.9)%
  {x*(1-x-alpha12*y)/(rho*y*(1-y-alpha21*x))}
\pstODEsolve[varsteptol=1e-5,saveData]%
  {y0a}%
  {0 1}%
  {0}{40}{1000}%
  {0.1 0.1}%
  {x[0]*(1-x[0]-alpha12*x[1]) | rho*x[1]*(1-x[1]-alpha21*x[0])}
\psset{arrows=-,linewidth=1pt}%
\listplot[linecolor=red]{y0a}
\end{pspicture}

\end{document}

enter image description here