In [ ]:
from pygslodeiv2 import integrate_predefined, fpes
import numpy as np
from van_der_pol import get_f_and_j
In [ ]:
help(integrate_predefined)
In [ ]:
rhs, jac = get_f_and_j(1.0)
xout = np.linspace(0, 10, 200)
yout, info = integrate_predefined(
rhs, jac, [0, 1], xout, dx0=1e-12, atol=1e-15, rtol=1e-15,
record_rhs_xvals=True, record_jac_xvals=True, record_order=True,
record_fpe=True, nsteps=2000)
print(info['nfev'], info['success'], info['time_wall'])
In [ ]:
import matplotlib.pyplot as plt
%matplotlib inline
fig, axes = plt.subplots(5, 1, figsize=(16,16))
for k, ax in zip(['steps', 'rhs', 'jac'], axes.flat):
ax.vlines(xout if k == 'steps' else info[k + '_xvals'], 0, 1, transform=ax.get_xaxis_transform(),
colors='darkgreen', alpha=0.006 if k == 'rhs' else 0.5)
#for x in xout if k == 'steps' else info[k + '_xvals']:
# ax.axvline(x, c='darkgreen', alpha=0.1)
ax.plot(xout, yout)
ax.set_xlim([xout[0], xout[-1]])
ax.set_ylabel(k)
axes[-2].plot(xout[1:], info['fpes'][1:] - fpes['FE_INEXACT'])
axes[-2].set_ylabel('fpes')
axes[-1].plot(xout, info['orders'])
axes[-1].set_ylabel('order')
_ = plt.tight_layout
In [ ]:
info.keys()
In [ ]:
fpes