How to use the pyodesys.util.stack_1d_on_left function in pyodesys

To help you get started, we’ve selected a few pyodesys examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bjodah / pyodesys / examples / van_der_pol.py View on Github external
savetxt='None', integrator='scipy', dpi=100, kwargs='',
         verbose=False):
    assert nt > 1
    y = sp.symarray('y', 2)
    p = sp.Symbol('p', real=True)
    f = [y[1], -y[0] + p*y[1]*(1 - y[0]**2)]
    odesys = SymbolicSys(zip(y, f), params=[p], names=True)
    tout = np.linspace(0, tend, nt)
    y0 = list(map(float, y0.split(',')))
    kwargs = dict(eval(kwargs) if kwargs else {})
    xout, yout, info = odesys.integrate(
        tout, y0, [mu], integrator=integrator, **kwargs)
    if verbose:
        print(info)
    if savetxt != 'None':
        np.savetxt(stack_1d_on_left(xout, yout), savetxt)
    if plot:
        import matplotlib.pyplot as plt
        odesys.plot_result()
        plt.legend()
        if savefig != 'None':
            plt.savefig(savefig, dpi=dpi)
        else:
            plt.show()
github bjodah / pyodesys / examples / pydy_double_pendulum.py View on Github external
def main(m=1, g=9.81, l=1, q1=.1, q2=.2, u1=0, u2=0, tend=10., nt=200,
         savefig='None', plot=False, savetxt='None', integrator='scipy',
         dpi=100, kwargs="", verbose=False):
    assert nt > 1
    kwargs = dict(eval(kwargs) if kwargs else {})
    odesys = SymbolicSys(get_equations(m, g, l), params=())
    tout = np.linspace(0, tend, nt)
    y0 = [q1, q2, u1, u2]
    xout, yout, info = odesys.integrate(
        tout, y0, integrator=integrator, **kwargs)
    if verbose:
        print(info)
    if savetxt != 'None':
        np.savetxt(stack_1d_on_left(xout, yout), savetxt)
    if plot:
        import matplotlib.pyplot as plt
        odesys.plot_result(xout, yout)
        if savefig != 'None':
            plt.savefig(savefig, dpi=dpi)
        else:
            plt.show()