conflict between a 1D array and 2D equations system

0

I am a beginner in python and I have zero programming knowledge. I'm trying to solve this system of equations with odeint :

def croissance(x,t):
    dx = [0,0]
    dx[0] = (gamma_ - alpha_ * beta_) * M - alpha_ * M * D
    dx[1] = alpha_ * beta_ * M + alpha_ * M * D
    return dx 

My full script is as follows:

# Parameters
alpha_ = 1.0
beta_ = 1.0
gamma_ = 1.0

# Differential system 
def croissance(x,t):
    dx = [0,0]
    dx[0] = (gamma_ - alpha_ * beta_) * x - alpha_ * x * x
    dx[1] = alpha_ * beta_ * x + alpha_ * x * x
    return dx 

# Initial conditions
N0 = [0.3,0.3]
t0 = 0.
dt = 0.01
tf = 60.
t = np.arange(t0, tf, dt)

N = odeint(croissance, N0, t)
plt.close('all')
plt.plot(t,N[:,0])
plt.plot(t,N[:,1],'--')
plt.show()

When I try to run the code in Jupyter I get the following error:

  

"RuntimeError: The array return by func must be one-dimensional, but got ndim = 2."

I understand what it means but I can not decipher my error. Is it a conflict between dx and N0?

    
asked by valeriahhdez 24.01.2018 в 09:57
source

0 answers