from math import sin, cos class forceddampedduffing2d(object): """Vector field that describes the phase space of the forced damped Duffing oscillator.""" def __init__(self, Alpha = -0.25, Beta = 0.4): self.alpha = Alpha self.beta = Beta # Samples the phase space vector field of the forced damped duffing oscillator def sample(self, x, y, t): u = y v = self.alpha * y - x * x*x + x + self.beta * cos(t) return u, v; # Samples the phase space x-partial of the vector field of the forced damped duffing oscillator def sample_dx(self, x, y, t): u = 0 v = 1 - 3 * x*x return u, v; # Samples the phase space y-partial of the vector field of the forced damped duffing oscillator def sample_dy(self, x, y, t): u = 1 v = self.alpha return u, v; # Samples the phase space t-partial of the vector field of the forced damped duffing oscillator def sample_dt(self, x, y, t): u = 0 v = -self.beta * sin(t) return u, v;