Nun habe ich aber folgendes Problem, dass die Lösung mir teilweise willkürlich erscheint. Betrachtet man folgende fast identische Codes:
Code: Alles auswählen
from numpy import *
from matplotlib import pyplot as plt
from scipy.integrate import odeint # Integrationsroutine importieren
def abl(y, t, A, B, omega):
x_dot=y[1] #x_dot=p
p_dot=(y[0]**3)*4 -2*y[0]+A+B+sin(omega * t) #p_dot=4x^3-2x+A+B+sin(wt)
return array([x_dot, p_dot])
B = 0.1
A = 0.1
omega = 1
y0 = array([0.0, 0.0]) # Anfangsbedingung: (x0, p0)
zeiten = linspace(0.0, 400*pi, 20) # Zeiten
y_t = odeint(abl, y0, zeiten, args=(A, B, omega)) # Integration der DGL
x_t = y_t[:, 0] # Auslesen der Spalten mit x
p_t = y_t[:, 1] # und p
print x_t
print p_t
plt.figure(1)
plt.subplot(111, xscale="log", yscale="log", autoscale_on=False)
plt.axis([1e-300, 1e300, 1e-300, 2e300])
plt.plot(x_t, p_t)
plt.show()
Code: Alles auswählen
from numpy import *
from matplotlib import pyplot as plt
from scipy.integrate import odeint # Integrationsroutine importieren
def abl(y, t, A, B, omega):
x_dot=y[1] #x_dot=p
p_dot=(y[0]**3)*4 -2*y[0]+A+B+sin(omega * t) #p_dot=4x^3-2x+A+B+sin(wt)
return array([x_dot, p_dot])
B = 0.1
A = 0.1
omega = 1
y0 = array([0.0, 0.0]) # Anfangsbedingung: (x0, p0)
zeiten = linspace(0.0, 400*pi, 20) # Zeiten
y_t = odeint(abl, y0, zeiten, args=(A, B, omega)) # Integration der DGL
x_t = y_t[:, 0] # Auslesen der Spalten mit x
p_t = y_t[:, 1] # und p
plt.figure(1)
plt.subplot(111, xscale="log", yscale="log", autoscale_on=False)
plt.axis([1e-300, 1e300, 1e-300, 2e300])
plt.plot(x_t, p_t)
plt.show()
PS: Ich weiß Sternchenimporte sind nicht so gut und die Kommentierung diente auch nur dem schnellen zweck und nicht der Form, die ich sonst hege. Darüber bitte ich hinwegzusehen
Danke für eure Hilfe!