Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

I am trying to stimulate color with the Belousov-Zhabotinsky reacting with the solving ODEs which has to produce a graph and demonstrate on oscillations using odeint.

When I am trying to do, I am getting an error message as:

'AxisError: axis -1 is out of bounds for an array of dimension 0'

I have no idea why am I getting this error.

This is the code which I am using:

import numpy as np

import matplotlib.pyplot as plt

from scipy.integrate import odeint

# Dimensionless parameters

c1 = 10

c2 = 0.15

c3 = 0.005

c4 = 0.02

#pack 3 initial conditions with state of x,y,z into y0

y0 = [1,0,0]

k = 1

def Oregonator (t,Y):

  x = Y[0]

  y = Y[1]

  z = Y[2]

 dxdt = c1 + c2*x - x - x*y**2

 dydt = (x + x*y**2 - y)/c3

 dzdt = (y-z)/c4

 return [dxdt,dydt,dzdt]

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

Y = odeint(y0,t,Oregonator)

plt.plot(t,Y)

plt.xlabel('time')

plt.ylabel('other side')

plt.show()

Can anyone help me?

1 Answer

0 votes
by (36.8k points)
edited by

So the problem is in the odeint. To fix it use the command below:

Y = odeint(Oregonator,y0,t, tfirst=True)

First, you need to equalize the indentation o=in the function named Oregonator and then get the oscillating graph. You also need to work on the resolution of the graph by providing 20 points interval with 1 oscillation because you have sharp peaks.

t = np.linspace(0, 10,5000)

I hope this will help you.

Improve your knowledge in data science from scratch using Data science online courses

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...