This notebook uses widgets allowing the user to vary an input parameter (you need to run the notebook locally for the widget to show). For performance reasons we are using symengine as the backend.
In [ ]:
import math
from ipywidgets import interact
from pyodesys.symbolic import SymbolicSys
use_gr = False
In [ ]:
if use_gr:
import gr
from gr.pygr import plot
gr.inline()
else: # use matplotlib
from matplotlib.pyplot import plot
%matplotlib inline
In [ ]:
def rhs(t, y, p, backend=math):
return [p[0]*y[1], -p[0]*y[0]]
In [ ]:
odesys = SymbolicSys.from_callback(rhs, 2, 1, backend='symengine')
In [ ]:
def integrate(alpha):
t, y, info = odesys.integrate(10, [0, 1], [alpha], integrator='cvode')
plot(t, y[:, 0])
plot(t, y[:, 1])
In [ ]:
interact(integrate, alpha=(.1, 1, 0.1))