【发布时间】:2016-06-13 21:42:32
【问题描述】:
我正在尝试通过以下示例使用 ODEINT 库来学习解决 ODE 问题。但是,当我输出结果时,时间步长只是跳过 0; 1个; 5.5; 25...有没有办法控制这个时间步长,使它增加“1”。谢谢!
#include <iostream>
#include <boost/array.hpp>
#include <boost/numeric/odeint.hpp>
using namespace std;
using namespace boost::numeric::odeint;
const double sigma = 0.0018;
typedef std::vector< double > state_type;
void my_ode( const state_type &x , state_type &dxdt , int t )
{
dxdt[0] = sigma * x[0]*( 1 - x[0] );
}
void write_ode( const state_type &x , const double t )
{
cout << t << '\t' << x[0] << endl;
}
int main(int argc, char **argv)
{
state_type x(1); // Initial condition, vector of 1 element (scalar problem)
x[0] = 0.001;
integrate( my_ode , x , 0.0 , 6000.0 , 1.0 , write_ode );
}
【问题讨论】: