Open fccoelho opened 8 years ago
For a 2-dimensional system nsim expects the state y to be an array of shape (2,) Your function f() returns an array of shape (2,1).
If you remove the extra brackets in f then it works:
def f(self, y, t):
A = np.array([-self.r0*y[0]*y[1],
self.r0*y[0]*y[1] - y[1]])
return A
The fact that you got an error message from numpy instead of a more helpful message means that nsim could use some better input validation. So this is a bug in nsim.
It's reasonable for people to give a (2,1) array as a column vector. I'll probably fix this bug by enhancing nsim so that the state y can be an array with arbitrary number of dimensions (using numpy.ravel). Then your code would work as-is.
Thanks! It is now working.
Hi, I am trying to use nsim to simulate the following model:
To simulate it I tried the following:
It seems to work but when I try to plot the results, I get this error:
Is this a bug, or maybe a mistake in my model?