In [ ]:
import subprocess
import matplotlib.pyplot as plt
from pyodesys.results import Result
from pyodesys.native import native_sys
from pyodesys.native.util import parse_standalone_output
from pyodesys.tests.test_symbolic import decay_rhs
from pyodesys.tests.bateman import bateman_full
%matplotlib inline

In [ ]:
k = [.7, .1]
native = native_sys['cvode'].from_callback(decay_rhs, len(k) + 1, len(k))

In [ ]:
res = native.integrate(13, [1] + [0]*len(k), k)

In [ ]:
res.plot()

In [ ]:
standalone_prog = native.as_standalone('standalone', compile_kwargs=dict(options=['warn', 'openmp', 'debug']))
standalone_prog

In [ ]:
output = subprocess.check_output([standalone_prog], stdin=open('standalone_input1.txt')).decode('utf-8')
print(output)

In [ ]:
results1 = [Result(*args, native) for args in parse_standalone_output(output.split('\n'))]

In [ ]:
fig, axes = plt.subplots(1, len(results1), figsize=(14, 4))
for i, res in enumerate(results1):
    res.plot(ax=axes[i])
    axes[i].set_title(res.info['nfev'])

In [ ]:
results2 = [Result(*args, native) for args in parse_standalone_output(
        subprocess.check_output(
            [standalone_prog],
            stdin=open('standalone_input2.txt')
        ).decode('utf-8').split('\n'))]
fig, axes = plt.subplots(1, len(results2), figsize=(14, 4))
for i, res in enumerate(results2):
    res.plot(ax=axes[i])
    axes[i].set_title(res.info['nfev'])

In [ ]: