Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexEMG committed Dec 8, 2021
1 parent 42c7e8a commit e7b18cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion LotkaVolterraClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def LyapunovFunction():
# TODO: https://www.sciencedirect.com/science/article/pii/S1474667017354101
raise NotImplementedError()


if __name__ == "__main__":
# Definition of parameters
a = 1.0 # natural growth rate of rabbits (prey)
Expand Down Expand Up @@ -108,5 +109,4 @@ def LyapunovFunction():

fig1.savefig("rabbits_and_foxes" + str(numiter) + ".png")


plt.show()
10 changes: 4 additions & 6 deletions test_LVC.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,18 @@
numiter = 10000
dt = 1.0 / numiter


def test_sameresult():
lvm = LVM(a, b, c, d, dt)
saver = DataSaver(lvm)


X0 = np.array([10, 5]) # initial conditions: 10 rabbits and 5 foxes
lvm.dynamics(X0, numiter, saver)
T, Xeuler = saver.get_data()["state_T"], np.array(saver.get_data()["state_X"])
rabbits, foxes = Xeuler.T

X, infodict = integrate.odeint(
lambda x, _: dX_dt(x, a, b, c, d), X0,T, full_output=True
lambda x, _: dX_dt(x, a, b, c, d), X0, T, full_output=True
)

assert np.allclose(Xeuler , X,atol=1e-3)


assert np.allclose(Xeuler, X, atol=1e-3)

0 comments on commit e7b18cb

Please sign in to comment.