jueves, 28 de julio de 2016

Simulation of predator-prey model with type II functional response

Code in Python:
from numpy import *
from scipy import integrate
from math import sqrt
import pylab as p
import matplotlib.pyplot as mplot


m = 3
K = 3
c = 1
# Funciones
def dx_dt(X, t=0):
    x = X[0]
    y = X[1]
    dx = x*(1 - x/K) - m*x*y/(1+x)
    dy = -c*y + m*x*y/(1+x)
    return array([dx ,dy])

f = p.figure(figsize=(14, 6))
t = linspace(0,100,500)
X = integrate.odeint( dx_dt, array([1, .5]), t)
p.plot(t, X[:,1], lw=2, color = "green" , label = "Predator")
p.plot(t, X[:,0], lw=2, color = "red" , label = "Prey")
p.grid()
p.legend()
p.xlabel("Time")
p.ylabel("Populations")
f.savefig('RM.pdf')
f.savefig('RM.png')
https://math.la.asu.edu/~halsmith/Rosenzweig.pdf

No hay comentarios:

Publicar un comentario