Lotka-Volterra DGL Plot liefert nicht das richtige Ergebnis
Verfasst: Sonntag 1. August 2021, 23:59
Hallo liebes Forum,
ich bin neu in Python unterwegs (für das Studium sinnvoll) und möchte lernen DGLs mit Python zu lösen. Dazu habe ich das Lotka-Volterra Modell nach dieser Anleitung https://www.youtube.com/watch?v=2f5aRTBmm10 auf YouTube nachgebaut. Allerdings erhalte ich einen völlig anderen Plot, der auch wenig sinnvoll ist... Was mache ich falsch/anders?
Als Graph erhalte einmal eine Konstante und einmal einen scheinbaren exponentiellen Zerfall, aber das ist absoluter Schwachsinn inhaltlich.... Die Modellgleichungen passen auch, habe ich irgendwas falsch eingestellt? Ich stehe gerade echt auf den Schlauch...
Vielen Dank für jede Unterstützung!
VG Physiker2020
ich bin neu in Python unterwegs (für das Studium sinnvoll) und möchte lernen DGLs mit Python zu lösen. Dazu habe ich das Lotka-Volterra Modell nach dieser Anleitung https://www.youtube.com/watch?v=2f5aRTBmm10 auf YouTube nachgebaut. Allerdings erhalte ich einen völlig anderen Plot, der auch wenig sinnvoll ist... Was mache ich falsch/anders?
Code: Alles auswählen
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from scipy.integrate import odeint
y0 = [1000,100]
t = np.linspace(0,100,num=1000)
alpha = 0.1
beta = 0.4
delta = 0.1
gamma = 0.4
params = [alpha, beta, gamma, delta, gamma]
def sim(variables, t, params):
x = variables[0]
y = variables[1]
alpha = params[0]
beta = params[1]
delta = params[2]
gamma = params[3]
dxdt = alpha * x - beta * x * y
dydt = delta * x * y - gamma * y
return([dxdt,dydt])
y = odeint(sim, y0, t, args=(params,))
f,(ax1,ax2) = plt.subplots(2)
line1, = ax1.plot(t,y[:,0], color="b")
line2, = ax2.plot(t,y[:,1], color="r")
plt.show()
Vielen Dank für jede Unterstützung!
VG Physiker2020