Skip to content Skip to sidebar Skip to footer

Python Non Linear Ode With 2 Variables

I am trying to solve the Brusselator model, a non-linear ODE, using python. I used to do this with MATLAB but now am building an application with python as a backend. That's why I

Solution 1:

I know this is an old question. Nevertheless, I managed to formulate your question in the code below.

There, I implemented your two differential equations in a single function, that I later integrate through ODEINT module from scypy.

I hope this answer your problem.

Sincerely yours,

import scipy.integrate
import numpy as np
import matplotlib.pyplot as plt

def Integrate(y, t, B, A):
    X, Y = y

    dX_dt = A + (X**2)*(Y) - B*X - X

    dY_dt = B*X - (X**2)*(Y)



    return [dX_dt, dY_dt]

A0 = 0.9
B0 = 0.6
X0 = 0.1
Y0 = 0.0
B0 = 0.35


t = np.linspace(0,100, 10000)


solution = scipy.integrate.odeint(Integrate, y0=[X0, Y0], t=t, args=(A0, B0) )

plt.plot(t, solution[:,1], label='solution')
plt.legend()
plt.xlabel('time')
plt.ylabel('Y')
plt.show()

Post a Comment for "Python Non Linear Ode With 2 Variables"