【问题标题】:Solving a system of ODEs backwards in time in c++在 C++ 中及时解决 ODE 系统
【发布时间】:2016-05-26 17:22:08
【问题描述】:

不幸的是,我注意到 BOOST 的 odeint 无法及时解决 ODE 系统,即当我更改条件以使

typedef std::vector< double > state_type;

void ode_function(const state_type &x, state_type &dxdt, const double     
{
dxdt[0] = x[0];
}

using namespace std;
using namespace boost::numeric::odeint;

state_type x(1);
x[0] = std::exp(1); 


runge_kutta4< state_type > stepper;
integrate_const(stepper, ode_function, x, 1., 0., 0.01);

cout << x[0] << endl;

这实际上什么都不做,并且返回初始条件不变。在这个简单的例子中,可以通过改变变量 s=-t 来解决这个问题。但是,我不确定这个技巧是否适用于任何 ODE 系统。当我在我的程序中使用它时,我不确定它是否给出了正确的结果。 因此,有人知道任何允许向后时间集成的 c++ 库吗?

【问题讨论】:

    标签: c++ boost odeint


    【解决方案1】:

    在 odeint 中,如果您想及时向后积分,您还必须使用负步长。在您的情况下,您应该使用 -0.01 作为integrate_const 函数中的最后一个参数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-23
      相关资源
      最近更新 更多