使用 scipy odeint 及时向后积分 [英] Backward integration in time using scipy odeint

查看:48
本文介绍了使用 scipy odeint 及时向后积分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在时间上向后积分任何常微分方程使用 scipy.integrate.odeint 吗?如果可能的话,有人能告诉我'odeint.

Is it possible to integrate any Ordinary Differential Equation backward in time using scipy.integrate.odeint ? If it is possible, could someone tell me what should be the arguement 'time' in 'odeint.

推荐答案

odeint 处理 t 参数的负值.无需特殊处理.

odeint handles negative values of the t argument. No special treatment is needed.

这是一个例子:

import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt


def mysys(z, t):
    """A slightly damped oscillator."""
    return [z[1] - 0.02*z[0], -z[0]]


if __name__ == "__main__":
    # Note that t starts at 0 and goes "backwards"
    t = np.linspace(0, -50, 501)

    z0 = [1, 1]
    sol = odeint(mysys, z0, t)

    plt.plot(t, sol)
    plt.xlabel('t')
    plt.show()

剧情:

这篇关于使用 scipy odeint 及时向后积分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆