In [30]:
%matplotlib inline
The equations read:
$$ \begin{aligned} \dot{x} &= \alpha x - \beta x y \\ \dot{y} &= \delta x y - \gamma y \end{aligned} $$where $x$ represents prey and $y$ represents predator. $ \alpha, \beta, \delta$ and $\gamma$ are model parameters defining the interactions between the spicies.
For further information see.
The implementation of the Lotka-Volterra equations in FABM was done by Fenjuan Hu when she started her PhD to get familiar with the FABM framework.
Import standard python packages
In [31]:
import numpy
import scipy.integrate
Import pyfabm - the python module that contains the Fortran based FABM
In [32]:
import pyfabm
#pyfabm.get_version()
In [33]:
yaml_file = '../../../../testcases/fabm-au-prey_predator.yaml'
model = pyfabm.Model(yaml_file)
model.findDependency('bottom_depth').value = 1.
model.checkReady(stop=True)
y0 = model.state
In [34]:
def dy(y,t0):
model.state[:] = y
return model.getRates()
In [35]:
t = numpy.linspace(0,200.,100)
y = scipy.integrate.odeint(dy,model.state,10000*t)
In [36]:
import pylab
pylab.plot(t,y)
pylab.title('Time series plots')
pylab.legend([variable.path for variable in model.state_variables])
pylab.show()
pylab.plot(y[:,0],y[:,1])
pylab.plot(y[:,2],y[:,3])
pylab.title('Limit circles')
pylab.show()
The Lotka-Volterra equations in a different context:
In [ ]: